get_around_owner 1.0.0 → 1.0.3

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 (198) hide show
  1. checksums.yaml +4 -4
  2. data/Owner API v1.json +2938 -0
  3. data/README.md +338 -181
  4. data/Rakefile +0 -2
  5. data/docs/Car.md +12 -0
  6. data/docs/CarId.md +6 -0
  7. data/docs/CarIdUnavailabilitiesJsonBody.md +9 -0
  8. data/docs/CarsApi.md +38 -79
  9. data/docs/CarsIndex.md +6 -0
  10. data/docs/Checkin.md +10 -0
  11. data/docs/CheckinsApi.md +76 -33
  12. data/docs/CheckinsIndex.md +6 -0
  13. data/docs/Checkout.md +11 -0
  14. data/docs/CheckoutsApi.md +76 -33
  15. data/docs/CheckoutsIndex.md +6 -0
  16. data/docs/EndsAt.md +6 -0
  17. data/docs/Invoice.md +15 -0
  18. data/docs/InvoicesApi.md +62 -124
  19. data/docs/InvoicesIndex.md +6 -0
  20. data/docs/Message.md +11 -0
  21. data/docs/MessagesApi.md +122 -31
  22. data/docs/MessagesSent.md +6 -0
  23. data/docs/Payout.md +12 -0
  24. data/docs/PayoutsApi.md +42 -83
  25. data/docs/PayoutsIndex.md +6 -0
  26. data/docs/Rental.md +14 -0
  27. data/docs/RentalIdMessagesJsonBody.md +7 -0
  28. data/docs/RentalInvoicesIndex.md +6 -0
  29. data/docs/RentalMessagesIndex.md +6 -0
  30. data/docs/RentalsApi.md +54 -203
  31. data/docs/RentalsBooked.md +6 -0
  32. data/docs/RentalsCanceled.md +6 -0
  33. data/docs/RentalsCarCheckedIn.md +6 -0
  34. data/docs/RentalsCarCheckedOut.md +6 -0
  35. data/docs/RentalsCarSwitched.md +6 -0
  36. data/docs/RentalsIndex.md +6 -0
  37. data/docs/RentalsTimesChanged.md +6 -0
  38. data/docs/StartsAt.md +6 -0
  39. data/docs/UnavailabilitiesApi.md +100 -68
  40. data/docs/UnavailabilitiesCreated.md +6 -0
  41. data/docs/UnavailabilitiesDeleted.md +6 -0
  42. data/docs/UnavailabilitiesIndex.md +6 -0
  43. data/docs/Unavailability.md +10 -0
  44. data/docs/User.md +19 -0
  45. data/docs/UsersApi.md +27 -41
  46. data/docs/UsersUpdated.md +6 -0
  47. data/docs/Webhook.md +9 -0
  48. data/get_around_owner-1.0.0.gem +0 -0
  49. data/get_around_owner-1.0.1.gem +0 -0
  50. data/get_around_owner.gemspec +16 -3
  51. data/getaround-api.gemspec +38 -0
  52. data/git_push.sh +9 -11
  53. data/lib/{get_around_owner → getaround-api}/api/cars_api.rb +25 -41
  54. data/lib/getaround-api/api/checkins_api.rb +146 -0
  55. data/lib/getaround-api/api/checkouts_api.rb +146 -0
  56. data/lib/{get_around_owner → getaround-api}/api/invoices_api.rb +43 -66
  57. data/lib/getaround-api/api/messages_api.rb +198 -0
  58. data/lib/{get_around_owner → getaround-api}/api/payouts_api.rb +29 -45
  59. data/lib/getaround-api/api/rentals_api.rb +146 -0
  60. data/lib/getaround-api/api/unavailabilities_api.rb +208 -0
  61. data/lib/{get_around_owner/api/messages_api.rb → getaround-api/api/users_api.rb} +31 -37
  62. data/lib/{get_around_owner → getaround-api}/api_client.rb +71 -77
  63. data/lib/{get_around_owner → getaround-api}/api_error.rb +5 -6
  64. data/lib/{get_around_owner → getaround-api}/configuration.rb +13 -106
  65. data/lib/{get_around_owner/models/getaround_car.rb → getaround-api/models/car.rb} +36 -56
  66. data/lib/{get_around_owner/models/getaround_users_updated_all_of_data.rb → getaround-api/models/car_id.rb} +33 -50
  67. data/lib/{get_around_owner/models/getaround_destroy_unavailability_request.rb → getaround-api/models/car_id_unavailabilities_json_body.rb} +45 -47
  68. data/lib/{get_around_owner/models/getaround_rentals_booked_all_of_data.rb → getaround-api/models/cars_index.rb} +33 -50
  69. data/lib/{get_around_owner/models/getaround_checkin.rb → getaround-api/models/checkin.rb} +34 -65
  70. data/lib/{get_around_owner/models/getaround_rentals_index_inner.rb → getaround-api/models/checkins_index.rb} +32 -58
  71. data/lib/{get_around_owner/models/getaround_checkout.rb → getaround-api/models/checkout.rb} +35 -70
  72. data/lib/getaround-api/models/checkouts_index.rb +197 -0
  73. data/lib/getaround-api/models/ends_at.rb +198 -0
  74. data/lib/{get_around_owner/models/getaround_invoice.rb → getaround-api/models/invoice.rb} +45 -113
  75. data/lib/getaround-api/models/invoices_index.rb +198 -0
  76. data/lib/{get_around_owner/models/getaround_message.rb → getaround-api/models/message.rb} +35 -53
  77. data/lib/getaround-api/models/messages_sent.rb +197 -0
  78. data/lib/{get_around_owner/models/getaround_payout.rb → getaround-api/models/payout.rb} +37 -101
  79. data/lib/getaround-api/models/payouts_index.rb +198 -0
  80. data/lib/{get_around_owner/models/getaround_rental.rb → getaround-api/models/rental.rb} +38 -100
  81. data/lib/{get_around_owner/models/getaround_create_messages_request.rb → getaround-api/models/rental_id_messages_json_body.rb} +31 -41
  82. data/lib/getaround-api/models/rental_invoices_index.rb +198 -0
  83. data/lib/getaround-api/models/rental_messages_index.rb +198 -0
  84. data/lib/getaround-api/models/rentals_booked.rb +197 -0
  85. data/lib/getaround-api/models/rentals_canceled.rb +197 -0
  86. data/lib/getaround-api/models/rentals_car_checked_in.rb +197 -0
  87. data/lib/getaround-api/models/rentals_car_checked_out.rb +197 -0
  88. data/lib/getaround-api/models/rentals_car_switched.rb +197 -0
  89. data/lib/getaround-api/models/rentals_index.rb +198 -0
  90. data/lib/getaround-api/models/rentals_times_changed.rb +197 -0
  91. data/lib/getaround-api/models/starts_at.rb +198 -0
  92. data/lib/{get_around_owner/models/getaround_cars_index_inner.rb → getaround-api/models/unavailabilities_created.rb} +32 -58
  93. data/lib/getaround-api/models/unavailabilities_deleted.rb +197 -0
  94. data/lib/getaround-api/models/unavailabilities_index.rb +198 -0
  95. data/lib/{get_around_owner/models/getaround_unavailabilities_created_all_of_data.rb → getaround-api/models/unavailability.rb} +51 -65
  96. data/lib/{get_around_owner/models/getaround_user.rb → getaround-api/models/user.rb} +43 -75
  97. data/lib/getaround-api/models/users_updated.rb +197 -0
  98. data/lib/{get_around_owner/models/getaround_webhook.rb → getaround-api/models/webhook.rb} +38 -47
  99. data/lib/{get_around_owner → getaround-api}/version.rb +5 -6
  100. data/lib/getaround-api.rb +81 -0
  101. data/openapi.yml +2298 -0
  102. data/spec/api/cars_api_spec.rb +13 -14
  103. data/spec/api/checkins_api_spec.rb +13 -14
  104. data/spec/api/checkouts_api_spec.rb +13 -14
  105. data/spec/api/invoices_api_spec.rb +19 -20
  106. data/spec/api/messages_api_spec.rb +14 -15
  107. data/spec/api/payouts_api_spec.rb +13 -14
  108. data/spec/api/rentals_api_spec.rb +13 -14
  109. data/spec/api/unavailabilities_api_spec.rb +14 -16
  110. data/spec/api/users_api_spec.rb +9 -10
  111. data/spec/api_client_spec.rb +225 -0
  112. data/spec/base_object_spec.rb +109 -0
  113. data/spec/{models/getaround_checkins_index_inner_spec.rb → configuration_spec.rb} +26 -21
  114. data/spec/models/{getaround_reason_spec.rb → car_id_spec.rb} +18 -14
  115. data/spec/models/{getaround_unavailabilities_deleted_all_of_data_spec.rb → car_id_unavailabilities_json_body_spec.rb} +24 -20
  116. data/spec/models/{getaround_car_spec.rb → car_spec.rb} +24 -20
  117. data/spec/models/cars_index_spec.rb +34 -0
  118. data/spec/models/{getaround_checkin_spec.rb → checkin_spec.rb} +22 -18
  119. data/spec/models/checkins_index_spec.rb +34 -0
  120. data/spec/models/{getaround_checkout_spec.rb → checkout_spec.rb} +23 -19
  121. data/spec/models/checkouts_index_spec.rb +34 -0
  122. data/spec/models/ends_at_spec.rb +34 -0
  123. data/spec/models/{getaround_invoice_spec.rb → invoice_spec.rb} +27 -31
  124. data/spec/models/invoices_index_spec.rb +34 -0
  125. data/spec/models/{getaround_message_spec.rb → message_spec.rb} +23 -19
  126. data/spec/models/messages_sent_spec.rb +34 -0
  127. data/spec/models/{getaround_payout_spec.rb → payout_spec.rb} +24 -24
  128. data/spec/models/payouts_index_spec.rb +34 -0
  129. data/spec/models/{getaround_create_messages_request_spec.rb → rental_id_messages_json_body_spec.rb} +19 -15
  130. data/spec/models/{getaround_rentals_index_inner_spec.rb → rental_invoices_index_spec.rb} +16 -18
  131. data/spec/models/rental_messages_index_spec.rb +34 -0
  132. data/spec/models/{getaround_rental_spec.rb → rental_spec.rb} +26 -22
  133. data/spec/models/rentals_booked_spec.rb +34 -0
  134. data/spec/models/rentals_canceled_spec.rb +34 -0
  135. data/spec/models/rentals_car_checked_in_spec.rb +34 -0
  136. data/spec/models/rentals_car_checked_out_spec.rb +34 -0
  137. data/spec/models/rentals_car_switched_spec.rb +34 -0
  138. data/spec/models/rentals_index_spec.rb +34 -0
  139. data/spec/models/rentals_times_changed_spec.rb +34 -0
  140. data/spec/models/starts_at_spec.rb +34 -0
  141. data/spec/models/{getaround_cars_index_inner_spec.rb → unavailabilities_created_spec.rb} +16 -18
  142. data/spec/models/{getaround_payouts_index_inner_spec.rb → unavailabilities_deleted_spec.rb} +16 -18
  143. data/spec/models/unavailabilities_index_spec.rb +34 -0
  144. data/spec/models/{getaround_unavailabilities_created_all_of_data_spec.rb → unavailability_spec.rb} +22 -18
  145. data/spec/models/{getaround_user_spec.rb → user_spec.rb} +31 -27
  146. data/spec/models/users_updated_spec.rb +34 -0
  147. data/spec/models/{getaround_webhook_spec.rb → webhook_spec.rb} +21 -17
  148. data/spec/spec_helper.rb +5 -6
  149. metadata +237 -132
  150. data/lib/get_around_owner/api/checkins_api.rb +0 -82
  151. data/lib/get_around_owner/api/checkouts_api.rb +0 -82
  152. data/lib/get_around_owner/api/rentals_api.rb +0 -262
  153. data/lib/get_around_owner/api/unavailabilities_api.rb +0 -142
  154. data/lib/get_around_owner/api/users_api.rb +0 -82
  155. data/lib/get_around_owner/models/getaround_checkins_index_inner.rb +0 -222
  156. data/lib/get_around_owner/models/getaround_create_unavailabilities_request.rb +0 -283
  157. data/lib/get_around_owner/models/getaround_invoice_charges_inner.rb +0 -225
  158. data/lib/get_around_owner/models/getaround_invoices_index_inner.rb +0 -223
  159. data/lib/get_around_owner/models/getaround_messages_sent.rb +0 -257
  160. data/lib/get_around_owner/models/getaround_messages_sent_all_of_data.rb +0 -225
  161. data/lib/get_around_owner/models/getaround_payout_invoices_inner.rb +0 -223
  162. data/lib/get_around_owner/models/getaround_payouts_index_inner.rb +0 -223
  163. data/lib/get_around_owner/models/getaround_reason.rb +0 -45
  164. data/lib/get_around_owner/models/getaround_rental_invoices_index_inner.rb +0 -223
  165. data/lib/get_around_owner/models/getaround_rental_messages_index_inner.rb +0 -223
  166. data/lib/get_around_owner/models/getaround_rentals_booked.rb +0 -257
  167. data/lib/get_around_owner/models/getaround_rentals_canceled.rb +0 -257
  168. data/lib/get_around_owner/models/getaround_rentals_car_checked_in.rb +0 -257
  169. data/lib/get_around_owner/models/getaround_rentals_car_checked_out.rb +0 -257
  170. data/lib/get_around_owner/models/getaround_rentals_car_switched.rb +0 -257
  171. data/lib/get_around_owner/models/getaround_rentals_times_changed.rb +0 -257
  172. data/lib/get_around_owner/models/getaround_unavailabilities_created.rb +0 -257
  173. data/lib/get_around_owner/models/getaround_unavailabilities_deleted.rb +0 -257
  174. data/lib/get_around_owner/models/getaround_unavailabilities_deleted_all_of_data.rb +0 -235
  175. data/lib/get_around_owner/models/getaround_unavailability.rb +0 -302
  176. data/lib/get_around_owner/models/getaround_users_updated.rb +0 -257
  177. data/lib/get_around_owner.rb +0 -86
  178. data/spec/models/getaround_create_unavailabilities_request_spec.rb +0 -52
  179. data/spec/models/getaround_destroy_unavailability_request_spec.rb +0 -42
  180. data/spec/models/getaround_invoice_charges_inner_spec.rb +0 -42
  181. data/spec/models/getaround_invoices_index_inner_spec.rb +0 -36
  182. data/spec/models/getaround_messages_sent_all_of_data_spec.rb +0 -42
  183. data/spec/models/getaround_messages_sent_spec.rb +0 -48
  184. data/spec/models/getaround_payout_invoices_inner_spec.rb +0 -36
  185. data/spec/models/getaround_rental_invoices_index_inner_spec.rb +0 -36
  186. data/spec/models/getaround_rental_messages_index_inner_spec.rb +0 -36
  187. data/spec/models/getaround_rentals_booked_all_of_data_spec.rb +0 -36
  188. data/spec/models/getaround_rentals_booked_spec.rb +0 -48
  189. data/spec/models/getaround_rentals_canceled_spec.rb +0 -48
  190. data/spec/models/getaround_rentals_car_checked_in_spec.rb +0 -48
  191. data/spec/models/getaround_rentals_car_checked_out_spec.rb +0 -48
  192. data/spec/models/getaround_rentals_car_switched_spec.rb +0 -48
  193. data/spec/models/getaround_rentals_times_changed_spec.rb +0 -48
  194. data/spec/models/getaround_unavailabilities_created_spec.rb +0 -48
  195. data/spec/models/getaround_unavailabilities_deleted_spec.rb +0 -48
  196. data/spec/models/getaround_unavailability_spec.rb +0 -58
  197. data/spec/models/getaround_users_updated_all_of_data_spec.rb +0 -36
  198. data/spec/models/getaround_users_updated_spec.rb +0 -48
