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,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 InvoicesApi
17
14
  attr_accessor :api_client
@@ -21,9 +18,9 @@ module GetAroundOwner
21
18
  end
22
19
  # Find an invoice by ID
23
20
  # Find an invoice by ID
24
- # @param id [String] ID of invoice to return
21
+ # @param id ID of invoice to return
25
22
  # @param [Hash] opts the optional parameters
26
- # @return [GetaroundInvoice]
23
+ # @return [Invoice]
27
24
  def get_invoice_by_id(id, opts = {})
28
25
  data, _status_code, _headers = get_invoice_by_id_with_http_info(id, opts)
29
26
  data
@@ -31,9 +28,9 @@ module GetAroundOwner
31
28
 
32
29
  # Find an invoice by ID
33
30
  # Find an invoice by ID
34
- # @param id [String] ID of invoice to return
31
+ # @param id ID of invoice to return
35
32
  # @param [Hash] opts the optional parameters
36
- # @return [Array<(GetaroundInvoice, Integer, Hash)>] GetaroundInvoice data, response status code and response headers
33
+ # @return [Array<(Invoice, Integer, Hash)>] Invoice data, response status code and response headers
37
34
  def get_invoice_by_id_with_http_info(id, opts = {})
38
35
  if @api_client.config.debugging
39
36
  @api_client.config.logger.debug 'Calling API: InvoicesApi.get_invoice_by_id ...'
@@ -43,7 +40,7 @@ module GetAroundOwner
43
40
  fail ArgumentError, "Missing the required parameter 'id' when calling InvoicesApi.get_invoice_by_id"
44
41
  end
45
42
  # resource path
46
- local_var_path = '/invoices/{id}.json'.sub('{' + 'id' + '}', CGI.escape(id.to_s))
43
+ local_var_path = '/invoices/{id}.json'.sub('{' + 'id' + '}', id.to_s)
47
44
 
48
45
  # query parameters
49
46
  query_params = opts[:query_params] || {}
@@ -57,39 +54,32 @@ module GetAroundOwner
57
54
  form_params = opts[:form_params] || {}
58
55
 
59
56
  # http body (model)
60
- post_body = opts[:debug_body]
57
+ post_body = opts[:body]
61
58
 
62
- # return_type
63
- return_type = opts[:debug_return_type] || 'GetaroundInvoice'
59
+ return_type = opts[:return_type] || 'Invoice'
64
60
 
