crisphive 0.1.0

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 (108) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/README.md +219 -0
  4. data/Rakefile +10 -0
  5. data/crisphive.gemspec +40 -0
  6. data/git_push.sh +57 -0
  7. data/lib/crisphive/api/business_skill_api.rb +211 -0
  8. data/lib/crisphive/api/customer_api.rb +371 -0
  9. data/lib/crisphive/api/job_request_business_api.rb +449 -0
  10. data/lib/crisphive/api/job_types_api.rb +141 -0
  11. data/lib/crisphive/api/service_area_api.rb +148 -0
  12. data/lib/crisphive/api/technician_api.rb +163 -0
  13. data/lib/crisphive/api/vehicle_api.rb +157 -0
  14. data/lib/crisphive/api_client.rb +437 -0
  15. data/lib/crisphive/api_error.rb +58 -0
  16. data/lib/crisphive/configuration.rb +393 -0
  17. data/lib/crisphive/models/create_customer200_response.rb +250 -0
  18. data/lib/crisphive/models/create_job_request200_response.rb +250 -0
  19. data/lib/crisphive/models/customer.rb +235 -0
  20. data/lib/crisphive/models/customer_address.rb +295 -0
  21. data/lib/crisphive/models/customer_address_request.rb +475 -0
  22. data/lib/crisphive/models/customer_contact.rb +255 -0
  23. data/lib/crisphive/models/customer_create_request.rb +383 -0
  24. data/lib/crisphive/models/customer_create_response.rb +215 -0
  25. data/lib/crisphive/models/customer_list.rb +247 -0
  26. data/lib/crisphive/models/customer_list_item.rb +341 -0
  27. data/lib/crisphive/models/customer_profile.rb +321 -0
  28. data/lib/crisphive/models/customer_spending.rb +299 -0
  29. data/lib/crisphive/models/customer_tier_progress.rb +235 -0
  30. data/lib/crisphive/models/customer_update_request.rb +434 -0
  31. data/lib/crisphive/models/get_customer200_response.rb +250 -0
  32. data/lib/crisphive/models/get_job_request200_response.rb +250 -0
  33. data/lib/crisphive/models/get_job_request_timeline200_response.rb +250 -0
  34. data/lib/crisphive/models/get_job_type200_response.rb +250 -0
  35. data/lib/crisphive/models/get_service_area200_response.rb +250 -0
  36. data/lib/crisphive/models/get_technician200_response.rb +250 -0
  37. data/lib/crisphive/models/get_vehicle200_response.rb +250 -0
  38. data/lib/crisphive/models/job_date.rb +225 -0
  39. data/lib/crisphive/models/job_date_business_range.rb +263 -0
  40. data/lib/crisphive/models/job_date_period.rb +41 -0
  41. data/lib/crisphive/models/job_date_period_entry.rb +247 -0
  42. data/lib/crisphive/models/job_request.rb +537 -0
  43. data/lib/crisphive/models/job_request_action_audit_by.rb +259 -0
  44. data/lib/crisphive/models/job_request_action_audit_entry.rb +235 -0
  45. data/lib/crisphive/models/job_request_action_summary.rb +281 -0
  46. data/lib/crisphive/models/job_request_address_summary.rb +295 -0
  47. data/lib/crisphive/models/job_request_archive_summary.rb +245 -0
  48. data/lib/crisphive/models/job_request_arrival_window.rb +235 -0
  49. data/lib/crisphive/models/job_request_assigned_vehicle.rb +225 -0
  50. data/lib/crisphive/models/job_request_assignment_summary.rb +255 -0
  51. data/lib/crisphive/models/job_request_booking_windows.rb +247 -0
  52. data/lib/crisphive/models/job_request_business_time_range.rb +279 -0
  53. data/lib/crisphive/models/job_request_changes.rb +237 -0
  54. data/lib/crisphive/models/job_request_create_request.rb +339 -0
  55. data/lib/crisphive/models/job_request_create_response.rb +245 -0
  56. data/lib/crisphive/models/job_request_crew_member.rb +352 -0
  57. data/lib/crisphive/models/job_request_customer_summary.rb +245 -0
  58. data/lib/crisphive/models/job_request_day_windows.rb +227 -0
  59. data/lib/crisphive/models/job_request_job_date_business_range_request.rb +279 -0
  60. data/lib/crisphive/models/job_request_job_date_period_request.rb +268 -0
  61. data/lib/crisphive/models/job_request_job_date_request.rb +269 -0
  62. data/lib/crisphive/models/job_request_list.rb +227 -0
  63. data/lib/crisphive/models/job_request_period.rb +261 -0
  64. data/lib/crisphive/models/job_request_quote_summary.rb +245 -0
  65. data/lib/crisphive/models/job_request_rating_summary.rb +245 -0
  66. data/lib/crisphive/models/job_request_schedule.rb +289 -0
  67. data/lib/crisphive/models/job_request_session.rb +274 -0
  68. data/lib/crisphive/models/job_request_skill_summary.rb +255 -0
  69. data/lib/crisphive/models/job_request_status_summary.rb +225 -0
  70. data/lib/crisphive/models/job_request_technician_info.rb +265 -0
  71. data/lib/crisphive/models/job_request_timeline.rb +257 -0
  72. data/lib/crisphive/models/job_request_timeline_action.rb +311 -0
  73. data/lib/crisphive/models/job_request_timeline_event.rb +291 -0
  74. data/lib/crisphive/models/job_type.rb +309 -0
  75. data/lib/crisphive/models/list_customers200_response.rb +250 -0
  76. data/lib/crisphive/models/list_job_request_booking_windows200_response.rb +250 -0
  77. data/lib/crisphive/models/list_job_request_changes200_response.rb +250 -0
  78. data/lib/crisphive/models/list_job_requests200_response.rb +250 -0
  79. data/lib/crisphive/models/list_job_types200_response.rb +252 -0
  80. data/lib/crisphive/models/list_service_areas200_response.rb +250 -0
  81. data/lib/crisphive/models/list_skill_categories200_response.rb +250 -0
  82. data/lib/crisphive/models/list_skills200_response.rb +250 -0
  83. data/lib/crisphive/models/list_skills_by_category200_response.rb +250 -0
  84. data/lib/crisphive/models/list_technicians200_response.rb +250 -0
  85. data/lib/crisphive/models/list_vehicles200_response.rb +250 -0
  86. data/lib/crisphive/models/pagination.rb +250 -0
  87. data/lib/crisphive/models/response_envelope.rb +244 -0
  88. data/lib/crisphive/models/service_area.rb +315 -0
  89. data/lib/crisphive/models/service_area_list.rb +227 -0
  90. data/lib/crisphive/models/skill.rb +278 -0
  91. data/lib/crisphive/models/skill_by_category_list.rb +225 -0
  92. data/lib/crisphive/models/skill_category.rb +250 -0
  93. data/lib/crisphive/models/skill_category_list.rb +225 -0
  94. data/lib/crisphive/models/skill_list.rb +217 -0
  95. data/lib/crisphive/models/skill_summary.rb +255 -0
  96. data/lib/crisphive/models/technician.rb +499 -0
  97. data/lib/crisphive/models/technician_address.rb +275 -0
  98. data/lib/crisphive/models/technician_lead_ref.rb +225 -0
  99. data/lib/crisphive/models/technician_list.rb +247 -0
  100. data/lib/crisphive/models/technician_service_area_ref.rb +225 -0
  101. data/lib/crisphive/models/technician_status.rb +41 -0
  102. data/lib/crisphive/models/vehicle.rb +413 -0
  103. data/lib/crisphive/models/vehicle_list.rb +247 -0
  104. data/lib/crisphive/models/vehicle_owner.rb +225 -0
  105. data/lib/crisphive/version.rb +15 -0
  106. data/lib/crisphive.rb +134 -0
  107. data/spec/spec_helper.rb +111 -0
  108. metadata +220 -0