@@ -1,21 +1,19 @@
1
1
  =begin
2
2
  #Getaround Owner API
3
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.
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
5
 
6
- The version of the OpenAPI document: 1.0.0
6
+ OpenAPI spec version: 1.0.0
7
7
  Contact: owner-api@getaround.com
8
- Generated by: https://openapi-generator.tech
9
- Generator version: 7.6.0
10
-
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 3.0.66
11
10
  =end
12
11
 
13
12
  require 'date'
14
- require 'time'
15
13
 
16
14
  module GetAroundOwner
17
15
  # A checkout is the event created when the user finished the drop off inspection.
18
- class GetaroundCheckout
16
+ class Checkout
19
17
  # Rental's ID linked to this checkout
20
18
  attr_accessor :rental_id
21
19
 
@@ -42,49 +40,40 @@ module GetAroundOwner
42
40
  }
43
41
  end
44
42
 
45
- # Returns all the JSON keys this model knows about
46
- def self.acceptable_attributes
47
- attribute_map.values
48
- end
49
-
50
43
  # Attribute type mapping.
51
44
  def self.openapi_types
52
45
  {
53
- :'rental_id' => :'Integer',
54
- :'mileage' => :'Integer',
55
- :'fuel_level' => :'Integer',
56
- :'distance_driven' => :'Integer',
57
- :'occurred_at' => :'Time'
46
+ :'rental_id' => :'Object',
47
+ :'mileage' => :'Object',
48
+ :'fuel_level' => :'Object',
49
+ :'distance_driven' => :'Object',
50
+ :'occurred_at' => :'Object'
58
51
  }
