loyalty-sdk 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +28 -0
  3. data/README.md +187 -0
  4. data/bin/console +15 -0
  5. data/lib/loyalty_ap_is/api_helper.rb +10 -0
  6. data/lib/loyalty_ap_is/apis/authorization_api.rb +116 -0
  7. data/lib/loyalty_ap_is/apis/balances_api.rb +96 -0
  8. data/lib/loyalty_ap_is/apis/base_api.rb +67 -0
  9. data/lib/loyalty_ap_is/apis/oauth_authorization_api.rb +44 -0
  10. data/lib/loyalty_ap_is/apis/offer_api.rb +164 -0
  11. data/lib/loyalty_ap_is/apis/profile_management_api.rb +44 -0
  12. data/lib/loyalty_ap_is/apis/redemption_api.rb +107 -0
  13. data/lib/loyalty_ap_is/apis/transaction_api.rb +143 -0
  14. data/lib/loyalty_ap_is/client.rb +137 -0
  15. data/lib/loyalty_ap_is/configuration.rb +238 -0
  16. data/lib/loyalty_ap_is/exceptions/api_exception.rb +21 -0
  17. data/lib/loyalty_ap_is/exceptions/common_error_exception.rb +98 -0
  18. data/lib/loyalty_ap_is/exceptions/consumers_balances400_error_exception.rb +57 -0
  19. data/lib/loyalty_ap_is/exceptions/consumers_balances401_error_exception.rb +57 -0
  20. data/lib/loyalty_ap_is/exceptions/consumers_balances404_error_exception.rb +57 -0
  21. data/lib/loyalty_ap_is/exceptions/consumers_balances422_error_exception.rb +57 -0
  22. data/lib/loyalty_ap_is/exceptions/error_response_exception.rb +57 -0
  23. data/lib/loyalty_ap_is/exceptions/json_api_error_exception.rb +60 -0
  24. data/lib/loyalty_ap_is/exceptions/oauth_provider_exception.rb +64 -0
  25. data/lib/loyalty_ap_is/exceptions/resource_not_found_error_exception.rb +57 -0
  26. data/lib/loyalty_ap_is/http/api_response.rb +19 -0
  27. data/lib/loyalty_ap_is/http/auth/client_authorization_token.rb +148 -0
  28. data/lib/loyalty_ap_is/http/auth/customer_header.rb +52 -0
  29. data/lib/loyalty_ap_is/http/auth/private_basic_token.rb +52 -0
  30. data/lib/loyalty_ap_is/http/auth/public_basic_token.rb +52 -0
  31. data/lib/loyalty_ap_is/http/auth/public_bearer_token.rb +53 -0
  32. data/lib/loyalty_ap_is/http/http_call_back.rb +10 -0
  33. data/lib/loyalty_ap_is/http/http_method_enum.rb +10 -0
  34. data/lib/loyalty_ap_is/http/http_request.rb +10 -0
  35. data/lib/loyalty_ap_is/http/http_response.rb +10 -0
  36. data/lib/loyalty_ap_is/http/proxy_settings.rb +22 -0
  37. data/lib/loyalty_ap_is/logging/configuration/api_logging_configuration.rb +186 -0
  38. data/lib/loyalty_ap_is/logging/sdk_logger.rb +17 -0
  39. data/lib/loyalty_ap_is/models/access_code_response.rb +87 -0
  40. data/lib/loyalty_ap_is/models/assign_offer_channel.rb +26 -0
  41. data/lib/loyalty_ap_is/models/auth_token_request.rb +75 -0
  42. data/lib/loyalty_ap_is/models/auth_token_response.rb +106 -0
  43. data/lib/loyalty_ap_is/models/bad_request_error.rb +63 -0
  44. data/lib/loyalty_ap_is/models/balance_amount.rb +84 -0
  45. data/lib/loyalty_ap_is/models/balance_amount_detail.rb +141 -0
  46. data/lib/loyalty_ap_is/models/balance_currency_amount.rb +93 -0
  47. data/lib/loyalty_ap_is/models/balance_currency_type.rb +60 -0
  48. data/lib/loyalty_ap_is/models/balance_state.rb +72 -0
  49. data/lib/loyalty_ap_is/models/base_model.rb +110 -0
  50. data/lib/loyalty_ap_is/models/client_auth_token_request.rb +78 -0
  51. data/lib/loyalty_ap_is/models/currency_data.rb +101 -0
  52. data/lib/loyalty_ap_is/models/customer_balances.rb +84 -0
  53. data/lib/loyalty_ap_is/models/error_base_container.rb +82 -0
  54. data/lib/loyalty_ap_is/models/error_info.rb +84 -0
  55. data/lib/loyalty_ap_is/models/error_item.rb +105 -0
  56. data/lib/loyalty_ap_is/models/error_presenter.rb +150 -0
  57. data/lib/loyalty_ap_is/models/error_source.rb +75 -0
  58. data/lib/loyalty_ap_is/models/ev_charging_details.rb +151 -0
  59. data/lib/loyalty_ap_is/models/exchange_access_code_request.rb +77 -0
  60. data/lib/loyalty_ap_is/models/fault.rb +85 -0
  61. data/lib/loyalty_ap_is/models/fault_detail.rb +76 -0
  62. data/lib/loyalty_ap_is/models/json_api_version.rb +75 -0
  63. data/lib/loyalty_ap_is/models/loyalty_card_info.rb +76 -0
  64. data/lib/loyalty_ap_is/models/m200_user_partners.rb +109 -0
  65. data/lib/loyalty_ap_is/models/method_not_allowed_error.rb +62 -0
  66. data/lib/loyalty_ap_is/models/not_found_error.rb +62 -0
  67. data/lib/loyalty_ap_is/models/not_found_error_response.rb +90 -0
  68. data/lib/loyalty_ap_is/models/oauth_provider_error.rb +62 -0
  69. data/lib/loyalty_ap_is/models/oauth_token.rb +96 -0
  70. data/lib/loyalty_ap_is/models/offer.rb +155 -0
  71. data/lib/loyalty_ap_is/models/offer_assignment.rb +172 -0
  72. data/lib/loyalty_ap_is/models/offer_base.rb +101 -0
  73. data/lib/loyalty_ap_is/models/offer_info.rb +156 -0
  74. data/lib/loyalty_ap_is/models/offer_language.rb +100 -0
  75. data/lib/loyalty_ap_is/models/points_to_cash.rb +99 -0
  76. data/lib/loyalty_ap_is/models/product_type.rb +53 -0
  77. data/lib/loyalty_ap_is/models/redeemed_item.rb +221 -0
  78. data/lib/loyalty_ap_is/models/redeemed_item_product.rb +131 -0
  79. data/lib/loyalty_ap_is/models/redemption_item.rb +109 -0
  80. data/lib/loyalty_ap_is/models/redemption_request.rb +107 -0
  81. data/lib/loyalty_ap_is/models/redemption_response.rb +118 -0
  82. data/lib/loyalty_ap_is/models/redemption_response_item.rb +111 -0
  83. data/lib/loyalty_ap_is/models/refresh_token_request.rb +75 -0
  84. data/lib/loyalty_ap_is/models/refresh_token_response.rb +93 -0
  85. data/lib/loyalty_ap_is/models/sale_item.rb +262 -0
  86. data/lib/loyalty_ap_is/models/sale_item_product.rb +135 -0
  87. data/lib/loyalty_ap_is/models/site_data.rb +121 -0
  88. data/lib/loyalty_ap_is/models/transaction.rb +351 -0
  89. data/lib/loyalty_ap_is/models/transaction_balance.rb +91 -0
  90. data/lib/loyalty_ap_is/models/transaction_balance_amount.rb +82 -0
  91. data/lib/loyalty_ap_is/models/transaction_balance_state.rb +64 -0
  92. data/lib/loyalty_ap_is/models/transaction_currency_type.rb +56 -0
  93. data/lib/loyalty_ap_is/models/transaction_detail_type.rb +53 -0
  94. data/lib/loyalty_ap_is/models/transaction_type_filter.rb +40 -0
  95. data/lib/loyalty_ap_is/models/transaction_voucher.rb +109 -0
  96. data/lib/loyalty_ap_is/models/transactions_response.rb +118 -0
  97. data/lib/loyalty_ap_is/models/unauthorized_error.rb +62 -0
  98. data/lib/loyalty_ap_is/models/unit_measure.rb +40 -0
  99. data/lib/loyalty_ap_is/models/unprocessable_entity_error_response.rb +90 -0
  100. data/lib/loyalty_ap_is/models/voucher_item.rb +99 -0
  101. data/lib/loyalty_ap_is/utilities/date_time_helper.rb +11 -0
  102. data/lib/loyalty_ap_is/utilities/file_wrapper.rb +28 -0
  103. data/lib/loyalty_ap_is.rb +128 -0
  104. metadata +189 -0
