get_around_owner 1.0.1 → 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 (237) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +9 -0
  3. data/Owner API v1.json +2938 -0
  4. data/README.md +338 -181
  5. data/Rakefile +8 -0
  6. data/docs/Car.md +12 -0
  7. data/docs/CarId.md +6 -0
  8. data/docs/CarIdUnavailabilitiesJsonBody.md +9 -0
  9. data/docs/CarsApi.md +110 -0
  10. data/docs/CarsIndex.md +6 -0
  11. data/docs/Checkin.md +10 -0
  12. data/docs/CheckinsApi.md +114 -0
  13. data/docs/CheckinsIndex.md +6 -0
  14. data/docs/Checkout.md +11 -0
  15. data/docs/CheckoutsApi.md +114 -0
  16. data/docs/CheckoutsIndex.md +6 -0
  17. data/docs/EndsAt.md +6 -0
  18. data/docs/GetaroundCar.md +28 -0
  19. data/docs/GetaroundCarsIndexInner.md +18 -0
  20. data/docs/GetaroundCheckin.md +24 -0
  21. data/docs/GetaroundCheckinsIndexInner.md +18 -0
  22. data/docs/GetaroundCheckout.md +26 -0
  23. data/docs/GetaroundCreateMessagesRequest.md +18 -0
  24. data/docs/GetaroundCreateUnavailabilitiesRequest.md +22 -0
  25. data/docs/GetaroundDestroyUnavailabilityRequest.md +20 -0
  26. data/docs/GetaroundInvoice.md +34 -0
  27. data/docs/GetaroundInvoiceChargesInner.md +20 -0
  28. data/docs/GetaroundInvoicesIndexInner.md +18 -0
  29. data/docs/GetaroundMessage.md +26 -0
  30. data/docs/GetaroundMessagesSent.md +22 -0
  31. data/docs/GetaroundMessagesSentAllOfData.md +20 -0
  32. data/docs/GetaroundPayout.md +28 -0
  33. data/docs/GetaroundPayoutInvoicesInner.md +18 -0
  34. data/docs/GetaroundPayoutsIndexInner.md +18 -0
  35. data/docs/GetaroundReason.md +15 -0
  36. data/docs/GetaroundRental.md +32 -0
  37. data/docs/GetaroundRentalInvoicesIndexInner.md +18 -0
  38. data/docs/GetaroundRentalMessagesIndexInner.md +18 -0
  39. data/docs/GetaroundRentalsBooked.md +22 -0
  40. data/docs/GetaroundRentalsBookedAllOfData.md +18 -0
  41. data/docs/GetaroundRentalsCanceled.md +22 -0
  42. data/docs/GetaroundRentalsCarCheckedIn.md +22 -0
  43. data/docs/GetaroundRentalsCarCheckedOut.md +22 -0
  44. data/docs/GetaroundRentalsCarSwitched.md +22 -0
  45. data/docs/GetaroundRentalsIndexInner.md +18 -0
  46. data/docs/GetaroundRentalsTimesChanged.md +22 -0
  47. data/docs/GetaroundUnavailabilitiesCreated.md +22 -0
  48. data/docs/GetaroundUnavailabilitiesCreatedAllOfData.md +24 -0
  49. data/docs/GetaroundUnavailabilitiesDeleted.md +22 -0
  50. data/docs/GetaroundUnavailabilitiesDeletedAllOfData.md +22 -0
  51. data/docs/GetaroundUnavailability.md +24 -0
  52. data/docs/GetaroundUser.md +42 -0
  53. data/docs/GetaroundUsersUpdated.md +22 -0
  54. data/docs/GetaroundUsersUpdatedAllOfData.md +18 -0
  55. data/docs/GetaroundWebhook.md +22 -0
  56. data/docs/Invoice.md +15 -0
  57. data/docs/InvoicesApi.md +169 -0
  58. data/docs/InvoicesIndex.md +6 -0
  59. data/docs/Message.md +11 -0
  60. data/docs/MessagesApi.md +162 -0
  61. data/docs/MessagesSent.md +6 -0
  62. data/docs/Payout.md +12 -0
  63. data/docs/PayoutsApi.md +114 -0
  64. data/docs/PayoutsIndex.md +6 -0
  65. data/docs/Rental.md +14 -0
  66. data/docs/RentalIdMessagesJsonBody.md +7 -0
  67. data/docs/RentalInvoicesIndex.md +6 -0
  68. data/docs/RentalMessagesIndex.md +6 -0
  69. data/docs/RentalsApi.md +114 -0
  70. data/docs/RentalsBooked.md +6 -0
  71. data/docs/RentalsCanceled.md +6 -0
  72. data/docs/RentalsCarCheckedIn.md +6 -0
  73. data/docs/RentalsCarCheckedOut.md +6 -0
  74. data/docs/RentalsCarSwitched.md +6 -0
  75. data/docs/RentalsIndex.md +6 -0
  76. data/docs/RentalsTimesChanged.md +6 -0
  77. data/docs/StartsAt.md +6 -0
  78. data/docs/UnavailabilitiesApi.md +167 -0
  79. data/docs/UnavailabilitiesCreated.md +6 -0
  80. data/docs/UnavailabilitiesDeleted.md +6 -0
  81. data/docs/UnavailabilitiesIndex.md +6 -0
  82. data/docs/Unavailability.md +10 -0
  83. data/docs/User.md +19 -0
  84. data/docs/UsersApi.md +57 -0
  85. data/docs/UsersUpdated.md +6 -0
  86. data/docs/Webhook.md +9 -0
  87. data/get_around_owner-1.0.0.gem +0 -0
  88. data/get_around_owner-1.0.1.gem +0 -0
  89. data/get_around_owner.gemspec +39 -0
  90. data/getaround-api.gemspec +38 -0
  91. data/git_push.sh +55 -0
  92. data/lib/{get_around_owner → getaround-api}/api/cars_api.rb +25 -41
  93. data/lib/getaround-api/api/checkins_api.rb +146 -0
  94. data/lib/getaround-api/api/checkouts_api.rb +146 -0
  95. data/lib/{get_around_owner → getaround-api}/api/invoices_api.rb +43 -66
  96. data/lib/getaround-api/api/messages_api.rb +198 -0
  97. data/lib/{get_around_owner → getaround-api}/api/payouts_api.rb +29 -45
  98. data/lib/getaround-api/api/rentals_api.rb +146 -0
  99. data/lib/getaround-api/api/unavailabilities_api.rb +208 -0
  100. data/lib/{get_around_owner/api/messages_api.rb → getaround-api/api/users_api.rb} +31 -37
  101. data/lib/{get_around_owner → getaround-api}/api_client.rb +71 -77
  102. data/lib/{get_around_owner → getaround-api}/api_error.rb +5 -6
  103. data/lib/{get_around_owner → getaround-api}/configuration.rb +13 -106
  104. data/lib/{get_around_owner/models/getaround_car.rb → getaround-api/models/car.rb} +36 -56
  105. data/lib/{get_around_owner/models/getaround_users_updated_all_of_data.rb → getaround-api/models/car_id.rb} +33 -50
  106. data/lib/{get_around_owner/models/getaround_destroy_unavailability_request.rb → getaround-api/models/car_id_unavailabilities_json_body.rb} +45 -47
  107. data/lib/{get_around_owner/models/getaround_rentals_booked_all_of_data.rb → getaround-api/models/cars_index.rb} +33 -50
  108. data/lib/{get_around_owner/models/getaround_checkin.rb → getaround-api/models/checkin.rb} +34 -65
  109. data/lib/{get_around_owner/models/getaround_rentals_index_inner.rb → getaround-api/models/checkins_index.rb} +32 -58
  110. data/lib/{get_around_owner/models/getaround_checkout.rb → getaround-api/models/checkout.rb} +35 -70
  111. data/lib/getaround-api/models/checkouts_index.rb +197 -0
  112. data/lib/getaround-api/models/ends_at.rb +198 -0
  113. data/lib/{get_around_owner/models/getaround_invoice.rb → getaround-api/models/invoice.rb} +45 -113
  114. data/lib/getaround-api/models/invoices_index.rb +198 -0
  115. data/lib/{get_around_owner/models/getaround_message.rb → getaround-api/models/message.rb} +35 -53
  116. data/lib/getaround-api/models/messages_sent.rb +197 -0
  117. data/lib/{get_around_owner/models/getaround_payout.rb → getaround-api/models/payout.rb} +37 -101
  118. data/lib/getaround-api/models/payouts_index.rb +198 -0
  119. data/lib/{get_around_owner/models/getaround_rental.rb → getaround-api/models/rental.rb} +38 -100
  120. data/lib/{get_around_owner/models/getaround_create_messages_request.rb → getaround-api/models/rental_id_messages_json_body.rb} +31 -41
  121. data/lib/getaround-api/models/rental_invoices_index.rb +198 -0
  122. data/lib/getaround-api/models/rental_messages_index.rb +198 -0
  123. data/lib/getaround-api/models/rentals_booked.rb +197 -0
  124. data/lib/getaround-api/models/rentals_canceled.rb +197 -0
  125. data/lib/getaround-api/models/rentals_car_checked_in.rb +197 -0
  126. data/lib/getaround-api/models/rentals_car_checked_out.rb +197 -0
  127. data/lib/getaround-api/models/rentals_car_switched.rb +197 -0
  128. data/lib/getaround-api/models/rentals_index.rb +198 -0
  129. data/lib/getaround-api/models/rentals_times_changed.rb +197 -0
  130. data/lib/getaround-api/models/starts_at.rb +198 -0
  131. data/lib/{get_around_owner/models/getaround_cars_index_inner.rb → getaround-api/models/unavailabilities_created.rb} +32 -58
  132. data/lib/getaround-api/models/unavailabilities_deleted.rb +197 -0
  133. data/lib/getaround-api/models/unavailabilities_index.rb +198 -0
  134. data/lib/{get_around_owner/models/getaround_unavailabilities_created_all_of_data.rb → getaround-api/models/unavailability.rb} +51 -65
  135. data/lib/{get_around_owner/models/getaround_user.rb → getaround-api/models/user.rb} +43 -75
  136. data/lib/getaround-api/models/users_updated.rb +197 -0
  137. data/lib/{get_around_owner/models/getaround_webhook.rb → getaround-api/models/webhook.rb} +38 -47
  138. data/lib/{get_around_owner → getaround-api}/version.rb +5 -6
  139. data/lib/getaround-api.rb +81 -0
  140. data/openapi.yml +2298 -0
  141. data/spec/api/cars_api_spec.rb +13 -14
  142. data/spec/api/checkins_api_spec.rb +13 -14
  143. data/spec/api/checkouts_api_spec.rb +13 -14
  144. data/spec/api/invoices_api_spec.rb +19 -20
  145. data/spec/api/messages_api_spec.rb +14 -15
  146. data/spec/api/payouts_api_spec.rb +13 -14
  147. data/spec/api/rentals_api_spec.rb +13 -14
  148. data/spec/api/unavailabilities_api_spec.rb +14 -16
  149. data/spec/api/users_api_spec.rb +9 -10
  150. data/spec/api_client_spec.rb +225 -0
  151. data/spec/base_object_spec.rb +109 -0
  152. data/spec/{models/getaround_checkins_index_inner_spec.rb → configuration_spec.rb} +26 -21
  153. data/spec/models/{getaround_reason_spec.rb → car_id_spec.rb} +18 -14
  154. data/spec/models/{getaround_unavailabilities_deleted_all_of_data_spec.rb → car_id_unavailabilities_json_body_spec.rb} +24 -20
  155. data/spec/models/{getaround_car_spec.rb → car_spec.rb} +24 -20
  156. data/spec/models/cars_index_spec.rb +34 -0
  157. data/spec/models/{getaround_checkin_spec.rb → checkin_spec.rb} +22 -18
  158. data/spec/models/checkins_index_spec.rb +34 -0
  159. data/spec/models/{getaround_checkout_spec.rb → checkout_spec.rb} +23 -19
  160. data/spec/models/checkouts_index_spec.rb +34 -0
  161. data/spec/models/ends_at_spec.rb +34 -0
  162. data/spec/models/{getaround_invoice_spec.rb → invoice_spec.rb} +27 -31
  163. data/spec/models/invoices_index_spec.rb +34 -0
  164. data/spec/models/{getaround_message_spec.rb → message_spec.rb} +23 -19
  165. data/spec/models/messages_sent_spec.rb +34 -0
  166. data/spec/models/{getaround_payout_spec.rb → payout_spec.rb} +24 -24
  167. data/spec/models/payouts_index_spec.rb +34 -0
  168. data/spec/models/{getaround_create_messages_request_spec.rb → rental_id_messages_json_body_spec.rb} +19 -15
  169. data/spec/models/{getaround_rentals_index_inner_spec.rb → rental_invoices_index_spec.rb} +16 -18
  170. data/spec/models/rental_messages_index_spec.rb +34 -0
  171. data/spec/models/{getaround_rental_spec.rb → rental_spec.rb} +26 -22
  172. data/spec/models/rentals_booked_spec.rb +34 -0
  173. data/spec/models/rentals_canceled_spec.rb +34 -0
  174. data/spec/models/rentals_car_checked_in_spec.rb +34 -0
  175. data/spec/models/rentals_car_checked_out_spec.rb +34 -0
  176. data/spec/models/rentals_car_switched_spec.rb +34 -0
  177. data/spec/models/rentals_index_spec.rb +34 -0
  178. data/spec/models/rentals_times_changed_spec.rb +34 -0
  179. data/spec/models/starts_at_spec.rb +34 -0
  180. data/spec/models/{getaround_cars_index_inner_spec.rb → unavailabilities_created_spec.rb} +16 -18
  181. data/spec/models/{getaround_payouts_index_inner_spec.rb → unavailabilities_deleted_spec.rb} +16 -18
  182. data/spec/models/unavailabilities_index_spec.rb +34 -0
  183. data/spec/models/{getaround_unavailabilities_created_all_of_data_spec.rb → unavailability_spec.rb} +22 -18
  184. data/spec/models/{getaround_user_spec.rb → user_spec.rb} +31 -27
  185. data/spec/models/users_updated_spec.rb +34 -0
  186. data/spec/models/{getaround_webhook_spec.rb → webhook_spec.rb} +21 -17
  187. data/spec/spec_helper.rb +5 -6
  188. metadata +289 -133
  189. data/lib/get_around_owner/api/checkins_api.rb +0 -82
  190. data/lib/get_around_owner/api/checkouts_api.rb +0 -82
  191. data/lib/get_around_owner/api/rentals_api.rb +0 -262
  192. data/lib/get_around_owner/api/unavailabilities_api.rb +0 -142
  193. data/lib/get_around_owner/api/users_api.rb +0 -82
  194. data/lib/get_around_owner/models/getaround_checkins_index_inner.rb +0 -222
  195. data/lib/get_around_owner/models/getaround_create_unavailabilities_request.rb +0 -283
  196. data/lib/get_around_owner/models/getaround_invoice_charges_inner.rb +0 -225
  197. data/lib/get_around_owner/models/getaround_invoices_index_inner.rb +0 -223
  198. data/lib/get_around_owner/models/getaround_messages_sent.rb +0 -257
  199. data/lib/get_around_owner/models/getaround_messages_sent_all_of_data.rb +0 -225
  200. data/lib/get_around_owner/models/getaround_payout_invoices_inner.rb +0 -223
  201. data/lib/get_around_owner/models/getaround_payouts_index_inner.rb +0 -223
  202. data/lib/get_around_owner/models/getaround_reason.rb +0 -45
  203. data/lib/get_around_owner/models/getaround_rental_invoices_index_inner.rb +0 -223
  204. data/lib/get_around_owner/models/getaround_rental_messages_index_inner.rb +0 -223
  205. data/lib/get_around_owner/models/getaround_rentals_booked.rb +0 -257
  206. data/lib/get_around_owner/models/getaround_rentals_canceled.rb +0 -257
  207. data/lib/get_around_owner/models/getaround_rentals_car_checked_in.rb +0 -257
  208. data/lib/get_around_owner/models/getaround_rentals_car_checked_out.rb +0 -257
  209. data/lib/get_around_owner/models/getaround_rentals_car_switched.rb +0 -257
  210. data/lib/get_around_owner/models/getaround_rentals_times_changed.rb +0 -257
  211. data/lib/get_around_owner/models/getaround_unavailabilities_created.rb +0 -257
  212. data/lib/get_around_owner/models/getaround_unavailabilities_deleted.rb +0 -257
  213. data/lib/get_around_owner/models/getaround_unavailabilities_deleted_all_of_data.rb +0 -235
  214. data/lib/get_around_owner/models/getaround_unavailability.rb +0 -302
  215. data/lib/get_around_owner/models/getaround_users_updated.rb +0 -257
  216. data/lib/get_around_owner.rb +0 -86
  217. data/spec/models/getaround_create_unavailabilities_request_spec.rb +0 -52
  218. data/spec/models/getaround_destroy_unavailability_request_spec.rb +0 -42
  219. data/spec/models/getaround_invoice_charges_inner_spec.rb +0 -42
  220. data/spec/models/getaround_invoices_index_inner_spec.rb +0 -36
  221. data/spec/models/getaround_messages_sent_all_of_data_spec.rb +0 -42
  222. data/spec/models/getaround_messages_sent_spec.rb +0 -48
  223. data/spec/models/getaround_payout_invoices_inner_spec.rb +0 -36
  224. data/spec/models/getaround_rental_invoices_index_inner_spec.rb +0 -36
  225. data/spec/models/getaround_rental_messages_index_inner_spec.rb +0 -36
  226. data/spec/models/getaround_rentals_booked_all_of_data_spec.rb +0 -36
  227. data/spec/models/getaround_rentals_booked_spec.rb +0 -48
  228. data/spec/models/getaround_rentals_canceled_spec.rb +0 -48
  229. data/spec/models/getaround_rentals_car_checked_in_spec.rb +0 -48
  230. data/spec/models/getaround_rentals_car_checked_out_spec.rb +0 -48
  231. data/spec/models/getaround_rentals_car_switched_spec.rb +0 -48
  232. data/spec/models/getaround_rentals_times_changed_spec.rb +0 -48
  233. data/spec/models/getaround_unavailabilities_created_spec.rb +0 -48
  234. data/spec/models/getaround_unavailabilities_deleted_spec.rb +0 -48
  235. data/spec/models/getaround_unavailability_spec.rb +0 -58
  236. data/spec/models/getaround_users_updated_all_of_data_spec.rb +0 -36
  237. data/spec/models/getaround_users_updated_spec.rb +0 -48
