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,64 @@
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 amount
8
+ class TransactionBalanceState
9
+ TRANSACTION_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
+ ].freeze
37
+
38
+ def self.validate(value)
39
+ return false if value.nil?
40
+
41
+ TRANSACTION_BALANCE_STATE.include?(value)
42
+ end
43
+
44
+ def self.from_value(value, default_value = AVAILABLE)
45
+ return default_value if value.nil?
46
+
47
+ str = value.to_s.strip
48
+
49
+ case str.downcase
50
+ when 'available' then AVAILABLE
51
+ when 'expiring' then EXPIRING
52
+ when 'reserved' then RESERVED
53
+ when 'target' then TARGET
54
+ when 'boost' then BOOST
55
+ when 'change' then CHANGE
56
+ when 'total_spent' then TOTAL_SPENT
57
+ when 'earned' then EARNED
58
+ when 'redeemed' then REDEEMED
59
+ else
60
+ default_value
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,56 @@
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
+ # Type of balance
8
+ class TransactionCurrencyType
9
+ TRANSACTION_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
+ ].freeze
31
+
32
+ def self.validate(value)
33
+ return false if value.nil?
34
+
35
+ TRANSACTION_CURRENCY_TYPE.include?(value)
36
+ end
37
+
38
+ def self.from_value(value, default_value = QV)
39
+ return default_value if value.nil?
40
+
41
+ str = value.to_s.strip
42
+
43
+ case str.downcase
44
+ when 'qv' then QV
45
+ when 'point' then POINT
46
+ when 'stamp' then STAMP
47
+ when 'airmiles' then AIRMILES
48
+ when 'miles' then MILES
49
+ when 'cash' then CASH
50
+ when 'stamp_counter' then STAMP_COUNTER
51
+ else
52
+ default_value
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,53 @@
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
+ # Indicates the Type of the transaction detail row (award, redemption,
8
+ # transfer, voucher, refund or central award).
9
+ class TransactionDetailType
10
+ TRANSACTION_DETAIL_TYPE = [
11
+ # TODO: Write general description for AWARD
12
+ AWARD = 'AWARD'.freeze,
13
+
14
+ # TODO: Write general description for REDEMPTION
15
+ REDEMPTION = 'REDEMPTION'.freeze,
16
+
17
+ # TODO: Write general description for TRANSFER
18
+ TRANSFER = 'TRANSFER'.freeze,
19
+
20
+ # TODO: Write general description for REFUND
21
+ REFUND = 'REFUND'.freeze,
22
+
23
+ # TODO: Write general description for CENTRAL_AWARD
24
+ CENTRAL_AWARD = 'CENTRAL_AWARD'.freeze,
25
+
26
+ # TODO: Write general description for VOUCHER
27
+ VOUCHER = 'VOUCHER'.freeze
28
+ ].freeze
29
+
30
+ def self.validate(value)
31
+ return false if value.nil?
32
+
33
+ TRANSACTION_DETAIL_TYPE.include?(value)
34
+ end
35
+
36
+ def self.from_value(value, default_value = AWARD)
37
+ return default_value if value.nil?
38
+
39
+ str = value.to_s.strip
40
+
41
+ case str.downcase
42
+ when 'award' then AWARD
43
+ when 'redemption' then REDEMPTION
44
+ when 'transfer' then TRANSFER
45
+ when 'refund' then REFUND
46
+ when 'central_award' then CENTRAL_AWARD
47
+ when 'voucher' then VOUCHER
48
+ else
49
+ default_value
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,40 @@
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
+ # Transaction Type Filter.
8
+ class TransactionTypeFilter
9
+ TRANSACTION_TYPE_FILTER = [
10
+ # TODO: Write general description for EARN
11
+ EARN = 'EARN'.freeze,
12
+
13
+ # TODO: Write general description for SPENT
14
+ SPENT = 'SPENT'.freeze,
15
+
16
+ # TODO: Write general description for ALL
17
+ ALL = 'ALL'.freeze
18
+ ].freeze
19
+
20
+ def self.validate(value)
21
+ return false if value.nil?
22
+
23
+ TRANSACTION_TYPE_FILTER.include?(value)
24
+ end
25
+
26
+ def self.from_value(value, default_value = EARN)
27
+ return default_value if value.nil?
28
+
29
+ str = value.to_s.strip
30
+
31
+ case str.downcase
32
+ when 'earn' then EARN
33
+ when 'spent' then SPENT
34
+ when 'all' then ALL
35
+ else
36
+ default_value
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,109 @@
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
+ # TransactionVoucher Model.
8
+ class TransactionVoucher < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
12
+ # Indicates the Type of the transaction detail row (award, redemption,
13
+ # transfer, voucher, refund or central award).
14
+ # @return [TransactionDetailType]
15
+ attr_accessor :detail_type
16
+
17
+ # Unique code of the voucher
18
+ # @return [String]
19
+ attr_accessor :code
20
+
21
+ # Name of the voucher
22
+ # @return [String]
23
+ attr_accessor :name
24
+
25
+ # Sum amount of the voucher
26
+ # @return [Float]
27
+ attr_accessor :amount
28
+
29
+ # Quantity of vouchers
30
+ # @return [Float]
31
+ attr_accessor :quantity
32
+
33
+ # A mapping from model property names to API property names.
34
+ def self.names
35
+ @_hash = {} if @_hash.nil?
36
+ @_hash['detail_type'] = 'detailType'
37
+ @_hash['code'] = 'code'
38
+ @_hash['name'] = 'name'
39
+ @_hash['amount'] = 'amount'
40
+ @_hash['quantity'] = 'quantity'
41
+ @_hash
42
+ end
43
+
44
+ # An array for optional fields
45
+ def self.optionals
46
+ []
47
+ end
48
+
49
+ # An array for nullable fields
50
+ def self.nullables
51
+ []
52
+ end
53
+
54
+ def initialize(detail_type:, code:, name:, amount:, quantity:,
55
+ additional_properties: nil)
56
+ # Add additional model properties to the instance
57
+ additional_properties = {} if additional_properties.nil?
58
+
59
+ @detail_type = detail_type
60
+ @code = code
61
+ @name = name
62
+ @amount = amount
63
+ @quantity = quantity
64
+ @additional_properties = additional_properties
65
+ end
66
+
67
+ # Creates an instance of the object from a hash.
68
+ def self.from_hash(hash)
69
+ return nil unless hash
70
+
71
+ # Extract variables from the hash.
72
+ detail_type = hash.key?('detailType') ? hash['detailType'] : nil
73
+ code = hash.key?('code') ? hash['code'] : nil
74
+ name = hash.key?('name') ? hash['name'] : nil
75
+ amount = hash.key?('amount') ? hash['amount'] : nil
76
+ quantity = hash.key?('quantity') ? hash['quantity'] : nil
77
+
78
+ # Create a new hash for additional properties, removing known properties.
79
+ new_hash = hash.reject { |k, _| names.value?(k) }
80
+
81
+ additional_properties = APIHelper.get_additional_properties(
82
+ new_hash, proc { |value| value }
83
+ )
84
+
85
+ # Create object from extracted values.
86
+ TransactionVoucher.new(detail_type: detail_type,
87
+ code: code,
88
+ name: name,
89
+ amount: amount,
90
+ quantity: quantity,
91
+ additional_properties: additional_properties)
92
+ end
93
+
94
+ # Provides a human-readable string representation of the object.
95
+ def to_s
96
+ class_name = self.class.name.split('::').last
97
+ "<#{class_name} detail_type: #{@detail_type}, code: #{@code}, name: #{@name}, amount:"\
98
+ " #{@amount}, quantity: #{@quantity}, additional_properties: #{@additional_properties}>"
99
+ end
100
+
101
+ # Provides a debugging-friendly string with detailed object information.
102
+ def inspect
103
+ class_name = self.class.name.split('::').last
104
+ "<#{class_name} detail_type: #{@detail_type.inspect}, code: #{@code.inspect}, name:"\
105
+ " #{@name.inspect}, amount: #{@amount.inspect}, quantity: #{@quantity.inspect},"\
106
+ " additional_properties: #{@additional_properties}>"
107
+ end
108
+ end
109
+ end
@@ -0,0 +1,118 @@
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
+ # TransactionsResponse Model.
8
+ class TransactionsResponse < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
12
+ # Total no of resource which will be sent back across all pages
13
+ # @return [Integer]
14
+ attr_accessor :total_results
15
+
16
+ # API URI which must be used to retrieve the next page of resources
17
+ # @return [String]
18
+ attr_accessor :next_page
19
+
20
+ # API URI which must be used to retrieve the previous page of resources
21
+ # @return [String]
22
+ attr_accessor :previous_page
23
+
24
+ # Total amount saved so far
25
+ # @return [Float]
26
+ attr_accessor :total_saved
27
+
28
+ # Transactions list
29
+ # @return [Array[Transaction]]
30
+ attr_accessor :transactions
31
+
32
+ # A mapping from model property names to API property names.
33
+ def self.names
34
+ @_hash = {} if @_hash.nil?
35
+ @_hash['total_results'] = 'totalResults'
36
+ @_hash['next_page'] = 'nextPage'
37
+ @_hash['previous_page'] = 'previousPage'
38
+ @_hash['total_saved'] = 'totalSaved'
39
+ @_hash['transactions'] = 'transactions'
40
+ @_hash
41
+ end
42
+
43
+ # An array for optional fields
44
+ def self.optionals
45
+ []
46
+ end
47
+
48
+ # An array for nullable fields
49
+ def self.nullables
50
+ []
51
+ end
52
+
53
+ def initialize(total_results:, next_page:, previous_page:, total_saved:,
54
+ transactions:, additional_properties: nil)
55
+ # Add additional model properties to the instance
56
+ additional_properties = {} if additional_properties.nil?
57
+
58
+ @total_results = total_results
59
+ @next_page = next_page
60
+ @previous_page = previous_page
61
+ @total_saved = total_saved
62
+ @transactions = transactions
63
+ @additional_properties = additional_properties
64
+ end
65
+
66
+ # Creates an instance of the object from a hash.
67
+ def self.from_hash(hash)
68
+ return nil unless hash
69
+
70
+ # Extract variables from the hash.
71
+ total_results = hash.key?('totalResults') ? hash['totalResults'] : nil
72
+ next_page = hash.key?('nextPage') ? hash['nextPage'] : nil
73
+ previous_page = hash.key?('previousPage') ? hash['previousPage'] : nil
74
+ total_saved = hash.key?('totalSaved') ? hash['totalSaved'] : nil
75
+ # Parameter is an array, so we need to iterate through it
76
+ transactions = nil
77
+ unless hash['transactions'].nil?
78
+ transactions = []
79
+ hash['transactions'].each do |structure|
80
+ transactions << (Transaction.from_hash(structure) if structure)
81
+ end
82
+ end
83
+
84
+ transactions = nil unless hash.key?('transactions')
85
+
86
+ # Create a new hash for additional properties, removing known properties.
87
+ new_hash = hash.reject { |k, _| names.value?(k) }
88
+
89
+ additional_properties = APIHelper.get_additional_properties(
90
+ new_hash, proc { |value| value }
91
+ )
92
+
93
+ # Create object from extracted values.
94
+ TransactionsResponse.new(total_results: total_results,
95
+ next_page: next_page,
96
+ previous_page: previous_page,
97
+ total_saved: total_saved,
98
+ transactions: transactions,
99
+ additional_properties: additional_properties)
100
+ end
101
+
102
+ # Provides a human-readable string representation of the object.
103
+ def to_s
104
+ class_name = self.class.name.split('::').last
105
+ "<#{class_name} total_results: #{@total_results}, next_page: #{@next_page}, previous_page:"\
106
+ " #{@previous_page}, total_saved: #{@total_saved}, transactions: #{@transactions},"\
107
+ " additional_properties: #{@additional_properties}>"
108
+ end
109
+
110
+ # Provides a debugging-friendly string with detailed object information.
111
+ def inspect
112
+ class_name = self.class.name.split('::').last
113
+ "<#{class_name} total_results: #{@total_results.inspect}, next_page: #{@next_page.inspect},"\
114
+ " previous_page: #{@previous_page.inspect}, total_saved: #{@total_saved.inspect},"\
115
+ " transactions: #{@transactions.inspect}, additional_properties: #{@additional_properties}>"
116
+ end
117
+ end
118
+ 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
+ # The application is not authorised to use the requested grant type.
8
+ class UnauthorizedError < 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
+ UnauthorizedError.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,40 @@
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
+ # Unit of measure
8
+ class UnitMeasure
9
+ UNIT_MEASURE = [
10
+ # TODO: Write general description for KW
11
+ KW = 'KW'.freeze,
12
+
13
+ # TODO: Write general description for LITRE
14
+ LITRE = 'LITRE'.freeze,
15
+
16
+ # TODO: Write general description for EACH
17
+ EACH = 'EACH'.freeze
18
+ ].freeze
19
+
20
+ def self.validate(value)
21
+ return false if value.nil?
22
+
23
+ UNIT_MEASURE.include?(value)
24
+ end
25
+
26
+ def self.from_value(value, default_value = KW)
27
+ return default_value if value.nil?
28
+
29
+ str = value.to_s.strip
30
+
31
+ case str.downcase
32
+ when 'kw' then KW
33
+ when 'litre' then LITRE
34
+ when 'each' then EACH
35
+ else
36
+ default_value
37
+ end
38
+ end
39
+ end
40
+ 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
+ # UnprocessableEntityErrorResponse Model.
8
+ class UnprocessableEntityErrorResponse < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
12
+ # HTTP error code 422
13
+ # @return [Float]
14
+ attr_accessor :error_code
15
+
16
+ # HTTP error message - Unprocessable entity
17
+ # @return [String]
18
+ attr_accessor :message
19
+
20
+ # HTTP error message - Unprocessable entity
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
+ UnprocessableEntityErrorResponse.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