65
- # auth_names
66
- auth_names = opts[:debug_auth_names] || ['bearerAuth']
67
-
68
- new_options = opts.merge(
69
- :operation => :"InvoicesApi.get_invoice_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: InvoicesApi#get_invoice_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 invoices emitted between dates
86
76
  # Find invoices emitted between dates
87
77
  # @param [Hash] opts the optional parameters
88
- # @option opts [Time] :start_date Start date and time in [ISO8601 format](https://www.iso.org/iso-8601-date-and-time-format.html)
89
- # @option opts [Time] :end_date End date and time in [ISO8601 format](https://www.iso.org/iso-8601-date-and-time-format.html)
90
- # @option opts [String] :page Page number
91
- # @option opts [String] :per_page Page size (default to '30')
92
- # @return [Array<GetaroundInvoicesIndexInner>]
78
+ # @option opts [] :start_date Start date and time in [ISO8601 format](https://www.iso.org/iso-8601-date-and-time-format.html)
79
+ # @option opts [] :end_date End date and time in [ISO8601 format](https://www.iso.org/iso-8601-date-and-time-format.html)
80
+ # @option opts [] :page Page number
81
+ # @option opts [] :per_page Page size (default to 30)
82
+ # @return [InvoicesIndex]
93
83
  def get_invoices(opts = {})
94
84
  data, _status_code, _headers = get_invoices_with_http_info(opts)
95
85
  data
@@ -98,11 +88,11 @@ module GetAroundOwner
98
88
  # Find invoices emitted between dates
99
89
  # Find invoices emitted between dates
100
90
  # @param [Hash] opts the optional parameters
101
- # @option opts [Time] :start_date Start date and time in [ISO8601 format](https://www.iso.org/iso-8601-date-and-time-format.html)
102
- # @option opts [Time] :end_date End date and time in [ISO8601 format](https://www.iso.org/iso-8601-date-and-time-format.html)
103
- # @option opts [String] :page Page number
104
- # @option opts [String] :per_page Page size (default to '30')
105
- # @return [Array<(Array<GetaroundInvoicesIndexInner>, Integer, Hash)>] Array<GetaroundInvoicesIndexInner> data, response status code and response headers
91
+ # @option opts [] :start_date Start date and time in [ISO8601 format](https://www.iso.org/iso-8601-date-and-time-format.html)
92
+ # @option opts [] :end_date End date and time in [ISO8601 format](https://www.iso.org/iso-8601-date-and-time-format.html)
93
+ # @option opts [] :page Page number
94
+ # @option opts [] :per_page Page size
95
+ # @return [Array<(InvoicesIndex, Integer, Hash)>] InvoicesIndex data, response status code and response headers
106
96
  def get_invoices_with_http_info(opts = {})
107
97
  if @api_client.config.debugging
108
98
  @api_client.config.logger.debug 'Calling API: InvoicesApi.get_invoices ...'
@@ -126,38 +116,31 @@ module GetAroundOwner
126
116
  form_params = opts[:form_params] || {}
127
117
 
128
118
  # http body (model)
129
- post_body = opts[:debug_body]
119
+ post_body = opts[:body]
130
120
 
131
- # return_type
132
- return_type = opts[:debug_return_type] || 'Array<GetaroundInvoicesIndexInner>'
121
+ return_type = opts[:return_type] || 'InvoicesIndex'
133
122
 
134
- # auth_names
135
- auth_names = opts[:debug_auth_names] || ['bearerAuth']
136
-
137
- new_options = opts.merge(
138
- :operation => :"InvoicesApi.get_invoices",
123
+ auth_names = opts[:auth_names] || ['bearerAuth']
124
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path,
139
125
  :header_params => header_params,
140
126
  :query_params => query_params,
141
127
  :form_params => form_params,
142
128
  :body => post_body,
143
129
  :auth_names => auth_names,
144
- :return_type => return_type
145
- )
130
+ :return_type => return_type)
146
131
 
147
- data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
148
132
  if @api_client.config.debugging
149
133
  @api_client.config.logger.debug "API called: InvoicesApi#get_invoices\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
150
134
  end
151
135
  return data, status_code, headers
152
136
  end
153
-
154
137
  # Find invoices associated to a rental
155
138
  # Find invoices associated to a rental
156
- # @param rental_id [String] ID of rental
139
+ # @param rental_id ID of rental
157
140
  # @param [Hash] opts the optional parameters
158
- # @option opts [String] :page Page number
159
- # @option opts [String] :per_page Page size (default to '30')
160
- # @return [Array<GetaroundRentalInvoicesIndexInner>]
141
+ # @option opts [] :page Page number
142
+ # @option opts [] :per_page Page size (default to 30)
143
+ # @return [RentalInvoicesIndex]
161
144
  def get_invoices_for_rental(rental_id, opts = {})
162
145
  data, _status_code, _headers = get_invoices_for_rental_with_http_info(rental_id, opts)
163
146
  data
@@ -165,11 +148,11 @@ module GetAroundOwner
165
148
 
166
149
  # Find invoices associated to a rental
167
150
  # Find invoices associated to a rental
168
- # @param rental_id [String] ID of rental
151
+ # @param rental_id ID of rental
169
152
  # @param [Hash] opts the optional parameters
170
- # @option opts [String] :page Page number
171
- # @option opts [String] :per_page Page size (default to '30')
172
- # @return [Array<(Array<GetaroundRentalInvoicesIndexInner>, Integer, Hash)>] Array<GetaroundRentalInvoicesIndexInner> data, response status code and response headers
153
+ # @option opts [] :page Page number
154
+ # @option opts [] :per_page Page size
155
+ # @return [Array<(RentalInvoicesIndex, Integer, Hash)>] RentalInvoicesIndex data, response status code and response headers
173
156
  def get_invoices_for_rental_with_http_info(rental_id, opts = {})
