Module: Wso2Toolbox::TokenManager::ApiManagerService

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

Class Method Summary collapse

Class Method Details

.build_paramsObject



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

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

.configObject



24
25
26
# File 'lib/wso2_toolbox/token_manager/api_manager_service.rb', line 24

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(config.token_url, build_params)
end

.post(url, params) ⇒ Object



35
36
37
38
39
# File 'lib/wso2_toolbox/token_manager/api_manager_service.rb', line 35

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

.refresh_token(token) ⇒ Object



14
15
16
# File 'lib/wso2_toolbox/token_manager/api_manager_service.rb', line 14

def refresh_token(token)
  post(config.refresh_token_url, token: token)
end

.revoke_token(token) ⇒ Object



18
19
20
# File 'lib/wso2_toolbox/token_manager/api_manager_service.rb', line 18

def revoke_token(token)
  post(config.revoke_token_url, token: token)
end