59
52
  end
60
53
 
61
54
  # List of attributes with nullable: true
62
55
  def self.openapi_nullable
63
56
  Set.new([
64
- :'mileage',
65
- :'fuel_level',
66
57
  ])
67
58
  end
68
-
59
+
69
60
  # Initializes the object
70
61
  # @param [Hash] attributes Model attributes in the form of hash
71
62
  def initialize(attributes = {})
72
63
  if (!attributes.is_a?(Hash))
73
- fail ArgumentError, "The input argument (attributes) must be a hash in `GetAroundOwner::GetaroundCheckout` initialize method"
64
+ fail ArgumentError, "The input argument (attributes) must be a hash in `GetAroundOwner::Checkout` initialize method"
74
65
  end
75
66
 
76
67
  # check to see if the attribute exists and convert string to symbol for hash key
77
68
  attributes = attributes.each_with_object({}) { |(k, v), h|
78
69
  if (!self.class.attribute_map.key?(k.to_sym))
79
- fail ArgumentError, "`#{k}` is not a valid attribute in `GetAroundOwner::GetaroundCheckout`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
70
+ fail ArgumentError, "`#{k}` is not a valid attribute in `GetAroundOwner::Checkout`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
80
71
  end
81
72
  h[k.to_sym] = v
82
73
  }
