Class: DnaPaymentsPartnerReportingSettlementApIs::AuthenticationApi
- Inherits:
-
BaseApi
- Object
- BaseApi
- DnaPaymentsPartnerReportingSettlementApIs::AuthenticationApi
- Defined in:
- lib/dna_payments_partner_reporting_settlement_ap_is/apis/authentication_api.rb
Overview
AuthenticationApi
Constant Summary
Constants inherited from BaseApi
Instance Attribute Summary
Attributes inherited from BaseApi
Instance Method Summary collapse
-
#get_access_token(grant_type, scope, client_id, client_secret) ⇒ ApiResponse
Prior to querying any Reporting or Settlement API endpoint, an access token must be obtained.
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 DnaPaymentsPartnerReportingSettlementApIs::BaseApi
Instance Method Details
#get_access_token(grant_type, scope, client_id, client_secret) ⇒ ApiResponse
Prior to querying any Reporting or Settlement API endpoint, an access
token must be obtained. This endpoint is shared by both the Reporting API
and the Settlement API (both use the partners_reporting scope).
required to confirm the action required.
performed with the credentials.
following successful creation of a test account.
integrator following successful creation of a test account.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/dna_payments_partner_reporting_settlement_ap_is/apis/authentication_api.rb', line 21 def get_access_token(grant_type, scope, client_id, client_secret) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/oauth2/token', Server::DEFAULT) .form_param(new_parameter(grant_type, key: 'grant_type') .is_required(true)) .form_param(new_parameter(scope, key: 'scope') .is_required(true)) .form_param(new_parameter(client_id, key: 'client_id') .is_required(true)) .form_param(new_parameter(client_secret, key: 'client_secret') .is_required(true)) .header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type')) .header_param(new_parameter('application/json', key: 'accept'))) .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 — request format is invalid.', ErrorException) .local_error('401', 'Unauthorized — invalid authentication credentials have been'\ ' supplied.', ErrorException)) .execute end |