@@ -0,0 +1,281 @@
1
+ =begin
2
+ #CrispHive Developer API
3
+
4
+ #Public REST API for integrating CrispHive from your own backend. Authenticate every request with a secret API key as a Bearer token (`Authorization: Bearer chsk_live_…`). The key prefix selects the data environment: `chsk_live_…` → production (live), `chsk_test_…` → sandbox (isolated test). **Key scopes (restricted keys).** A key is either *full-access* (can call every endpoint below) or *restricted* to a set of permission codes chosen at creation — the same codes as the dashboard permission grid (e.g. `customers_view`, `job_create`, `team_manage`). A restricted key calling an endpoint outside its scope gets `403`. The full code list is the permission catalog (`GET /permission/modules` on the dashboard API). Create, scope, and revoke keys from the business dashboard. Every response is wrapped in the envelope `{ \"error_code\": 0, \"message\": \"Success\", \"data\": <payload> }`.
5
+
6
+ The version of the OpenAPI document: 1.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.11.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Crisphive
17
+ class JobRequestActionSummary
18
+ # Role expected to fire this action.
19
+ attr_accessor :actor
20
+
21
+ # Capability slugs declared on the action (e.g. client_location). Omitted when none.
22
+ attr_accessor :capabilities
23
+
24
+ # Action key (e.g. quote, confirm_booking, complete, or a custom DYNAMIC action).
25
+ attr_accessor :key
26
+
27
+ # Action label, resolved to the request locale.
28
+ attr_accessor :label
29
+
30
+ class EnumAttributeValidator
31
+ attr_reader :datatype
32
+ attr_reader :allowable_values
33
+
34
+ def initialize(datatype, allowable_values)
35
+ @allowable_values = allowable_values.map do |value|
36
+ case datatype.to_s
37
+ when /Integer/i
38
+ value.to_i
39
+ when /Float/i
40
+ value.to_f
41
+ else
42
+ value
43
+ end
44
+ end
45
+ end
46
+
47
+ def valid?(value)
48
+ !value || allowable_values.include?(value)
49
+ end
50
+ end
51
+
52
+ # Attribute mapping from ruby-style variable name to JSON key.
53
+ def self.attribute_map
54
+ {
55
+ :'actor' => :'actor',
56
+ :'capabilities' => :'capabilities',
57
+ :'key' => :'key',
58
+ :'label' => :'label'
59
+ }
60
+ end
61
+
62
+ # Returns all the JSON keys this model knows about
63
+ def self.acceptable_attributes
64
+ attribute_map.values
65
+ end
66
+
67
+ # Attribute type mapping.
68
+ def self.openapi_types
69
+ {
70
+ :'actor' => :'String',
71
+ :'capabilities' => :'Array<String>',
72
+ :'key' => :'String',
73
+ :'label' => :'String'
74
+ }
75
+ end
76
+
77
+ # List of attributes with nullable: true
78
+ def self.openapi_nullable
79
+ Set.new([
80
+ ])
81
+ end
82
+
83
+ # Initializes the object
84
+ # @param [Hash] attributes Model attributes in the form of hash
85
+ def initialize(attributes = {})
86
+ if (!attributes.is_a?(Hash))
87
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Crisphive::JobRequestActionSummary` initialize method"
88
+ end
89
+
90
+ # check to see if the attribute exists and convert string to symbol for hash key
91
+ attributes = attributes.each_with_object({}) { |(k, v), h|
92
+ if (!self.class.attribute_map.key?(k.to_sym))
93
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Crisphive::JobRequestActionSummary`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
94
+ end
95
+ h[k.to_sym] = v
96
+ }
97
+
98
+ if attributes.key?(:'actor')
99
+ self.actor = attributes[:'actor']
100
+ end
101
+
102
+ if attributes.key?(:'capabilities')
103
+ if (value = attributes[:'capabilities']).is_a?(Array)
104
+ self.capabilities = value
105
+ end
106
+ end
107
+
108
+ if attributes.key?(:'key')
109
+ self.key = attributes[:'key']
110
+ end
111
+
112
+ if attributes.key?(:'label')
113
+ self.label = attributes[:'label']
114
+ end
115
+ end
116
+
117
+ # Show invalid properties with the reasons. Usually used together with valid?
118
+ # @return Array for valid properties with the reasons
119
+ def list_invalid_properties
120
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
121
+ invalid_properties = Array.new
122
+ invalid_properties
123
+ end
124
+
125
+ # Check to see if the all the properties in the model are valid
126
+ # @return true if the model is valid
127
+ def valid?
128
+ warn '[DEPRECATED] the `valid?` method is obsolete'
129
+ actor_validator = EnumAttributeValidator.new('String', ["business", "customer", "technician", "system"])
130
+ return false unless actor_validator.valid?(@actor)
131
+ true
132
+ end
133
+
134
+ # Custom attribute writer method checking allowed values (enum).
135
+ # @param [Object] actor Object to be assigned
136
+ def actor=(actor)
137
+ validator = EnumAttributeValidator.new('String', ["business", "customer", "technician", "system"])
138
+ unless validator.valid?(actor)
139
+ fail ArgumentError, "invalid value for \"actor\", must be one of #{validator.allowable_values}."
140
+ end
141
+ @actor = actor
142
+ end
143
+
144
+ # Checks equality by comparing each attribute.
145
+ # @param [Object] Object to be compared
146
+ def ==(o)
147
+ return true if self.equal?(o)
148
+ self.class == o.class &&
149
+ actor == o.actor &&
150
+ capabilities == o.capabilities &&
151
+ key == o.key &&
152
+ label == o.label
153
+ end
154
+
155
+ # @see the `==` method
156
+ # @param [Object] Object to be compared
157
+ def eql?(o)
158
+ self == o
159
+ end
160
+
161
+ # Calculates hash code according to all attributes.
162
+ # @return [Integer] Hash code
163
+ def hash
164
+ [actor, capabilities, key, label].hash
165
+ end
166
+
167
+ # Builds the object from hash
168
+ # @param [Hash] attributes Model attributes in the form of hash
169
+ # @return [Object] Returns the model itself
170
+ def self.build_from_hash(attributes)
171
+ return nil unless attributes.is_a?(Hash)
172
+ attributes = attributes.transform_keys(&:to_sym)
173
+ transformed_hash = {}
174
+ openapi_types.each_pair do |key, type|
175
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
176
+ transformed_hash["#{key}"] = nil
177
+ elsif type =~ /\AArray<(.*)>/i
178
+ # check to ensure the input is an array given that the attribute
179
+ # is documented as an array but the input is not
180
+ if attributes[attribute_map[key]].is_a?(Array)
181
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
182
+ end
183
+ elsif !attributes[attribute_map[key]].nil?
184
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
185
+ end
186
+ end
187
+ new(transformed_hash)
188
+ end
189
+
190
+ # Deserializes the data based on type
191
+ # @param string type Data type
192
+ # @param string value Value to be deserialized
193
+ # @return [Object] Deserialized data
194
+ def self._deserialize(type, value)
195
+ case type.to_sym
196
+ when :Time
197
+ Time.parse(value)
198
+ when :Date
199
+ Date.parse(value)
200
+ when :String
201
+ value.to_s
202
+ when :Integer
203
+ value.to_i
204
+ when :Float
205
+ value.to_f
206
+ when :Boolean
207
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
208
+ true
209
+ else
210
+ false
211
+ end
212
+ when :Object
213
+ # generic object (usually a Hash), return directly
214
+ value
215
+ when /\AArray<(?<inner_type>.+)>\z/
216
+ inner_type = Regexp.last_match[:inner_type]
217
+ value.map { |v| _deserialize(inner_type, v) }
218
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
219
+ k_type = Regexp.last_match[:k_type]
220
+ v_type = Regexp.last_match[:v_type]
221
+ {}.tap do |hash|
222
+ value.each do |k, v|
223
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
224
+ end
225
+ end
226
+ else # model
227
+ # models (e.g. Pet) or oneOf
228
+ klass = Crisphive.const_get(type)
229
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
230
+ end
231
+ end
232
+
233
+ # Returns the string representation of the object
234
+ # @return [String] String presentation of the object
235
+ def to_s
236
+ to_hash.to_s
237
+ end
238
+
239
+ # to_body is an alias to to_hash (backward compatibility)
240
+ # @return [Hash] Returns the object in the form of hash
241
+ def to_body
242
+ to_hash
243
+ end
244
+
245
+ # Returns the object in the form of hash
246
+ # @return [Hash] Returns the object in the form of hash
247
+ def to_hash
248
+ hash = {}
249
+ self.class.attribute_map.each_pair do |attr, param|
250
+ value = self.send(attr)
251
+ if value.nil?
252
+ is_nullable = self.class.openapi_nullable.include?(attr)
253
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
254
+ end
255
+
256
+ hash[param] = _to_hash(value)
257
+ end
258
+ hash
259
+ end
260
+
261
+ # Outputs non-array value in the form of hash
262
+ # For object, use to_hash. Otherwise, just return the value
263
+ # @param [Object] value Any valid value
264
+ # @return [Hash] Returns the value in the form of hash
265
+ def _to_hash(value)
266
+ if value.is_a?(Array)
267
+ value.compact.map { |v| _to_hash(v) }
268
+ elsif value.is_a?(Hash)
269
+ {}.tap do |hash|
270
+ value.each { |k, v| hash[k] = _to_hash(v) }
271
+ end
272
+ elsif value.respond_to? :to_hash
273
+ value.to_hash
274
+ else
275
+ value
276
+ end
277
+ end
278
+
279
+ end
280
+
281
+ end
@@ -0,0 +1,295 @@
1
+ =begin
2
+ #CrispHive Developer API
3
+
4
+ #Public REST API for integrating CrispHive from your own backend. Authenticate every request with a secret API key as a Bearer token (`Authorization: Bearer chsk_live_…`). The key prefix selects the data environment: `chsk_live_…` → production (live), `chsk_test_…` → sandbox (isolated test). **Key scopes (restricted keys).** A key is either *full-access* (can call every endpoint below) or *restricted* to a set of permission codes chosen at creation — the same codes as the dashboard permission grid (e.g. `customers_view`, `job_create`, `team_manage`). A restricted key calling an endpoint outside its scope gets `403`. The full code list is the permission catalog (`GET /permission/modules` on the dashboard API). Create, scope, and revoke keys from the business dashboard. Every response is wrapped in the envelope `{ \"error_code\": 0, \"message\": \"Success\", \"data\": <payload> }`.
5
+
6
+ The version of the OpenAPI document: 1.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.11.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Crisphive
17
+ class JobRequestAddressSummary
18
+ # City / locality.
19
+ attr_accessor :city
20
+
21
+ # Country (free-form or ISO code as supplied).
22
+ attr_accessor :country
23
+
24
+ # Human-readable single-line address. Omitted if not composed.
25
+ attr_accessor :formatted
26
+
27
+ # Geographic latitude in decimal degrees; null if no coordinates are saved.
28
+ attr_accessor :latitude
29
+
30
+ # Street address, line 1.
31
+ attr_accessor :line
32
+
33
+ # Street address, line 2 (apartment, suite, unit). Omitted if unused.
34
+ attr_accessor :line2
35
+
36
+ # Geographic longitude in decimal degrees; null if no coordinates are saved.
37
+ attr_accessor :longitude
38
+
39
+ # Postal / ZIP code.
40
+ attr_accessor :postal
41
+
42
+ # State / province / region.
43
+ attr_accessor :state
44
+
45
+ # Attribute mapping from ruby-style variable name to JSON key.
46
+ def self.attribute_map
47
+ {
48
+ :'city' => :'city',
49
+ :'country' => :'country',
50
+ :'formatted' => :'formatted',
51
+ :'latitude' => :'latitude',
52
+ :'line' => :'line',
53
+ :'line2' => :'line2',
54
+ :'longitude' => :'longitude',
55
+ :'postal' => :'postal',
56
+ :'state' => :'state'
57
+ }
58
+ end
59
+
60
+ # Returns all the JSON keys this model knows about
61
+ def self.acceptable_attributes
62
+ attribute_map.values
63
+ end
64
+
65
+ # Attribute type mapping.
66
+ def self.openapi_types
67
+ {
68
+ :'city' => :'String',
69
+ :'country' => :'String',
70
+ :'formatted' => :'String',
71
+ :'latitude' => :'Float',
72
+ :'line' => :'String',
73
+ :'line2' => :'String',
74
+ :'longitude' => :'Float',
75
+ :'postal' => :'String',
76
+ :'state' => :'String'
77
+ }
78
+ end
79
+
80
+ # List of attributes with nullable: true
81
+ def self.openapi_nullable
82
+ Set.new([
83
+ ])
84
+ end
85
+
86
+ # Initializes the object
87
+ # @param [Hash] attributes Model attributes in the form of hash
88
+ def initialize(attributes = {})
89
+ if (!attributes.is_a?(Hash))
90
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Crisphive::JobRequestAddressSummary` initialize method"
91
+ end
92
+
93
+ # check to see if the attribute exists and convert string to symbol for hash key
94
+ attributes = attributes.each_with_object({}) { |(k, v), h|
95
+ if (!self.class.attribute_map.key?(k.to_sym))
96
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Crisphive::JobRequestAddressSummary`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
97
+ end
98
+ h[k.to_sym] = v
99
+ }
100
+
101
+ if attributes.key?(:'city')
102
+ self.city = attributes[:'city']
103
+ end
104
+
105
+ if attributes.key?(:'country')
106
+ self.country = attributes[:'country']
107
+ end
108
+
109
+ if attributes.key?(:'formatted')
110
+ self.formatted = attributes[:'formatted']
111
+ end
112
+
113
+ if attributes.key?(:'latitude')
114
+ self.latitude = attributes[:'latitude']
115
+ end
116
+
117
+ if attributes.key?(:'line')
118
+ self.line = attributes[:'line']
119
+ end
120
+
121
+ if attributes.key?(:'line2')
122
+ self.line2 = attributes[:'line2']
123
+ end
124
+
125
+ if attributes.key?(:'longitude')
126
+ self.longitude = attributes[:'longitude']
127
+ end
128
+
129
+ if attributes.key?(:'postal')
130
+ self.postal = attributes[:'postal']
131
+ end
132
+
133
+ if attributes.key?(:'state')
134
+ self.state = attributes[:'state']
135
+ end
136
+ end
137
+
138
+ # Show invalid properties with the reasons. Usually used together with valid?
139
+ # @return Array for valid properties with the reasons
140
+ def list_invalid_properties
141
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
142
+ invalid_properties = Array.new
143
+ invalid_properties
144
+ end
145
+
146
+ # Check to see if the all the properties in the model are valid
147
+ # @return true if the model is valid
148
+ def valid?
149
+ warn '[DEPRECATED] the `valid?` method is obsolete'
150
+ true
151
+ end
152
+
153
+ # Checks equality by comparing each attribute.
154
+ # @param [Object] Object to be compared
155
+ def ==(o)
156
+ return true if self.equal?(o)
157
+ self.class == o.class &&
158
+ city == o.city &&
159
+ country == o.country &&
160
+ formatted == o.formatted &&
161
+ latitude == o.latitude &&
162
+ line == o.line &&
163
+ line2 == o.line2 &&
164
+ longitude == o.longitude &&
165
+ postal == o.postal &&
166
+ state == o.state
167
+ end
168
+
169
+ # @see the `==` method
170
+ # @param [Object] Object to be compared
171
+ def eql?(o)
172
+ self == o
173
+ end
174
+
175
+ # Calculates hash code according to all attributes.
176
+ # @return [Integer] Hash code
177
+ def hash
178
+ [city, country, formatted, latitude, line, line2, longitude, postal, state].hash
179
+ end
180
+
181
+ # Builds the object from hash
182
+ # @param [Hash] attributes Model attributes in the form of hash
183
+ # @return [Object] Returns the model itself
184
+ def self.build_from_hash(attributes)
185
+ return nil unless attributes.is_a?(Hash)
186
+ attributes = attributes.transform_keys(&:to_sym)
187
+ transformed_hash = {}
188
+ openapi_types.each_pair do |key, type|
189
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
190
+ transformed_hash["#{key}"] = nil
191
+ elsif type =~ /\AArray<(.*)>/i
192
+ # check to ensure the input is an array given that the attribute
193
+ # is documented as an array but the input is not
194
+ if attributes[attribute_map[key]].is_a?(Array)
195
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
196
+ end
197
+ elsif !attributes[attribute_map[key]].nil?
198
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
199
+ end
200
+ end
201
+ new(transformed_hash)
202
+ end
203
+
204
+ # Deserializes the data based on type
205
+ # @param string type Data type
206
+ # @param string value Value to be deserialized
207
+ # @return [Object] Deserialized data
208
+ def self._deserialize(type, value)
209
+ case type.to_sym
210
+ when :Time
211
+ Time.parse(value)
212
+ when :Date
213
+ Date.parse(value)
214
+ when :String
215
+ value.to_s
216
+ when :Integer
217
+ value.to_i
218
+ when :Float
219
+ value.to_f
220
+ when :Boolean
221
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
222
+ true
223
+ else
224
+ false
225
+ end
226
+ when :Object
227
+ # generic object (usually a Hash), return directly
228
+ value
229
+ when /\AArray<(?<inner_type>.+)>\z/
230
+ inner_type = Regexp.last_match[:inner_type]
231
+ value.map { |v| _deserialize(inner_type, v) }
232
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
233
+ k_type = Regexp.last_match[:k_type]
234
+ v_type = Regexp.last_match[:v_type]
235
+ {}.tap do |hash|
236
+ value.each do |k, v|
237
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
238
+ end
239
+ end
240
+ else # model
241
+ # models (e.g. Pet) or oneOf
242
+ klass = Crisphive.const_get(type)
243
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
244
+ end
245
+ end
246
+
247
+ # Returns the string representation of the object
248
+ # @return [String] String presentation of the object
249
+ def to_s
250
+ to_hash.to_s
251
+ end
252
+
253
+ # to_body is an alias to to_hash (backward compatibility)
254
+ # @return [Hash] Returns the object in the form of hash
255
+ def to_body
256
+ to_hash
257
+ end
258
+
259
+ # Returns the object in the form of hash
260
+ # @return [Hash] Returns the object in the form of hash
261
+ def to_hash
262
+ hash = {}
263
+ self.class.attribute_map.each_pair do |attr, param|
264
+ value = self.send(attr)
265
+ if value.nil?
266
+ is_nullable = self.class.openapi_nullable.include?(attr)
267
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
268
+ end
269
+
270
+ hash[param] = _to_hash(value)
271
+ end
272
+ hash
273
+ end
274
+
275
+ # Outputs non-array value in the form of hash
276
+ # For object, use to_hash. Otherwise, just return the value
277
+ # @param [Object] value Any valid value
278
+ # @return [Hash] Returns the value in the form of hash
279
+ def _to_hash(value)
280
+ if value.is_a?(Array)
281
+ value.compact.map { |v| _to_hash(v) }
282
+ elsif value.is_a?(Hash)
283
+ {}.tap do |hash|
284
+ value.each { |k, v| hash[k] = _to_hash(v) }
285
+ end
286
+ elsif value.respond_to? :to_hash
287
+ value.to_hash
288
+ else
289
+ value
290
+ end
291
+ end
292
+
293
+ end
294
+
295
+ end