83
74
 
84
75
  if attributes.key?(:'rental_id')
85
76
  self.rental_id = attributes[:'rental_id']
86
- else
87
- self.rental_id = nil
88
77
  end
89
78
 
90
79
  if attributes.key?(:'mileage')
@@ -97,30 +86,21 @@ module GetAroundOwner
97
86
 
98
87
  if attributes.key?(:'distance_driven')
99
88
  self.distance_driven = attributes[:'distance_driven']
100
- else
101
- self.distance_driven = nil
102
89
  end
103
90
 
104
91
  if attributes.key?(:'occurred_at')
105
92
  self.occurred_at = attributes[:'occurred_at']
106
- else
107
- self.occurred_at = nil
108
93
  end
109
94
  end
110
95
 
111
96
  # Show invalid properties with the reasons. Usually used together with valid?
112
97
  # @return Array for valid properties with the reasons
113
98
  def list_invalid_properties
114
- warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
115
99
  invalid_properties = Array.new
116
100
  if @rental_id.nil?
117
101
  invalid_properties.push('invalid value for "rental_id", rental_id cannot be nil.')
118
102
  end
119
103
 
120
- if @rental_id < 1
121
- invalid_properties.push('invalid value for "rental_id", must be greater than or equal to 1.')
122
- end
123
-
124
104
  if @distance_driven.nil?