174
157
  if @api_client.config.debugging
175
158
  @api_client.config.logger.debug 'Calling API: InvoicesApi.get_invoices_for_rental ...'
@@ -179,7 +162,7 @@ module GetAroundOwner
179
162
  fail ArgumentError, "Missing the required parameter 'rental_id' when calling InvoicesApi.get_invoices_for_rental"
180
163
  end
181
164
  # resource path
182
- local_var_path = '/rentals/{rental_id}/invoices.json'.sub('{' + 'rental_id' + '}', CGI.escape(rental_id.to_s))
165
+ local_var_path = '/rentals/{rental_id}/invoices.json'.sub('{' + 'rental_id' + '}', rental_id.to_s)
183
166
 
184
167
  # query parameters
185
168
  query_params = opts[:query_params] || {}
@@ -195,25 +178,19 @@ module GetAroundOwner
195
178
  form_params = opts[:form_params] || {}
196
179
 
197
180
  # http body (model)
198
- post_body = opts[:debug_body]
199
-
200
- # return_type
201
- return_type = opts[:debug_return_type] || 'Array<GetaroundRentalInvoicesIndexInner>'
181
+ post_body = opts[:body]
202
182
 
203
- # auth_names
204
- auth_names = opts[:debug_auth_names] || ['bearerAuth']
183
+ return_type = opts[:return_type] || 'RentalInvoicesIndex'
205
184
 
206
- new_options = opts.merge(
207
- :operation => :"InvoicesApi.get_invoices_for_rental",
185
+ auth_names = opts[:auth_names] || ['bearerAuth']
186
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path,
208
187
  :header_params => header_params,
209
188
  :query_params => query_params,
210
189
  :form_params => form_params,
211
190
  :body => post_body,
212
191
  :auth_names => auth_names,
213
- :return_type => return_type
214
- )
192
+ :return_type => return_type)
215
193
 
216
- data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
217
194
  if @api_client.config.debugging
218
195
  @api_client.config.logger.debug "API called: InvoicesApi#get_invoices_for_rental\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
219
196
  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
