get_around_owner 1.0.1 → 1.0.4
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.
- checksums.yaml +4 -4
- data/Gemfile +9 -0
- data/Owner API v1.json +2938 -0
- data/README.md +359 -203
- data/Rakefile +8 -0
- data/docs/Car.md +12 -0
- data/docs/CarId.md +6 -0
- data/docs/CarIdUnavailabilitiesJsonBody.md +9 -0
- data/docs/CarsApi.md +109 -0
- data/docs/CarsIndex.md +6 -0
- data/docs/Checkin.md +10 -0
- data/docs/CheckinsApi.md +113 -0
- data/docs/CheckinsIndex.md +6 -0
- data/docs/Checkout.md +11 -0
- data/docs/CheckoutsApi.md +113 -0
- data/docs/CheckoutsIndex.md +6 -0
- data/docs/EndsAt.md +6 -0
- data/docs/GetaroundCar.md +28 -0
- data/docs/GetaroundCarsIndexInner.md +18 -0
- data/docs/GetaroundCheckin.md +24 -0
- data/docs/GetaroundCheckinsIndexInner.md +18 -0
- data/docs/GetaroundCheckout.md +26 -0
- data/docs/GetaroundCreateMessagesRequest.md +18 -0
- data/docs/GetaroundCreateUnavailabilitiesRequest.md +22 -0
- data/docs/GetaroundDestroyUnavailabilityRequest.md +20 -0
- data/docs/GetaroundInvoice.md +34 -0
- data/docs/GetaroundInvoiceChargesInner.md +20 -0
- data/docs/GetaroundInvoicesIndexInner.md +18 -0
- data/docs/GetaroundMessage.md +26 -0
- data/docs/GetaroundMessagesSent.md +22 -0
- data/docs/GetaroundMessagesSentAllOfData.md +20 -0
- data/docs/GetaroundPayout.md +28 -0
- data/docs/GetaroundPayoutInvoicesInner.md +18 -0
- data/docs/GetaroundPayoutsIndexInner.md +18 -0
- data/docs/GetaroundReason.md +15 -0
- data/docs/GetaroundRental.md +32 -0
- data/docs/GetaroundRentalInvoicesIndexInner.md +18 -0
- data/docs/GetaroundRentalMessagesIndexInner.md +18 -0
- data/docs/GetaroundRentalsBooked.md +22 -0
- data/docs/GetaroundRentalsBookedAllOfData.md +18 -0
- data/docs/GetaroundRentalsCanceled.md +22 -0
- data/docs/GetaroundRentalsCarCheckedIn.md +22 -0
- data/docs/GetaroundRentalsCarCheckedOut.md +22 -0
- data/docs/GetaroundRentalsCarSwitched.md +22 -0
- data/docs/GetaroundRentalsIndexInner.md +18 -0
- data/docs/GetaroundRentalsTimesChanged.md +22 -0
- data/docs/GetaroundUnavailabilitiesCreated.md +22 -0
- data/docs/GetaroundUnavailabilitiesCreatedAllOfData.md +24 -0
- data/docs/GetaroundUnavailabilitiesDeleted.md +22 -0
- data/docs/GetaroundUnavailabilitiesDeletedAllOfData.md +22 -0
- data/docs/GetaroundUnavailability.md +24 -0
- data/docs/GetaroundUser.md +42 -0
- data/docs/GetaroundUsersUpdated.md +22 -0
- data/docs/GetaroundUsersUpdatedAllOfData.md +18 -0
- data/docs/GetaroundWebhook.md +22 -0
- data/docs/Invoice.md +15 -0
- data/docs/InvoicesApi.md +168 -0
- data/docs/InvoicesIndex.md +6 -0
- data/docs/Message.md +11 -0
- data/docs/MessagesApi.md +161 -0
- data/docs/MessagesSent.md +6 -0
- data/docs/Payout.md +12 -0
- data/docs/PayoutsApi.md +113 -0
- data/docs/PayoutsIndex.md +6 -0
- data/docs/Rental.md +14 -0
- data/docs/RentalIdMessagesJsonBody.md +7 -0
- data/docs/RentalInvoicesIndex.md +6 -0
- data/docs/RentalMessagesIndex.md +6 -0
- data/docs/RentalsApi.md +113 -0
- data/docs/RentalsBooked.md +6 -0
- data/docs/RentalsCanceled.md +6 -0
- data/docs/RentalsCarCheckedIn.md +6 -0
- data/docs/RentalsCarCheckedOut.md +6 -0
- data/docs/RentalsCarSwitched.md +6 -0
- data/docs/RentalsIndex.md +6 -0
- data/docs/RentalsTimesChanged.md +6 -0
- data/docs/StartsAt.md +6 -0
- data/docs/UnavailabilitiesApi.md +166 -0
- data/docs/UnavailabilitiesCreated.md +6 -0
- data/docs/UnavailabilitiesDeleted.md +6 -0
- data/docs/UnavailabilitiesIndex.md +6 -0
- data/docs/Unavailability.md +10 -0
- data/docs/User.md +19 -0
- data/docs/UsersApi.md +56 -0
- data/docs/UsersUpdated.md +6 -0
- data/docs/Webhook.md +9 -0
- data/get_around_owner-1.0.0.gem +0 -0
- data/get_around_owner-1.0.1.gem +0 -0
- data/get_around_owner-1.0.3.gem +0 -0
- data/get_around_owner.gemspec +39 -0
- data/getaround-api.gemspec +38 -0
- data/git_push.sh +55 -0
- data/lib/get_around_owner/api/cars_api.rb +25 -41
- data/lib/get_around_owner/api/checkins_api.rb +99 -35
- data/lib/get_around_owner/api/checkouts_api.rb +99 -35
- data/lib/get_around_owner/api/invoices_api.rb +43 -66
- data/lib/get_around_owner/api/messages_api.rb +149 -33
- data/lib/get_around_owner/api/payouts_api.rb +29 -45
- data/lib/get_around_owner/api/rentals_api.rb +67 -183
- data/lib/get_around_owner/api/unavailabilities_api.rb +124 -58
- data/lib/get_around_owner/api/users_api.rb +30 -36
- data/lib/get_around_owner/api_client.rb +71 -77
- data/lib/get_around_owner/api_error.rb +5 -6
- data/lib/get_around_owner/configuration.rb +13 -106
- data/lib/get_around_owner/models/{getaround_car.rb → car.rb} +36 -56
- data/lib/get_around_owner/models/{getaround_users_updated_all_of_data.rb → car_id.rb} +33 -50
- data/lib/get_around_owner/models/{getaround_destroy_unavailability_request.rb → car_id_unavailabilities_json_body.rb} +45 -47
- data/lib/get_around_owner/models/{getaround_rentals_booked_all_of_data.rb → cars_index.rb} +33 -50
- data/lib/get_around_owner/models/{getaround_checkin.rb → checkin.rb} +34 -65
- data/lib/get_around_owner/models/{getaround_payouts_index_inner.rb → checkins_index.rb} +32 -58
- data/lib/get_around_owner/models/{getaround_checkout.rb → checkout.rb} +35 -70
- data/lib/get_around_owner/models/checkouts_index.rb +197 -0
- data/lib/get_around_owner/models/ends_at.rb +198 -0
- data/lib/get_around_owner/models/{getaround_invoice.rb → invoice.rb} +45 -113
- data/lib/get_around_owner/models/invoices_index.rb +198 -0
- data/lib/get_around_owner/models/{getaround_message.rb → message.rb} +35 -53
- data/lib/get_around_owner/models/messages_sent.rb +197 -0
- data/lib/get_around_owner/models/{getaround_payout.rb → payout.rb} +37 -101
- data/lib/get_around_owner/models/payouts_index.rb +198 -0
- data/lib/get_around_owner/models/{getaround_rental.rb → rental.rb} +38 -100
- data/lib/get_around_owner/models/{getaround_create_messages_request.rb → rental_id_messages_json_body.rb} +31 -41
- data/lib/get_around_owner/models/rental_invoices_index.rb +198 -0
- data/lib/get_around_owner/models/rental_messages_index.rb +198 -0
- data/lib/get_around_owner/models/rentals_booked.rb +197 -0
- data/lib/get_around_owner/models/rentals_canceled.rb +197 -0
- data/lib/get_around_owner/models/rentals_car_checked_in.rb +197 -0
- data/lib/get_around_owner/models/rentals_car_checked_out.rb +197 -0
- data/lib/get_around_owner/models/rentals_car_switched.rb +197 -0
- data/lib/get_around_owner/models/rentals_index.rb +198 -0
- data/lib/get_around_owner/models/rentals_times_changed.rb +197 -0
- data/lib/get_around_owner/models/starts_at.rb +198 -0
- data/lib/get_around_owner/models/{getaround_cars_index_inner.rb → unavailabilities_created.rb} +32 -58
- data/lib/get_around_owner/models/unavailabilities_deleted.rb +197 -0
- data/lib/get_around_owner/models/unavailabilities_index.rb +198 -0
- data/lib/get_around_owner/models/{getaround_unavailabilities_created_all_of_data.rb → unavailability.rb} +51 -65
- data/lib/get_around_owner/models/{getaround_user.rb → user.rb} +43 -75
- data/lib/get_around_owner/models/users_updated.rb +197 -0
- data/lib/get_around_owner/models/{getaround_webhook.rb → webhook.rb} +38 -47
- data/lib/get_around_owner/version.rb +5 -6
- data/lib/get_around_owner.rb +38 -43
- data/openapi.yml +2298 -0
- data/spec/api/cars_api_spec.rb +13 -14
- data/spec/api/checkins_api_spec.rb +13 -14
- data/spec/api/checkouts_api_spec.rb +13 -14
- data/spec/api/invoices_api_spec.rb +19 -20
- data/spec/api/messages_api_spec.rb +14 -15
- data/spec/api/payouts_api_spec.rb +13 -14
- data/spec/api/rentals_api_spec.rb +13 -14
- data/spec/api/unavailabilities_api_spec.rb +14 -16
- data/spec/api/users_api_spec.rb +9 -10
- data/spec/api_client_spec.rb +225 -0
- data/spec/base_object_spec.rb +109 -0
- data/spec/{models/getaround_checkins_index_inner_spec.rb → configuration_spec.rb} +26 -21
- data/spec/models/{getaround_reason_spec.rb → car_id_spec.rb} +18 -14
- data/spec/models/{getaround_unavailabilities_deleted_all_of_data_spec.rb → car_id_unavailabilities_json_body_spec.rb} +24 -20
- data/spec/models/{getaround_car_spec.rb → car_spec.rb} +24 -20
- data/spec/models/{getaround_rentals_index_inner_spec.rb → cars_index_spec.rb} +16 -18
- data/spec/models/{getaround_checkin_spec.rb → checkin_spec.rb} +22 -18
- data/spec/models/checkins_index_spec.rb +34 -0
- data/spec/models/{getaround_checkout_spec.rb → checkout_spec.rb} +23 -19
- data/spec/models/checkouts_index_spec.rb +34 -0
- data/spec/models/ends_at_spec.rb +34 -0
- data/spec/models/{getaround_invoice_spec.rb → invoice_spec.rb} +27 -31
- data/spec/models/invoices_index_spec.rb +34 -0
- data/spec/models/{getaround_message_spec.rb → message_spec.rb} +23 -19
- data/spec/models/messages_sent_spec.rb +34 -0
- data/spec/models/{getaround_payout_spec.rb → payout_spec.rb} +24 -24
- data/spec/models/payouts_index_spec.rb +34 -0
- data/spec/models/{getaround_create_messages_request_spec.rb → rental_id_messages_json_body_spec.rb} +19 -15
- data/spec/models/rental_invoices_index_spec.rb +34 -0
- data/spec/models/rental_messages_index_spec.rb +34 -0
- data/spec/models/{getaround_rental_spec.rb → rental_spec.rb} +26 -22
- data/spec/models/rentals_booked_spec.rb +34 -0
- data/spec/models/rentals_canceled_spec.rb +34 -0
- data/spec/models/rentals_car_checked_in_spec.rb +34 -0
- data/spec/models/rentals_car_checked_out_spec.rb +34 -0
- data/spec/models/rentals_car_switched_spec.rb +34 -0
- data/spec/models/rentals_index_spec.rb +34 -0
- data/spec/models/rentals_times_changed_spec.rb +34 -0
- data/spec/models/starts_at_spec.rb +34 -0
- data/spec/models/{getaround_cars_index_inner_spec.rb → unavailabilities_created_spec.rb} +16 -18
- data/spec/models/{getaround_payouts_index_inner_spec.rb → unavailabilities_deleted_spec.rb} +16 -18
- data/spec/models/unavailabilities_index_spec.rb +34 -0
- data/spec/models/{getaround_unavailabilities_created_all_of_data_spec.rb → unavailability_spec.rb} +22 -18
- data/spec/models/{getaround_user_spec.rb → user_spec.rb} +31 -27
- data/spec/models/users_updated_spec.rb +34 -0
- data/spec/models/{getaround_webhook_spec.rb → webhook_spec.rb} +21 -17
- data/spec/spec_helper.rb +4 -5
- metadata +276 -119
- data/lib/get_around_owner/models/getaround_checkins_index_inner.rb +0 -222
- data/lib/get_around_owner/models/getaround_create_unavailabilities_request.rb +0 -283
- data/lib/get_around_owner/models/getaround_invoice_charges_inner.rb +0 -225
- data/lib/get_around_owner/models/getaround_invoices_index_inner.rb +0 -223
- data/lib/get_around_owner/models/getaround_messages_sent.rb +0 -257
- data/lib/get_around_owner/models/getaround_messages_sent_all_of_data.rb +0 -225
- data/lib/get_around_owner/models/getaround_payout_invoices_inner.rb +0 -223
- data/lib/get_around_owner/models/getaround_reason.rb +0 -45
- data/lib/get_around_owner/models/getaround_rental_invoices_index_inner.rb +0 -223
- data/lib/get_around_owner/models/getaround_rental_messages_index_inner.rb +0 -223
- data/lib/get_around_owner/models/getaround_rentals_booked.rb +0 -257
- data/lib/get_around_owner/models/getaround_rentals_canceled.rb +0 -257
- data/lib/get_around_owner/models/getaround_rentals_car_checked_in.rb +0 -257
- data/lib/get_around_owner/models/getaround_rentals_car_checked_out.rb +0 -257
- data/lib/get_around_owner/models/getaround_rentals_car_switched.rb +0 -257
- data/lib/get_around_owner/models/getaround_rentals_index_inner.rb +0 -223
- data/lib/get_around_owner/models/getaround_rentals_times_changed.rb +0 -257
- data/lib/get_around_owner/models/getaround_unavailabilities_created.rb +0 -257
- data/lib/get_around_owner/models/getaround_unavailabilities_deleted.rb +0 -257
- data/lib/get_around_owner/models/getaround_unavailabilities_deleted_all_of_data.rb +0 -235
- data/lib/get_around_owner/models/getaround_unavailability.rb +0 -302
- data/lib/get_around_owner/models/getaround_users_updated.rb +0 -257
- data/spec/models/getaround_create_unavailabilities_request_spec.rb +0 -52
- data/spec/models/getaround_destroy_unavailability_request_spec.rb +0 -42
- data/spec/models/getaround_invoice_charges_inner_spec.rb +0 -42
- data/spec/models/getaround_invoices_index_inner_spec.rb +0 -36
- data/spec/models/getaround_messages_sent_all_of_data_spec.rb +0 -42
- data/spec/models/getaround_messages_sent_spec.rb +0 -48
- data/spec/models/getaround_payout_invoices_inner_spec.rb +0 -36
- data/spec/models/getaround_rental_invoices_index_inner_spec.rb +0 -36
- data/spec/models/getaround_rental_messages_index_inner_spec.rb +0 -36
- data/spec/models/getaround_rentals_booked_all_of_data_spec.rb +0 -36
- data/spec/models/getaround_rentals_booked_spec.rb +0 -48
- data/spec/models/getaround_rentals_canceled_spec.rb +0 -48
- data/spec/models/getaround_rentals_car_checked_in_spec.rb +0 -48
- data/spec/models/getaround_rentals_car_checked_out_spec.rb +0 -48
- data/spec/models/getaround_rentals_car_switched_spec.rb +0 -48
- data/spec/models/getaround_rentals_times_changed_spec.rb +0 -48
- data/spec/models/getaround_unavailabilities_created_spec.rb +0 -48
- data/spec/models/getaround_unavailabilities_deleted_spec.rb +0 -48
- data/spec/models/getaround_unavailability_spec.rb +0 -58
- data/spec/models/getaround_users_updated_all_of_data_spec.rb +0 -36
- data/spec/models/getaround_users_updated_spec.rb +0 -48
@@ -1,21 +1,19 @@
|
|
1
1
|
=begin
|
2
2
|
#Getaround Owner API
|
3
3
|
|
4
|
-
## Quick Start The Owner API uses the JSON format, and must be accessed over a [secure connection](https://en.wikipedia.org/wiki/HTTPS). Let’s assume that the access token provided by your account manager is “TOKEN”. Here’s how to get the list of ids of all your invoices from the first week of August with a shell script: ```bash query=\"end_date=2018-08-08T00%3A00%3A00%2B00%3A00&start_date=2018-08-01T00%3A00%3A00%2B00%3A00\" curl -i \"https://api-eu.getaround.com/owner/v1/invoices?${query}\" \\ -H \"Authorization: Bearer TOKEN\" \\ -H \"Accept:application/json\" \\ -H \"Content-Type:application/json\" ``` And here’s how to get the invoice with the id 12345: ```bash curl -i \"https://api-eu.getaround.com/owner/v1/invoices/12345\" \\ -H \"Authorization: Bearer TOKEN\" \\ -H \"Accept: application/json\" \\ -H \"Content-Type: application/json\"\" ``` See the [endpoints section](#tag/Invoices) of this guide for details about the response format. Dates in request params should follow the ISO 8601 standard. # Authentication All requests must be authenticated with a [bearer token header](https://tools.ietf.org/html/rfc6750#section-2.1). You token will be sent to you by your account manager. Unauthenticated requests will return a 401 status. # Pagination The page number and the number of items per page can be set with the “page” and “per_page” params. For example, this request will return the second page of invoices, and 50 invoices per page: `https://api-eu.getaround.com/owner/v1/invoices?page=2&per_page=50` Both of these params are optional. The default page size is 30 items. The Getaround Owner API follows the [RFC 8288 convention](https://datatracker.ietf.org/doc/html/rfc8288) of using the `Link` header to provide the `next` page URL. Please don't build the pagination URLs yourself. The `next` page will be missing when you are requesting the last available page. Here's an example response header from requesting the second page of invoices `https://api-eu.getaround.com/owner/v1/invoices?page=2&per_page=50` ``` Link: <https://api-eu.getaround.com/owner/v1/invoices?page=3&per_page=50>; rel=\"next\" ``` # Throttling policy and Date range limitation We have throttling policy that prevents you to perform more than 100 requests per min from the same IP. Also, there is a limitation on the size of the range of dates given in params in some requests. All requests that need start_date and end_date, do not accept a range bigger than 30 days. # Webhooks Getaround can send webhook events that notify your application when certain events happen on your account. This is especially useful to follow the lifecycle of rentals, tracking for example bookings or cancellations. ### Setup To set up an endpoint, you need to define a route on your server for receiving events, and then <a href=\"mailto:owner-api@getaround.com\">ask Getaround</a> to add this URL to your account. To acknowledge receipt of a event, your endpoint must: - Return a `2xx` HTTP status code. - Be a secure `https` endpoint with a valid SSL certificate. ### Testing Once Getaround has set up the endpoint, and it is properly configured as described above, a test `ping` event can be sent by clicking the button below: <form action=\"/docs/api/owner/fire_ping_webhook\" method=\"post\"><input type=\"submit\" value=\"Send Ping Event\"></form> You should receive the following JSON payload: ```json { \"data\": { \"ping\": \"pong\" }, \"type\": \"ping\", \"occurred_at\": \"2019-04-18T08:30:05Z\" } ``` ### Retries Webhook deliveries will be attempted for up to three days with an exponential back off. After that point the delivery will be abandoned. ### Verifying Signatures Getaround will also provide you with a secret token, which is used to create a hash signature with each payload. This hash signature is passed along with each request in the headers as `X-Drivy-Signature`. Suppose you have a basic server listening to webhooks that looks like this: ```ruby require 'sinatra' require 'json' post '/payload' do push = JSON.parse(params[:payload]) \"I got some JSON:
|
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
|
-
|
6
|
+
OpenAPI spec version: 1.0.0
|
7
7
|
Contact: owner-api@getaround.com
|
8
|
-
Generated by: https://
|
9
|
-
|
10
|
-
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 3.0.66
|
11
10
|
=end
|
12
11
|
|
13
12
|
require 'date'
|
14
|
-
require 'time'
|
15
13
|
|
16
14
|
module GetAroundOwner
|
17
15
|
# A checkin is the event created when the user finished the pick up inspection.
|
18
|
-
class
|
16
|
+
class Checkin
|
19
17
|
# Rental's ID linked to this checkin
|
20
18
|
attr_accessor :rental_id
|
21
19
|
|
@@ -38,18 +36,13 @@ module GetAroundOwner
|
|
38
36
|
}
|
39
37
|
end
|
40
38
|
|
41
|
-
# Returns all the JSON keys this model knows about
|
42
|
-
def self.acceptable_attributes
|
43
|
-
attribute_map.values
|
44
|
-
end
|
45
|
-
|
46
39
|
# Attribute type mapping.
|
47
40
|
def self.openapi_types
|
48
41
|
{
|
49
|
-
:'rental_id' => :'
|
50
|
-
:'mileage' => :'
|
51
|
-
:'fuel_level' => :'
|
52
|
-
:'occurred_at' => :'
|
42
|
+
:'rental_id' => :'Object',
|
43
|
+
:'mileage' => :'Object',
|
44
|
+
:'fuel_level' => :'Object',
|
45
|
+
:'occurred_at' => :'Object'
|
53
46
|
}
|
54
47
|
end
|
55
48
|
|
@@ -58,26 +51,24 @@ module GetAroundOwner
|
|
58
51
|
Set.new([
|
59
52
|
])
|
60
53
|
end
|
61
|
-
|
54
|
+
|
62
55
|
# Initializes the object
|
63
56
|
# @param [Hash] attributes Model attributes in the form of hash
|
64
57
|
def initialize(attributes = {})
|
65
58
|
if (!attributes.is_a?(Hash))
|
66
|
-
fail ArgumentError, "The input argument (attributes) must be a hash in `GetAroundOwner::
|
59
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `GetAroundOwner::Checkin` initialize method"
|
67
60
|
end
|
68
61
|
|
69
62
|
# check to see if the attribute exists and convert string to symbol for hash key
|
70
63
|
attributes = attributes.each_with_object({}) { |(k, v), h|
|
71
64
|
if (!self.class.attribute_map.key?(k.to_sym))
|
72
|
-
fail ArgumentError, "`#{k}` is not a valid attribute in `GetAroundOwner::
|
65
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `GetAroundOwner::Checkin`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
73
66
|
end
|
74
67
|
h[k.to_sym] = v
|
75
68
|
}
|
76
69
|
|
77
70
|
if attributes.key?(:'rental_id')
|
78
71
|
self.rental_id = attributes[:'rental_id']
|
79
|
-
else
|
80
|
-
self.rental_id = nil
|
81
72
|
end
|
82
73
|
|
83
74
|
if attributes.key?(:'mileage')
|
@@ -90,24 +81,17 @@ module GetAroundOwner
|
|
90
81
|
|
91
82
|
if attributes.key?(:'occurred_at')
|
92
83
|
self.occurred_at = attributes[:'occurred_at']
|
93
|
-
else
|
94
|
-
self.occurred_at = nil
|
95
84
|
end
|
96
85
|
end
|
97
86
|
|
98
87
|
# Show invalid properties with the reasons. Usually used together with valid?
|
99
88
|
# @return Array for valid properties with the reasons
|
100
89
|
def list_invalid_properties
|
101
|
-
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
102
90
|
invalid_properties = Array.new
|
103
91
|
if @rental_id.nil?
|
104
92
|
invalid_properties.push('invalid value for "rental_id", rental_id cannot be nil.')
|
105
93
|
end
|
106
94
|
|
107
|
-
if @rental_id < 1
|
108
|
-
invalid_properties.push('invalid value for "rental_id", must be greater than or equal to 1.')
|
109
|
-
end
|
110
|
-
|
111
95
|
if @occurred_at.nil?
|
112
96
|
invalid_properties.push('invalid value for "occurred_at", occurred_at cannot be nil.')
|
113
97
|
end
|
@@ -118,27 +102,11 @@ module GetAroundOwner
|
|
118
102
|
# Check to see if the all the properties in the model are valid
|
119
103
|
# @return true if the model is valid
|
120
104
|
def valid?
|
121
|
-
warn '[DEPRECATED] the `valid?` method is obsolete'
|
122
105
|
return false if @rental_id.nil?
|
123
|
-
return false if @rental_id < 1
|
124
106
|
return false if @occurred_at.nil?
|
125
107
|
true
|
126
108
|
end
|
127
109
|
|
128
|
-
# Custom attribute writer method with validation
|
129
|
-
# @param [Object] rental_id Value to be assigned
|
130
|
-
def rental_id=(rental_id)
|
131
|
-
if rental_id.nil?
|
132
|
-
fail ArgumentError, 'rental_id cannot be nil'
|
133
|
-
end
|
134
|
-
|
135
|
-
if rental_id < 1
|
136
|
-
fail ArgumentError, 'invalid value for "rental_id", must be greater than or equal to 1.'
|
137
|
-
end
|
138
|
-
|
139
|
-
@rental_id = rental_id
|
140
|
-
end
|
141
|
-
|
142
110
|
# Checks equality by comparing each attribute.
|
143
111
|
# @param [Object] Object to be compared
|
144
112
|
def ==(o)
|
@@ -166,33 +134,39 @@ module GetAroundOwner
|
|
166
134
|
# @param [Hash] attributes Model attributes in the form of hash
|
167
135
|
# @return [Object] Returns the model itself
|
168
136
|
def self.build_from_hash(attributes)
|
137
|
+
new.build_from_hash(attributes)
|
138
|
+
end
|
139
|
+
|
140
|
+
# Builds the object from hash
|
141
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
142
|
+
# @return [Object] Returns the model itself
|
143
|
+
def build_from_hash(attributes)
|
169
144
|
return nil unless attributes.is_a?(Hash)
|
170
|
-
|
171
|
-
|
172
|
-
openapi_types.each_pair do |key, type|
|
173
|
-
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
174
|
-
transformed_hash["#{key}"] = nil
|
175
|
-
elsif type =~ /\AArray<(.*)>/i
|
145
|
+
self.class.openapi_types.each_pair do |key, type|
|
146
|
+
if type =~ /\AArray<(.*)>/i
|
176
147
|
# check to ensure the input is an array given that the attribute
|
177
148
|
# is documented as an array but the input is not
|
178
|
-
if attributes[attribute_map[key]].is_a?(Array)
|
179
|
-
|
149
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
150
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
180
151
|
end
|
181
|
-
elsif !attributes[attribute_map[key]].nil?
|
182
|
-
|
152
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
153
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
154
|
+
elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
155
|
+
self.send("#{key}=", nil)
|
183
156
|
end
|
184
157
|
end
|
185
|
-
|
158
|
+
|
159
|
+
self
|
186
160
|
end
|
187
161
|
|
188
162
|
# Deserializes the data based on type
|
189
163
|
# @param string type Data type
|
190
164
|
# @param string value Value to be deserialized
|
191
165
|
# @return [Object] Deserialized data
|
192
|
-
def
|
166
|
+
def _deserialize(type, value)
|
193
167
|
case type.to_sym
|
194
|
-
when :
|
195
|
-
|
168
|
+
when :DateTime
|
169
|
+
DateTime.parse(value)
|
196
170
|
when :Date
|
197
171
|
Date.parse(value)
|
198
172
|
when :String
|
@@ -222,9 +196,7 @@ module GetAroundOwner
|
|
222
196
|
end
|
223
197
|
end
|
224
198
|
else # model
|
225
|
-
|
226
|
-
klass = GetAroundOwner.const_get(type)
|
227
|
-
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
199
|
+
GetAroundOwner.const_get(type).build_from_hash(value)
|
228
200
|
end
|
229
201
|
end
|
230
202
|
|
@@ -272,8 +244,5 @@ module GetAroundOwner
|
|
272
244
|
else
|
273
245
|
value
|
274
246
|
end
|
275
|
-
end
|
276
|
-
|
277
|
-
end
|
278
|
-
|
247
|
+
end end
|
279
248
|
end
|
@@ -1,40 +1,27 @@
|
|
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:
|
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
|
-
|
6
|
+
OpenAPI spec version: 1.0.0
|
7
7
|
Contact: owner-api@getaround.com
|
8
|
-
Generated by: https://
|
9
|
-
|
10
|
-
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 3.0.66
|
11
10
|
=end
|
12
11
|
|
13
12
|
require 'date'
|
14
|
-
require 'time'
|
15
13
|
|
16
14
|
module GetAroundOwner
|
17
|
-
|
18
|
-
class GetaroundPayoutsIndexInner
|
19
|
-
# The payout ID
|
20
|
-
attr_accessor :id
|
21
|
-
|
15
|
+
class CheckinsIndex
|
22
16
|
# Attribute mapping from ruby-style variable name to JSON key.
|
23
17
|
def self.attribute_map
|
24
18
|
{
|
25
|
-
:'id' => :'id'
|
26
19
|
}
|
27
20
|
end
|
28
21
|
|
29
|
-
# Returns all the JSON keys this model knows about
|
30
|
-
def self.acceptable_attributes
|
31
|
-
attribute_map.values
|
32
|
-
end
|
33
|
-
|
34
22
|
# Attribute type mapping.
|
35
23
|
def self.openapi_types
|
36
24
|
{
|
37
|
-
:'id' => :'Integer'
|
38
25
|
}
|
39
26
|
end
|
40
27
|
|
@@ -43,46 +30,33 @@ module GetAroundOwner
|
|
43
30
|
Set.new([
|
44
31
|
])
|
45
32
|
end
|
46
|
-
|
33
|
+
|
47
34
|
# Initializes the object
|
48
35
|
# @param [Hash] attributes Model attributes in the form of hash
|
49
36
|
def initialize(attributes = {})
|
50
37
|
if (!attributes.is_a?(Hash))
|
51
|
-
fail ArgumentError, "The input argument (attributes) must be a hash in `GetAroundOwner::
|
38
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `GetAroundOwner::CheckinsIndex` initialize method"
|
52
39
|
end
|
53
40
|
|
54
41
|
# check to see if the attribute exists and convert string to symbol for hash key
|
55
42
|
attributes = attributes.each_with_object({}) { |(k, v), h|
|
56
43
|
if (!self.class.attribute_map.key?(k.to_sym))
|
57
|
-
fail ArgumentError, "`#{k}` is not a valid attribute in `GetAroundOwner::
|
44
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `GetAroundOwner::CheckinsIndex`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
58
45
|
end
|
59
46
|
h[k.to_sym] = v
|
60
47
|
}
|
61
|
-
|
62
|
-
if attributes.key?(:'id')
|
63
|
-
self.id = attributes[:'id']
|
64
|
-
else
|
65
|
-
self.id = nil
|
66
|
-
end
|
67
48
|
end
|
68
49
|
|
69
50
|
# Show invalid properties with the reasons. Usually used together with valid?
|
70
51
|
# @return Array for valid properties with the reasons
|
71
52
|
def list_invalid_properties
|
72
|
-
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
73
53
|
invalid_properties = Array.new
|
74
|
-
if @id.nil?
|
75
|
-
invalid_properties.push('invalid value for "id", id cannot be nil.')
|
76
|
-
end
|
77
|
-
|
78
54
|
invalid_properties
|
79
55
|
end
|
80
56
|
|
81
57
|
# Check to see if the all the properties in the model are valid
|
82
58
|
# @return true if the model is valid
|
83
59
|
def valid?
|
84
|
-
warn '[DEPRECATED] the `valid?` method is obsolete'
|
85
|
-
return false if @id.nil?
|
86
60
|
true
|
87
61
|
end
|
88
62
|
|
@@ -90,8 +64,7 @@ module GetAroundOwner
|
|
90
64
|
# @param [Object] Object to be compared
|
91
65
|
def ==(o)
|
92
66
|
return true if self.equal?(o)
|
93
|
-
self.class == o.class
|
94
|
-
id == o.id
|
67
|
+
self.class == o.class
|
95
68
|
end
|
96
69
|
|
97
70
|
# @see the `==` method
|
@@ -103,40 +76,46 @@ module GetAroundOwner
|
|
103
76
|
# Calculates hash code according to all attributes.
|
104
77
|
# @return [Integer] Hash code
|
105
78
|
def hash
|
106
|
-
[
|
79
|
+
[].hash
|
107
80
|
end
|
108
81
|
|
109
82
|
# Builds the object from hash
|
110
83
|
# @param [Hash] attributes Model attributes in the form of hash
|
111
84
|
# @return [Object] Returns the model itself
|
112
85
|
def self.build_from_hash(attributes)
|
86
|
+
new.build_from_hash(attributes)
|
87
|
+
end
|
88
|
+
|
89
|
+
# Builds the object from hash
|
90
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
91
|
+
# @return [Object] Returns the model itself
|
92
|
+
def build_from_hash(attributes)
|
113
93
|
return nil unless attributes.is_a?(Hash)
|
114
|
-
|
115
|
-
|
116
|
-
openapi_types.each_pair do |key, type|
|
117
|
-
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
118
|
-
transformed_hash["#{key}"] = nil
|
119
|
-
elsif type =~ /\AArray<(.*)>/i
|
94
|
+
self.class.openapi_types.each_pair do |key, type|
|
95
|
+
if type =~ /\AArray<(.*)>/i
|
120
96
|
# check to ensure the input is an array given that the attribute
|
121
97
|
# is documented as an array but the input is not
|
122
|
-
if attributes[attribute_map[key]].is_a?(Array)
|
123
|
-
|
98
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
99
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
124
100
|
end
|
125
|
-
elsif !attributes[attribute_map[key]].nil?
|
126
|
-
|
101
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
102
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
103
|
+
elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
104
|
+
self.send("#{key}=", nil)
|
127
105
|
end
|
128
106
|
end
|
129
|
-
|
107
|
+
|
108
|
+
self
|
130
109
|
end
|
131
110
|
|
132
111
|
# Deserializes the data based on type
|
133
112
|
# @param string type Data type
|
134
113
|
# @param string value Value to be deserialized
|
135
114
|
# @return [Object] Deserialized data
|
136
|
-
def
|
115
|
+
def _deserialize(type, value)
|
137
116
|
case type.to_sym
|
138
|
-
when :
|
139
|
-
|
117
|
+
when :DateTime
|
118
|
+
DateTime.parse(value)
|
140
119
|
when :Date
|
141
120
|
Date.parse(value)
|
142
121
|
when :String
|
@@ -166,9 +145,7 @@ module GetAroundOwner
|
|
166
145
|
end
|
167
146
|
end
|
168
147
|
else # model
|
169
|
-
|
170
|
-
klass = GetAroundOwner.const_get(type)
|
171
|
-
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
148
|
+
GetAroundOwner.const_get(type).build_from_hash(value)
|
172
149
|
end
|
173
150
|
end
|
174
151
|
|
@@ -216,8 +193,5 @@ module GetAroundOwner
|
|
216
193
|
else
|
217
194
|
value
|
218
195
|
end
|
219
|
-
end
|
220
|
-
|
221
|
-
end
|
222
|
-
|
196
|
+
end end
|
223
197
|
end
|