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,141 @@
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
+ # BalanceAmountDetail Model.
9
+ class BalanceAmountDetail < BaseModel
10
+ SKIP = Object.new
11
+ private_constant :SKIP
12
+
13
+ # Current value of specified balance.
14
+ # @return [Float]
15
+ attr_accessor :amount
16
+
17
+ # State of the points balance amount.
18
+ # @return [BalanceState]
19
+ attr_accessor :state
20
+
21
+ # Expiration Date in JSON recommended format: “yyyy-MM-ddTHH:mm:ssZ”
22
+ # Nullable.
23
+ # @return [DateTime]
24
+ attr_accessor :date_time
25
+
26
+ # Date as Unix epoch (UTC).
27
+ # @return [Integer]
28
+ attr_accessor :date_timestamp
29
+
30
+ # Point to cash exchange amnount.
31
+ # @return [Float]
32
+ attr_accessor :cash_amount
33
+
34
+ # Period of expiration, minimum value is 1. Seralized only when it’s not
35
+ # null.
36
+ # @return [Integer]
37
+ attr_accessor :period
38
+
39
+ # The list of numbers describes an index of boost’s position in qualifying
40
+ # visit, Seralized only when it’s not null and not empty.
41
+ # @return [Array[Integer]]
42
+ attr_accessor :position
43
+
44
+ # A mapping from model property names to API property names.
45
+ def self.names
46
+ @_hash = {} if @_hash.nil?
47
+ @_hash['amount'] = 'amount'
48
+ @_hash['state'] = 'state'
49
+ @_hash['date_time'] = 'dateTime'
50
+ @_hash['date_timestamp'] = 'dateTimestamp'
51
+ @_hash['cash_amount'] = 'cashAmount'
52
+ @_hash['period'] = 'period'
53
+ @_hash['position'] = 'position'
54
+ @_hash
55
+ end
56
+
57
+ # An array for optional fields
58
+ def self.optionals
59
+ %w[
60
+ cash_amount
61
+ period
62
+ position
63
+ ]
64
+ end
65
+
66
+ # An array for nullable fields
67
+ def self.nullables
68
+ []
69
+ end
70
+
71
+ def initialize(amount:, state:, date_time:, date_timestamp:,
72
+ cash_amount: SKIP, period: SKIP, position: SKIP,
73
+ additional_properties: nil)
74
+ # Add additional model properties to the instance
75
+ additional_properties = {} if additional_properties.nil?
76
+
77
+ @amount = amount
78
+ @state = state
79
+ @date_time = date_time
80
+ @date_timestamp = date_timestamp
81
+ @cash_amount = cash_amount unless cash_amount == SKIP
82
+ @period = period unless period == SKIP
83
+ @position = position unless position == SKIP
84
+ @additional_properties = additional_properties
85
+ end
86
+
87
+ # Creates an instance of the object from a hash.
88
+ def self.from_hash(hash)
89
+ return nil unless hash
90
+
91
+ # Extract variables from the hash.
92
+ amount = hash.key?('amount') ? hash['amount'] : nil
93
+ state = hash.key?('state') ? hash['state'] : nil
94
+ date_time = if hash.key?('dateTime')
95
+ (DateTimeHelper.from_rfc3339(hash['dateTime']) if hash['dateTime'])
96
+ end
97
+ date_timestamp = hash.key?('dateTimestamp') ? hash['dateTimestamp'] : nil
98
+ cash_amount = hash.key?('cashAmount') ? hash['cashAmount'] : SKIP
99
+ period = hash.key?('period') ? hash['period'] : SKIP
100
+ position = hash.key?('position') ? hash['position'] : SKIP
101
+
102
+ # Create a new hash for additional properties, removing known properties.
103
+ new_hash = hash.reject { |k, _| names.value?(k) }
104
+
105
+ additional_properties = APIHelper.get_additional_properties(
106
+ new_hash, proc { |value| value }
107
+ )
108
+
109
+ # Create object from extracted values.
110
+ BalanceAmountDetail.new(amount: amount,
111
+ state: state,
112
+ date_time: date_time,
113
+ date_timestamp: date_timestamp,
114
+ cash_amount: cash_amount,
115
+ period: period,
116
+ position: position,
117
+ additional_properties: additional_properties)
118
+ end
119
+
120
+ def to_custom_date_time
121
+ DateTimeHelper.to_rfc3339(date_time)
122
+ end
123
+
124
+ # Provides a human-readable string representation of the object.
125
+ def to_s
126
+ class_name = self.class.name.split('::').last
127
+ "<#{class_name} amount: #{@amount}, state: #{@state}, date_time: #{@date_time},"\
128
+ " date_timestamp: #{@date_timestamp}, cash_amount: #{@cash_amount}, period: #{@period},"\
129
+ " position: #{@position}, additional_properties: #{@additional_properties}>"
130
+ end
131
+
132
+ # Provides a debugging-friendly string with detailed object information.
133
+ def inspect
134
+ class_name = self.class.name.split('::').last
135
+ "<#{class_name} amount: #{@amount.inspect}, state: #{@state.inspect}, date_time:"\
136
+ " #{@date_time.inspect}, date_timestamp: #{@date_timestamp.inspect}, cash_amount:"\
137
+ " #{@cash_amount.inspect}, period: #{@period.inspect}, position: #{@position.inspect},"\
138
+ " additional_properties: #{@additional_properties}>"
139
+ end
140
+ end
141
+ end
@@ -0,0 +1,93 @@
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
+ # BalanceCurrencyAmount Model.
8
+ class BalanceCurrencyAmount < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
12
+ # TODO: Write general description for this method
13
+ # @return [BalanceCurrencyType]
14
+ attr_accessor :currency_type
15
+
16
+ # TODO: Write general description for this method
17
+ # @return [Array[BalanceAmountDetail]]
18
+ attr_accessor :amounts
19
+
20
+ # A mapping from model property names to API property names.
21
+ def self.names
22
+ @_hash = {} if @_hash.nil?
23
+ @_hash['currency_type'] = 'currencyType'
24
+ @_hash['amounts'] = 'amounts'
25
+ @_hash
26
+ end
27
+
28
+ # An array for optional fields
29
+ def self.optionals
30
+ %w[
31
+ amounts
32
+ ]
33
+ end
34
+
35
+ # An array for nullable fields
36
+ def self.nullables
37
+ []
38
+ end
39
+
40
+ def initialize(currency_type:, amounts: SKIP, additional_properties: nil)
41
+ # Add additional model properties to the instance
42
+ additional_properties = {} if additional_properties.nil?
43
+
44
+ @currency_type = currency_type
45
+ @amounts = amounts unless amounts == SKIP
46
+ @additional_properties = additional_properties
47
+ end
48
+
49
+ # Creates an instance of the object from a hash.
50
+ def self.from_hash(hash)
51
+ return nil unless hash
52
+
53
+ # Extract variables from the hash.
54
+ currency_type = hash.key?('currencyType') ? hash['currencyType'] : nil
55
+ # Parameter is an array, so we need to iterate through it
56
+ amounts = nil
57
+ unless hash['amounts'].nil?
58
+ amounts = []
59
+ hash['amounts'].each do |structure|
60
+ amounts << (BalanceAmountDetail.from_hash(structure) if structure)
61
+ end
62
+ end
63
+
64
+ amounts = SKIP unless hash.key?('amounts')
65
+
66
+ # Create a new hash for additional properties, removing known properties.
67
+ new_hash = hash.reject { |k, _| names.value?(k) }
68
+
69
+ additional_properties = APIHelper.get_additional_properties(
70
+ new_hash, proc { |value| value }
71
+ )
72
+
73
+ # Create object from extracted values.
74
+ BalanceCurrencyAmount.new(currency_type: currency_type,
75
+ amounts: amounts,
76
+ additional_properties: additional_properties)
77
+ end
78
+
79
+ # Provides a human-readable string representation of the object.
80
+ def to_s
81
+ class_name = self.class.name.split('::').last
82
+ "<#{class_name} currency_type: #{@currency_type}, amounts: #{@amounts},"\
83
+ " additional_properties: #{@additional_properties}>"
84
+ end
85
+
86
+ # Provides a debugging-friendly string with detailed object information.
87
+ def inspect
88
+ class_name = self.class.name.split('::').last
89
+ "<#{class_name} currency_type: #{@currency_type.inspect}, amounts: #{@amounts.inspect},"\
90
+ " additional_properties: #{@additional_properties}>"
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,60 @@
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
+ # Balance Currency Type.
8
+ class BalanceCurrencyType
9
+ BALANCE_CURRENCY_TYPE = [
10
+ # TODO: Write general description for QV
11
+ QV = 'QV'.freeze,
12
+
13
+ # TODO: Write general description for POINT
14
+ POINT = 'POINT'.freeze,
15
+
16
+ # TODO: Write general description for STAMP
17
+ STAMP = 'STAMP'.freeze,
18
+
19
+ # TODO: Write general description for AIRMILES
20
+ AIRMILES = 'AIRMILES'.freeze,
21
+
22
+ # TODO: Write general description for MILES
23
+ MILES = 'MILES'.freeze,
24
+
25
+ # TODO: Write general description for CASH
26
+ CASH = 'CASH'.freeze,
27
+
28
+ # TODO: Write general description for STAMP_COUNTER
29
+ STAMP_COUNTER = 'STAMP_COUNTER'.freeze,
30
+
31
+ # TODO: Write general description for NBS
32
+ NBS = 'NBS'.freeze
33
+ ].freeze
34
+
35
+ def self.validate(value)
36
+ return false if value.nil?
37
+
38
+ BALANCE_CURRENCY_TYPE.include?(value)
39
+ end
40
+
41
+ def self.from_value(value, default_value = QV)
42
+ return default_value if value.nil?
43
+
44
+ str = value.to_s.strip
45
+
46
+ case str.downcase
47
+ when 'qv' then QV
48
+ when 'point' then POINT
49
+ when 'stamp' then STAMP
50
+ when 'airmiles' then AIRMILES
51
+ when 'miles' then MILES
52
+ when 'cash' then CASH
53
+ when 'stamp_counter' then STAMP_COUNTER
54
+ when 'nbs' then NBS
55
+ else
56
+ default_value
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,72 @@
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
+ # State of the points balance amount.
8
+ class BalanceState
9
+ BALANCE_STATE = [
10
+ # TODO: Write general description for AVAILABLE
11
+ AVAILABLE = 'AVAILABLE'.freeze,
12
+
13
+ # TODO: Write general description for EXPIRING
14
+ EXPIRING = 'EXPIRING'.freeze,
15
+
16
+ # TODO: Write general description for RESERVED
17
+ RESERVED = 'RESERVED'.freeze,
18
+
19
+ # TODO: Write general description for TARGET
20
+ TARGET = 'TARGET'.freeze,
21
+
22
+ # TODO: Write general description for BOOST
23
+ BOOST = 'BOOST'.freeze,
24
+
25
+ # TODO: Write general description for CHANGE
26
+ CHANGE = 'CHANGE'.freeze,
27
+
28
+ # TODO: Write general description for TOTAL_SPENT
29
+ TOTAL_SPENT = 'TOTAL_SPENT'.freeze,
30
+
31
+ # TODO: Write general description for EARNED
32
+ EARNED = 'EARNED'.freeze,
33
+
34
+ # TODO: Write general description for REDEEMED
35
+ REDEEMED = 'REDEEMED'.freeze,
36
+
37
+ # TODO: Write general description for TOTAL
38
+ TOTAL = 'TOTAL'.freeze,
39
+
40
+ # TODO: Write general description for LAST
41
+ LAST = 'LAST'.freeze
42
+ ].freeze
43
+
44
+ def self.validate(value)
45
+ return false if value.nil?
46
+
47
+ BALANCE_STATE.include?(value)
48
+ end
49
+
50
+ def self.from_value(value, default_value = AVAILABLE)
51
+ return default_value if value.nil?
52
+
53
+ str = value.to_s.strip
54
+
55
+ case str.downcase
56
+ when 'available' then AVAILABLE
57
+ when 'expiring' then EXPIRING
58
+ when 'reserved' then RESERVED
59
+ when 'target' then TARGET
60
+ when 'boost' then BOOST
61
+ when 'change' then CHANGE
62
+ when 'total_spent' then TOTAL_SPENT
63
+ when 'earned' then EARNED
64
+ when 'redeemed' then REDEEMED
65
+ when 'total' then TOTAL
66
+ when 'last' then LAST
67
+ else
68
+ default_value
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,110 @@
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
+ # Base model.
8
+ # rubocop:disable all
9
+ class BaseModel < CoreLibrary::BaseModel
10
+ # Returns a Hash representation of the current object.
11
+ def to_hash
12
+ # validating the model being serialized
13
+ self.class.validate(self) if self.class.respond_to?(:validate)
14
+
15
+ hash = {}
16
+ instance_variables.each do |name|
17
+ value = instance_variable_get(name)
18
+ name = name[1..]
19
+ if name == 'additional_properties'
20
+ additional_properties = process_additional_properties(value, self.class.names)
21
+ hash.merge!(additional_properties)
22
+ else
23
+ key = self.class.names.key?(name) ? self.class.names[name] : name
24
+ optional_fields = self.class.optionals
25
+ nullable_fields = self.class.nullables
26
+ if value.nil?
27
+ next unless nullable_fields.include?(name)
28
+
29
+ if !optional_fields.include?(name) && !nullable_fields.include?(name)
30
+ raise ArgumentError,
31
+ "`#{name}` cannot be nil in `#{self.class}`. Please specify a valid value."
32
+ end
33
+ end
34
+
35
+ hash[key] = nil
36
+ unless value.nil?
37
+ if respond_to?("to_custom_#{name}")
38
+ if (value.instance_of? Array) || (value.instance_of? Hash)
39
+ params = [hash, key]
40
+ hash[key] = send("to_custom_#{name}", *params)
41
+ else
42
+ hash[key] = send("to_custom_#{name}")
43
+ end
44
+ elsif respond_to?("to_union_type_#{name}")
45
+ hash[key] = send("to_union_type_#{name}")
46
+ elsif value.instance_of? Array
47
+ hash[key] = value.map { |v| v.is_a?(BaseModel) ? v.to_hash : v }
48
+ elsif value.instance_of? Hash
49
+ hash[key] = {}
50
+ value.each do |k, v|
51
+ hash[key][k] = v.is_a?(BaseModel) ? v.to_hash : v
52
+ end
53
+ else
54
+ hash[key] = value.is_a?(BaseModel) ? value.to_hash : value
55
+ end
56
+ end
57
+ end
58
+ end
59
+ hash
60
+ end
61
+
62
+ # Processes additional properties, ensuring no conflicts with existing properties.
63
+ def process_additional_properties(additional_properties, existing_prop_names)
64
+ hash = {}
65
+ additional_properties.each do |name, value|
66
+ check_for_conflict(name, existing_prop_names)
67
+
68
+ hash[name] = if value.is_a?(Array)
69
+ process_array(value)
70
+ elsif value.is_a?(Hash)
71
+ process_hash(value)
72
+ else
73
+ process_basic_value(value)
74
+ end
75
+ end
76
+ hash
77
+ end
78
+
79
+ # Checks if an additional property conflicts with a model's existing property.
80
+ def check_for_conflict(name, existing_prop_names)
81
+ return unless existing_prop_names.key?(name)
82
+
83
+ raise ArgumentError, "An additional property key, '#{name}' conflicts with one of the model's properties"
84
+ end
85
+
86
+ # Processes an array of values, recursively calling `to_hash` on BaseModel objects.
87
+ def process_array(value)
88
+ value.map { |v| v.is_a?(BaseModel) ? v.to_hash : v }
89
+ end
90
+
91
+ # Processes a hash of values, recursively calling `to_hash` on BaseModel objects.
92
+ def process_hash(value)
93
+ value.transform_values do |v|
94
+ v.is_a?(BaseModel) ? v.to_hash : v
95
+ end
96
+ end
97
+
98
+ # Processes a basic value (non-array, non-hash).
99
+ def process_basic_value(value)
100
+ value.is_a?(BaseModel) ? value.to_hash : value
101
+ end
102
+
103
+ # Returns a JSON representation of the curent object.
104
+ def to_json(options = {})
105
+ hash = to_hash
106
+ hash.to_json(options)
107
+ end
108
+ end
109
+ # rubocop:enable all
110
+ end
@@ -0,0 +1,78 @@
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
+ # ClientAuthTokenRequest Model.
8
+ class ClientAuthTokenRequest < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
12
+ # Client ID provided by Shell
13
+ # @return [String]
14
+ attr_accessor :client_id
15
+
16
+ # Client Secret provided by Shell
17
+ # @return [String]
18
+ attr_accessor :client_secret
19
+
20
+ # Grant type value for access
21
+ # @return [String]
22
+ attr_accessor :grant_type
23
+
24
+ # A mapping from model property names to API property names.
25
+ def self.names
26
+ @_hash = {} if @_hash.nil?
27
+ @_hash['client_id'] = 'client_id'
28
+ @_hash['client_secret'] = 'client_secret'
29
+ @_hash['grant_type'] = 'grant_type'
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(client_id:, client_secret:, grant_type:)
44
+ @client_id = client_id
45
+ @client_secret = client_secret
46
+ @grant_type = grant_type
47
+ end
48
+
49
+ # Creates an instance of the object from a hash.
50
+ def self.from_hash(hash)
51
+ return nil unless hash
52
+
53
+ # Extract variables from the hash.
54
+ client_id = hash.key?('client_id') ? hash['client_id'] : nil
55
+ client_secret = hash.key?('client_secret') ? hash['client_secret'] : nil
56
+ grant_type = hash.key?('grant_type') ? hash['grant_type'] : nil
57
+
58
+ # Create object from extracted values.
59
+ ClientAuthTokenRequest.new(client_id: client_id,
60
+ client_secret: client_secret,
61
+ grant_type: grant_type)
62
+ end
63
+
64
+ # Provides a human-readable string representation of the object.
65
+ def to_s
66
+ class_name = self.class.name.split('::').last
67
+ "<#{class_name} client_id: #{@client_id}, client_secret: #{@client_secret}, grant_type:"\
68
+ " #{@grant_type}>"
69
+ end
70
+
71
+ # Provides a debugging-friendly string with detailed object information.
72
+ def inspect
73
+ class_name = self.class.name.split('::').last
74
+ "<#{class_name} client_id: #{@client_id.inspect}, client_secret: #{@client_secret.inspect},"\
75
+ " grant_type: #{@grant_type.inspect}>"
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,101 @@
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
+ # currencyData is only filled, where there is possible non-same currency
8
+ # cross-border transaction
9
+ class CurrencyData < BaseModel
10
+ SKIP = Object.new
11
+ private_constant :SKIP
12
+
13
+ # Currency code
14
+ # @return [String]
15
+ attr_accessor :code
16
+
17
+ # Currency symbol
18
+ # @return [String]
19
+ attr_accessor :symbol
20
+
21
+ # Currency format (is the symbol after the value)
22
+ # @return [TrueClass | FalseClass]
23
+ attr_accessor :is_suffix
24
+
25
+ # Currency format (is there a space between the symbol and the value)
26
+ # @return [TrueClass | FalseClass]
27
+ attr_accessor :has_space
28
+
29
+ # A mapping from model property names to API property names.
30
+ def self.names
31
+ @_hash = {} if @_hash.nil?
32
+ @_hash['code'] = 'code'
33
+ @_hash['symbol'] = 'symbol'
34
+ @_hash['is_suffix'] = 'isSuffix'
35
+ @_hash['has_space'] = 'hasSpace'
36
+ @_hash
37
+ end
38
+
39
+ # An array for optional fields
40
+ def self.optionals
41
+ []
42
+ end
43
+
44
+ # An array for nullable fields
45
+ def self.nullables
46
+ []
47
+ end
48
+
49
+ def initialize(code:, symbol:, is_suffix:, has_space:,
50
+ additional_properties: nil)
51
+ # Add additional model properties to the instance
52
+ additional_properties = {} if additional_properties.nil?
53
+
54
+ @code = code
55
+ @symbol = symbol
56
+ @is_suffix = is_suffix
57
+ @has_space = has_space
58
+ @additional_properties = additional_properties
59
+ end
60
+
61
+ # Creates an instance of the object from a hash.
62
+ def self.from_hash(hash)
63
+ return nil unless hash
64
+
65
+ # Extract variables from the hash.
66
+ code = hash.key?('code') ? hash['code'] : nil
67
+ symbol = hash.key?('symbol') ? hash['symbol'] : nil
68
+ is_suffix = hash.key?('isSuffix') ? hash['isSuffix'] : nil
69
+ has_space = hash.key?('hasSpace') ? hash['hasSpace'] : nil
70
+
71
+ # Create a new hash for additional properties, removing known properties.
72
+ new_hash = hash.reject { |k, _| names.value?(k) }
73
+
74
+ additional_properties = APIHelper.get_additional_properties(
75
+ new_hash, proc { |value| value }
76
+ )
77
+
78
+ # Create object from extracted values.
79
+ CurrencyData.new(code: code,
80
+ symbol: symbol,
81
+ is_suffix: is_suffix,
82
+ has_space: has_space,
83
+ additional_properties: additional_properties)
84
+ end
85
+
86
+ # Provides a human-readable string representation of the object.
87
+ def to_s
88
+ class_name = self.class.name.split('::').last
89
+ "<#{class_name} code: #{@code}, symbol: #{@symbol}, is_suffix: #{@is_suffix}, has_space:"\
90
+ " #{@has_space}, additional_properties: #{@additional_properties}>"
91
+ end
92
+
93
+ # Provides a debugging-friendly string with detailed object information.
94
+ def inspect
95
+ class_name = self.class.name.split('::').last
96
+ "<#{class_name} code: #{@code.inspect}, symbol: #{@symbol.inspect}, is_suffix:"\
97
+ " #{@is_suffix.inspect}, has_space: #{@has_space.inspect}, additional_properties:"\
98
+ " #{@additional_properties}>"
99
+ end
100
+ end
101
+ end