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,341 @@
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 CustomerListItem
18
+ # Set (RFC3339) only when the record has been soft-deleted; omitted otherwise.
19
+ attr_accessor :deleted_at
20
+
21
+ # Customer's full name.
22
+ attr_accessor :full_name
23
+
24
+ # Customer UUID.
25
+ attr_accessor :id
26
+
27
+ # When the customer last booked, or null if never (RFC3339).
28
+ attr_accessor :last_request_at
29
+
30
+ # Total number of job requests booked.
31
+ attr_accessor :request_count
32
+
33
+ # Lifecycle status.
34
+ attr_accessor :status
35
+
36
+ # Loyalty tier.
37
+ attr_accessor :tier
38
+
39
+ # Your external reference for this customer. Optional.
40
+ attr_accessor :uid
41
+
42
+ # When this record was last modified (RFC3339).
43
+ attr_accessor :updated_at
44
+
45
+ class EnumAttributeValidator
46
+ attr_reader :datatype
47
+ attr_reader :allowable_values
48
+
49
+ def initialize(datatype, allowable_values)
50
+ @allowable_values = allowable_values.map do |value|
51
+ case datatype.to_s
52
+ when /Integer/i
53
+ value.to_i
54
+ when /Float/i
55
+ value.to_f
56
+ else
57
+ value
58
+ end
59
+ end
60
+ end
61
+
62
+ def valid?(value)
63
+ !value || allowable_values.include?(value)
64
+ end
65
+ end
66
+
67
+ # Attribute mapping from ruby-style variable name to JSON key.
68
+ def self.attribute_map
69
+ {
70
+ :'deleted_at' => :'deleted_at',
71
+ :'full_name' => :'full_name',
72
+ :'id' => :'id',
73
+ :'last_request_at' => :'last_request_at',
74
+ :'request_count' => :'request_count',
75
+ :'status' => :'status',
76
+ :'tier' => :'tier',
77
+ :'uid' => :'uid',
78
+ :'updated_at' => :'updated_at'
79
+ }
80
+ end
81
+
82
+ # Returns all the JSON keys this model knows about
83
+ def self.acceptable_attributes
84
+ attribute_map.values
85
+ end
86
+
87
+ # Attribute type mapping.
88
+ def self.openapi_types
89
+ {
90
+ :'deleted_at' => :'Time',
91
+ :'full_name' => :'String',
92
+ :'id' => :'String',
93
+ :'last_request_at' => :'Time',
94
+ :'request_count' => :'Integer',
95
+ :'status' => :'String',
96
+ :'tier' => :'String',
97
+ :'uid' => :'String',
98
+ :'updated_at' => :'Time'
99
+ }
100
+ end
101
+
102
+ # List of attributes with nullable: true
103
+ def self.openapi_nullable
104
+ Set.new([
105
+ ])
106
+ end
107
+
108
+ # Initializes the object
109
+ # @param [Hash] attributes Model attributes in the form of hash
110
+ def initialize(attributes = {})
111
+ if (!attributes.is_a?(Hash))
112
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Crisphive::CustomerListItem` initialize method"
113
+ end
114
+
115
+ # check to see if the attribute exists and convert string to symbol for hash key
116
+ attributes = attributes.each_with_object({}) { |(k, v), h|
117
+ if (!self.class.attribute_map.key?(k.to_sym))
118
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Crisphive::CustomerListItem`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
119
+ end
120
+ h[k.to_sym] = v
121
+ }
122
+
123
+ if attributes.key?(:'deleted_at')
124
+ self.deleted_at = attributes[:'deleted_at']
125
+ end
126
+
127
+ if attributes.key?(:'full_name')
128
+ self.full_name = attributes[:'full_name']
129
+ end
130
+
131
+ if attributes.key?(:'id')
132
+ self.id = attributes[:'id']
133
+ end
134
+
135
+ if attributes.key?(:'last_request_at')
136
+ self.last_request_at = attributes[:'last_request_at']
137
+ end
138
+
139
+ if attributes.key?(:'request_count')
140
+ self.request_count = attributes[:'request_count']
141
+ end
142
+
143
+ if attributes.key?(:'status')
144
+ self.status = attributes[:'status']
145
+ end
146
+
147
+ if attributes.key?(:'tier')
148
+ self.tier = attributes[:'tier']
149
+ end
150
+
151
+ if attributes.key?(:'uid')
152
+ self.uid = attributes[:'uid']
153
+ end
154
+
155
+ if attributes.key?(:'updated_at')
156
+ self.updated_at = attributes[:'updated_at']
157
+ end
158
+ end
159
+
160
+ # Show invalid properties with the reasons. Usually used together with valid?
161
+ # @return Array for valid properties with the reasons
162
+ def list_invalid_properties
163
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
164
+ invalid_properties = Array.new
165
+ invalid_properties
166
+ end
167
+
168
+ # Check to see if the all the properties in the model are valid
169
+ # @return true if the model is valid
170
+ def valid?
171
+ warn '[DEPRECATED] the `valid?` method is obsolete'
172
+ status_validator = EnumAttributeValidator.new('String', ["active", "inactive"])
173
+ return false unless status_validator.valid?(@status)
174
+ tier_validator = EnumAttributeValidator.new('String', ["regular", "vip"])
175
+ return false unless tier_validator.valid?(@tier)
176
+ true
177
+ end
178
+
179
+ # Custom attribute writer method checking allowed values (enum).
180
+ # @param [Object] status Object to be assigned
181
+ def status=(status)
182
+ validator = EnumAttributeValidator.new('String', ["active", "inactive"])
183
+ unless validator.valid?(status)
184
+ fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}."
185
+ end
186
+ @status = status
187
+ end
188
+
189
+ # Custom attribute writer method checking allowed values (enum).
190
+ # @param [Object] tier Object to be assigned
191
+ def tier=(tier)
192
+ validator = EnumAttributeValidator.new('String', ["regular", "vip"])
193
+ unless validator.valid?(tier)
194
+ fail ArgumentError, "invalid value for \"tier\", must be one of #{validator.allowable_values}."
195
+ end
196
+ @tier = tier
197
+ end
198
+
199
+ # Checks equality by comparing each attribute.
200
+ # @param [Object] Object to be compared
201
+ def ==(o)
202
+ return true if self.equal?(o)
203
+ self.class == o.class &&
204
+ deleted_at == o.deleted_at &&
205
+ full_name == o.full_name &&
206
+ id == o.id &&
207
+ last_request_at == o.last_request_at &&
208
+ request_count == o.request_count &&
209
+ status == o.status &&
210
+ tier == o.tier &&
211
+ uid == o.uid &&
212
+ updated_at == o.updated_at
213
+ end
214
+
215
+ # @see the `==` method
216
+ # @param [Object] Object to be compared
217
+ def eql?(o)
218
+ self == o
219
+ end
220
+
221
+ # Calculates hash code according to all attributes.
222
+ # @return [Integer] Hash code
223
+ def hash
224
+ [deleted_at, full_name, id, last_request_at, request_count, status, tier, uid, updated_at].hash
225
+ end
226
+
227
+ # Builds the object from hash
228
+ # @param [Hash] attributes Model attributes in the form of hash
229
+ # @return [Object] Returns the model itself
230
+ def self.build_from_hash(attributes)
231
+ return nil unless attributes.is_a?(Hash)
232
+ attributes = attributes.transform_keys(&:to_sym)
233
+ transformed_hash = {}
234
+ openapi_types.each_pair do |key, type|
235
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
236
+ transformed_hash["#{key}"] = nil
237
+ elsif type =~ /\AArray<(.*)>/i
238
+ # check to ensure the input is an array given that the attribute
239
+ # is documented as an array but the input is not
240
+ if attributes[attribute_map[key]].is_a?(Array)
241
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
242
+ end
243
+ elsif !attributes[attribute_map[key]].nil?
244
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
245
+ end
246
+ end
247
+ new(transformed_hash)
248
+ end
249
+
250
+ # Deserializes the data based on type
251
+ # @param string type Data type
252
+ # @param string value Value to be deserialized
253
+ # @return [Object] Deserialized data
254
+ def self._deserialize(type, value)
255
+ case type.to_sym
256
+ when :Time
257
+ Time.parse(value)
258
+ when :Date
259
+ Date.parse(value)
260
+ when :String
261
+ value.to_s
262
+ when :Integer
263
+ value.to_i
264
+ when :Float
265
+ value.to_f
266
+ when :Boolean
267
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
268
+ true
269
+ else
270
+ false
271
+ end
272
+ when :Object
273
+ # generic object (usually a Hash), return directly
274
+ value
275
+ when /\AArray<(?<inner_type>.+)>\z/
276
+ inner_type = Regexp.last_match[:inner_type]
277
+ value.map { |v| _deserialize(inner_type, v) }
278
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
279
+ k_type = Regexp.last_match[:k_type]
280
+ v_type = Regexp.last_match[:v_type]
281
+ {}.tap do |hash|
282
+ value.each do |k, v|
283
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
284
+ end
285
+ end
286
+ else # model
287
+ # models (e.g. Pet) or oneOf
288
+ klass = Crisphive.const_get(type)
289
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
290
+ end
291
+ end
292
+
293
+ # Returns the string representation of the object
294
+ # @return [String] String presentation of the object
295
+ def to_s
296
+ to_hash.to_s
297
+ end
298
+
299
+ # to_body is an alias to to_hash (backward compatibility)
300
+ # @return [Hash] Returns the object in the form of hash
301
+ def to_body
302
+ to_hash
303
+ end
304
+
305
+ # Returns the object in the form of hash
306
+ # @return [Hash] Returns the object in the form of hash
307
+ def to_hash
308
+ hash = {}
309
+ self.class.attribute_map.each_pair do |attr, param|
310
+ value = self.send(attr)
311
+ if value.nil?
312
+ is_nullable = self.class.openapi_nullable.include?(attr)
313
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
314
+ end
315
+
316
+ hash[param] = _to_hash(value)
317
+ end
318
+ hash
319
+ end
320
+
321
+ # Outputs non-array value in the form of hash
322
+ # For object, use to_hash. Otherwise, just return the value
323
+ # @param [Object] value Any valid value
324
+ # @return [Hash] Returns the value in the form of hash
325
+ def _to_hash(value)
326
+ if value.is_a?(Array)
327
+ value.compact.map { |v| _to_hash(v) }
328
+ elsif value.is_a?(Hash)
329
+ {}.tap do |hash|
330
+ value.each { |k, v| hash[k] = _to_hash(v) }
331
+ end
332
+ elsif value.respond_to? :to_hash
333
+ value.to_hash
334
+ else
335
+ value
336
+ end
337
+ end
338
+
339
+ end
340
+
341
+ end
@@ -0,0 +1,321 @@
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 CustomerProfile
18
+ # When the customer record was created (RFC3339).
19
+ attr_accessor :created_at
20
+
21
+ # Customer's full name.
22
+ attr_accessor :full_name
23
+
24
+ # Customer UUID — the stable identifier used in every customer endpoint.
25
+ attr_accessor :id
26
+
27
+ # Total number of job requests this customer has booked.
28
+ attr_accessor :request_count
29
+
30
+ # Lifecycle status.
31
+ attr_accessor :status
32
+
33
+ # Loyalty tier.
34
+ attr_accessor :tier
35
+
36
+ # Your external reference for this customer (your own system's ID). Optional.
37
+ attr_accessor :uid
38
+
39
+ class EnumAttributeValidator
40
+ attr_reader :datatype
41
+ attr_reader :allowable_values
42
+
43
+ def initialize(datatype, allowable_values)
44
+ @allowable_values = allowable_values.map do |value|
45
+ case datatype.to_s
46
+ when /Integer/i
47
+ value.to_i
48
+ when /Float/i
49
+ value.to_f
50
+ else
51
+ value
52
+ end
53
+ end
54
+ end
55
+
56
+ def valid?(value)
57
+ !value || allowable_values.include?(value)
58
+ end
59
+ end
60
+
61
+ # Attribute mapping from ruby-style variable name to JSON key.
62
+ def self.attribute_map
63
+ {
64
+ :'created_at' => :'created_at',
65
+ :'full_name' => :'full_name',
66
+ :'id' => :'id',
67
+ :'request_count' => :'request_count',
68
+ :'status' => :'status',
69
+ :'tier' => :'tier',
70
+ :'uid' => :'uid'
71
+ }
72
+ end
73
+
74
+ # Returns all the JSON keys this model knows about
75
+ def self.acceptable_attributes
76
+ attribute_map.values
77
+ end
78
+
79
+ # Attribute type mapping.
80
+ def self.openapi_types
81
+ {
82
+ :'created_at' => :'Time',
83
+ :'full_name' => :'String',
84
+ :'id' => :'String',
85
+ :'request_count' => :'Integer',
86
+ :'status' => :'String',
87
+ :'tier' => :'String',
88
+ :'uid' => :'String'
89
+ }
90
+ end
91
+
92
+ # List of attributes with nullable: true
93
+ def self.openapi_nullable
94
+ Set.new([
95
+ ])
96
+ end
97
+
98
+ # Initializes the object
99
+ # @param [Hash] attributes Model attributes in the form of hash
100
+ def initialize(attributes = {})
101
+ if (!attributes.is_a?(Hash))
102
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Crisphive::CustomerProfile` initialize method"
103
+ end
104
+
105
+ # check to see if the attribute exists and convert string to symbol for hash key
106
+ attributes = attributes.each_with_object({}) { |(k, v), h|
107
+ if (!self.class.attribute_map.key?(k.to_sym))
108
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Crisphive::CustomerProfile`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
109
+ end
110
+ h[k.to_sym] = v
111
+ }
112
+
113
+ if attributes.key?(:'created_at')
114
+ self.created_at = attributes[:'created_at']
115
+ end
116
+
117
+ if attributes.key?(:'full_name')
118
+ self.full_name = attributes[:'full_name']
119
+ end
120
+
121
+ if attributes.key?(:'id')
122
+ self.id = attributes[:'id']
123
+ end
124
+
125
+ if attributes.key?(:'request_count')
126
+ self.request_count = attributes[:'request_count']
127
+ end
128
+
129
+ if attributes.key?(:'status')
130
+ self.status = attributes[:'status']
131
+ end
132
+
133
+ if attributes.key?(:'tier')
134
+ self.tier = attributes[:'tier']
135
+ end
136
+
137
+ if attributes.key?(:'uid')
138
+ self.uid = attributes[:'uid']
139
+ end
140
+ end
141
+
142
+ # Show invalid properties with the reasons. Usually used together with valid?
143
+ # @return Array for valid properties with the reasons
144
+ def list_invalid_properties
145
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
146
+ invalid_properties = Array.new
147
+ invalid_properties
148
+ end
149
+
150
+ # Check to see if the all the properties in the model are valid
151
+ # @return true if the model is valid
152
+ def valid?
153
+ warn '[DEPRECATED] the `valid?` method is obsolete'
154
+ status_validator = EnumAttributeValidator.new('String', ["active", "inactive"])
155
+ return false unless status_validator.valid?(@status)
156
+ tier_validator = EnumAttributeValidator.new('String', ["regular", "vip"])
157
+ return false unless tier_validator.valid?(@tier)
158
+ true
159
+ end
160
+
161
+ # Custom attribute writer method checking allowed values (enum).
162
+ # @param [Object] status Object to be assigned
163
+ def status=(status)
164
+ validator = EnumAttributeValidator.new('String', ["active", "inactive"])
165
+ unless validator.valid?(status)
166
+ fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}."
167
+ end
168
+ @status = status
169
+ end
170
+
171
+ # Custom attribute writer method checking allowed values (enum).
172
+ # @param [Object] tier Object to be assigned
173
+ def tier=(tier)
174
+ validator = EnumAttributeValidator.new('String', ["regular", "vip"])
175
+ unless validator.valid?(tier)
176
+ fail ArgumentError, "invalid value for \"tier\", must be one of #{validator.allowable_values}."
177
+ end
178
+ @tier = tier
179
+ end
180
+
181
+ # Checks equality by comparing each attribute.
182
+ # @param [Object] Object to be compared
183
+ def ==(o)
184
+ return true if self.equal?(o)
185
+ self.class == o.class &&
186
+ created_at == o.created_at &&
187
+ full_name == o.full_name &&
188
+ id == o.id &&
189
+ request_count == o.request_count &&
190
+ status == o.status &&
191
+ tier == o.tier &&
192
+ uid == o.uid
193
+ end
194
+
195
+ # @see the `==` method
196
+ # @param [Object] Object to be compared
197
+ def eql?(o)
198
+ self == o
199
+ end
200
+
201
+ # Calculates hash code according to all attributes.
202
+ # @return [Integer] Hash code
203
+ def hash
204
+ [created_at, full_name, id, request_count, status, tier, uid].hash
205
+ end
206
+
207
+ # Builds the object from hash
208
+ # @param [Hash] attributes Model attributes in the form of hash
209
+ # @return [Object] Returns the model itself
210
+ def self.build_from_hash(attributes)
211
+ return nil unless attributes.is_a?(Hash)
212
+ attributes = attributes.transform_keys(&:to_sym)
213
+ transformed_hash = {}
214
+ openapi_types.each_pair do |key, type|
215
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
216
+ transformed_hash["#{key}"] = nil
217
+ elsif type =~ /\AArray<(.*)>/i
218
+ # check to ensure the input is an array given that the attribute
219
+ # is documented as an array but the input is not
220
+ if attributes[attribute_map[key]].is_a?(Array)
221
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
222
+ end
223
+ elsif !attributes[attribute_map[key]].nil?
224
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
225
+ end
226
+ end
227
+ new(transformed_hash)
228
+ end
229
+
230
+ # Deserializes the data based on type
231
+ # @param string type Data type
232
+ # @param string value Value to be deserialized
233
+ # @return [Object] Deserialized data
234
+ def self._deserialize(type, value)
235
+ case type.to_sym
236
+ when :Time
237
+ Time.parse(value)
238
+ when :Date
239
+ Date.parse(value)
240
+ when :String
241
+ value.to_s
242
+ when :Integer
243
+ value.to_i
244
+ when :Float
245
+ value.to_f
246
+ when :Boolean
247
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
248
+ true
249
+ else
250
+ false
251
+ end
252
+ when :Object
253
+ # generic object (usually a Hash), return directly
254
+ value
255
+ when /\AArray<(?<inner_type>.+)>\z/
256
+ inner_type = Regexp.last_match[:inner_type]
257
+ value.map { |v| _deserialize(inner_type, v) }
258
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
259
+ k_type = Regexp.last_match[:k_type]
260
+ v_type = Regexp.last_match[:v_type]
261
+ {}.tap do |hash|
262
+ value.each do |k, v|
263
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
264
+ end
265
+ end
266
+ else # model
267
+ # models (e.g. Pet) or oneOf
268
+ klass = Crisphive.const_get(type)
269
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
270
+ end
271
+ end
272
+
273
+ # Returns the string representation of the object
274
+ # @return [String] String presentation of the object
275
+ def to_s
276
+ to_hash.to_s
277
+ end
278
+
279
+ # to_body is an alias to to_hash (backward compatibility)
280
+ # @return [Hash] Returns the object in the form of hash
281
+ def to_body
282
+ to_hash
283
+ end
284
+
285
+ # Returns the object in the form of hash
286
+ # @return [Hash] Returns the object in the form of hash
287
+ def to_hash
288
+ hash = {}
289
+ self.class.attribute_map.each_pair do |attr, param|
290
+ value = self.send(attr)
291
+ if value.nil?
292
+ is_nullable = self.class.openapi_nullable.include?(attr)
293
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
294
+ end
295
+
296
+ hash[param] = _to_hash(value)
297
+ end
298
+ hash
299
+ end
300
+
301
+ # Outputs non-array value in the form of hash
302
+ # For object, use to_hash. Otherwise, just return the value
303
+ # @param [Object] value Any valid value
304
+ # @return [Hash] Returns the value in the form of hash
305
+ def _to_hash(value)
306
+ if value.is_a?(Array)
307
+ value.compact.map { |v| _to_hash(v) }
308
+ elsif value.is_a?(Hash)
309
+ {}.tap do |hash|
310
+ value.each { |k, v| hash[k] = _to_hash(v) }
311
+ end
312
+ elsif value.respond_to? :to_hash
313
+ value.to_hash
314
+ else
315
+ value
316
+ end
317
+ end
318
+
319
+ end
320
+
321
+ end