+ module GetAroundOwner
13
+ class MessagesApi
14
+ attr_accessor :api_client
15
+
16
+ def initialize(api_client = ApiClient.default)
17
+ @api_client = api_client
18
+ end
19
+ # Create Message associated to a rental
20
+ # Create Message associated to a rental
21
+ # @param rental_id ID of rental
22
+ # @param [Hash] opts the optional parameters
23
+ # @option opts [RentalIdMessagesJsonBody] :body Message to create
24
+ # @return [Message]
25
+ def create_messages(rental_id, opts = {})
26
+ data, _status_code, _headers = create_messages_with_http_info(rental_id, opts)
27
+ data
28
+ end
29
+
30
+ # Create Message associated to a rental
31
+ # Create Message associated to a rental
32
+ # @param rental_id ID of rental
33
+ # @param [Hash] opts the optional parameters
34
+ # @option opts [RentalIdMessagesJsonBody] :body Message to create
35
+ # @return [Array<(Message, Integer, Hash)>] Message data, response status code and response headers
36
+ def create_messages_with_http_info(rental_id, opts = {})
37
+ if @api_client.config.debugging
38
+ @api_client.config.logger.debug 'Calling API: MessagesApi.create_messages ...'
39
+ end
40
+ # verify the required parameter 'rental_id' is set
41
+ if @api_client.config.client_side_validation && rental_id.nil?
42
+ fail ArgumentError, "Missing the required parameter 'rental_id' when calling MessagesApi.create_messages"
43
+ end
44
+ # resource path
45
+ local_var_path = '/rentals/{rental_id}/messages.json'.sub('{' + 'rental_id' + '}', rental_id.to_s)
46
+
47
+ # query parameters
48
+ query_params = opts[:query_params] || {}
49
+
50
+ # header parameters
51
+ header_params = opts[:header_params] || {}
52
+ # HTTP header 'Accept' (if needed)
53
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
54
+ # HTTP header 'Content-Type'
55
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
56
+
57
+ # form parameters
58
+ form_params = opts[:form_params] || {}
59
+
60
+ # http body (model)
61
+ post_body = opts[:body] || @api_client.object_to_http_body(opts[:'body'])
62
+
63
+ return_type = opts[:return_type] || 'Message'
64
+
65
+ auth_names = opts[:auth_names] || ['bearerAuth']
66
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path,
67
+ :header_params => header_params,
68
+ :query_params => query_params,
69
+ :form_params => form_params,
70
+ :body => post_body,
71
+ :auth_names => auth_names,
72
+ :return_type => return_type)
73
+
74
+ if @api_client.config.debugging
75
+ @api_client.config.logger.debug "API called: MessagesApi#create_messages\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
76
+ end
77
+ return data, status_code, headers
78
+ end
79
+ # Find a message by ID associated to a rental
80
+ # Find a message by ID associated to a rental
81
+ # @param rental_id ID of rental
82
+ # @param id ID of message to return
83
+ # @param [Hash] opts the optional parameters
84
+ # @return [Message]
85
+ def get_message_by_id(rental_id, id, opts = {})
86
+ data, _status_code, _headers = get_message_by_id_with_http_info(rental_id, id, opts)
87
+ data
88
+ end
89
+
90
+ # Find a message by ID associated to a rental
91
+ # Find a message by ID associated to a rental
92
+ # @param rental_id ID of rental
93
+ # @param id ID of message to return
94
+ # @param [Hash] opts the optional parameters
95
+ # @return [Array<(Message, Integer, Hash)>] Message data, response status code and response headers
96
+ def get_message_by_id_with_http_info(rental_id, id, opts = {})
97
+ if @api_client.config.debugging
98
+ @api_client.config.logger.debug 'Calling API: MessagesApi.get_message_by_id ...'
99
+ end
100
+ # verify the required parameter 'rental_id' is set
101
+ if @api_client.config.client_side_validation && rental_id.nil?
102
+ fail ArgumentError, "Missing the required parameter 'rental_id' when calling MessagesApi.get_message_by_id"
103
+ end
104
+ # verify the required parameter 'id' is set
105
+ if @api_client.config.client_side_validation && id.nil?
106
+ fail ArgumentError, "Missing the required parameter 'id' when calling MessagesApi.get_message_by_id"
107
+ end
108
+ # resource path
109
+ local_var_path = '/rentals/{rental_id}/messages/{id}.json'.sub('{' + 'rental_id' + '}', rental_id.to_s).sub('{' + 'id' + '}', id.to_s)
110
+
111
+ # query parameters
112
+ query_params = opts[:query_params] || {}
113
+
114
+ # header parameters
115
+ header_params = opts[:header_params] || {}
116
+ # HTTP header 'Accept' (if needed)
117
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
118
+
119
+ # form parameters
120
+ form_params = opts[:form_params] || {}
121
+
122
+ # http body (model)
123
+ post_body = opts[:body]
124
+
125
+ return_type = opts[:return_type] || 'Message'
126
+
127
+ auth_names = opts[:auth_names] || ['bearerAuth']
128
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path,
129
+ :header_params => header_params,
130
+ :query_params => query_params,
131
+ :form_params => form_params,
132
+ :body => post_body,
133
+ :auth_names => auth_names,
134
+ :return_type => return_type)
135
+
136
+ if @api_client.config.debugging
137
+ @api_client.config.logger.debug "API called: MessagesApi#get_message_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
138
+ end
139
+ return data, status_code, headers
140
+ end
141
+ # Find messages associated to a rental
142
+ # Find messages associated to a rental
143
+ # @param rental_id ID of rental
144
+ # @param [Hash] opts the optional parameters
145
+ # @return [RentalMessagesIndex]
146
+ def get_messages_for_rental(rental_id, opts = {})
147
+ data, _status_code, _headers = get_messages_for_rental_with_http_info(rental_id, opts)
148
+ data
149
+ end
150
+
151
+ # Find messages associated to a rental
152
+ # Find messages associated to a rental
153
+ # @param rental_id ID of rental
154
+ # @param [Hash] opts the optional parameters
155
+ # @return [Array<(RentalMessagesIndex, Integer, Hash)>] RentalMessagesIndex data, response status code and response headers
156
+ def get_messages_for_rental_with_http_info(rental_id, opts = {})
157
+ if @api_client.config.debugging
158
+ @api_client.config.logger.debug 'Calling API: MessagesApi.get_messages_for_rental ...'
159
+ end
160
+ # verify the required parameter 'rental_id' is set
161
+ if @api_client.config.client_side_validation && rental_id.nil?
162
+ fail ArgumentError, "Missing the required parameter 'rental_id' when calling MessagesApi.get_messages_for_rental"
163
+ end
164
+ # resource path
165
+ local_var_path = '/rentals/{rental_id}/messages.json'.sub('{' + 'rental_id' + '}', rental_id.to_s)
166
+
167
+ # query parameters
168
+ query_params = opts[:query_params] || {}
169
+
170
+ # header parameters
171
+ header_params = opts[:header_params] || {}
172
+ # HTTP header 'Accept' (if needed)
173
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
174
+
175
+ # form parameters
176
+ form_params = opts[:form_params] || {}
177
+
178
+ # http body (model)
179
+ post_body = opts[:body]
180
+
181
+ return_type = opts[:return_type] || 'RentalMessagesIndex'
182
+
183
+ auth_names = opts[:auth_names] || ['bearerAuth']
184
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path,
185
+ :header_params => header_params,
186
+ :query_params => query_params,
187
+ :form_params => form_params,
188
+ :body => post_body,
189
+ :auth_names => auth_names,
190
+ :return_type => return_type)
191
+
192
+ if @api_client.config.debugging
193
+ @api_client.config.logger.debug "API called: MessagesApi#get_messages_for_rental\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
194
+ end
195
+ return data, status_code, headers
196
+ end
197
+ end
198
+ end
@@ -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 PayoutsApi
17
14
  attr_accessor :api_client