@@ -1,17 +1,14 @@
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
- require 'cgi'
14
-
15
12
  module GetAroundOwner
16
13
  class CarsApi
17
14
  attr_accessor :api_client
@@ -21,9 +18,9 @@ module GetAroundOwner
21
18
  end
22
19
  # Find a car by ID
23
20
  # Find a car by ID
24
- # @param id [String] ID of car to return
21
+ # @param id ID of car to return
25
22
  # @param [Hash] opts the optional parameters
26
- # @return [GetaroundCar]
23
+ # @return [Car]
27
24
  def get_car_by_id(id, opts = {})
28
25
  data, _status_code, _headers = get_car_by_id_with_http_info(id, opts)
29
26
  data
@@ -31,9 +28,9 @@ module GetAroundOwner
31
28
 
32
29
  # Find a car by ID
33
30
  # Find a car by ID
34
- # @param id [String] ID of car to return
31
+ # @param id ID of car to return
35
32
  # @param [Hash] opts the optional parameters
36
- # @return [Array<(GetaroundCar, Integer, Hash)>] GetaroundCar data, response status code and response headers
33
+ # @return [Array<(Car, Integer, Hash)>] Car data, response status code and response headers
37
34
  def get_car_by_id_with_http_info(id, opts = {})
38
35
  if @api_client.config.debugging
