helloextend_api_client 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/README.md +151 -0
  4. data/Rakefile +10 -0
  5. data/docs/Address.md +27 -0
  6. data/docs/Amount.md +19 -0
  7. data/docs/Contract.md +39 -0
  8. data/docs/ContractPlan.md +19 -0
  9. data/docs/ContractProduct.md +27 -0
  10. data/docs/ContractsApi.md +180 -0
  11. data/docs/Customer.md +23 -0
  12. data/docs/Error.md +19 -0
  13. data/docs/Invoice.md +27 -0
  14. data/docs/InvoiceDetails.md +19 -0
  15. data/docs/InvoiceDiscount.md +21 -0
  16. data/docs/InvoiceItems.md +31 -0
  17. data/docs/InvoiceMetadata.md +21 -0
  18. data/docs/InvoiceMetadataProduct.md +21 -0
  19. data/docs/InvoicePayee.md +23 -0
  20. data/docs/InvoicePayer.md +23 -0
  21. data/docs/Offer.md +17 -0
  22. data/docs/OfferPlan.md +23 -0
  23. data/docs/OfferPlanContract.md +27 -0
  24. data/docs/OffersApi.md +58 -0
  25. data/docs/Plan.md +21 -0
  26. data/docs/PlanDetails.md +21 -0
  27. data/docs/PlanPrices.md +21 -0
  28. data/docs/PlansApi.md +61 -0
  29. data/docs/PlansList.md +17 -0
  30. data/docs/Product.md +45 -0
  31. data/docs/ProductIdentifiers.md +25 -0
  32. data/docs/ProductMfrWarranty.md +21 -0
  33. data/docs/ProductsApi.md +241 -0
  34. data/git_push.sh +58 -0
  35. data/helloextend_api_client.gemspec +39 -0
  36. data/lib/helloextend_api_client.rb +68 -0
  37. data/lib/helloextend_api_client/api/contracts_api.rb +229 -0
  38. data/lib/helloextend_api_client/api/offers_api.rb +90 -0
  39. data/lib/helloextend_api_client/api/plans_api.rb +82 -0
  40. data/lib/helloextend_api_client/api/products_api.rb +298 -0
  41. data/lib/helloextend_api_client/api_client.rb +388 -0
  42. data/lib/helloextend_api_client/api_error.rb +57 -0
  43. data/lib/helloextend_api_client/configuration.rb +248 -0
  44. data/lib/helloextend_api_client/models/address.rb +259 -0
  45. data/lib/helloextend_api_client/models/amount.rb +217 -0
  46. data/lib/helloextend_api_client/models/contract.rb +378 -0
  47. data/lib/helloextend_api_client/models/contract_plan.rb +228 -0
  48. data/lib/helloextend_api_client/models/contract_product.rb +268 -0
  49. data/lib/helloextend_api_client/models/customer.rb +245 -0
  50. data/lib/helloextend_api_client/models/error.rb +225 -0
  51. data/lib/helloextend_api_client/models/invoice.rb +254 -0
  52. data/lib/helloextend_api_client/models/invoice_details.rb +216 -0
  53. data/lib/helloextend_api_client/models/invoice_discount.rb +226 -0
  54. data/lib/helloextend_api_client/models/invoice_items.rb +271 -0
  55. data/lib/helloextend_api_client/models/invoice_metadata.rb +226 -0
  56. data/lib/helloextend_api_client/models/invoice_metadata_product.rb +225 -0
  57. data/lib/helloextend_api_client/models/invoice_payee.rb +233 -0
  58. data/lib/helloextend_api_client/models/invoice_payer.rb +233 -0
  59. data/lib/helloextend_api_client/models/offer.rb +208 -0
  60. data/lib/helloextend_api_client/models/offer_plan.rb +236 -0
  61. data/lib/helloextend_api_client/models/offer_plan_contract.rb +258 -0
  62. data/lib/helloextend_api_client/models/plan.rb +225 -0
  63. data/lib/helloextend_api_client/models/plan_details.rb +227 -0
  64. data/lib/helloextend_api_client/models/plan_prices.rb +230 -0
  65. data/lib/helloextend_api_client/models/plans_list.rb +208 -0
  66. data/lib/helloextend_api_client/models/product.rb +429 -0
  67. data/lib/helloextend_api_client/models/product_identifiers.rb +247 -0
  68. data/lib/helloextend_api_client/models/product_mfr_warranty.rb +228 -0
  69. data/lib/helloextend_api_client/version.rb +15 -0
  70. data/spec/api/contracts_api_spec.rb +74 -0
  71. data/spec/api/offers_api_spec.rb +48 -0
  72. data/spec/api/plans_api_spec.rb +46 -0
  73. data/spec/api/products_api_spec.rb +88 -0
  74. data/spec/api_client_spec.rb +226 -0
  75. data/spec/configuration_spec.rb +42 -0
  76. data/spec/models/address_spec.rb +71 -0
  77. data/spec/models/amount_spec.rb +47 -0
  78. data/spec/models/contract_plan_spec.rb +47 -0
  79. data/spec/models/contract_product_spec.rb +71 -0
  80. data/spec/models/contract_spec.rb +111 -0
  81. data/spec/models/customer_spec.rb +59 -0
  82. data/spec/models/error_spec.rb +47 -0
  83. data/spec/models/invoice_details_spec.rb +47 -0
  84. data/spec/models/invoice_discount_spec.rb +53 -0
  85. data/spec/models/invoice_items_spec.rb +83 -0
  86. data/spec/models/invoice_metadata_product_spec.rb +53 -0
  87. data/spec/models/invoice_metadata_spec.rb +53 -0
  88. data/spec/models/invoice_payee_spec.rb +59 -0
  89. data/spec/models/invoice_payer_spec.rb +59 -0
  90. data/spec/models/invoice_spec.rb +71 -0
  91. data/spec/models/offer_plan_contract_spec.rb +71 -0
  92. data/spec/models/offer_plan_spec.rb +59 -0
  93. data/spec/models/offer_spec.rb +41 -0
  94. data/spec/models/plan_details_spec.rb +53 -0
  95. data/spec/models/plan_prices_spec.rb +53 -0
  96. data/spec/models/plan_spec.rb +53 -0
  97. data/spec/models/plans_list_spec.rb +41 -0
  98. data/spec/models/product_identifiers_spec.rb +65 -0
  99. data/spec/models/product_mfr_warranty_spec.rb +53 -0
  100. data/spec/models/product_spec.rb +129 -0
  101. data/spec/spec_helper.rb +111 -0
  102. metadata +235 -0