@@ -21,9 +18,9 @@ module GetAroundOwner
21
18
  end
22
19
  # Find a payout by ID
23
20
  # Find a payout by ID
24
- # @param id [String] ID of payout to return
21
+ # @param id ID of payout to return
25
22
  # @param [Hash] opts the optional parameters
26
- # @return [GetaroundPayout]
23
+ # @return [Payout]
27
24
  def get_payout_by_id(id, opts = {})
28
25
  data, _status_code, _headers = get_payout_by_id_with_http_info(id, opts)
29
26
  data
@@ -31,9 +28,9 @@ module GetAroundOwner
31
28
 
32
29
  # Find a payout by ID
33
30
  # Find a payout by ID
34
- # @param id [String] ID of payout to return
31
+ # @param id ID of payout to return
35
32
  # @param [Hash] opts the optional parameters
36
- # @return [Array<(GetaroundPayout, Integer, Hash)>] GetaroundPayout data, response status code and response headers
33
+ # @return [Array<(Payout, Integer, Hash)>] Payout data, response status code and response headers
37
34
  def get_payout_by_id_with_http_info(id, opts = {})
38
35
  if @api_client.config.debugging
39
36
  @api_client.config.logger.debug 'Calling API: PayoutsApi.get_payout_by_id ...'
@@ -43,7 +40,7 @@ module GetAroundOwner
43
40
  fail ArgumentError, "Missing the required parameter 'id' when calling PayoutsApi.get_payout_by_id"
44
41
  end
45
42
  # resource path