39
36
  @api_client.config.logger.debug 'Calling API: CarsApi.get_car_by_id ...'
@@ -43,7 +40,7 @@ module GetAroundOwner
43
40
  fail ArgumentError, "Missing the required parameter 'id' when calling CarsApi.get_car_by_id"
44
41
  end
45
42
  # resource path
46
- local_var_path = '/cars/{id}.json'.sub('{' + 'id' + '}', CGI.escape(id.to_s))
43
+ local_var_path = '/cars/{id}.json'.sub('{' + 'id' + '}', id.to_s)
47
44
 
48
45
  # query parameters
49
46
  query_params = opts[:query_params] || {}
@@ -57,37 +54,30 @@ module GetAroundOwner
57
54
  form_params = opts[:form_params] || {}
58
55
 
59
56
  # http body (model)
60
- post_body = opts[:debug_body]
61
-
62
- # return_type
63
- return_type = opts[:debug_return_type] || 'GetaroundCar'
57
+ post_body = opts[:body]
64
58
 
65
- # auth_names
66
- auth_names = opts[:debug_auth_names] || ['bearerAuth']
59
+ return_type = opts[:return_type] || 'Car'
67
60
 
68
- new_options = opts.merge(
69
- :operation => :"CarsApi.get_car_by_id",
61
+ auth_names = opts[:auth_names] || ['bearerAuth']
62
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path,
70
63
  :header_params => header_params,
71
64
  :query_params => query_params,
72
65
  :form_params => form_params,
73
66
  :body => post_body,
74
67
  :auth_names => auth_names,
75
- :return_type => return_type
76
- )
68
+ :return_type => return_type)
77
69
 