@@ -0,0 +1,57 @@
1
+ =begin
2
+ #Extend API Reference
3
+
4
+ ## Introduction Welcome to the Extend API Documentation! Our goal is to make your integration as clear and easy as possible, so if you have feedback or suggestions for our API or reference docs, [please let us know](mailto:devs@helloextend.com). If you are implementing the API for the first time, please use the latest \"2019-08-01\" API version. If you have already implemented the API and haven't specified a version, you are on the \"Default\" API version. #### You can get up and running with Extend with just 5 simple steps: * Create an account with Extend, and get an access token from your Extend merchant portal * Sync your store's products to Extend * Get the relevant Extend warranty SKUs and add them to your store * Add the JS SDK snippets to your store's website, which will enable warranty offers to be displayed in your store * Record warranty purchases with Extend so we can create a new contract and deliver it to the customer, or record warranty returns / refunds so we can cancel the contract and account for the refunded amount <div class='wrapper tip'><h2>Pro Tip! Keep your store's products up to date</h2><p>To make sure you are selling warranty plans on all eligible products (and not selling them on ineligible ones), it is best to keep your store's products in sync with Extend. If you update your products infrequently, it might be easiest to manually upload or edit products in your merchant portal. If you do update frequently, though, consider integrating with our Products API resource.</p><p>Need help? <a href='mailto:devs@helloextend.com'>Contact us!</a> We love to help!</p></div>
5
+
6
+ The version of the OpenAPI document: Default
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.3.1-SNAPSHOT
10
+
11
+ =end
12
+
13
+ module HelloextendApiClient
14
+ class ApiError < StandardError
15
+ attr_reader :code, :response_headers, :response_body
16
+
17
+ # Usage examples:
18
+ # ApiError.new
19
+ # ApiError.new("message")
20
+ # ApiError.new(:code => 500, :response_headers => {}, :response_body => "")
21
+ # ApiError.new(:code => 404, :message => "Not Found")
22
+ def initialize(arg = nil)
23
+ if arg.is_a? Hash
24
+ if arg.key?(:message) || arg.key?('message')
25
+ super(arg[:message] || arg['message'])
26
+ else
27
+ super arg
28
+ end
29
+
30
+ arg.each do |k, v|
31
+ instance_variable_set "@#{k}", v
32
+ end
33
+ else
34
+ super arg
35
+ end
36
+ end
37
+
38
+ # Override to_s to display a friendly error message
39
+ def to_s
40
+ message
41
+ end
42
+
43
+ def message
44
+ if @message.nil?
45
+ msg = "Error message: the server returns an error"
46
+ else
47
+ msg = @message
48
+ end
49
+
50
+ msg += "\nHTTP status code: #{code}" if code
51
+ msg += "\nResponse headers: #{response_headers}" if response_headers
52
+ msg += "\nResponse body: #{response_body}" if response_body
53
+
54
+ msg
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,248 @@
1
+ =begin
2
+ #Extend API Reference
3
+
4
+ ## Introduction Welcome to the Extend API Documentation! Our goal is to make your integration as clear and easy as possible, so if you have feedback or suggestions for our API or reference docs, [please let us know](mailto:devs@helloextend.com). If you are implementing the API for the first time, please use the latest \"2019-08-01\" API version. If you have already implemented the API and haven't specified a version, you are on the \"Default\" API version. #### You can get up and running with Extend with just 5 simple steps: * Create an account with Extend, and get an access token from your Extend merchant portal * Sync your store's products to Extend * Get the relevant Extend warranty SKUs and add them to your store * Add the JS SDK snippets to your store's website, which will enable warranty offers to be displayed in your store * Record warranty purchases with Extend so we can create a new contract and deliver it to the customer, or record warranty returns / refunds so we can cancel the contract and account for the refunded amount <div class='wrapper tip'><h2>Pro Tip! Keep your store's products up to date</h2><p>To make sure you are selling warranty plans on all eligible products (and not selling them on ineligible ones), it is best to keep your store's products in sync with Extend. If you update your products infrequently, it might be easiest to manually upload or edit products in your merchant portal. If you do update frequently, though, consider integrating with our Products API resource.</p><p>Need help? <a href='mailto:devs@helloextend.com'>Contact us!</a> We love to help!</p></div>
5
+
6
+ The version of the OpenAPI document: Default
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.3.1-SNAPSHOT
10
+
11
+ =end
12
+
13
+ module HelloextendApiClient
14
+ class Configuration
15
+ # Defines url scheme
16
+ attr_accessor :scheme
17
+
18
+ # Defines url host
19
+ attr_accessor :host
20
+
21
+ # Defines url base path
22
+ attr_accessor :base_path
23
+
24
+ # Defines API keys used with API Key authentications.
25
+ #
26
+ # @return [Hash] key: parameter name, value: parameter value (API key)
27
+ #
28
+ # @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
29
+ # config.api_key['api_key'] = 'xxx'
30
+ attr_accessor :api_key
31
+
32
+ # Defines API key prefixes used with API Key authentications.
33
+ #
34
+ # @return [Hash] key: parameter name, value: API key prefix
35
+ #
36
+ # @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
37
+ # config.api_key_prefix['api_key'] = 'Token'
38
+ attr_accessor :api_key_prefix
39
+
40
+ # Defines the username used with HTTP basic authentication.
41
+ #
42
+ # @return [String]
43
+ attr_accessor :username
44
+
45
+ # Defines the password used with HTTP basic authentication.
46
+ #
47
+ # @return [String]
48
+ attr_accessor :password
49
+
50
+ # Defines the access token (Bearer) used with OAuth2.
51
+ attr_accessor :access_token
52
+
53
+ # Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
54
+ # details will be logged with `logger.debug` (see the `logger` attribute).
55
+ # Default to false.
56
+ #
57
+ # @return [true, false]
58
+ attr_accessor :debugging
59
+
60
+ # Defines the logger used for debugging.
61
+ # Default to `Rails.logger` (when in Rails) or logging to STDOUT.
62
+ #
63
+ # @return [#debug]
64
+ attr_accessor :logger
65
+
66
+ # Defines the temporary folder to store downloaded files
67
+ # (for API endpoints that have file response).
68
+ # Default to use `Tempfile`.
69
+ #
70
+ # @return [String]
71
+ attr_accessor :temp_folder_path
72
+
73
+ # The time limit for HTTP request in seconds.
74
+ # Default to 0 (never times out).
75
+ attr_accessor :timeout
76
+
77
+ # Set this to false to skip client side validation in the operation.
78
+ # Default to true.
79
+ # @return [true, false]
80
+ attr_accessor :client_side_validation
81
+
82
+ ### TLS/SSL setting
83
+ # Set this to false to skip verifying SSL certificate when calling API from https server.
84
+ # Default to true.
85
+ #
86
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
87
+ #
88
+ # @return [true, false]
89
+ attr_accessor :verify_ssl
90
+
91
+ ### TLS/SSL setting
92
+ # Set this to false to skip verifying SSL host name
93
+ # Default to true.
94
+ #
95
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
96
+ #
97
+ # @return [true, false]
98
+ attr_accessor :verify_ssl_host
99
+
100
+ ### TLS/SSL setting
101
+ # Set this to customize the certificate file to verify the peer.
102
+ #
103
+ # @return [String] the path to the certificate file
104
+ #
105
+ # @see The `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code:
106
+ # https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
107
+ attr_accessor :ssl_ca_cert
108
+
109
+ ### TLS/SSL setting
110
+ # Client certificate file (for client certificate)
111
+ attr_accessor :cert_file
112
+
113
+ ### TLS/SSL setting
114
+ # Client private key file (for client certificate)
115
+ attr_accessor :key_file
116
+
117
+ # Set this to customize parameters encoding of array parameter with multi collectionFormat.
118
+ # Default to nil.
119
+ #
120
+ # @see The params_encoding option of Ethon. Related source code:
121
+ # https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
122
+ attr_accessor :params_encoding
123
+
124
+ attr_accessor :inject_format
125
+
126
+ attr_accessor :force_ending_format
127
+
128
+ def initialize
129
+ @scheme = 'https'
130
+ @host = 'api-demo.helloextend.com'
131
+ @base_path = ''
132
+ @api_key = {}
133
+ @api_key_prefix = {}
134
+ @timeout = 0
135
+ @client_side_validation = true
136
+ @verify_ssl = true
137
+ @verify_ssl_host = true
138
+ @params_encoding = nil
139
+ @cert_file = nil
140
+ @key_file = nil
141
+ @debugging = false
142
+ @inject_format = false
143
+ @force_ending_format = false
144
+ @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
145
+
146
+ yield(self) if block_given?
147
+ end
148
+
149
+ # The default Configuration object.
150
+ def self.default
151
+ @@default ||= Configuration.new
152
+ end
153
+
154
+ def configure
155
+ yield(self) if block_given?
156
+ end
157
+
158
+ def scheme=(scheme)
159
+ # remove :// from scheme
160
+ @scheme = scheme.sub(/:\/\//, '')
161
+ end
162
+
163
+ def host=(host)
164
+ # remove http(s):// and anything after a slash
165
+ @host = host.sub(/https?:\/\//, '').split('/').first
166
+ end
167
+
168
+ def base_path=(base_path)
169
+ # Add leading and trailing slashes to base_path
170
+ @base_path = "/#{base_path}".gsub(/\/+/, '/')
171
+ @base_path = '' if @base_path == '/'
172
+ end
173
+
174
+ def base_url
175
+ "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
176
+ end
177
+
178
+ # Gets API key (with prefix if set).
179
+ # @param [String] param_name the parameter name of API key auth
180
+ def api_key_with_prefix(param_name)
181
+ if @api_key_prefix[param_name]
182
+ "#{@api_key_prefix[param_name]} #{@api_key[param_name]}"
183
+ else
184
+ @api_key[param_name]
185
+ end
186
+ end
187
+
188
+ # Gets Basic Auth token string
189
+ def basic_auth_token
190
+ 'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
191
+ end
192
+
193
+ # Returns Auth Settings hash for api client.
194
+ def auth_settings
195
+ {
196
+ 'ExtendAccessToken' =>
197
+ {
198
+ type: 'api_key',
199
+ in: 'header',
200
+ key: 'X-Extend-Access-Token',
201
+ value: api_key_with_prefix('X-Extend-Access-Token')
202
+ },
203
+ }
204
+ end
205
+
206
+ # Returns an array of Server setting
207
+ def server_settings
208
+ [
209
+ {
210
+ url: "https://api-demo.helloextend.com",
211
+ description: "No description provided",
212
+ }
213
+ ]
214
+ end
215
+
216
+ # Returns URL based on server settings
217
+ #
218
+ # @param index array index of the server settings
219
+ # @param variables hash of variable and the corresponding value
220
+ def server_url(index, variables = {})
221
+ servers = server_settings
222
+
223
+ # check array index out of bound
224
+ if (index < 0 || index >= servers.size)
225
+ fail ArgumentError, "Invalid index #{index} when selecting the server. Must be less than #{servers.size}"
226
+ end
227
+
228
+ server = servers[index]
229
+ url = server[:url]
230
+
231
+ # go through variable and assign a value
232
+ server[:variables].each do |name, variable|
233
+ if variables.key?(name)
234
+ if (server[:variables][name][:enum_values].include? variables[name])
235
+ url.gsub! "{" + name.to_s + "}", variables[name]
236
+ else
237
+ fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."
238
+ end
239
+ else
240
+ # use default value
241
+ url.gsub! "{" + name.to_s + "}", server[:variables][name][:default_value]
242
+ end
243
+ end
244
+
245
+ url
246
+ end
247
+ end
248
+ end
@@ -0,0 +1,259 @@
1
+ =begin
2
+ #Extend API Reference
3
+
4
+ ## Introduction Welcome to the Extend API Documentation! Our goal is to make your integration as clear and easy as possible, so if you have feedback or suggestions for our API or reference docs, [please let us know](mailto:devs@helloextend.com). If you are implementing the API for the first time, please use the latest \"2019-08-01\" API version. If you have already implemented the API and haven't specified a version, you are on the \"Default\" API version. #### You can get up and running with Extend with just 5 simple steps: * Create an account with Extend, and get an access token from your Extend merchant portal * Sync your store's products to Extend * Get the relevant Extend warranty SKUs and add them to your store * Add the JS SDK snippets to your store's website, which will enable warranty offers to be displayed in your store * Record warranty purchases with Extend so we can create a new contract and deliver it to the customer, or record warranty returns / refunds so we can cancel the contract and account for the refunded amount <div class='wrapper tip'><h2>Pro Tip! Keep your store's products up to date</h2><p>To make sure you are selling warranty plans on all eligible products (and not selling them on ineligible ones), it is best to keep your store's products in sync with Extend. If you update your products infrequently, it might be easiest to manually upload or edit products in your merchant portal. If you do update frequently, though, consider integrating with our Products API resource.</p><p>Need help? <a href='mailto:devs@helloextend.com'>Contact us!</a> We love to help!</p></div>
5
+
6
+ The version of the OpenAPI document: Default
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.3.1-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module HelloextendApiClient
16
+ # Shipping address where the product associated with the extended warranty is being sent.
17
+ class Address
18
+ attr_accessor :address1
19
+
20
+ attr_accessor :address2
21
+
22
+ attr_accessor :city
23
+
24
+ # This is an ISO 3166 formatted country code. See <a href='https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes for examples'>https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes for examples</a> for more information
25
+ attr_accessor :country_code
26
+
27
+ attr_accessor :postal_code
28
+
29
+ # This is an ISO 3166-2 formatted region. See <a href='https://en.wikipedia.org/wiki/ISO_3166-2'>https://en.wikipedia.org/wiki/ISO_3166-2</a> for more information
30
+ attr_accessor :province_code
31
+
32
+ # Attribute mapping from ruby-style variable name to JSON key.
33
+ def self.attribute_map
34
+ {
35
+ :'address1' => :'address1',
36
+ :'address2' => :'address2',
37
+ :'city' => :'city',
38
+ :'country_code' => :'countryCode',
39
+ :'postal_code' => :'postalCode',
40
+ :'province_code' => :'provinceCode'
41
+ }
42
+ end
43
+
44
+ # Attribute type mapping.
45
+ def self.openapi_types
46
+ {
47
+ :'address1' => :'String',
48
+ :'address2' => :'String',
49
+ :'city' => :'String',
50
+ :'country_code' => :'String',
51
+ :'postal_code' => :'String',
52
+ :'province_code' => :'String'
53
+ }
54
+ end
55
+
56
+ # List of attributes with nullable: true
57
+ def self.openapi_nullable
58
+ Set.new([
59
+ ])
60
+ end
61
+
62
+ # Initializes the object
63
+ # @param [Hash] attributes Model attributes in the form of hash
64
+ def initialize(attributes = {})
65
+ if (!attributes.is_a?(Hash))
66
+ fail ArgumentError, "The input argument (attributes) must be a hash in `HelloextendApiClient::Address` initialize method"
67
+ end
68
+
69
+ # check to see if the attribute exists and convert string to symbol for hash key
70
+ attributes = attributes.each_with_object({}) { |(k, v), h|
71
+ if (!self.class.attribute_map.key?(k.to_sym))
72
+ fail ArgumentError, "`#{k}` is not a valid attribute in `HelloextendApiClient::Address`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
73
+ end
74
+ h[k.to_sym] = v
75
+ }
76
+
77
+ if attributes.key?(:'address1')
78
+ self.address1 = attributes[:'address1']
79
+ end
80
+
81
+ if attributes.key?(:'address2')
82
+ self.address2 = attributes[:'address2']
83
+ end
84
+
85
+ if attributes.key?(:'city')
86
+ self.city = attributes[:'city']
87
+ end
88
+
89
+ if attributes.key?(:'country_code')
90
+ self.country_code = attributes[:'country_code']
91
+ end
92
+
93
+ if attributes.key?(:'postal_code')
94
+ self.postal_code = attributes[:'postal_code']
95
+ end
96
+
97
+ if attributes.key?(:'province_code')
98
+ self.province_code = attributes[:'province_code']
99
+ end
100
+ end
101
+
102
+ # Show invalid properties with the reasons. Usually used together with valid?
103
+ # @return Array for valid properties with the reasons
104
+ def list_invalid_properties
105
+ invalid_properties = Array.new
106
+ if @address1.nil?
107
+ invalid_properties.push('invalid value for "address1", address1 cannot be nil.')
108
+ end
109
+
110
+ invalid_properties
111
+ end
112
+
113
+ # Check to see if the all the properties in the model are valid
114
+ # @return true if the model is valid
115
+ def valid?
116
+ return false if @address1.nil?
117
+ true
118
+ end
119
+
120
+ # Checks equality by comparing each attribute.
121
+ # @param [Object] Object to be compared
122
+ def ==(o)
123
+ return true if self.equal?(o)
124
+ self.class == o.class &&
125
+ address1 == o.address1 &&
126
+ address2 == o.address2 &&
127
+ city == o.city &&
128
+ country_code == o.country_code &&
129
+ postal_code == o.postal_code &&
130
+ province_code == o.province_code
131
+ end
132
+
133
+ # @see the `==` method
134
+ # @param [Object] Object to be compared
135
+ def eql?(o)
136
+ self == o
137
+ end
138
+
139
+ # Calculates hash code according to all attributes.
140
+ # @return [Integer] Hash code
141
+ def hash
142
+ [address1, address2, city, country_code, postal_code, province_code].hash
143
+ end
144
+
145
+ # Builds the object from hash
146
+ # @param [Hash] attributes Model attributes in the form of hash
147
+ # @return [Object] Returns the model itself
148
+ def self.build_from_hash(attributes)
149
+ new.build_from_hash(attributes)
150
+ end
151
+
152
+ # Builds the object from hash
153
+ # @param [Hash] attributes Model attributes in the form of hash
154
+ # @return [Object] Returns the model itself
155
+ def build_from_hash(attributes)
156
+ return nil unless attributes.is_a?(Hash)
157
+ self.class.openapi_types.each_pair do |key, type|
158
+ if type =~ /\AArray<(.*)>/i
159
+ # check to ensure the input is an array given that the attribute
160
+ # is documented as an array but the input is not
161
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
162
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
163
+ end
164
+ elsif !attributes[self.class.attribute_map[key]].nil?
165
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
166
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
167
+ end
168
+
169
+ self
170
+ end
171
+
172
+ # Deserializes the data based on type
173
+ # @param string type Data type
174
+ # @param string value Value to be deserialized
175
+ # @return [Object] Deserialized data
176
+ def _deserialize(type, value)
177
+ case type.to_sym
178
+ when :DateTime
179
+ DateTime.parse(value)
180
+ when :Date
181
+ Date.parse(value)
182
+ when :String
183
+ value.to_s
184
+ when :Integer
185
+ value.to_i
186
+ when :Float
187
+ value.to_f
188
+ when :Boolean
189
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
190
+ true
191
+ else
192
+ false
193
+ end
194
+ when :Object
195
+ # generic object (usually a Hash), return directly
196
+ value
197
+ when /\AArray<(?<inner_type>.+)>\z/
198
+ inner_type = Regexp.last_match[:inner_type]
199
+ value.map { |v| _deserialize(inner_type, v) }
200
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
201
+ k_type = Regexp.last_match[:k_type]
202
+ v_type = Regexp.last_match[:v_type]
203
+ {}.tap do |hash|
204
+ value.each do |k, v|
205
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
206
+ end
207
+ end
208
+ else # model
209
+ HelloextendApiClient.const_get(type).build_from_hash(value)
210
+ end
211
+ end
212
+
213
+ # Returns the string representation of the object
214
+ # @return [String] String presentation of the object
215
+ def to_s
216
+ to_hash.to_s
217
+ end
218
+
219
+ # to_body is an alias to to_hash (backward compatibility)
220
+ # @return [Hash] Returns the object in the form of hash
221
+ def to_body
222
+ to_hash
223
+ end
224
+
225
+ # Returns the object in the form of hash
226
+ # @return [Hash] Returns the object in the form of hash
227
+ def to_hash
228
+ hash = {}
229
+ self.class.attribute_map.each_pair do |attr, param|
230
+ value = self.send(attr)
231
+ if value.nil?
232
+ is_nullable = self.class.openapi_nullable.include?(attr)
233
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
234
+ end
235
+
236
+ hash[param] = _to_hash(value)
237
+ end
238
+ hash
239
+ end
240
+
241
+ # Outputs non-array value in the form of hash
242
+ # For object, use to_hash. Otherwise, just return the value
243
+ # @param [Object] value Any valid value
244
+ # @return [Hash] Returns the value in the form of hash
245
+ def _to_hash(value)
246
+ if value.is_a?(Array)
247
+ value.compact.map { |v| _to_hash(v) }
248
+ elsif value.is_a?(Hash)
249
+ {}.tap do |hash|
250
+ value.each { |k, v| hash[k] = _to_hash(v) }
251
+ end
252
+ elsif value.respond_to? :to_hash
253
+ value.to_hash
254
+ else
255
+ value
256
+ end
257
+ end
258
+ end
259
+ end