46
- local_var_path = '/payouts/{id}.json'.sub('{' + 'id' + '}', CGI.escape(id.to_s))
43
+ local_var_path = '/payouts/{id}.json'.sub('{' + 'id' + '}', id.to_s)
47
44
 
48
45
  # query parameters
49
46
  query_params = opts[:query_params] || {}
@@ -57,39 +54,32 @@ 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] || 'GetaroundPayout'
57
+ post_body = opts[:body]
64
58
 
65
- # auth_names
66
- auth_names = opts[:debug_auth_names] || ['bearerAuth']
59
+ return_type = opts[:return_type] || 'Payout'
67
60
 
68
- new_options = opts.merge(
69
- :operation => :"PayoutsApi.get_payout_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: PayoutsApi#get_payout_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 payouts paid between dates
86
76
  # Find payouts paid between dates
87
- # @param start_date [Time] Start date and time in [ISO8601 format](https://www.iso.org/iso-8601-date-and-time-format.html)
88
- # @param end_date [Time] End date and time in [ISO8601 format](https://www.iso.org/iso-8601-date-and-time-format.html)
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)
89
79
  # @param [Hash] opts the optional parameters
90
- # @option opts [String] :page Page number
91
- # @option opts [String] :per_page Page size (default to '30')
92
- # @return [Array<GetaroundPayoutsIndexInner>]
80
+ # @option opts [] :page Page number
81
+ # @option opts [] :per_page Page size (default to 30)
82
+ # @return [PayoutsIndex]
93
83
  def get_payouts(start_date, end_date, opts = {})
94
84
  data, _status_code, _headers = get_payouts_with_http_info(start_date, end_date, opts)
95
85
  data
@@ -97,12 +87,12 @@ module GetAroundOwner
97
87
 
98
88
  # Find payouts paid between dates
99
89
  # Find payouts paid between dates
100
- # @param start_date [Time] Start date and time in [ISO8601 format](https://www.iso.org/iso-8601-date-and-time-format.html)
101
- # @param end_date [Time] End date and time in [ISO8601 format](https://www.iso.org/iso-8601-date-and-time-format.html)
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)
102
92
  # @param [Hash] opts the optional parameters
103
- # @option opts [String] :page Page number
104
- # @option opts [String] :per_page Page size (default to '30')
105
- # @return [Array<(Array<GetaroundPayoutsIndexInner>, Integer, Hash)>] Array<GetaroundPayoutsIndexInner> data, response status code and response headers
93
+ # @option opts [] :page Page number
94
+ # @option opts [] :per_page Page size
95
+ # @return [Array<(PayoutsIndex, Integer, Hash)>] PayoutsIndex data, response status code and response headers
106
96
  def get_payouts_with_http_info(start_date, end_date, opts = {})
107
97
  if @api_client.config.debugging
108
98
  @api_client.config.logger.debug 'Calling API: PayoutsApi.get_payouts ...'
@@ -134,25 +124,19 @@ module GetAroundOwner
134
124
  form_params = opts[:form_params] || {}
135
125
 
136
126
  # http body (model)
137
- post_body = opts[:debug_body]
138
-
139
- # return_type
140
- return_type = opts[:debug_return_type] || 'Array<GetaroundPayoutsIndexInner>'
127
+ post_body = opts[:body]
141
128
 
142
- # auth_names
143
- auth_names = opts[:debug_auth_names] || ['bearerAuth']
129
+ return_type = opts[:return_type] || 'PayoutsIndex'
144
130
 
145
- new_options = opts.merge(
146
- :operation => :"PayoutsApi.get_payouts",
131
+ auth_names = opts[:auth_names] || ['bearerAuth']
132
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path,
147
133
  :header_params => header_params,
148
134
  :query_params => query_params,
149
135
  :form_params => form_params,
150
136
  :body => post_body,
151
137
  :auth_names => auth_names,
152
- :return_type => return_type
153
- )
138
+ :return_type => return_type)
154
139
 
155
- data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
156
140
  if @api_client.config.debugging
157
141
  @api_client.config.logger.debug "API called: PayoutsApi#get_payouts\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
158
142
  end