Sha256: 36c9bc05126968a5f5445df66a5d910abc16960f23b55b289ba3ce597e095466

Contents?: true

Size: 721 Bytes

Versions: 3

Compression:

Stored size: 721 Bytes

Contents

# frozen_string_literal: true

require 'rest-client'

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
          {
            username: 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

3 entries across 3 versions & 1 rubygems

Version Path
wso2_toolbox-0.2.2 lib/wso2_toolbox/token_manager/api_manager_service.rb
wso2_toolbox-0.2.1 lib/wso2_toolbox/token_manager/api_manager_service.rb
wso2_toolbox-0.2.0 lib/wso2_toolbox/token_manager/api_manager_service.rb