Class: LoyaltyApIs::AuthorizationApi
- Defined in:
- lib/loyalty_ap_is/apis/authorization_api.rb
Overview
AuthorizationApi
Constant Summary
Constants inherited from BaseApi
Instance Attribute Summary
Attributes inherited from BaseApi
Instance Method Summary collapse
-
#exchange_access_code(authorization, body) ⇒ ApiResponse
This endpoint allows to given an access code to retrieve an user profile with a pair of valid tokens.
-
#get_authorization_token(body) ⇒ ApiResponse
When partner wants to get the basic public token, to be authorized to perform any other call inside SSO, needs to call this endpoint using sha256(client_id).
-
#refresh(authorization, body: nil) ⇒ ApiResponse
When an access token has expired, a partner that wants to get a new pair of valid tokens to go on performing operations against SSO needs to call this endpoint.
Methods inherited from BaseApi
#initialize, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters
Constructor Details
This class inherits a constructor from LoyaltyApIs::BaseApi
Instance Method Details
#exchange_access_code(authorization, body) ⇒ ApiResponse
This endpoint allows to given an access code to retrieve an user profile with a pair of valid tokens. In this end point, accessCode can be exchanged for an accessToken which is user-authorization-token. was generated with auth/token end point. access code data
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/loyalty_ap_is/apis/authorization_api.rb', line 48 def exchange_access_code(, body) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/api/v2/auth/exchangeAccessCode', Server::SHELL) .header_param(new_parameter(, key: 'Authorization') .is_required(true)) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body) .is_required(true)) .header_param(new_parameter('application/json', key: 'accept')) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(Single.new('PublicBasicToken'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(M200UserPartners.method(:from_hash)) .is_api_response(true) .local_error('401', 'Unauthorized. If making the call with an invalid token', JsonApiErrorException) .local_error('404', 'Not found. If the access code is not in the database', JsonApiErrorException) .local_error('500', 'Any unexpected error', JsonApiErrorException)) .execute end |
#get_authorization_token(body) ⇒ ApiResponse
When partner wants to get the basic public token, to be authorized to perform any other call inside SSO, needs to call this endpoint using sha256(client_id)
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/loyalty_ap_is/apis/authorization_api.rb', line 14 def (body) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/api/v2/auth/token', Server::SHELL) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body) .is_required(true)) .header_param(new_parameter('application/json', key: 'accept')) .body_serializer(proc do |param| param.to_json unless param.nil? end)) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(AuthTokenResponse.method(:from_hash)) .is_api_response(true) .local_error('400', 'Bad Request. If the request is missing the digest field', JsonApiErrorException) .local_error('401', 'Unauthorized. If the digest provided is not valid', JsonApiErrorException) .local_error('500', 'Any unexpected error', JsonApiErrorException)) .execute end |
#refresh(authorization, body: nil) ⇒ ApiResponse
When an access token has expired, a partner that wants to get a new pair of valid tokens to go on performing operations against SSO needs to call this endpoint. was generated with auth/token end point. description here
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/loyalty_ap_is/apis/authorization_api.rb', line 86 def refresh(, body: nil) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/api/v2/auth/token/refresh', Server::SHELL) .header_param(new_parameter(, key: 'Authorization') .is_required(true)) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body)) .header_param(new_parameter('application/json', key: 'accept')) .body_serializer(proc do |param| param.to_json unless param.nil? end)) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(RefreshTokenResponse.method(:from_hash)) .is_api_response(true) .local_error('400', 'Bad Request. The request is missing the Refresh Token field.', JsonApiErrorException) .local_error('401', 'Unauthorized. This response is generated when either the Basic'\ ' Token is invalid or the Refresh Token is invalid (see'\ ' examples)', JsonApiErrorException) .local_error('500', 'Any unexpected error', JsonApiErrorException)) .execute end |