get_around_owner 1.0.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 (154) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/README.md +303 -0
  4. data/Rakefile +10 -0
  5. data/docs/CarsApi.md +151 -0
  6. data/docs/CheckinsApi.md +71 -0
  7. data/docs/CheckoutsApi.md +71 -0
  8. data/docs/GetaroundCar.md +28 -0
  9. data/docs/GetaroundCarsIndexInner.md +18 -0
  10. data/docs/GetaroundCheckin.md +24 -0
  11. data/docs/GetaroundCheckinsIndexInner.md +18 -0
  12. data/docs/GetaroundCheckout.md +26 -0
  13. data/docs/GetaroundCreateMessagesRequest.md +18 -0
  14. data/docs/GetaroundCreateUnavailabilitiesRequest.md +22 -0
  15. data/docs/GetaroundDestroyUnavailabilityRequest.md +20 -0
  16. data/docs/GetaroundInvoice.md +34 -0
  17. data/docs/GetaroundInvoiceChargesInner.md +20 -0
  18. data/docs/GetaroundInvoicesIndexInner.md +18 -0
  19. data/docs/GetaroundMessage.md +26 -0
  20. data/docs/GetaroundMessagesSent.md +22 -0
  21. data/docs/GetaroundMessagesSentAllOfData.md +20 -0
  22. data/docs/GetaroundPayout.md +28 -0
  23. data/docs/GetaroundPayoutInvoicesInner.md +18 -0
  24. data/docs/GetaroundPayoutsIndexInner.md +18 -0
  25. data/docs/GetaroundReason.md +15 -0
  26. data/docs/GetaroundRental.md +32 -0
  27. data/docs/GetaroundRentalInvoicesIndexInner.md +18 -0
  28. data/docs/GetaroundRentalMessagesIndexInner.md +18 -0
  29. data/docs/GetaroundRentalsBooked.md +22 -0
  30. data/docs/GetaroundRentalsBookedAllOfData.md +18 -0
  31. data/docs/GetaroundRentalsCanceled.md +22 -0
  32. data/docs/GetaroundRentalsCarCheckedIn.md +22 -0
  33. data/docs/GetaroundRentalsCarCheckedOut.md +22 -0
  34. data/docs/GetaroundRentalsCarSwitched.md +22 -0
  35. data/docs/GetaroundRentalsIndexInner.md +18 -0
  36. data/docs/GetaroundRentalsTimesChanged.md +22 -0
  37. data/docs/GetaroundUnavailabilitiesCreated.md +22 -0
  38. data/docs/GetaroundUnavailabilitiesCreatedAllOfData.md +24 -0
  39. data/docs/GetaroundUnavailabilitiesDeleted.md +22 -0
  40. data/docs/GetaroundUnavailabilitiesDeletedAllOfData.md +22 -0
  41. data/docs/GetaroundUnavailability.md +24 -0
  42. data/docs/GetaroundUser.md +42 -0
  43. data/docs/GetaroundUsersUpdated.md +22 -0
  44. data/docs/GetaroundUsersUpdatedAllOfData.md +18 -0
  45. data/docs/GetaroundWebhook.md +22 -0
  46. data/docs/InvoicesApi.md +231 -0
  47. data/docs/MessagesApi.md +71 -0
  48. data/docs/PayoutsApi.md +155 -0
  49. data/docs/RentalsApi.md +263 -0
  50. data/docs/UnavailabilitiesApi.md +135 -0
  51. data/docs/UsersApi.md +71 -0
  52. data/get_around_owner.gemspec +26 -0
  53. data/git_push.sh +57 -0
  54. data/lib/get_around_owner/api/cars_api.rb +148 -0
  55. data/lib/get_around_owner/api/checkins_api.rb +82 -0
  56. data/lib/get_around_owner/api/checkouts_api.rb +82 -0
  57. data/lib/get_around_owner/api/invoices_api.rb +223 -0
  58. data/lib/get_around_owner/api/messages_api.rb +82 -0
  59. data/lib/get_around_owner/api/payouts_api.rb +162 -0
  60. data/lib/get_around_owner/api/rentals_api.rb +262 -0
  61. data/lib/get_around_owner/api/unavailabilities_api.rb +142 -0
  62. data/lib/get_around_owner/api/users_api.rb +82 -0
  63. data/lib/get_around_owner/api_client.rb +394 -0
  64. data/lib/get_around_owner/api_error.rb +58 -0
  65. data/lib/get_around_owner/configuration.rb +298 -0
  66. data/lib/get_around_owner/models/getaround_car.rb +308 -0
  67. data/lib/get_around_owner/models/getaround_cars_index_inner.rb +223 -0
  68. data/lib/get_around_owner/models/getaround_checkin.rb +279 -0
  69. data/lib/get_around_owner/models/getaround_checkins_index_inner.rb +222 -0
  70. data/lib/get_around_owner/models/getaround_checkout.rb +298 -0
  71. data/lib/get_around_owner/models/getaround_create_messages_request.rb +222 -0
  72. data/lib/get_around_owner/models/getaround_create_unavailabilities_request.rb +283 -0
  73. data/lib/get_around_owner/models/getaround_destroy_unavailability_request.rb +239 -0
  74. data/lib/get_around_owner/models/getaround_invoice.rb +396 -0
  75. data/lib/get_around_owner/models/getaround_invoice_charges_inner.rb +225 -0
  76. data/lib/get_around_owner/models/getaround_invoices_index_inner.rb +223 -0
  77. data/lib/get_around_owner/models/getaround_message.rb +291 -0
  78. data/lib/get_around_owner/models/getaround_messages_sent.rb +257 -0
  79. data/lib/get_around_owner/models/getaround_messages_sent_all_of_data.rb +225 -0
  80. data/lib/get_around_owner/models/getaround_payout.rb +347 -0
  81. data/lib/get_around_owner/models/getaround_payout_invoices_inner.rb +223 -0
  82. data/lib/get_around_owner/models/getaround_payouts_index_inner.rb +223 -0
  83. data/lib/get_around_owner/models/getaround_reason.rb +45 -0
  84. data/lib/get_around_owner/models/getaround_rental.rb +380 -0
  85. data/lib/get_around_owner/models/getaround_rental_invoices_index_inner.rb +223 -0
  86. data/lib/get_around_owner/models/getaround_rental_messages_index_inner.rb +223 -0
  87. data/lib/get_around_owner/models/getaround_rentals_booked.rb +257 -0
  88. data/lib/get_around_owner/models/getaround_rentals_booked_all_of_data.rb +215 -0
  89. data/lib/get_around_owner/models/getaround_rentals_canceled.rb +257 -0
  90. data/lib/get_around_owner/models/getaround_rentals_car_checked_in.rb +257 -0
  91. data/lib/get_around_owner/models/getaround_rentals_car_checked_out.rb +257 -0
  92. data/lib/get_around_owner/models/getaround_rentals_car_switched.rb +257 -0
  93. data/lib/get_around_owner/models/getaround_rentals_index_inner.rb +223 -0
  94. data/lib/get_around_owner/models/getaround_rentals_times_changed.rb +257 -0
  95. data/lib/get_around_owner/models/getaround_unavailabilities_created.rb +257 -0
  96. data/lib/get_around_owner/models/getaround_unavailabilities_created_all_of_data.rb +267 -0
  97. data/lib/get_around_owner/models/getaround_unavailabilities_deleted.rb +257 -0
  98. data/lib/get_around_owner/models/getaround_unavailabilities_deleted_all_of_data.rb +235 -0
  99. data/lib/get_around_owner/models/getaround_unavailability.rb +302 -0
  100. data/lib/get_around_owner/models/getaround_user.rb +420 -0
  101. data/lib/get_around_owner/models/getaround_users_updated.rb +257 -0
  102. data/lib/get_around_owner/models/getaround_users_updated_all_of_data.rb +215 -0
  103. data/lib/get_around_owner/models/getaround_webhook.rb +252 -0
  104. data/lib/get_around_owner/version.rb +15 -0
  105. data/lib/get_around_owner.rb +86 -0
  106. data/spec/api/cars_api_spec.rb +60 -0
  107. data/spec/api/checkins_api_spec.rb +62 -0
  108. data/spec/api/checkouts_api_spec.rb +62 -0
  109. data/spec/api/invoices_api_spec.rb +76 -0
  110. data/spec/api/messages_api_spec.rb +73 -0
  111. data/spec/api/payouts_api_spec.rb +62 -0
  112. data/spec/api/rentals_api_spec.rb +62 -0
  113. data/spec/api/unavailabilities_api_spec.rb +77 -0
  114. data/spec/api/users_api_spec.rb +47 -0
  115. data/spec/models/getaround_car_spec.rb +66 -0
  116. data/spec/models/getaround_cars_index_inner_spec.rb +36 -0
  117. data/spec/models/getaround_checkin_spec.rb +54 -0
  118. data/spec/models/getaround_checkins_index_inner_spec.rb +36 -0
  119. data/spec/models/getaround_checkout_spec.rb +60 -0
  120. data/spec/models/getaround_create_messages_request_spec.rb +36 -0
  121. data/spec/models/getaround_create_unavailabilities_request_spec.rb +52 -0
  122. data/spec/models/getaround_destroy_unavailability_request_spec.rb +42 -0
  123. data/spec/models/getaround_invoice_charges_inner_spec.rb +42 -0
  124. data/spec/models/getaround_invoice_spec.rb +92 -0
  125. data/spec/models/getaround_invoices_index_inner_spec.rb +36 -0
  126. data/spec/models/getaround_message_spec.rb +60 -0
  127. data/spec/models/getaround_messages_sent_all_of_data_spec.rb +42 -0
  128. data/spec/models/getaround_messages_sent_spec.rb +48 -0
  129. data/spec/models/getaround_payout_invoices_inner_spec.rb +36 -0
  130. data/spec/models/getaround_payout_spec.rb +70 -0
  131. data/spec/models/getaround_payouts_index_inner_spec.rb +36 -0
  132. data/spec/models/getaround_reason_spec.rb +30 -0
  133. data/spec/models/getaround_rental_invoices_index_inner_spec.rb +36 -0
  134. data/spec/models/getaround_rental_messages_index_inner_spec.rb +36 -0
  135. data/spec/models/getaround_rental_spec.rb +78 -0
  136. data/spec/models/getaround_rentals_booked_all_of_data_spec.rb +36 -0
  137. data/spec/models/getaround_rentals_booked_spec.rb +48 -0
  138. data/spec/models/getaround_rentals_canceled_spec.rb +48 -0
  139. data/spec/models/getaround_rentals_car_checked_in_spec.rb +48 -0
  140. data/spec/models/getaround_rentals_car_checked_out_spec.rb +48 -0
  141. data/spec/models/getaround_rentals_car_switched_spec.rb +48 -0
  142. data/spec/models/getaround_rentals_index_inner_spec.rb +36 -0
  143. data/spec/models/getaround_rentals_times_changed_spec.rb +48 -0
  144. data/spec/models/getaround_unavailabilities_created_all_of_data_spec.rb +54 -0
  145. data/spec/models/getaround_unavailabilities_created_spec.rb +48 -0
  146. data/spec/models/getaround_unavailabilities_deleted_all_of_data_spec.rb +48 -0
  147. data/spec/models/getaround_unavailabilities_deleted_spec.rb +48 -0
  148. data/spec/models/getaround_unavailability_spec.rb +58 -0
  149. data/spec/models/getaround_user_spec.rb +108 -0
  150. data/spec/models/getaround_users_updated_all_of_data_spec.rb +36 -0
  151. data/spec/models/getaround_users_updated_spec.rb +48 -0
  152. data/spec/models/getaround_webhook_spec.rb +48 -0
  153. data/spec/spec_helper.rb +111 -0
  154. metadata +283 -0
