Class: LoyaltyApIs::RedemptionApi

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

Overview

RedemptionApi

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

#point_redemption(language_code, user_authorization_token, consumer_uuid, country_code, x_correlation_id: nil, channel: nil, application: nil, retry_after: nil, body: nil) ⇒ ApiResponse

Point redemption API for customers to redeem loyalty points via the partner channel language code (lower case) and country code (upper case), separated by a hyphen. the accessToken retrieved from the /auth/exchangeAccessCode endpoint. This is referred to as user-authorization-token where the access is provided by the end user. signed in with Shell credentials Format: 32 hexadecimal digits grouped the following way: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx 3166-1 alpha-2 country code. in GUID format in order to track the request. a specified number of seconds have elapsed. loyalty points

Parameters:

  • language_code (String)

    Required parameter: A combination of

  • user_authorization_token (String)

    Required parameter: The value of

  • consumer_uuid (String)

    Required parameter: SSO uuid of the user

  • country_code (String)

    Required parameter: The two character ISO

  • x_correlation_id (UUID | String) (defaults to: nil)

    Optional parameter: An unique ID

  • channel (AssignOfferChannel) (defaults to: nil)

    Optional parameter: Channel.

  • application (String) (defaults to: nil)

    Optional parameter: String

  • retry_after (Integer) (defaults to: nil)

    Optional parameter: Retry the operation after

  • body (RedemptionRequest) (defaults to: nil)

    Optional parameter: Redeem a customer's

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



34
35
36
37
38
39
40
41
42
43
44
45
46
47
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
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
# File 'lib/loyalty_ap_is/apis/redemption_api.rb', line 34

def point_redemption(language_code,
                     user_authorization_token,
                     consumer_uuid,
                     country_code,
                     x_correlation_id: nil,
                     channel: nil,
                     application: nil,
                     retry_after: nil,
                     body: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/consumers/redemption',
                                 Server::SHELL1)
               .query_param(new_parameter(language_code, key: 'language_code')
                             .is_required(true))
               .header_param(new_parameter(user_authorization_token, key: 'user-authorization-token')
                              .is_required(true))
               .header_param(new_parameter(consumer_uuid, key: 'consumerUUID')
                              .is_required(true))
               .header_param(new_parameter(country_code, key: 'country-code')
                              .is_required(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .header_param(new_parameter(x_correlation_id, key: 'x-correlation-id'))
               .header_param(new_parameter(channel, key: 'channel'))
               .header_param(new_parameter(application, key: 'application'))
               .header_param(new_parameter(retry_after, key: 'Retry-After'))
               .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)
               .auth(Single.new('client-authorization-token')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(RedemptionResponse.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.',
                             ConsumersBalances400ErrorException)
                .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",
                             ConsumersBalances400ErrorException)
                .local_error('404',
                             'Not found - the server can not find the requested resource.',
                             ConsumersBalances400ErrorException)
                .local_error('422',
                             "Unprocessable Entity (WebDAV). If you are receiving an HTTP'\
                              ' 422 - Unprocessable Entity error, \nthere are several'\
                              ' possibilities for why it might be occurring-<br>\n - You are'\
                              ' sending in a payload that is not valid JSON. <br> \n - You are'\
                              ' sending HTTP headers, such as Content-Type or Accept, which'\
                              ' specify a value other than application/json. <br>\n - The'\
                              ' request may be valid JSON, but there is something wrong with'\
                              ' the content. \n",
                             ConsumersBalances400ErrorException)
                .local_error('429',
                             'Rate limit hit. See the Retry-After header to specify a delay,'\
                              ' but note that there is no guarantee that subsequent requests'\
                              ' won\'t be limited.',
                             APIException)
                .local_error('500',
                             'Internal server error',
                             APIException))
    .execute
end