@@ -0,0 +1,62 @@
1
+ # loyalty_ap_is
2
+ #
3
+ # This file was automatically generated by APIMATIC v3.0 (
4
+ # https://www.apimatic.io ).
5
+
6
+ module LoyaltyApIs
7
+ # An error response.
8
+ class MethodNotAllowedError < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
12
+ # TODO: Write general description for this method
13
+ # @return [Fault]
14
+ attr_accessor :fault
15
+
16
+ # A mapping from model property names to API property names.
17
+ def self.names
18
+ @_hash = {} if @_hash.nil?
19
+ @_hash['fault'] = 'fault'
20
+ @_hash
21
+ end
22
+
23
+ # An array for optional fields
24
+ def self.optionals
25
+ %w[
26
+ fault
27
+ ]
28
+ end
29
+
30
+ # An array for nullable fields
31
+ def self.nullables
32
+ []
33
+ end
34
+
35
+ def initialize(fault: SKIP)
36
+ @fault = fault unless fault == SKIP
37
+ end
38
+
39
+ # Creates an instance of the object from a hash.
40
+ def self.from_hash(hash)
41
+ return nil unless hash
42
+
43
+ # Extract variables from the hash.
44
+ fault = Fault.from_hash(hash['fault']) if hash['fault']
45
+
46
+ # Create object from extracted values.
47
+ MethodNotAllowedError.new(fault: fault)
48
+ end
49
+
50
+ # Provides a human-readable string representation of the object.
51
+ def to_s
52
+ class_name = self.class.name.split('::').last
53
+ "<#{class_name} fault: #{@fault}>"
54
+ end
55
+
56
+ # Provides a debugging-friendly string with detailed object information.
57
+ def inspect
58
+ class_name = self.class.name.split('::').last
59
+ "<#{class_name} fault: #{@fault.inspect}>"
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,62 @@
1
+ # loyalty_ap_is
2
+ #
3
+ # This file was automatically generated by APIMATIC v3.0 (
4
+ # https://www.apimatic.io ).
5
+
6
+ module LoyaltyApIs
7
+ # An error response.
8
+ class NotFoundError < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
12
+ # TODO: Write general description for this method
13
+ # @return [Fault]
14
+ attr_accessor :fault
15
+
16
+ # A mapping from model property names to API property names.
17
+ def self.names
18
+ @_hash = {} if @_hash.nil?
19
+ @_hash['fault'] = 'fault'
20
+ @_hash
21
+ end
22
+
23
+ # An array for optional fields
24
+ def self.optionals
25
+ %w[
26
+ fault
27
+ ]
28
+ end
29
+
30
+ # An array for nullable fields
31
+ def self.nullables
32
+ []
33
+ end
34
+
35
+ def initialize(fault: SKIP)
36
+ @fault = fault unless fault == SKIP
37
+ end
38
+
39
+ # Creates an instance of the object from a hash.
40
+ def self.from_hash(hash)
41
+ return nil unless hash
42
+
43
+ # Extract variables from the hash.
44
+ fault = Fault.from_hash(hash['fault']) if hash['fault']
45
+
46
+ # Create object from extracted values.
47
+ NotFoundError.new(fault: fault)
48
+ end
49
+
50
+ # Provides a human-readable string representation of the object.
51
+ def to_s
52
+ class_name = self.class.name.split('::').last
53
+ "<#{class_name} fault: #{@fault}>"
54
+ end
55
+
56
+ # Provides a debugging-friendly string with detailed object information.
57
+ def inspect
58
+ class_name = self.class.name.split('::').last
59
+ "<#{class_name} fault: #{@fault.inspect}>"
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,90 @@
1
+ # loyalty_ap_is
2
+ #
3
+ # This file was automatically generated by APIMATIC v3.0 (
4
+ # https://www.apimatic.io ).
5
+
6
+ module LoyaltyApIs
7
+ # NotFoundErrorResponse Model.
8
+ class NotFoundErrorResponse < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
12
+ # HTTP error code 404
13
+ # @return [Float]
14
+ attr_accessor :error_code
15
+
16
+ # HTTP error message - Not Found
17
+ # @return [String]
18
+ attr_accessor :message
19
+
20
+ # HTTP error message - Not Found
21
+ # @return [ErrorInfo]
22
+ attr_accessor :error
23
+
24
+ # A mapping from model property names to API property names.
25
+ def self.names
26
+ @_hash = {} if @_hash.nil?
27
+ @_hash['error_code'] = 'errorCode'
28
+ @_hash['message'] = 'message'
29
+ @_hash['error'] = 'error'
30
+ @_hash
31
+ end
32
+
33
+ # An array for optional fields
34
+ def self.optionals
35
+ []
36
+ end
37
+
38
+ # An array for nullable fields
39
+ def self.nullables
40
+ []
41
+ end
42
+
43
+ def initialize(error_code:, message:, error:, additional_properties: nil)
44
+ # Add additional model properties to the instance
45
+ additional_properties = {} if additional_properties.nil?
46
+
47
+ @error_code = error_code
48
+ @message = message
49
+ @error = error
50
+ @additional_properties = additional_properties
51
+ end
52
+
53
+ # Creates an instance of the object from a hash.
54
+ def self.from_hash(hash)
55
+ return nil unless hash
56
+
57
+ # Extract variables from the hash.
58
+ error_code = hash.key?('errorCode') ? hash['errorCode'] : nil
59
+ message = hash.key?('message') ? hash['message'] : nil
60
+ error = ErrorInfo.from_hash(hash['error']) if hash['error']
61
+
62
+ # Create a new hash for additional properties, removing known properties.
63
+ new_hash = hash.reject { |k, _| names.value?(k) }
64
+
65
+ additional_properties = APIHelper.get_additional_properties(
66
+ new_hash, proc { |value| value }
67
+ )
68
+
69
+ # Create object from extracted values.
70
+ NotFoundErrorResponse.new(error_code: error_code,
71
+ message: message,
72
+ error: error,
73
+ additional_properties: additional_properties)
74
+ end
75
+
76
+ # Provides a human-readable string representation of the object.
77
+ def to_s
78
+ class_name = self.class.name.split('::').last
79
+ "<#{class_name} error_code: #{@error_code}, message: #{@message}, error: #{@error},"\
80
+ " additional_properties: #{@additional_properties}>"
81
+ end
82
+
83
+ # Provides a debugging-friendly string with detailed object information.
84
+ def inspect
85
+ class_name = self.class.name.split('::').last
86
+ "<#{class_name} error_code: #{@error_code.inspect}, message: #{@message.inspect}, error:"\
87
+ " #{@error.inspect}, additional_properties: #{@additional_properties}>"
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,62 @@
1
+ # loyalty_ap_is
2
+ #
3
+ # This file was automatically generated by APIMATIC v3.0 (
4
+ # https://www.apimatic.io ).
5
+
6
+ module LoyaltyApIs
7
+ # OAuth 2 Authorization error codes
8
+ class OauthProviderError
9
+ OAUTH_PROVIDER_ERROR = [
10
+ # The request is missing a required parameter, includes an unsupported
11
+ # parameter value (other than grant type), repeats a parameter, includes
12
+ # multiple credentials, utilizes more than one mechanism for
13
+ # authenticating the client, or is otherwise malformed.
14
+ INVALID_REQUEST = 'invalid_request'.freeze,
15
+
16
+ # Client authentication failed (e.g., unknown client, no client
17
+ # authentication included, or unsupported authentication method).
18
+ INVALID_CLIENT = 'invalid_client'.freeze,
19
+
20
+ # The provided authorization grant (e.g., authorization code, resource
21
+ # owner credentials) or refresh token is invalid, expired, revoked, does
22
+ # not match the redirection URI used in the authorization request, or was
23
+ # issued to another client.
24
+ INVALID_GRANT = 'invalid_grant'.freeze,
25
+
26
+ # The authenticated client is not authorized to use this authorization
27
+ # grant type.
28
+ UNAUTHORIZED_CLIENT = 'unauthorized_client'.freeze,
29
+
30
+ # The authorization grant type is not supported by the authorization
31
+ # server.
32
+ UNSUPPORTED_GRANT_TYPE = 'unsupported_grant_type'.freeze,
33
+
34
+ # The requested scope is invalid, unknown, malformed, or exceeds the scope
35
+ # granted by the resource owner.
36
+ INVALID_SCOPE = 'invalid_scope'.freeze
37
+ ].freeze
38
+
39
+ def self.validate(value)
40
+ return false if value.nil?
41
+
42
+ OAUTH_PROVIDER_ERROR.include?(value)
43
+ end
44
+
45
+ def self.from_value(value, default_value = INVALID_REQUEST)
46
+ return default_value if value.nil?
47
+
48
+ str = value.to_s.strip
49
+
50
+ case str.downcase
51
+ when 'invalid_request' then INVALID_REQUEST
52
+ when 'invalid_client' then INVALID_CLIENT
53
+ when 'invalid_grant' then INVALID_GRANT
54
+ when 'unauthorized_client' then UNAUTHORIZED_CLIENT
55
+ when 'unsupported_grant_type' then UNSUPPORTED_GRANT_TYPE
56
+ when 'invalid_scope' then INVALID_SCOPE
57
+ else
58
+ default_value
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,96 @@
1
+ # loyalty_ap_is
2
+ #
3
+ # This file was automatically generated by APIMATIC v3.0 (
4
+ # https://www.apimatic.io ).
5
+
6
+ module LoyaltyApIs
7
+ # OAuth 2 Authorization endpoint response
8
+ class OauthToken < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
12
+ # Access token
13
+ # @return [String]
14
+ attr_accessor :access_token
15
+
16
+ # Type of access token
17
+ # @return [String]
18
+ attr_accessor :token_type
19
+
20
+ # Time in seconds before the access token expires
21
+ # @return [Integer]
22
+ attr_accessor :expires_in
23
+
24
+ # List of scopes granted
25
+ # This is a space-delimited list of strings.
26
+ # @return [String]
27
+ attr_accessor :scope
28
+
29
+ # Time of token expiry as unix timestamp (UTC)
30
+ # @return [Integer]
31
+ attr_accessor :expiry
32
+
33
+ # Refresh token
34
+ # Used to get a new access token when it expires.
35
+ # @return [String]
36
+ attr_accessor :refresh_token
37
+
38
+ # A mapping from model property names to API property names.
39
+ def self.names
40
+ @_hash = {} if @_hash.nil?
41
+ @_hash['access_token'] = 'access_token'
42
+ @_hash['token_type'] = 'token_type'
43
+ @_hash['expires_in'] = 'expires_in'
44
+ @_hash['scope'] = 'scope'
45
+ @_hash['expiry'] = 'expiry'
46
+ @_hash['refresh_token'] = 'refresh_token'
47
+ @_hash
48
+ end
49
+
50
+ # An array for optional fields
51
+ def self.optionals
52
+ %w[
53
+ expires_in
54
+ scope
55
+ expiry
56
+ refresh_token
57
+ ]
58
+ end
59
+
60
+ # An array for nullable fields
61
+ def self.nullables
62
+ []
63
+ end
64
+
65
+ def initialize(access_token:, token_type:, expires_in: SKIP, scope: SKIP,
66
+ expiry: SKIP, refresh_token: SKIP)
67
+ @access_token = access_token
68
+ @token_type = token_type
69
+ @expires_in = expires_in unless expires_in == SKIP
70
+ @scope = scope unless scope == SKIP
71
+ @expiry = expiry unless expiry == SKIP
72
+ @refresh_token = refresh_token unless refresh_token == SKIP
73
+ end
74
+
75
+ # Creates an instance of the object from a hash.
76
+ def self.from_hash(hash)
77
+ return nil unless hash
78
+
79
+ # Extract variables from the hash.
80
+ access_token = hash.key?('access_token') ? hash['access_token'] : nil
81
+ token_type = hash.key?('token_type') ? hash['token_type'] : nil
82
+ expires_in = hash.key?('expires_in') ? hash['expires_in'] : SKIP
83
+ scope = hash.key?('scope') ? hash['scope'] : SKIP
84
+ expiry = hash.key?('expiry') ? hash['expiry'] : SKIP
85
+ refresh_token = hash.key?('refresh_token') ? hash['refresh_token'] : SKIP
86
+
87
+ # Create object from extracted values.
88
+ OauthToken.new(access_token: access_token,
89
+ token_type: token_type,
90
+ expires_in: expires_in,
91
+ scope: scope,
92
+ expiry: expiry,
93
+ refresh_token: refresh_token)
94
+ end
95
+ end
96
+ end
@@ -0,0 +1,155 @@
1
+ # loyalty_ap_is
2
+ #
3
+ # This file was automatically generated by APIMATIC v3.0 (
4
+ # https://www.apimatic.io ).
5
+
6
+ require 'date'
7
+ module LoyaltyApIs
8
+ # Offer Model.
9
+ class Offer < BaseModel
10
+ SKIP = Object.new
11
+ private_constant :SKIP
12
+
13
+ # Offer ID provided upon offer configuration
14
+ # @return [Integer]
15
+ attr_accessor :offer_id
16
+
17
+ # Unique Reference ID for the transaction from the partner. Used to identify
18
+ # duplicate requests.
19
+ # @return [String]
20
+ attr_accessor :reference_id
21
+
22
+ # Title of the partner's offer, given upon configuration
23
+ # @return [String]
24
+ attr_accessor :title
25
+
26
+ # Description of the partner's offer, set up upon offer configuration
27
+ # @return [String]
28
+ attr_accessor :description
29
+
30
+ # Offer validity start date in JSON recommended format:
31
+ # "yyyy-MM-ddTHH:mm:ssZ".
32
+ # The date format must follow ISO_8601. If 'Z' is written immediately after
33
+ # the time, it is considered UTC.
34
+ # Time offset from UTC can be appended instead of 'Z' using plus or minus
35
+ # signs. Negative UTC offsets describe a time zone west of UTC�00:00, where
36
+ # the civil time is behind (or earlier) than UTC. Positive UTC offsets
37
+ # describe a time zone east of UTC�00:00, where the civil time is ahead (or
38
+ # later) than UTC
39
+ # @return [DateTime]
40
+ attr_accessor :valid_from
41
+
42
+ # Offer validity end date in JSON recommended format:
43
+ # "yyyy-MM-ddTHH:mm:ssZ".
44
+ # The date format must follow ISO_8601. If 'Z' is written immediately after
45
+ # the time, it is considered UTC.
46
+ # Time offset from UTC can be appended instead of 'Z' using plus or minus
47
+ # signs. Negative UTC offsets describe a time zone west of UTC�00:00, where
48
+ # the civil time is behind (or earlier) than UTC. Positive UTC offsets
49
+ # describe a time zone east of UTC�00:00, where the civil time is ahead (or
50
+ # later) than UTC
51
+ # Nullable field value, in case of the offer has infinite valid to.
52
+ # @return [DateTime]
53
+ attr_accessor :valid_to
54
+
55
+ # A mapping from model property names to API property names.
56
+ def self.names
57
+ @_hash = {} if @_hash.nil?
58
+ @_hash['offer_id'] = 'offerId'
59
+ @_hash['reference_id'] = 'referenceId'
60
+ @_hash['title'] = 'title'
61
+ @_hash['description'] = 'description'
62
+ @_hash['valid_from'] = 'validFrom'
63
+ @_hash['valid_to'] = 'validTo'
64
+ @_hash
65
+ end
66
+
67
+ # An array for optional fields
68
+ def self.optionals
69
+ %w[
70
+ valid_to
71
+ ]
72
+ end
73
+
74
+ # An array for nullable fields
75
+ def self.nullables
76
+ %w[
77
+ valid_to
78
+ ]
79
+ end
80
+
81
+ def initialize(offer_id:, reference_id:, title:, description:, valid_from:,
82
+ valid_to: SKIP, additional_properties: nil)
83
+ # Add additional model properties to the instance
84
+ additional_properties = {} if additional_properties.nil?
85
+
86
+ @offer_id = offer_id
87
+ @reference_id = reference_id
88
+ @title = title
89
+ @description = description
90
+ @valid_from = valid_from
91
+ @valid_to = valid_to unless valid_to == SKIP
92
+ @additional_properties = additional_properties
93
+ end
94
+
95
+ # Creates an instance of the object from a hash.
96
+ def self.from_hash(hash)
97
+ return nil unless hash
98
+
99
+ # Extract variables from the hash.
100
+ offer_id = hash.key?('offerId') ? hash['offerId'] : nil
101
+ reference_id = hash.key?('referenceId') ? hash['referenceId'] : nil
102
+ title = hash.key?('title') ? hash['title'] : nil
103
+ description = hash.key?('description') ? hash['description'] : nil
104
+ valid_from = if hash.key?('validFrom')
105
+ (DateTimeHelper.from_rfc3339(hash['validFrom']) if hash['validFrom'])
106
+ end
107
+ valid_to = if hash.key?('validTo')
108
+ (DateTimeHelper.from_rfc3339(hash['validTo']) if hash['validTo'])
109
+ else
110
+ SKIP
111
+ end
112
+
113
+ # Create a new hash for additional properties, removing known properties.
114
+ new_hash = hash.reject { |k, _| names.value?(k) }
115
+
116
+ additional_properties = APIHelper.get_additional_properties(
117
+ new_hash, proc { |value| value }
118
+ )
119
+
120
+ # Create object from extracted values.
121
+ Offer.new(offer_id: offer_id,
122
+ reference_id: reference_id,
123
+ title: title,
124
+ description: description,
125
+ valid_from: valid_from,
126
+ valid_to: valid_to,
127
+ additional_properties: additional_properties)
128
+ end
129
+
130
+ def to_custom_valid_from
131
+ DateTimeHelper.to_rfc3339(valid_from)
132
+ end
133
+
134
+ def to_custom_valid_to
135
+ DateTimeHelper.to_rfc3339(valid_to)
136
+ end
137
+
138
+ # Provides a human-readable string representation of the object.
139
+ def to_s
140
+ class_name = self.class.name.split('::').last
141
+ "<#{class_name} offer_id: #{@offer_id}, reference_id: #{@reference_id}, title: #{@title},"\
142
+ " description: #{@description}, valid_from: #{@valid_from}, valid_to: #{@valid_to},"\
143
+ " additional_properties: #{@additional_properties}>"
144
+ end
145
+
146
+ # Provides a debugging-friendly string with detailed object information.
147
+ def inspect
148
+ class_name = self.class.name.split('::').last
149
+ "<#{class_name} offer_id: #{@offer_id.inspect}, reference_id: #{@reference_id.inspect},"\
150
+ " title: #{@title.inspect}, description: #{@description.inspect}, valid_from:"\
151
+ " #{@valid_from.inspect}, valid_to: #{@valid_to.inspect}, additional_properties:"\
152
+ " #{@additional_properties}>"
153
+ end
154
+ end
155
+ end
@@ -0,0 +1,172 @@
1
+ # loyalty_ap_is
2
+ #
3
+ # This file was automatically generated by APIMATIC v3.0 (
4
+ # https://www.apimatic.io ).
5
+
6
+ require 'date'
7
+ module LoyaltyApIs
8
+ # OfferAssignment Model.
9
+ class OfferAssignment < BaseModel
10
+ SKIP = Object.new
11
+ private_constant :SKIP
12
+
13
+ # Unique Reference ID for the transaction from the partner. Used to identify
14
+ # duplicate requests.
15
+ # @return [String]
16
+ attr_accessor :reference_id
17
+
18
+ # SSO uuid of the user signed in with Shell credentials
19
+ # Format: 32 hexadecimal digits grouped the following way:
20
+ # xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
21
+ # @return [UUID | String]
22
+ attr_accessor :consumer_uuid
23
+
24
+ # Offer identifier shared by Shell.
25
+ # Format: string(30)
26
+ # @return [String]
27
+ attr_accessor :offer_id
28
+
29
+ # Offer validity start date in JSON recommended format:
30
+ # "yyyy-MM-ddTHH:mm:ssZ".
31
+ # The date format must follow ISO_8601. If 'Z' is written immediately after
32
+ # the time, it is considered UTC.
33
+ # Time offset from UTC can be appended instead of 'Z' using plus or minus
34
+ # signs. Negative UTC offsets describe a time zone west of UTC�00:00, where
35
+ # the civil time is behind (or earlier) than UTC. Positive UTC offsets
36
+ # describe a time zone east of UTC�00:00, where the civil time is ahead (or
37
+ # later) than UTC
38
+ # @return [DateTime]
39
+ attr_accessor :valid_from
40
+
41
+ # Offer validity period (Number of days)
42
+ # If validityPeriod is greater than zero, validTo will be ignored.
43
+ # The offer will be valid till:
44
+ # validfrom + validityperiod
45
+ # If the resulting valid to date would be during the day, then its validity
46
+ # is modified to last until midnight in the timezone of the validFrom date.
47
+ # E.g. If valiFrom is "2021-03-08T17:12:55Z+01:00" (Central European time)
48
+ # and validtyPeriod is 3 then the offer will be valid till
49
+ # "2021-03-11T23:59:59Z+01:00" (Central European Time)
50
+ # @return [Float]
51
+ attr_accessor :validity_period
52
+
53
+ # Offer validity end date in JSON recommended format:
54
+ # "yyyy-MM-ddTHH:mm:ssZ".
55
+ # Field value is ignored if validityPeriod is bigger than zero.
56
+ # The date format must follow ISO_8601. If 'Z' is written immediately after
57
+ # the time, it is considered UTC.
58
+ # Time offset from UTC can be appended instead of 'Z' using plus or minus
59
+ # signs. Negative UTC offsets describe a time zone west of UTC�00:00, where
60
+ # the civil time is behind (or earlier) than UTC. Positive UTC offsets
61
+ # describe a time zone east of UTC�00:00, where the civil time is ahead (or
62
+ # later) than UTC
63
+ # @return [DateTime]
64
+ attr_accessor :valid_to
65
+
66
+ # A mapping from model property names to API property names.
67
+ def self.names
68
+ @_hash = {} if @_hash.nil?
69
+ @_hash['reference_id'] = 'referenceId'
70
+ @_hash['consumer_uuid'] = 'consumerUuid'
71
+ @_hash['offer_id'] = 'offerId'
72
+ @_hash['valid_from'] = 'validFrom'
73
+ @_hash['validity_period'] = 'validityPeriod'
74
+ @_hash['valid_to'] = 'validTo'
75
+ @_hash
76
+ end
77
+
78
+ # An array for optional fields
79
+ def self.optionals
80
+ %w[
81
+ valid_from
82
+ validity_period
83
+ valid_to
84
+ ]
85
+ end
86
+
87
+ # An array for nullable fields
88
+ def self.nullables
89
+ %w[
90
+ valid_to
91
+ ]
92
+ end
93
+
94
+ def initialize(reference_id:, consumer_uuid:, offer_id:, valid_from: SKIP,
95
+ validity_period: SKIP, valid_to: SKIP,
96
+ additional_properties: nil)
97
+ # Add additional model properties to the instance
98
+ additional_properties = {} if additional_properties.nil?
99
+
100
+ @reference_id = reference_id
101
+ @consumer_uuid = consumer_uuid
102
+ @offer_id = offer_id
103
+ @valid_from = valid_from unless valid_from == SKIP
104
+ @validity_period = validity_period unless validity_period == SKIP
105
+ @valid_to = valid_to unless valid_to == SKIP
106
+ @additional_properties = additional_properties
107
+ end
108
+
109
+ # Creates an instance of the object from a hash.
110
+ def self.from_hash(hash)
111
+ return nil unless hash
112
+
113
+ # Extract variables from the hash.
114
+ reference_id = hash.key?('referenceId') ? hash['referenceId'] : nil
115
+ consumer_uuid = hash.key?('consumerUuid') ? hash['consumerUuid'] : nil
116
+ offer_id = hash.key?('offerId') ? hash['offerId'] : nil
117
+ valid_from = if hash.key?('validFrom')
118
+ (DateTimeHelper.from_rfc3339(hash['validFrom']) if hash['validFrom'])
119
+ else
120
+ SKIP
121
+ end
122
+ validity_period =
123
+ hash.key?('validityPeriod') ? hash['validityPeriod'] : SKIP
124
+ valid_to = if hash.key?('validTo')
125
+ (DateTimeHelper.from_rfc3339(hash['validTo']) if hash['validTo'])
126
+ else
127
+ SKIP
128
+ end
129
+
130
+ # Create a new hash for additional properties, removing known properties.
131
+ new_hash = hash.reject { |k, _| names.value?(k) }
132
+
133
+ additional_properties = APIHelper.get_additional_properties(
134
+ new_hash, proc { |value| value }
135
+ )
136
+
137
+ # Create object from extracted values.
138
+ OfferAssignment.new(reference_id: reference_id,
139
+ consumer_uuid: consumer_uuid,
140
+ offer_id: offer_id,
141
+ valid_from: valid_from,
142
+ validity_period: validity_period,
143
+ valid_to: valid_to,
144
+ additional_properties: additional_properties)
145
+ end
146
+
147
+ def to_custom_valid_from
148
+ DateTimeHelper.to_rfc3339(valid_from)
149
+ end
150
+
151
+ def to_custom_valid_to
152
+ DateTimeHelper.to_rfc3339(valid_to)
153
+ end
154
+
155
+ # Provides a human-readable string representation of the object.
156
+ def to_s
157
+ class_name = self.class.name.split('::').last
158
+ "<#{class_name} reference_id: #{@reference_id}, consumer_uuid: #{@consumer_uuid}, offer_id:"\
159
+ " #{@offer_id}, valid_from: #{@valid_from}, validity_period: #{@validity_period}, valid_to:"\
160
+ " #{@valid_to}, additional_properties: #{@additional_properties}>"
161
+ end
162
+
163
+ # Provides a debugging-friendly string with detailed object information.
164
+ def inspect
165
+ class_name = self.class.name.split('::').last
166
+ "<#{class_name} reference_id: #{@reference_id.inspect}, consumer_uuid:"\
167
+ " #{@consumer_uuid.inspect}, offer_id: #{@offer_id.inspect}, valid_from:"\
168
+ " #{@valid_from.inspect}, validity_period: #{@validity_period.inspect}, valid_to:"\
169
+ " #{@valid_to.inspect}, additional_properties: #{@additional_properties}>"
170
+ end
171
+ end
172
+ end