@@ -0,0 +1,223 @@
1
+ =begin
2
+ #Getaround Owner API
3
+
4
+ ## Quick Start The Owner API uses the JSON format, and must be accessed over a [secure connection](https://en.wikipedia.org/wiki/HTTPS). Let’s assume that the access token provided by your account manager is “TOKEN”. Here’s how to get the list of ids of all your invoices from the first week of August with a shell script: ```bash query=\"end_date=2018-08-08T00%3A00%3A00%2B00%3A00&start_date=2018-08-01T00%3A00%3A00%2B00%3A00\" curl -i \"https://api-eu.getaround.com/owner/v1/invoices?${query}\" \\ -H \"Authorization: Bearer TOKEN\" \\ -H \"Accept:application/json\" \\ -H \"Content-Type:application/json\" ``` And here’s how to get the invoice with the id 12345: ```bash curl -i \"https://api-eu.getaround.com/owner/v1/invoices/12345\" \\ -H \"Authorization: Bearer TOKEN\" \\ -H \"Accept: application/json\" \\ -H \"Content-Type: application/json\"\" ``` See the [endpoints section](#tag/Invoices) of this guide for details about the response format. Dates in request params should follow the ISO 8601 standard. # Authentication All requests must be authenticated with a [bearer token header](https://tools.ietf.org/html/rfc6750#section-2.1). You token will be sent to you by your account manager. Unauthenticated requests will return a 401 status. # Pagination The page number and the number of items per page can be set with the “page” and “per_page” params. For example, this request will return the second page of invoices, and 50 invoices per page: `https://api-eu.getaround.com/owner/v1/invoices?page=2&per_page=50` Both of these params are optional. The default page size is 30 items. The Getaround Owner API follows the [RFC 8288 convention](https://datatracker.ietf.org/doc/html/rfc8288) of using the `Link` header to provide the `next` page URL. Please don't build the pagination URLs yourself. The `next` page will be missing when you are requesting the last available page. Here's an example response header from requesting the second page of invoices `https://api-eu.getaround.com/owner/v1/invoices?page=2&per_page=50` ``` Link: <https://api-eu.getaround.com/owner/v1/invoices?page=3&per_page=50>; rel=\"next\" ``` # Throttling policy and Date range limitation We have throttling policy that prevents you to perform more than 100 requests per min from the same IP. Also, there is a limitation on the size of the range of dates given in params in some requests. All requests that need start_date and end_date, do not accept a range bigger than 30 days. # Webhooks Getaround can send webhook events that notify your application when certain events happen on your account. This is especially useful to follow the lifecycle of rentals, tracking for example bookings or cancellations. ### Setup To set up an endpoint, you need to define a route on your server for receiving events, and then <a href=\"mailto:owner-api@getaround.com\">ask Getaround</a> to add this URL to your account. To acknowledge receipt of a event, your endpoint must: - Return a `2xx` HTTP status code. - Be a secure `https` endpoint with a valid SSL certificate. ### Testing Once Getaround has set up the endpoint, and it is properly configured as described above, a test `ping` event can be sent by clicking the button below: <form action=\"/docs/api/owner/fire_ping_webhook\" method=\"post\"><input type=\"submit\" value=\"Send Ping Event\"></form> You should receive the following JSON payload: ```json { \"data\": { \"ping\": \"pong\" }, \"type\": \"ping\", \"occurred_at\": \"2019-04-18T08:30:05Z\" } ``` ### Retries Webhook deliveries will be attempted for up to three days with an exponential back off. After that point the delivery will be abandoned. ### Verifying Signatures Getaround will also provide you with a secret token, which is used to create a hash signature with each payload. This hash signature is passed along with each request in the headers as `X-Drivy-Signature`. Suppose you have a basic server listening to webhooks that looks like this: ```ruby require 'sinatra' require 'json' post '/payload' do push = JSON.parse(params[:payload]) \"I got some JSON: \#{push.inspect}\" end ``` The goal is to compute a hash using your secret token, and ensure that the hash from Getaround matches. Getaround uses an HMAC hexdigest to compute the hash, so you could change your server to look a little like this: ```ruby post '/payload' do request.body.rewind payload_body = request.body.read verify_signature(payload_body) push = JSON.parse(params[:payload]) \"I got some JSON: \#{push.inspect}\" end def verify_signature(payload_body) signature = 'sha1=' + OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha1'), ENV['SECRET_TOKEN'], payload_body) return halt 500, \"Signatures didn't match!\" unless Rack::Utils.secure_compare(signature, request.env['HTTP_X_DRIVY_SIGNATURE']) end ``` Obviously, your language and server implementations may differ from this code. There are a couple of important things to point out, however: No matter which implementation you use, the hash signature starts with `sha1=`, using the key of your secret token and your payload body. Using a plain `==` operator is not advised. A method like secure_compare performs a \"constant time\" string comparison, which renders it safe from certain timing attacks against regular equality operators. ### Best Practices - **Acknowledge events immediately**. If your webhook script performs complex logic, or makes network calls, it’s possible that the script would time out before Getaround sees its complete execution. Ideally, your webhook handler code (acknowledging receipt of an event by returning a `2xx` status code) is separate of any other logic you do for that event. - **Handle duplicate events**. Webhook endpoints might occasionally receive the same event more than once. We advise you to guard against duplicated event receipts by making your event processing idempotent. One way of doing this is logging the events you’ve processed, and then not processing already-logged events. - **Do not expect events in order**. Getaround does not guarantee delivery of events in the order in which they are generated. Your endpoint should therefore handle this accordingly. We do provide an `occurred_at` timestamp for each event, though, to help reconcile ordering.
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ Contact: owner-api@getaround.com
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.6.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module GetAroundOwner
17
+ # A payout.
18
+ class GetaroundPayoutsIndexInner
19
+ # The payout ID
20
+ attr_accessor :id
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+ :'id' => :'id'
26
+ }
27
+ end
28
+
29
+ # Returns all the JSON keys this model knows about
30
+ def self.acceptable_attributes
31
+ attribute_map.values
32
+ end
33
+
34
+ # Attribute type mapping.
35
+ def self.openapi_types
36
+ {
37
+ :'id' => :'Integer'
38
+ }
39
+ end
40
+
41
+ # List of attributes with nullable: true
42
+ def self.openapi_nullable
43
+ Set.new([
44
+ ])
45
+ end
46
+
47
+ # Initializes the object
48
+ # @param [Hash] attributes Model attributes in the form of hash
49
+ def initialize(attributes = {})
50
+ if (!attributes.is_a?(Hash))
51
+ fail ArgumentError, "The input argument (attributes) must be a hash in `GetAroundOwner::GetaroundPayoutsIndexInner` initialize method"
52
+ end
53
+
54
+ # check to see if the attribute exists and convert string to symbol for hash key
55
+ attributes = attributes.each_with_object({}) { |(k, v), h|
56
+ if (!self.class.attribute_map.key?(k.to_sym))
57
+ fail ArgumentError, "`#{k}` is not a valid attribute in `GetAroundOwner::GetaroundPayoutsIndexInner`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
58
+ end
59
+ h[k.to_sym] = v
60
+ }
61
+
62
+ if attributes.key?(:'id')
63
+ self.id = attributes[:'id']
64
+ else
65
+ self.id = nil
66
+ end
67
+ end
68
+
69
+ # Show invalid properties with the reasons. Usually used together with valid?
70
+ # @return Array for valid properties with the reasons
71
+ def list_invalid_properties
72
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
73
+ invalid_properties = Array.new
74
+ if @id.nil?
75
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
76
+ end
77
+
78
+ invalid_properties
79
+ end
80
+
81
+ # Check to see if the all the properties in the model are valid
82
+ # @return true if the model is valid
83
+ def valid?
84
+ warn '[DEPRECATED] the `valid?` method is obsolete'
85
+ return false if @id.nil?
86
+ true
87
+ end
88
+
89
+ # Checks equality by comparing each attribute.
90
+ # @param [Object] Object to be compared
91
+ def ==(o)
92
+ return true if self.equal?(o)
93
+ self.class == o.class &&
94
+ id == o.id
95
+ end
96
+
97
+ # @see the `==` method
98
+ # @param [Object] Object to be compared
99
+ def eql?(o)
100
+ self == o
101
+ end
102
+
103
+ # Calculates hash code according to all attributes.
104
+ # @return [Integer] Hash code
105
+ def hash
106
+ [id].hash
107
+ end
108
+
109
+ # Builds the object from hash
110
+ # @param [Hash] attributes Model attributes in the form of hash
111
+ # @return [Object] Returns the model itself
112
+ def self.build_from_hash(attributes)
113
+ return nil unless attributes.is_a?(Hash)
114
+ attributes = attributes.transform_keys(&:to_sym)
115
+ transformed_hash = {}
116
+ openapi_types.each_pair do |key, type|
117
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
118
+ transformed_hash["#{key}"] = nil
119
+ elsif type =~ /\AArray<(.*)>/i
120
+ # check to ensure the input is an array given that the attribute
121
+ # is documented as an array but the input is not
122
+ if attributes[attribute_map[key]].is_a?(Array)
123
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
124
+ end
125
+ elsif !attributes[attribute_map[key]].nil?
126
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
127
+ end
128
+ end
129
+ new(transformed_hash)
130
+ end
131
+
132
+ # Deserializes the data based on type
133
+ # @param string type Data type
134
+ # @param string value Value to be deserialized
135
+ # @return [Object] Deserialized data
136
+ def self._deserialize(type, value)
137
+ case type.to_sym
138
+ when :Time
139
+ Time.parse(value)
140
+ when :Date
141
+ Date.parse(value)
142
+ when :String
143
+ value.to_s
144
+ when :Integer
145
+ value.to_i
146
+ when :Float
147
+ value.to_f
148
+ when :Boolean
149
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
150
+ true
151
+ else
152
+ false
153
+ end
154
+ when :Object
155
+ # generic object (usually a Hash), return directly
156
+ value
157
+ when /\AArray<(?<inner_type>.+)>\z/
158
+ inner_type = Regexp.last_match[:inner_type]
159
+ value.map { |v| _deserialize(inner_type, v) }
160
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
161
+ k_type = Regexp.last_match[:k_type]
162
+ v_type = Regexp.last_match[:v_type]
163
+ {}.tap do |hash|
164
+ value.each do |k, v|
165
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
166
+ end
167
+ end
168
+ else # model
169
+ # models (e.g. Pet) or oneOf
170
+ klass = GetAroundOwner.const_get(type)
171
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
172
+ end
173
+ end
174
+
175
+ # Returns the string representation of the object
176
+ # @return [String] String presentation of the object
177
+ def to_s
178
+ to_hash.to_s
179
+ end
180
+
181
+ # to_body is an alias to to_hash (backward compatibility)
182
+ # @return [Hash] Returns the object in the form of hash
183
+ def to_body
184
+ to_hash
185
+ end
186
+
187
+ # Returns the object in the form of hash
188
+ # @return [Hash] Returns the object in the form of hash
189
+ def to_hash
190
+ hash = {}
191
+ self.class.attribute_map.each_pair do |attr, param|
192
+ value = self.send(attr)
193
+ if value.nil?
194
+ is_nullable = self.class.openapi_nullable.include?(attr)
195
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
196
+ end
197
+
198
+ hash[param] = _to_hash(value)
199
+ end
200
+ hash
201
+ end
202
+
203
+ # Outputs non-array value in the form of hash
204
+ # For object, use to_hash. Otherwise, just return the value
205
+ # @param [Object] value Any valid value
206
+ # @return [Hash] Returns the value in the form of hash
207
+ def _to_hash(value)
208
+ if value.is_a?(Array)
209
+ value.compact.map { |v| _to_hash(v) }
210
+ elsif value.is_a?(Hash)
211
+ {}.tap do |hash|
212
+ value.each { |k, v| hash[k] = _to_hash(v) }
213
+ end
214
+ elsif value.respond_to? :to_hash
215
+ value.to_hash
216
+ else
217
+ value
218
+ end
219
+ end
220
+
221
+ end
222
+
223
+ end
@@ -0,0 +1,45 @@
1
+ =begin
2
+ #Getaround Owner API
3
+
4
+ ## Quick Start The Owner API uses the JSON format, and must be accessed over a [secure connection](https://en.wikipedia.org/wiki/HTTPS). Let’s assume that the access token provided by your account manager is “TOKEN”. Here’s how to get the list of ids of all your invoices from the first week of August with a shell script: ```bash query=\"end_date=2018-08-08T00%3A00%3A00%2B00%3A00&start_date=2018-08-01T00%3A00%3A00%2B00%3A00\" curl -i \"https://api-eu.getaround.com/owner/v1/invoices?${query}\" \\ -H \"Authorization: Bearer TOKEN\" \\ -H \"Accept:application/json\" \\ -H \"Content-Type:application/json\" ``` And here’s how to get the invoice with the id 12345: ```bash curl -i \"https://api-eu.getaround.com/owner/v1/invoices/12345\" \\ -H \"Authorization: Bearer TOKEN\" \\ -H \"Accept: application/json\" \\ -H \"Content-Type: application/json\"\" ``` See the [endpoints section](#tag/Invoices) of this guide for details about the response format. Dates in request params should follow the ISO 8601 standard. # Authentication All requests must be authenticated with a [bearer token header](https://tools.ietf.org/html/rfc6750#section-2.1). You token will be sent to you by your account manager. Unauthenticated requests will return a 401 status. # Pagination The page number and the number of items per page can be set with the “page” and “per_page” params. For example, this request will return the second page of invoices, and 50 invoices per page: `https://api-eu.getaround.com/owner/v1/invoices?page=2&per_page=50` Both of these params are optional. The default page size is 30 items. The Getaround Owner API follows the [RFC 8288 convention](https://datatracker.ietf.org/doc/html/rfc8288) of using the `Link` header to provide the `next` page URL. Please don't build the pagination URLs yourself. The `next` page will be missing when you are requesting the last available page. Here's an example response header from requesting the second page of invoices `https://api-eu.getaround.com/owner/v1/invoices?page=2&per_page=50` ``` Link: <https://api-eu.getaround.com/owner/v1/invoices?page=3&per_page=50>; rel=\"next\" ``` # Throttling policy and Date range limitation We have throttling policy that prevents you to perform more than 100 requests per min from the same IP. Also, there is a limitation on the size of the range of dates given in params in some requests. All requests that need start_date and end_date, do not accept a range bigger than 30 days. # Webhooks Getaround can send webhook events that notify your application when certain events happen on your account. This is especially useful to follow the lifecycle of rentals, tracking for example bookings or cancellations. ### Setup To set up an endpoint, you need to define a route on your server for receiving events, and then <a href=\"mailto:owner-api@getaround.com\">ask Getaround</a> to add this URL to your account. To acknowledge receipt of a event, your endpoint must: - Return a `2xx` HTTP status code. - Be a secure `https` endpoint with a valid SSL certificate. ### Testing Once Getaround has set up the endpoint, and it is properly configured as described above, a test `ping` event can be sent by clicking the button below: <form action=\"/docs/api/owner/fire_ping_webhook\" method=\"post\"><input type=\"submit\" value=\"Send Ping Event\"></form> You should receive the following JSON payload: ```json { \"data\": { \"ping\": \"pong\" }, \"type\": \"ping\", \"occurred_at\": \"2019-04-18T08:30:05Z\" } ``` ### Retries Webhook deliveries will be attempted for up to three days with an exponential back off. After that point the delivery will be abandoned. ### Verifying Signatures Getaround will also provide you with a secret token, which is used to create a hash signature with each payload. This hash signature is passed along with each request in the headers as `X-Drivy-Signature`. Suppose you have a basic server listening to webhooks that looks like this: ```ruby require 'sinatra' require 'json' post '/payload' do push = JSON.parse(params[:payload]) \"I got some JSON: \#{push.inspect}\" end ``` The goal is to compute a hash using your secret token, and ensure that the hash from Getaround matches. Getaround uses an HMAC hexdigest to compute the hash, so you could change your server to look a little like this: ```ruby post '/payload' do request.body.rewind payload_body = request.body.read verify_signature(payload_body) push = JSON.parse(params[:payload]) \"I got some JSON: \#{push.inspect}\" end def verify_signature(payload_body) signature = 'sha1=' + OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha1'), ENV['SECRET_TOKEN'], payload_body) return halt 500, \"Signatures didn't match!\" unless Rack::Utils.secure_compare(signature, request.env['HTTP_X_DRIVY_SIGNATURE']) end ``` Obviously, your language and server implementations may differ from this code. There are a couple of important things to point out, however: No matter which implementation you use, the hash signature starts with `sha1=`, using the key of your secret token and your payload body. Using a plain `==` operator is not advised. A method like secure_compare performs a \"constant time\" string comparison, which renders it safe from certain timing attacks against regular equality operators. ### Best Practices - **Acknowledge events immediately**. If your webhook script performs complex logic, or makes network calls, it’s possible that the script would time out before Getaround sees its complete execution. Ideally, your webhook handler code (acknowledging receipt of an event by returning a `2xx` status code) is separate of any other logic you do for that event. - **Handle duplicate events**. Webhook endpoints might occasionally receive the same event more than once. We advise you to guard against duplicated event receipts by making your event processing idempotent. One way of doing this is logging the events you’ve processed, and then not processing already-logged events. - **Do not expect events in order**. Getaround does not guarantee delivery of events in the order in which they are generated. Your endpoint should therefore handle this accordingly. We do provide an `occurred_at` timestamp for each event, though, to help reconcile ordering.
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ Contact: owner-api@getaround.com
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.6.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module GetAroundOwner
17
+ class GetaroundReason
18
+ CHECK_UP = "check_up".freeze
19
+ REPAIRS = "repairs".freeze
20
+ CONNECT_ISSUES = "connect_issues".freeze
21
+ REPATRIATION = "repatriation".freeze
22
+ BOOKED = "booked".freeze
23
+ OTHER = "other".freeze
24
+ NULL = "null".freeze
25
+
26
+ def self.all_vars
27
+ @all_vars ||= [CHECK_UP, REPAIRS, CONNECT_ISSUES, REPATRIATION, BOOKED, OTHER, NULL].freeze
28
+ end
29
+
30
+ # Builds the enum from string
31
+ # @param [String] The enum value in the form of the string
32
+ # @return [String] The enum value
33
+ def self.build_from_hash(value)
34
+ new.build_from_hash(value)
35
+ end
36
+
37
+ # Builds the enum from string
38
+ # @param [String] The enum value in the form of the string
39
+ # @return [String] The enum value
40
+ def build_from_hash(value)
41
+ return value if GetaroundReason.all_vars.include?(value)
42
+ raise "Invalid ENUM value #{value} for class #GetaroundReason"
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,380 @@
1
+ =begin
2
+ #Getaround Owner API
3
+
4
+ ## Quick Start The Owner API uses the JSON format, and must be accessed over a [secure connection](https://en.wikipedia.org/wiki/HTTPS). Let’s assume that the access token provided by your account manager is “TOKEN”. Here’s how to get the list of ids of all your invoices from the first week of August with a shell script: ```bash query=\"end_date=2018-08-08T00%3A00%3A00%2B00%3A00&start_date=2018-08-01T00%3A00%3A00%2B00%3A00\" curl -i \"https://api-eu.getaround.com/owner/v1/invoices?${query}\" \\ -H \"Authorization: Bearer TOKEN\" \\ -H \"Accept:application/json\" \\ -H \"Content-Type:application/json\" ``` And here’s how to get the invoice with the id 12345: ```bash curl -i \"https://api-eu.getaround.com/owner/v1/invoices/12345\" \\ -H \"Authorization: Bearer TOKEN\" \\ -H \"Accept: application/json\" \\ -H \"Content-Type: application/json\"\" ``` See the [endpoints section](#tag/Invoices) of this guide for details about the response format. Dates in request params should follow the ISO 8601 standard. # Authentication All requests must be authenticated with a [bearer token header](https://tools.ietf.org/html/rfc6750#section-2.1). You token will be sent to you by your account manager. Unauthenticated requests will return a 401 status. # Pagination The page number and the number of items per page can be set with the “page” and “per_page” params. For example, this request will return the second page of invoices, and 50 invoices per page: `https://api-eu.getaround.com/owner/v1/invoices?page=2&per_page=50` Both of these params are optional. The default page size is 30 items. The Getaround Owner API follows the [RFC 8288 convention](https://datatracker.ietf.org/doc/html/rfc8288) of using the `Link` header to provide the `next` page URL. Please don't build the pagination URLs yourself. The `next` page will be missing when you are requesting the last available page. Here's an example response header from requesting the second page of invoices `https://api-eu.getaround.com/owner/v1/invoices?page=2&per_page=50` ``` Link: <https://api-eu.getaround.com/owner/v1/invoices?page=3&per_page=50>; rel=\"next\" ``` # Throttling policy and Date range limitation We have throttling policy that prevents you to perform more than 100 requests per min from the same IP. Also, there is a limitation on the size of the range of dates given in params in some requests. All requests that need start_date and end_date, do not accept a range bigger than 30 days. # Webhooks Getaround can send webhook events that notify your application when certain events happen on your account. This is especially useful to follow the lifecycle of rentals, tracking for example bookings or cancellations. ### Setup To set up an endpoint, you need to define a route on your server for receiving events, and then <a href=\"mailto:owner-api@getaround.com\">ask Getaround</a> to add this URL to your account. To acknowledge receipt of a event, your endpoint must: - Return a `2xx` HTTP status code. - Be a secure `https` endpoint with a valid SSL certificate. ### Testing Once Getaround has set up the endpoint, and it is properly configured as described above, a test `ping` event can be sent by clicking the button below: <form action=\"/docs/api/owner/fire_ping_webhook\" method=\"post\"><input type=\"submit\" value=\"Send Ping Event\"></form> You should receive the following JSON payload: ```json { \"data\": { \"ping\": \"pong\" }, \"type\": \"ping\", \"occurred_at\": \"2019-04-18T08:30:05Z\" } ``` ### Retries Webhook deliveries will be attempted for up to three days with an exponential back off. After that point the delivery will be abandoned. ### Verifying Signatures Getaround will also provide you with a secret token, which is used to create a hash signature with each payload. This hash signature is passed along with each request in the headers as `X-Drivy-Signature`. Suppose you have a basic server listening to webhooks that looks like this: ```ruby require 'sinatra' require 'json' post '/payload' do push = JSON.parse(params[:payload]) \"I got some JSON: \#{push.inspect}\" end ``` The goal is to compute a hash using your secret token, and ensure that the hash from Getaround matches. Getaround uses an HMAC hexdigest to compute the hash, so you could change your server to look a little like this: ```ruby post '/payload' do request.body.rewind payload_body = request.body.read verify_signature(payload_body) push = JSON.parse(params[:payload]) \"I got some JSON: \#{push.inspect}\" end def verify_signature(payload_body) signature = 'sha1=' + OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha1'), ENV['SECRET_TOKEN'], payload_body) return halt 500, \"Signatures didn't match!\" unless Rack::Utils.secure_compare(signature, request.env['HTTP_X_DRIVY_SIGNATURE']) end ``` Obviously, your language and server implementations may differ from this code. There are a couple of important things to point out, however: No matter which implementation you use, the hash signature starts with `sha1=`, using the key of your secret token and your payload body. Using a plain `==` operator is not advised. A method like secure_compare performs a \"constant time\" string comparison, which renders it safe from certain timing attacks against regular equality operators. ### Best Practices - **Acknowledge events immediately**. If your webhook script performs complex logic, or makes network calls, it’s possible that the script would time out before Getaround sees its complete execution. Ideally, your webhook handler code (acknowledging receipt of an event by returning a `2xx` status code) is separate of any other logic you do for that event. - **Handle duplicate events**. Webhook endpoints might occasionally receive the same event more than once. We advise you to guard against duplicated event receipts by making your event processing idempotent. One way of doing this is logging the events you’ve processed, and then not processing already-logged events. - **Do not expect events in order**. Getaround does not guarantee delivery of events in the order in which they are generated. Your endpoint should therefore handle this accordingly. We do provide an `occurred_at` timestamp for each event, though, to help reconcile ordering.
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ Contact: owner-api@getaround.com
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.6.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module GetAroundOwner
17
+ # A Rental.
18
+ class GetaroundRental
19
+ # Rental's id
20
+ attr_accessor :id
21
+
22
+ # Vehicle's id
23
+ attr_accessor :car_id
24
+
25
+ # User id of the rental's driver
26
+ attr_accessor :user_id
27
+
28
+ # Rental's started time in ISO8601 format
29
+ attr_accessor :starts_at
30
+
31
+ # Rental's ended time in ISO8601 format
32
+ attr_accessor :ends_at
33
+
34
+ # Rental's booked time in ISO8601 format
35
+ attr_accessor :booked_at
36
+
37
+ # Price set by the owner (in cents 0.01€)
38
+ attr_accessor :price
39
+
40
+ # Insurance amount collected (in cents 0.01€)
41
+ attr_accessor :insurance_fee
42
+
43
+ # Attribute mapping from ruby-style variable name to JSON key.
44
+ def self.attribute_map
45
+ {
46
+ :'id' => :'id',
47
+ :'car_id' => :'car_id',
48
+ :'user_id' => :'user_id',
49
+ :'starts_at' => :'starts_at',
50
+ :'ends_at' => :'ends_at',
51
+ :'booked_at' => :'booked_at',
52
+ :'price' => :'price',
53
+ :'insurance_fee' => :'insurance_fee'
54
+ }
55
+ end
56
+
57
+ # Returns all the JSON keys this model knows about
58
+ def self.acceptable_attributes
59
+ attribute_map.values
60
+ end
61
+
62
+ # Attribute type mapping.
63
+ def self.openapi_types
64
+ {
65
+ :'id' => :'Integer',
66
+ :'car_id' => :'Integer',
67
+ :'user_id' => :'Integer',
68
+ :'starts_at' => :'Time',
69
+ :'ends_at' => :'Time',
70
+ :'booked_at' => :'Time',
71
+ :'price' => :'Integer',
72
+ :'insurance_fee' => :'Integer'
73
+ }
74
+ end
75
+
76
+ # List of attributes with nullable: true
77
+ def self.openapi_nullable
78
+ Set.new([
79
+ ])
80
+ end
81
+
82
+ # Initializes the object
83
+ # @param [Hash] attributes Model attributes in the form of hash
84
+ def initialize(attributes = {})
85
+ if (!attributes.is_a?(Hash))
86
+ fail ArgumentError, "The input argument (attributes) must be a hash in `GetAroundOwner::GetaroundRental` initialize method"
87
+ end
88
+
89
+ # check to see if the attribute exists and convert string to symbol for hash key
90
+ attributes = attributes.each_with_object({}) { |(k, v), h|
91
+ if (!self.class.attribute_map.key?(k.to_sym))
92
+ fail ArgumentError, "`#{k}` is not a valid attribute in `GetAroundOwner::GetaroundRental`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
93
+ end
94
+ h[k.to_sym] = v
95
+ }
96
+
97
+ if attributes.key?(:'id')
98
+ self.id = attributes[:'id']
99
+ else
100
+ self.id = nil
101
+ end
102
+
103
+ if attributes.key?(:'car_id')
104
+ self.car_id = attributes[:'car_id']
105
+ else
106
+ self.car_id = nil
107
+ end
108
+
109
+ if attributes.key?(:'user_id')
110
+ self.user_id = attributes[:'user_id']
111
+ else
112
+ self.user_id = nil
113
+ end
114
+
115
+ if attributes.key?(:'starts_at')
116
+ self.starts_at = attributes[:'starts_at']
117
+ else
118
+ self.starts_at = nil
119
+ end
120
+
121
+ if attributes.key?(:'ends_at')
122
+ self.ends_at = attributes[:'ends_at']
123
+ else
124
+ self.ends_at = nil
125
+ end
126
+
127
+ if attributes.key?(:'booked_at')
128
+ self.booked_at = attributes[:'booked_at']
129
+ else
130
+ self.booked_at = nil
131
+ end
132
+
133
+ if attributes.key?(:'price')
134
+ self.price = attributes[:'price']
135
+ else
136
+ self.price = nil
137
+ end
138
+
139
+ if attributes.key?(:'insurance_fee')
140
+ self.insurance_fee = attributes[:'insurance_fee']
141
+ else
142
+ self.insurance_fee = nil
143
+ end
144
+ end
145
+
146
+ # Show invalid properties with the reasons. Usually used together with valid?
147
+ # @return Array for valid properties with the reasons
148
+ def list_invalid_properties
149
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
150
+ invalid_properties = Array.new
151
+ if @id.nil?
152
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
153
+ end
154
+
155
+ if @car_id.nil?
156
+ invalid_properties.push('invalid value for "car_id", car_id cannot be nil.')
157
+ end
158
+
159
+ if @car_id < 1
160
+ invalid_properties.push('invalid value for "car_id", must be greater than or equal to 1.')
161
+ end
162
+
163
+ if @user_id.nil?
164
+ invalid_properties.push('invalid value for "user_id", user_id cannot be nil.')
165
+ end
166
+
167
+ if @user_id < 1
168
+ invalid_properties.push('invalid value for "user_id", must be greater than or equal to 1.')
169
+ end
170
+
171
+ if @starts_at.nil?
172
+ invalid_properties.push('invalid value for "starts_at", starts_at cannot be nil.')
173
+ end
174
+
175
+ if @ends_at.nil?
176
+ invalid_properties.push('invalid value for "ends_at", ends_at cannot be nil.')
177
+ end
178
+
179
+ if @booked_at.nil?
180
+ invalid_properties.push('invalid value for "booked_at", booked_at cannot be nil.')
181
+ end
182
+
183
+ if @price.nil?
184
+ invalid_properties.push('invalid value for "price", price cannot be nil.')
185
+ end
186
+
187
+ if @insurance_fee.nil?
188
+ invalid_properties.push('invalid value for "insurance_fee", insurance_fee cannot be nil.')
189
+ end
190
+
191
+ invalid_properties
192
+ end
193
+
194
+ # Check to see if the all the properties in the model are valid
195
+ # @return true if the model is valid
196
+ def valid?
197
+ warn '[DEPRECATED] the `valid?` method is obsolete'
198
+ return false if @id.nil?
199
+ return false if @car_id.nil?
200
+ return false if @car_id < 1
201
+ return false if @user_id.nil?
202
+ return false if @user_id < 1
203
+ return false if @starts_at.nil?
204
+ return false if @ends_at.nil?
205
+ return false if @booked_at.nil?
206
+ return false if @price.nil?
207
+ return false if @insurance_fee.nil?
208
+ true
209
+ end
210
+
211
+ # Custom attribute writer method with validation
212
+ # @param [Object] car_id Value to be assigned
213
+ def car_id=(car_id)
214
+ if car_id.nil?
215
+ fail ArgumentError, 'car_id cannot be nil'
216
+ end
217
+
218
+ if car_id < 1
219
+ fail ArgumentError, 'invalid value for "car_id", must be greater than or equal to 1.'
220
+ end
221
+
222
+ @car_id = car_id
223
+ end
224
+
225
+ # Custom attribute writer method with validation
226
+ # @param [Object] user_id Value to be assigned
227
+ def user_id=(user_id)
228
+ if user_id.nil?
229
+ fail ArgumentError, 'user_id cannot be nil'
230
+ end
231
+
232
+ if user_id < 1
233
+ fail ArgumentError, 'invalid value for "user_id", must be greater than or equal to 1.'
234
+ end
235
+
236
+ @user_id = user_id
237
+ end
238
+
239
+ # Checks equality by comparing each attribute.
240
+ # @param [Object] Object to be compared
241
+ def ==(o)
242
+ return true if self.equal?(o)
243
+ self.class == o.class &&
244
+ id == o.id &&
245
+ car_id == o.car_id &&
246
+ user_id == o.user_id &&
247
+ starts_at == o.starts_at &&
248
+ ends_at == o.ends_at &&
249
+ booked_at == o.booked_at &&
250
+ price == o.price &&
251
+ insurance_fee == o.insurance_fee
252
+ end
253
+
254
+ # @see the `==` method
255
+ # @param [Object] Object to be compared
256
+ def eql?(o)
257
+ self == o
258
+ end
259
+
260
+ # Calculates hash code according to all attributes.
261
+ # @return [Integer] Hash code
262
+ def hash
263
+ [id, car_id, user_id, starts_at, ends_at, booked_at, price, insurance_fee].hash
264
+ end
265
+
266
+ # Builds the object from hash
267
+ # @param [Hash] attributes Model attributes in the form of hash
268
+ # @return [Object] Returns the model itself
269
+ def self.build_from_hash(attributes)
270
+ return nil unless attributes.is_a?(Hash)
271
+ attributes = attributes.transform_keys(&:to_sym)
272
+ transformed_hash = {}
273
+ openapi_types.each_pair do |key, type|
274
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
275
+ transformed_hash["#{key}"] = nil
276
+ elsif type =~ /\AArray<(.*)>/i
277
+ # check to ensure the input is an array given that the attribute
278
+ # is documented as an array but the input is not
279
+ if attributes[attribute_map[key]].is_a?(Array)
280
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
281
+ end
282
+ elsif !attributes[attribute_map[key]].nil?
283
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
284
+ end
285
+ end
286
+ new(transformed_hash)
287
+ end
288
+
289
+ # Deserializes the data based on type
290
+ # @param string type Data type
291
+ # @param string value Value to be deserialized
292
+ # @return [Object] Deserialized data
293
+ def self._deserialize(type, value)
294
+ case type.to_sym
295
+ when :Time
296
+ Time.parse(value)
297
+ when :Date
298
+ Date.parse(value)
299
+ when :String
300
+ value.to_s
301
+ when :Integer
302
+ value.to_i
303
+ when :Float
304
+ value.to_f
305
+ when :Boolean
306
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
307
+ true
308
+ else
309
+ false
310
+ end
311
+ when :Object
312
+ # generic object (usually a Hash), return directly
313
+ value
314
+ when /\AArray<(?<inner_type>.+)>\z/
315
+ inner_type = Regexp.last_match[:inner_type]
316
+ value.map { |v| _deserialize(inner_type, v) }
317
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
318
+ k_type = Regexp.last_match[:k_type]
319
+ v_type = Regexp.last_match[:v_type]
320
+ {}.tap do |hash|
321
+ value.each do |k, v|
322
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
323
+ end
324
+ end
325
+ else # model
326
+ # models (e.g. Pet) or oneOf
327
+ klass = GetAroundOwner.const_get(type)
328
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
329
+ end
330
+ end
331
+
332
+ # Returns the string representation of the object
333
+ # @return [String] String presentation of the object
334
+ def to_s
335
+ to_hash.to_s
336
+ end
337
+
338
+ # to_body is an alias to to_hash (backward compatibility)
339
+ # @return [Hash] Returns the object in the form of hash
340
+ def to_body
341
+ to_hash
342
+ end
343
+
344
+ # Returns the object in the form of hash
345
+ # @return [Hash] Returns the object in the form of hash
346
+ def to_hash
347
+ hash = {}
348
+ self.class.attribute_map.each_pair do |attr, param|
349
+ value = self.send(attr)
350
+ if value.nil?
351
+ is_nullable = self.class.openapi_nullable.include?(attr)
352
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
353
+ end
354
+
355
+ hash[param] = _to_hash(value)
356
+ end
357
+ hash
358
+ end
359
+
360
+ # Outputs non-array value in the form of hash
361
+ # For object, use to_hash. Otherwise, just return the value
362
+ # @param [Object] value Any valid value
363
+ # @return [Hash] Returns the value in the form of hash
364
+ def _to_hash(value)
365
+ if value.is_a?(Array)
366
+ value.compact.map { |v| _to_hash(v) }
367
+ elsif value.is_a?(Hash)
368
+ {}.tap do |hash|
369
+ value.each { |k, v| hash[k] = _to_hash(v) }
370
+ end
371
+ elsif value.respond_to? :to_hash
372
+ value.to_hash
373
+ else
374
+ value
375
+ end
376
+ end
377
+
378
+ end
379
+
380
+ end