Module: Wso2Toolbox::TokenManager::ApiManagerService

Defined in:
lib/wso2_toolbox/token_manager/api_manager_service.rb

Class Method Summary collapse

Class Method Details

.build_paramsObject



20
21
22
23
24
25
# File 'lib/wso2_toolbox/token_manager/api_manager_service.rb', line 20

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

.configObject



16
17
18
# File 'lib/wso2_toolbox/token_manager/api_manager_service.rb', line 16

def config
  @config ||= Wso2Toolbox.configuration
end

.create_tokenObject



10
11
12
# File 'lib/wso2_toolbox/token_manager/api_manager_service.rb', line 10

def create_token
  post(build_params)
end

.post(params) ⇒ Object



27
28
29
30
31
# File 'lib/wso2_toolbox/token_manager/api_manager_service.rb', line 27

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