78
- data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
79
70
  if @api_client.config.debugging
80
71
  @api_client.config.logger.debug "API called: CarsApi#get_car_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
81
72
  end
82
73
  return data, status_code, headers
83
74
  end
84
-
85
75
  # Find all cars
86
76
  # Find all cars
87
77
  # @param [Hash] opts the optional parameters
88
- # @option opts [String] :page Page number
89
- # @option opts [String] :per_page Page size (default to '30')
90
- # @return [Array<GetaroundCarsIndexInner>]
78
+ # @option opts [] :page Page number
79
+ # @option opts [] :per_page Page size (default to 30)
80
+ # @return [CarsIndex]
91
81
  def get_cars(opts = {})
92
82
  data, _status_code, _headers = get_cars_with_http_info(opts)
93
83
  data
@@ -96,9 +86,9 @@ module GetAroundOwner
96
86
  # Find all cars
97
87
  # Find all cars
98
88
  # @param [Hash] opts the optional parameters
99
- # @option opts [String] :page Page number
100
- # @option opts [String] :per_page Page size (default to '30')
101
- # @return [Array<(Array<GetaroundCarsIndexInner>, Integer, Hash)>] Array<GetaroundCarsIndexInner> data, response status code and response headers
89
+ # @option opts [] :page Page number
90
+ # @option opts [] :per_page Page size
91
+ # @return [Array<(CarsIndex, Integer, Hash)>] CarsIndex data, response status code and response headers
102
92
  def get_cars_with_http_info(opts = {})
