Sha256: 93b4571e087fd83e32eeaf2ef1028fa90e6ab973dc2cbc83cfc9a8e9fa22afc6

Contents?: true

Size: 761 Bytes

Versions: 1

Compression:

Stored size: 761 Bytes

Contents

# frozen_string_literal: true

require 'rest-client'
require 'active_support/core_ext/hash'

module Wso2Toolbox
  module TokenManager
    module ApiManagerService
      class << self
        def create_token
          post(build_params)
        end

        private_class_method

        def config
          @config ||= Wso2Toolbox.configuration
        end

        def build_params
          {
            user_name: config.token_username,
            password: config.token_password
          }
        end

        def post(params)
          response = RestClient.post(config.token_url, params.to_json,
                                     content_type: :json)
          JSON.parse(response).with_indifferent_access
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wso2_toolbox-0.2.3 lib/wso2_toolbox/token_manager/api_manager_service.rb