125
105
  invalid_properties.push('invalid value for "distance_driven", distance_driven cannot be nil.')
126
106
  end
@@ -135,28 +115,12 @@ module GetAroundOwner
135
115
  # Check to see if the all the properties in the model are valid
136
116
  # @return true if the model is valid
137
117
  def valid?
138
- warn '[DEPRECATED] the `valid?` method is obsolete'
139
118
  return false if @rental_id.nil?
140
- return false if @rental_id < 1
141
119
  return false if @distance_driven.nil?
142
120
  return false if @occurred_at.nil?
143
121
  true
144
122
  end
145
123
 
146
- # Custom attribute writer method with validation
147
- # @param [Object] rental_id Value to be assigned
148
- def rental_id=(rental_id)
149
- if rental_id.nil?
150
- fail ArgumentError, 'rental_id cannot be nil'
151
- end
152
-
153
- if rental_id < 1
154
- fail ArgumentError, 'invalid value for "rental_id", must be greater than or equal to 1.'
155
- end
156
-
157
- @rental_id = rental_id
158
- end
159
-
160
124
  # Checks equality by comparing each attribute.
161
125
  # @param [Object] Object to be compared
162
126
  def ==(o)
@@ -185,33 +149,39 @@ module GetAroundOwner
185
149
  # @param [Hash] attributes Model attributes in the form of hash
186
150
  # @return [Object] Returns the model itself
187
151
  def self.build_from_hash(attributes)
152
+ new.build_from_hash(attributes)
153
+ end
154
+
155
+ # Builds the object from hash
156
+ # @param [Hash] attributes Model attributes in the form of hash
157
+ # @return [Object] Returns the model itself
158
+ def build_from_hash(attributes)
188
159
  return nil unless attributes.is_a?(Hash)
189
- attributes = attributes.transform_keys(&:to_sym)
190
- transformed_hash = {}
191
- openapi_types.each_pair do |key, type|
192
- if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
193
- transformed_hash["#{key}"] = nil
194
- elsif type =~ /\AArray<(.*)>/i
160
+ self.class.openapi_types.each_pair do |key, type|
161
+ if type =~ /\AArray<(.*)>/i
195
162
  # check to ensure the input is an array given that the attribute
196
163
  # is documented as an array but the input is not
197
- if attributes[attribute_map[key]].is_a?(Array)
198
- transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
164
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
165
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
199
166
  end
200
- elsif !attributes[attribute_map[key]].nil?
201
- transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
167
+ elsif !attributes[self.class.attribute_map[key]].nil?
168
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
169
+ elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
170
+ self.send("#{key}=", nil)
202
171
  end