103
93
  if @api_client.config.debugging
104
94
  @api_client.config.logger.debug 'Calling API: CarsApi.get_cars ...'
@@ -120,25 +110,19 @@ module GetAroundOwner
120
110
  form_params = opts[:form_params] || {}
121
111
 
122
112
  # http body (model)
123
- post_body = opts[:debug_body]
124
-
125
- # return_type
126
- return_type = opts[:debug_return_type] || 'Array<GetaroundCarsIndexInner>'
113
+ post_body = opts[:body]
127
114
 
128
- # auth_names
129
- auth_names = opts[:debug_auth_names] || ['bearerAuth']
115
+ return_type = opts[:return_type] || 'CarsIndex'
130
116
 
131
- new_options = opts.merge(
132
- :operation => :"CarsApi.get_cars",
117
+ auth_names = opts[:auth_names] || ['bearerAuth']
118
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path,
133
119
  :header_params => header_params,
134
120
  :query_params => query_params,
135
121
  :form_params => form_params,
136
122
  :body => post_body,
137
123
  :auth_names => auth_names,
138
- :return_type => return_type
139
- )
124
+ :return_type => return_type)
140
125
 
141
- data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
142
126
  if @api_client.config.debugging
143
127
  @api_client.config.logger.debug "API called: CarsApi#get_cars\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
