Class: LoyaltyApIs::TransactionApi

Inherits:
BaseApi
  • Object
show all
Defined in:
lib/loyalty_ap_is/apis/transaction_api.rb

Overview

TransactionApi

Constant Summary

Constants inherited from BaseApi

BaseApi::GLOBAL_ERRORS

Instance Attribute Summary

Attributes inherited from BaseApi

#config, #http_call_back

Instance Method Summary collapse

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

#get_transactions_l(country_code, consumer_uuid, user_authorization_token, application, language_code, language: 'en', channel: PARTNER, page: nil, limit: nil, offset: nil, page_size: nil, transaction_type: nil, from_date_time: nil, to_date_time: nil, filter_by_partner_code: nil) ⇒ ApiResponse

This API is used to fetch and retrieve the list of transactions of a customer. Example cURL request: curl --location 'https://api-test.shell.com/loyalty/v1/consumers/transactionsL?language_co de=pl-PL'
--header 'country-code: PL'
--header 'user-authorization-token: Bearer clk6qsn0z000o1rpactbsyu93'
--header 'client-authorization-token: Bearer fmVQg8M2F2NGeI3RE18G8R8luKTk'
--header 'language: en'
--header 'application: PARTNER'
--header 'channel: PARTNER'
--header 'consumerUUID: bd68f27f-80f7-440a-b096-f65155161345' 3166-1 standard Alpha-2 code of the Country, which is the first two characters of the country code. or customer's unique SSO UUID. consumer's SSO access, which you retrieved from /auth/exchangeAccessCode endpoint prefixed by Bearer. application. of language in lower case as per ISO 639-1 , β€œ-” and country code as per ISO 3166-1 alpha-2. For example: en-GB. 639-1 2 letter code format. be retrieved. to be sent across all pages. number of resources at the start of each page. of resources to be sent in each page of the response. is the type of the transaction. If the parameter is empty, it means that β€œALL” queries. from which the transaction details are required. until which the transaction details are required. This is used to filter the transactions based on partnerCode. If true, return the transactions related to partnerCode. If false, return all transactions.

Parameters:

  • country_code (String)

    Required parameter: This represents the ISO

  • consumer_uuid (String)

    Required parameter: This is the consumer's

  • user_authorization_token (String)

    Required parameter: This is the

  • application (String)

    Required parameter: This is the calling

  • language_code (String)

    Required parameter: This is a concatenation

  • language (String) (defaults to: 'en')

    Optional parameter: This is the language in ISO

  • channel (Object) (defaults to: PARTNER)

    Optional parameter: Channel.

  • page (Integer) (defaults to: nil)

    Optional parameter: The page number, which needs to

  • limit (Integer) (defaults to: nil)

    Optional parameter: The maximum number of resources

  • offset (Integer) (defaults to: nil)

    Optional parameter: This is used to skip a certain

  • page_size (Integer) (defaults to: nil)

    Optional parameter: This is the maximum number

  • transaction_type (TransactionTypeFilter) (defaults to: nil)

    Optional parameter: This

  • from_date_time (String) (defaults to: nil)

    Optional parameter: This is the datetime

  • to_date_time (String) (defaults to: nil)

    Optional parameter: This is the datetime

  • filter_by_partner_code (TrueClass | FalseClass) (defaults to: nil)

    Optional parameter:

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/loyalty_ap_is/apis/transaction_api.rb', line 59

def get_transactions_l(country_code,
                       consumer_uuid,
                       user_authorization_token,
                       application,
                       language_code,
                       language: 'en',
                       channel: PARTNER,
                       page: nil,
                       limit: nil,
                       offset: nil,
                       page_size: nil,
                       transaction_type: nil,
                       from_date_time: nil,
                       to_date_time: nil,
                       filter_by_partner_code: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/v1/consumers/transactionsL',
                                 Server::SHELL2)
               .header_param(new_parameter(country_code, key: 'country-code')
                              .is_required(true))
               .header_param(new_parameter(consumer_uuid, key: 'consumerUUID')
                              .is_required(true))
               .header_param(new_parameter(user_authorization_token, key: 'user-authorization-token')
                              .is_required(true))
               .header_param(new_parameter(application, key: 'application')
                              .is_required(true))
               .query_param(new_parameter(language_code, key: 'language_code')
                             .is_required(true))
               .header_param(new_parameter(language, key: 'language'))
               .header_param(new_parameter(channel, key: 'channel'))
               .query_param(new_parameter(page, key: 'page'))
               .query_param(new_parameter(limit, key: 'limit'))
               .query_param(new_parameter(offset, key: 'offset'))
               .query_param(new_parameter(page_size, key: 'pageSize'))
               .query_param(new_parameter(transaction_type, key: 'transactionType'))
               .query_param(new_parameter(from_date_time, key: 'fromDateTime'))
               .query_param(new_parameter(to_date_time, key: 'toDateTime'))
               .query_param(new_parameter(filter_by_partner_code, key: 'filterByPartnerCode'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('client-authorization-token')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(TransactionsResponse.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'Bad request - The request was not valid. This code is returned'\
                              ' when the server has attempted to process the request, but some'\
                              ' aspect of the request is not valid, for example an incorrectly'\
                              ' formatted resource or an attempt to deploy an invalid event'\
                              ' project to the event runtime. Information about the request is'\
                              ' provided in the response body and includes an error code and'\
                              ' error message.',
                             ErrorResponseException)
                .local_error('401',
                             "Unauthorized request, Missing Authorization header, or expired'\
                              ' authorization token etc. It is returned from the application'\
                              ' server\nwhen application security is enabled, and'\
                              ' authorization information was missing from the request.\n",
                             ErrorResponseException)
                .local_error('404',
                             'Not Found.',
                             ResourceNotFoundErrorException)
                .local_error('422',
                             "'Unprocessable Entity (WebDAV). If you are receiving an HTTP'\
                              ' 422 - Unprocessable Entity error, there are several'\
                              ' possibilities for why it might be occurring: <br><br> -You are'\
                              ' sending in a payload that is not valid JSON <br><br> -You are'\
                              ' sending HTTP headers, such as Content-Type or Accept, which'\
                              ' specify a value other than application/json <br><br> -The'\
                              ' request may be valid JSON, but there is something wrong with'\
                              ' the content.\n",
                             APIException)
                .local_error('429',
                             "Rate limit hit. See Retry-After header for a minimum amount of'\
                              ' delay, but note that there is no guarantee\nthat subsequent'\
                              ' request won't be limited.\n",
                             APIException)
                .local_error('500',
                             'Internal server error.',
                             APIException))
    .execute
end