203
172
  end
204
- new(transformed_hash)
173
+
174
+ self
205
175
  end
206
176
 
207
177
  # Deserializes the data based on type
208
178
  # @param string type Data type
209
179
  # @param string value Value to be deserialized
210
180
  # @return [Object] Deserialized data
211
- def self._deserialize(type, value)
181
+ def _deserialize(type, value)
212
182
  case type.to_sym
213
- when :Time
214
- Time.parse(value)
183
+ when :DateTime
184
+ DateTime.parse(value)
215
185
  when :Date
216
186
  Date.parse(value)
217
187
  when :String
@@ -241,9 +211,7 @@ module GetAroundOwner
241
211
  end
242
212
  end
243
213
  else # model
244
- # models (e.g. Pet) or oneOf
245
- klass = GetAroundOwner.const_get(type)
246
- klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
214
+ GetAroundOwner.const_get(type).build_from_hash(value)
247
215
  end
248
216
  end
249
217
 
@@ -291,8 +259,5 @@ module GetAroundOwner
291
259
  else
292
260
  value
293
261
  end
294
- end
295
-
296
- end
297
-
262
+ end end
298
263
  end
@@ -0,0 +1,197 @@
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
+ OpenAPI spec version: 1.0.0
7
+ Contact: owner-api@getaround.com
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 3.0.66
10
+ =end
11
+
12
+ require 'date'
13
+
14
+ module GetAroundOwner
15
+ class CheckoutsIndex
16
+ # Attribute mapping from ruby-style variable name to JSON key.
17
+ def self.attribute_map
18
+ {
19
+ }
20
+ end
21
+
22
+ # Attribute type mapping.
23
+ def self.openapi_types
24
+ {
25
+ }
26
+ end
27
+
28
+ # List of attributes with nullable: true
29
+ def self.openapi_nullable
30
+ Set.new([
31
+ ])
32
+ end
33
+
34
+ # Initializes the object
35
+ # @param [Hash] attributes Model attributes in the form of hash
36
+ def initialize(attributes = {})
37
+ if (!attributes.is_a?(Hash))
38
+ fail ArgumentError, "The input argument (attributes) must be a hash in `GetAroundOwner::CheckoutsIndex` initialize method"
39
+ end
40
+
41
+ # check to see if the attribute exists and convert string to symbol for hash key
42
+ attributes = attributes.each_with_object({}) { |(k, v), h|
43
+ if (!self.class.attribute_map.key?(k.to_sym))
44
+ fail ArgumentError, "`#{k}` is not a valid attribute in `GetAroundOwner::CheckoutsIndex`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
45
+ end
46
+ h[k.to_sym] = v
47
+ }
48
+ end
49
+
50
+ # Show invalid properties with the reasons. Usually used together with valid?
51
+ # @return Array for valid properties with the reasons
52
+ def list_invalid_properties
53
+ invalid_properties = Array.new
54
+ invalid_properties
55
+ end
56
+
57
+ # Check to see if the all the properties in the model are valid
58
+ # @return true if the model is valid
59
+ def valid?
60
+ true
61
+ end
62
+
63
+ # Checks equality by comparing each attribute.
64
+ # @param [Object] Object to be compared
65
+ def ==(o)
66
+ return true if self.equal?(o)
67
+ self.class == o.class
68
+ end
69
+
70
+ # @see the `==` method
71
+ # @param [Object] Object to be compared
72
+ def eql?(o)
73
+ self == o
74
+ end
75
+
76
+ # Calculates hash code according to all attributes.
77
+ # @return [Integer] Hash code
78
+ def hash
79
+ [].hash
80
+ end
81
+
82
+ # Builds the object from hash
83
+ # @param [Hash] attributes Model attributes in the form of hash
84
+ # @return [Object] Returns the model itself
85
+ def self.build_from_hash(attributes)
86
+ new.build_from_hash(attributes)
87
+ end
88
+
89
+ # Builds the object from hash
90
+ # @param [Hash] attributes Model attributes in the form of hash
91
+ # @return [Object] Returns the model itself
92
+ def build_from_hash(attributes)
93
+ return nil unless attributes.is_a?(Hash)
94
+ self.class.openapi_types.each_pair do |key, type|
95
+ if type =~ /\AArray<(.*)>/i
96
+ # check to ensure the input is an array given that the attribute
97
+ # is documented as an array but the input is not
98
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
99
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
100
+ end
101
+ elsif !attributes[self.class.attribute_map[key]].nil?
102
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
103
+ elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
104
+ self.send("#{key}=", nil)
105
+ end
106
+ end
107
+
108
+ self
109
+ end
110
+
111
+ # Deserializes the data based on type
112
+ # @param string type Data type
113
+ # @param string value Value to be deserialized
114
+ # @return [Object] Deserialized data
115
+ def _deserialize(type, value)
116
+ case type.to_sym
117
+ when :DateTime
118
+ DateTime.parse(value)
119
+ when :Date
120
+ Date.parse(value)
121
+ when :String
122
+ value.to_s
123
+ when :Integer
124
+ value.to_i
125
+ when :Float
126
+ value.to_f
127
+ when :Boolean
128
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
129
+ true
130
+ else
131
+ false
132
+ end
133
+ when :Object
134
+ # generic object (usually a Hash), return directly
135
+ value
136
+ when /\AArray<(?<inner_type>.+)>\z/
137
+ inner_type = Regexp.last_match[:inner_type]
138
+ value.map { |v| _deserialize(inner_type, v) }
139
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
140
+ k_type = Regexp.last_match[:k_type]
141
+ v_type = Regexp.last_match[:v_type]
142
+ {}.tap do |hash|
143
+ value.each do |k, v|
144
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
145
+ end
146
+ end
147
+ else # model
148
+ GetAroundOwner.const_get(type).build_from_hash(value)
149
+ end
150
+ end
151
+
152
+ # Returns the string representation of the object
153
+ # @return [String] String presentation of the object
154
+ def to_s
155
+ to_hash.to_s
156
+ end
157
+
158
+ # to_body is an alias to to_hash (backward compatibility)
159
+ # @return [Hash] Returns the object in the form of hash
160
+ def to_body
161
+ to_hash
162
+ end
163
+
164
+ # Returns the object in the form of hash
165
+ # @return [Hash] Returns the object in the form of hash
166
+ def to_hash
167
+ hash = {}
168
+ self.class.attribute_map.each_pair do |attr, param|
169
+ value = self.send(attr)
170
+ if value.nil?
171
+ is_nullable = self.class.openapi_nullable.include?(attr)
172
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
173
+ end
174
+
175
+ hash[param] = _to_hash(value)
176
+ end
177
+ hash
178
+ end
179
+
180
+ # Outputs non-array value in the form of hash
181
+ # For object, use to_hash. Otherwise, just return the value
182
+ # @param [Object] value Any valid value
183
+ # @return [Hash] Returns the value in the form of hash
184
+ def _to_hash(value)
185
+ if value.is_a?(Array)
186
+ value.compact.map { |v| _to_hash(v) }
187
+ elsif value.is_a?(Hash)
188
+ {}.tap do |hash|
189
+ value.each { |k, v| hash[k] = _to_hash(v) }
190
+ end
191
+ elsif value.respond_to? :to_hash
192
+ value.to_hash
193
+ else
194
+ value
195
+ end
196
+ end end
197
+ end
@@ -0,0 +1,198 @@
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
+ OpenAPI spec version: 1.0.0
7
+ Contact: owner-api@getaround.com
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 3.0.66
10
+ =end
11
+
12
+ require 'date'
13
+
14
+ module GetAroundOwner
15
+ # The ISO8601 formatted ending of the unavailability's period
16
+ class EndsAt
17
+ # Attribute mapping from ruby-style variable name to JSON key.
18
+ def self.attribute_map
19
+ {
20
+ }
21
+ end
22
+
23
+ # Attribute type mapping.
24
+ def self.openapi_types
25
+ {
26
+ }
27
+ end
28
+
29
+ # List of attributes with nullable: true
30
+ def self.openapi_nullable
31
+ Set.new([
32
+ ])
33
+ end
34
+
35
+ # Initializes the object
36
+ # @param [Hash] attributes Model attributes in the form of hash
37
+ def initialize(attributes = {})
38
+ if (!attributes.is_a?(Hash))
39
+ fail ArgumentError, "The input argument (attributes) must be a hash in `GetAroundOwner::EndsAt` initialize method"
40
+ end
41
+
42
+ # check to see if the attribute exists and convert string to symbol for hash key
43
+ attributes = attributes.each_with_object({}) { |(k, v), h|
44
+ if (!self.class.attribute_map.key?(k.to_sym))
45
+ fail ArgumentError, "`#{k}` is not a valid attribute in `GetAroundOwner::EndsAt`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
46
+ end
47
+ h[k.to_sym] = v
48
+ }
49
+ end
50
+
51
+ # Show invalid properties with the reasons. Usually used together with valid?
52
+ # @return Array for valid properties with the reasons
53
+ def list_invalid_properties
54
+ invalid_properties = Array.new
55
+ invalid_properties
56
+ end
57
+
58
+ # Check to see if the all the properties in the model are valid
59
+ # @return true if the model is valid
60
+ def valid?
61
+ true
62
+ end
63
+
64
+ # Checks equality by comparing each attribute.
65
+ # @param [Object] Object to be compared
66
+ def ==(o)
67
+ return true if self.equal?(o)
68
+ self.class == o.class
69
+ end
70
+
71
+ # @see the `==` method
72
+ # @param [Object] Object to be compared
73
+ def eql?(o)
74
+ self == o
75
+ end
76
+
77
+ # Calculates hash code according to all attributes.
78
+ # @return [Integer] Hash code
79
+ def hash
80
+ [].hash
81
+ end
82
+
83
+ # Builds the object from hash
84
+ # @param [Hash] attributes Model attributes in the form of hash
85
+ # @return [Object] Returns the model itself
86
+ def self.build_from_hash(attributes)
87
+ new.build_from_hash(attributes)
88
+ end
89
+
90
+ # Builds the object from hash
91
+ # @param [Hash] attributes Model attributes in the form of hash
92
+ # @return [Object] Returns the model itself
93
+ def build_from_hash(attributes)
94
+ return nil unless attributes.is_a?(Hash)
95
+ self.class.openapi_types.each_pair do |key, type|
96
+ if type =~ /\AArray<(.*)>/i
97
+ # check to ensure the input is an array given that the attribute
98
+ # is documented as an array but the input is not
99
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
100
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
101
+ end
102
+ elsif !attributes[self.class.attribute_map[key]].nil?
103
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
104
+ elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
105
+ self.send("#{key}=", nil)
106
+ end
107
+ end
108
+
109
+ self
110
+ end
111
+
112
+ # Deserializes the data based on type
113
+ # @param string type Data type
114
+ # @param string value Value to be deserialized
115
+ # @return [Object] Deserialized data
116
+ def _deserialize(type, value)
117
+ case type.to_sym
118
+ when :DateTime
119
+ DateTime.parse(value)
120
+ when :Date
121
+ Date.parse(value)
122
+ when :String
123
+ value.to_s
124
+ when :Integer
125
+ value.to_i
126
+ when :Float
127
+ value.to_f
128
+ when :Boolean
129
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
130
+ true
131
+ else
132
+ false
133
+ end
134
+ when :Object
135
+ # generic object (usually a Hash), return directly
136
+ value
137
+ when /\AArray<(?<inner_type>.+)>\z/
138
+ inner_type = Regexp.last_match[:inner_type]
139
+ value.map { |v| _deserialize(inner_type, v) }
140
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
141
+ k_type = Regexp.last_match[:k_type]
142
+ v_type = Regexp.last_match[:v_type]
143
+ {}.tap do |hash|
144
+ value.each do |k, v|
145
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
146
+ end
147
+ end
148
+ else # model
149
+ GetAroundOwner.const_get(type).build_from_hash(value)
150
+ end
151
+ end
152
+
153
+ # Returns the string representation of the object
154
+ # @return [String] String presentation of the object
155
+ def to_s
156
+ to_hash.to_s
157
+ end
158
+
159
+ # to_body is an alias to to_hash (backward compatibility)
160
+ # @return [Hash] Returns the object in the form of hash
161
+ def to_body
162
+ to_hash
163
+ end
164
+
165
+ # Returns the object in the form of hash
166
+ # @return [Hash] Returns the object in the form of hash
167
+ def to_hash
168
+ hash = {}
169
+ self.class.attribute_map.each_pair do |attr, param|
170
+ value = self.send(attr)
171
+ if value.nil?
172
+ is_nullable = self.class.openapi_nullable.include?(attr)
173
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
174
+ end
175
+
176
+ hash[param] = _to_hash(value)
177
+ end
178
+ hash
179
+ end
180
+
181
+ # Outputs non-array value in the form of hash
182
+ # For object, use to_hash. Otherwise, just return the value
183
+ # @param [Object] value Any valid value
184
+ # @return [Hash] Returns the value in the form of hash
185
+ def _to_hash(value)
186
+ if value.is_a?(Array)
187
+ value.compact.map { |v| _to_hash(v) }
188
+ elsif value.is_a?(Hash)
189
+ {}.tap do |hash|
190
+ value.each { |k, v| hash[k] = _to_hash(v) }
191
+ end
192
+ elsif value.respond_to? :to_hash
193
+ value.to_hash
194
+ else
195
+ value
196
+ end
197
+ end end
198
+ end