144
128
  end
@@ -0,0 +1,146 @@
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
+ module GetAroundOwner
13
+ class CheckinsApi
14
+ attr_accessor :api_client
15
+
16
+ def initialize(api_client = ApiClient.default)
17
+ @api_client = api_client
18
+ end
19
+ # Find a checkin by rental ID
20
+ # Find a checkin by rental ID
21
+ # @param rental_id ID of the rental related to the checkin to return
22
+ # @param [Hash] opts the optional parameters
23
+ # @return [Checkin]
24
+ def get_checkin_by_rental_id(rental_id, opts = {})
25
+ data, _status_code, _headers = get_checkin_by_rental_id_with_http_info(rental_id, opts)
26
+ data
27
+ end
28
+
29
+ # Find a checkin by rental ID
30
+ # Find a checkin by rental ID
31
+ # @param rental_id ID of the rental related to the checkin to return
32
+ # @param [Hash] opts the optional parameters
33
+ # @return [Array<(Checkin, Integer, Hash)>] Checkin data, response status code and response headers
34
+ def get_checkin_by_rental_id_with_http_info(rental_id, opts = {})
35
+ if @api_client.config.debugging
36
+ @api_client.config.logger.debug 'Calling API: CheckinsApi.get_checkin_by_rental_id ...'
37
+ end
38
+ # verify the required parameter 'rental_id' is set
39
+ if @api_client.config.client_side_validation && rental_id.nil?
40
+ fail ArgumentError, "Missing the required parameter 'rental_id' when calling CheckinsApi.get_checkin_by_rental_id"
41
+ end
42
+ # resource path
43
+ local_var_path = '/rentals/{rental_id}/checkin.json'.sub('{' + 'rental_id' + '}', rental_id.to_s)
44
+
45
+ # query parameters
46
+ query_params = opts[:query_params] || {}
47
+
48
+ # header parameters
49
+ header_params = opts[:header_params] || {}
50
+ # HTTP header 'Accept' (if needed)
51
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
52
+
53
+ # form parameters
54
+ form_params = opts[:form_params] || {}
55
+
56
+ # http body (model)
57
+ post_body = opts[:body]
58
+
59
+ return_type = opts[:return_type] || 'Checkin'
60
+
61
+ auth_names = opts[:auth_names] || ['bearerAuth']
62
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path,
63
+ :header_params => header_params,
64
+ :query_params => query_params,
65
+ :form_params => form_params,
66
+ :body => post_body,
67
+ :auth_names => auth_names,
68
+ :return_type => return_type)
69
+
70
+ if @api_client.config.debugging
71
+ @api_client.config.logger.debug "API called: CheckinsApi#get_checkin_by_rental_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
72
+ end
73
+ return data, status_code, headers
74
+ end
75
+ # List of checkins that occurred between two dates
76
+ # List of checkins that occurred between two dates
77
+ # @param start_date Start date and time in [ISO8601 format](https://www.iso.org/iso-8601-date-and-time-format.html)
78
+ # @param end_date End date and time in [ISO8601 format](https://www.iso.org/iso-8601-date-and-time-format.html)
79
+ # @param [Hash] opts the optional parameters
80
+ # @option opts [] :page Page number
81
+ # @option opts [] :per_page Page size (default to 30)
82
+ # @return [CheckinsIndex]
83
+ def get_checkins(start_date, end_date, opts = {})
84
+ data, _status_code, _headers = get_checkins_with_http_info(start_date, end_date, opts)
85
+ data
86
+ end
87
+
88
+ # List of checkins that occurred between two dates
89
+ # List of checkins that occurred between two dates
90
+ # @param start_date Start date and time in [ISO8601 format](https://www.iso.org/iso-8601-date-and-time-format.html)
91
+ # @param end_date End date and time in [ISO8601 format](https://www.iso.org/iso-8601-date-and-time-format.html)
92
+ # @param [Hash] opts the optional parameters
93
+ # @option opts [] :page Page number
94
+ # @option opts [] :per_page Page size
95
+ # @return [Array<(CheckinsIndex, Integer, Hash)>] CheckinsIndex data, response status code and response headers
96
+ def get_checkins_with_http_info(start_date, end_date, opts = {})
97
+ if @api_client.config.debugging
98
+ @api_client.config.logger.debug 'Calling API: CheckinsApi.get_checkins ...'
99
+ end
100
+ # verify the required parameter 'start_date' is set
101
+ if @api_client.config.client_side_validation && start_date.nil?
102
+ fail ArgumentError, "Missing the required parameter 'start_date' when calling CheckinsApi.get_checkins"
103
+ end
104
+ # verify the required parameter 'end_date' is set
105
+ if @api_client.config.client_side_validation && end_date.nil?
106
+ fail ArgumentError, "Missing the required parameter 'end_date' when calling CheckinsApi.get_checkins"
107
+ end
108
+ # resource path
109
+ local_var_path = '/checkins.json'
110
+
111
+ # query parameters
112
+ query_params = opts[:query_params] || {}
113
+ query_params[:'start_date'] = start_date
114
+ query_params[:'end_date'] = end_date
115
+ query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
116
+ query_params[:'per_page'] = opts[:'per_page'] if !opts[:'per_page'].nil?
117
+
118
+ # header parameters
119
+ header_params = opts[:header_params] || {}
120
+ # HTTP header 'Accept' (if needed)
121
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
122
+
123
+ # form parameters
124
+ form_params = opts[:form_params] || {}
125
+
126
+ # http body (model)
127
+ post_body = opts[:body]
128
+
129
+ return_type = opts[:return_type] || 'CheckinsIndex'
130
+
131
+ auth_names = opts[:auth_names] || ['bearerAuth']
132
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path,
133
+ :header_params => header_params,
134
+ :query_params => query_params,
135
+ :form_params => form_params,
136
+ :body => post_body,
137
+ :auth_names => auth_names,
138
+ :return_type => return_type)
139
+
140
+ if @api_client.config.debugging
141
+ @api_client.config.logger.debug "API called: CheckinsApi#get_checkins\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
142
+ end
143
+ return data, status_code, headers
144
+ end
145
+ end
146
+ end
@@ -0,0 +1,146 @@
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
+ module GetAroundOwner
13
+ class CheckoutsApi
14
+ attr_accessor :api_client
15
+
16
+ def initialize(api_client = ApiClient.default)
17
+ @api_client = api_client
18
+ end
19
+ # Find a checkout by rental ID
20
+ # Find a checkout by rental ID
21
+ # @param rental_id ID of the rental related to the checkout to return
22
+ # @param [Hash] opts the optional parameters
23
+ # @return [Checkout]
24
+ def get_checkout_by_rental_id(rental_id, opts = {})
25
+ data, _status_code, _headers = get_checkout_by_rental_id_with_http_info(rental_id, opts)
26
+ data
27
+ end
28
+
29
+ # Find a checkout by rental ID
30
+ # Find a checkout by rental ID
31
+ # @param rental_id ID of the rental related to the checkout to return
32
+ # @param [Hash] opts the optional parameters
33
+ # @return [Array<(Checkout, Integer, Hash)>] Checkout data, response status code and response headers
34
+ def get_checkout_by_rental_id_with_http_info(rental_id, opts = {})
35
+ if @api_client.config.debugging
36
+ @api_client.config.logger.debug 'Calling API: CheckoutsApi.get_checkout_by_rental_id ...'
37
+ end
38
+ # verify the required parameter 'rental_id' is set
39
+ if @api_client.config.client_side_validation && rental_id.nil?
40
+ fail ArgumentError, "Missing the required parameter 'rental_id' when calling CheckoutsApi.get_checkout_by_rental_id"
41
+ end
42
+ # resource path
43
+ local_var_path = '/rentals/{rental_id}/checkout.json'.sub('{' + 'rental_id' + '}', rental_id.to_s)
44
+
45
+ # query parameters
46
+ query_params = opts[:query_params] || {}
47
+
48
+ # header parameters
49
+ header_params = opts[:header_params] || {}
50
+ # HTTP header 'Accept' (if needed)
51
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
52
+
53
+ # form parameters
54
+ form_params = opts[:form_params] || {}
55
+
56
+ # http body (model)
57
+ post_body = opts[:body]
58
+
59
+ return_type = opts[:return_type] || 'Checkout'
60
+
61
+ auth_names = opts[:auth_names] || ['bearerAuth']
62
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path,
63
+ :header_params => header_params,
64
+ :query_params => query_params,
65
+ :form_params => form_params,
66
+ :body => post_body,
67
+ :auth_names => auth_names,
68
+ :return_type => return_type)
69
+
70
+ if @api_client.config.debugging
71
+ @api_client.config.logger.debug "API called: CheckoutsApi#get_checkout_by_rental_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
72
+ end
73
+ return data, status_code, headers
74
+ end
75
+ # List of checkouts that occurred between two dates
76
+ # List of checkouts that occurred between two dates
77
+ # @param start_date Start date and time in [ISO8601 format](https://www.iso.org/iso-8601-date-and-time-format.html)
78
+ # @param end_date End date and time in [ISO8601 format](https://www.iso.org/iso-8601-date-and-time-format.html)
79
+ # @param [Hash] opts the optional parameters
80
+ # @option opts [] :page Page number
81
+ # @option opts [] :per_page Page size (default to 30)
82
+ # @return [CheckoutsIndex]
83
+ def get_checkouts(start_date, end_date, opts = {})
84
+ data, _status_code, _headers = get_checkouts_with_http_info(start_date, end_date, opts)
85
+ data
86
+ end
87
+
88
+ # List of checkouts that occurred between two dates
89
+ # List of checkouts that occurred between two dates
90
+ # @param start_date Start date and time in [ISO8601 format](https://www.iso.org/iso-8601-date-and-time-format.html)
91
+ # @param end_date End date and time in [ISO8601 format](https://www.iso.org/iso-8601-date-and-time-format.html)
92
+ # @param [Hash] opts the optional parameters
93
+ # @option opts [] :page Page number
94
+ # @option opts [] :per_page Page size
95
+ # @return [Array<(CheckoutsIndex, Integer, Hash)>] CheckoutsIndex data, response status code and response headers
96
+ def get_checkouts_with_http_info(start_date, end_date, opts = {})
97
+ if @api_client.config.debugging
98
+ @api_client.config.logger.debug 'Calling API: CheckoutsApi.get_checkouts ...'
99
+ end
100
+ # verify the required parameter 'start_date' is set
101
+ if @api_client.config.client_side_validation && start_date.nil?
102
+ fail ArgumentError, "Missing the required parameter 'start_date' when calling CheckoutsApi.get_checkouts"
103
+ end
104
+ # verify the required parameter 'end_date' is set
105
+ if @api_client.config.client_side_validation && end_date.nil?
106
+ fail ArgumentError, "Missing the required parameter 'end_date' when calling CheckoutsApi.get_checkouts"
107
+ end
108
+ # resource path
109
+ local_var_path = '/checkouts.json'
110
+
111
+ # query parameters
112
+ query_params = opts[:query_params] || {}
113
+ query_params[:'start_date'] = start_date
114
+ query_params[:'end_date'] = end_date
115
+ query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
116
+ query_params[:'per_page'] = opts[:'per_page'] if !opts[:'per_page'].nil?
117
+
118
+ # header parameters
119
+ header_params = opts[:header_params] || {}
120
+ # HTTP header 'Accept' (if needed)
121
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
122
+
123
+ # form parameters
124
+ form_params = opts[:form_params] || {}
125
+
126
+ # http body (model)
127
+ post_body = opts[:body]
128
+
129
+ return_type = opts[:return_type] || 'CheckoutsIndex'
130
+
131
+ auth_names = opts[:auth_names] || ['bearerAuth']
132
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path,
133
+ :header_params => header_params,
134
+ :query_params => query_params,
135
+ :form_params => form_params,
136
+ :body => post_body,
137
+ :auth_names => auth_names,
138
+ :return_type => return_type)
139
+
140
+ if @api_client.config.debugging
141
+ @api_client.config.logger.debug "API called: CheckoutsApi#get_checkouts\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
142
+ end
143
+ return data, status_code, headers
144
+ end
145
+ end
146
+ end