Request / response

This page is applicable for the following endpoints:

Request parameters

Path variables

  • rental_type (string, required) The rental type: either pickup or return.
  • location_id (string, required) The location identifier: an unique identifier for the shop.
  • battery_id (string, required) The battery barcode on the back of the Chimpy (CODE128)
  • user_coupon (string, optional) The user coupon: it can take multiple forms (a QR code in the user mobile app, a swisspass, a free charge coupon in a sms, a paper coupon, etc.) and can lead to special deals (free charge) and / or in-app payments. Optional param.

Query parameters

  • lang (string, optional) The language to be used for the response. See Locales for more info.
  • slip_width (number, optional) The width of the sales slip in characters. Accepted values: 32, 42. Default/fallback value: 42.
  • partner_transaction_id (string, optional) An unique transaction id given by the partner terminal software. Optional param.
  • partner_terminal_id (string, optional) An unique id of the terminal where the rental is performed, according to the partner's numbering system. Optional param.
  • support_code (number, optional) During a return rental, a code to identify physical problems with the battery (example: cable missing). Currently supported values: 200 (cable missing).

Response

Response body

For HTTP status 200 OK the response body contains a JSON object with the following structure:

Response
Copy

Response items

  • status (string) The request status. Can be one of error, ready_for_pickup, ready_for_return, pickup_completed, return_completed.
  • error_type (string or null) The error type, expressed in a codified expression. It can be either null for a successful request or one of battery_non_existing, battery_not_rented_out, battery_already_returned, battery_expired, battery_already_used, user_hash_invalid, user_inactive, undefinedfor a failed request. See Error types for more.
  • error_message (string or null) The verbose description of the error in the requested locale. This field can be used to display an error on the screen.
  • rental_type (string) Either pickup or return.
  • coupon_type (string) Either free_charge or null. This field will be filled only if a valid user coupon that gives was used.
  • payment_via (string) Either app or shop.By default, the payment is carried out by the shop. But a user coupon may lead to a in-app payment (premium users, online coupon, etc.)
  • hashed_rental_id (string) A unique hash consisting of lowercase letters and numbers referencing a successful rental object. Can be used to retrieve a digital sales slip.
  • charge_currency (string) The currency used for the money transaction (ISO 4217 alphabetic currency code).
  • total_amounts (object of numbers) The total amounts of the transaction, listed by category. See Total amounts for more.
  • shop_provision (object of numbers) The previsional shop provision for the rental. Important note: a given rental may create provision amounts for other associated rentals (e.g. a return rental might create provision amounts for a pickup rental), thus the aggregation of this value over a period of time is not necessarily enough to calculate invoice amounts.
  • complete_slip (array of strings) The sales slip that can be printed, generated in the requested locale and with the requested slip width in characters.
  • slip_width (number) The slip width of the sales slip in characters.
  • number_of_lines (number) The length of the sales slip in lines.
  • locale (string) The locale as specified in the request. See Locales for more info.
  • req (object) Relevant information concerning the request received by the API.

Examples

The following request are all done using the GET method, hence they would not alter any database record. The response of the same requests done using the POST method would look exactly alike - except for the request status - and would create new records in the database.

Example I

A customer wants to pick up battery 10000001 at location sandbox_retail_fr_10001

Request - Pickup example
Copy

The battery can be picked up by the customer. Yay!

Response - Pickup example
Copy

Example II

A customer wants to pick up battery 10000001 at location sandbox_retail_ch_100001 with the valid free charge coupon greenaf000000

Request - Pickup with coupon
Copy

The coupon is valid and has been applied to the pricing

Response - Pickup with coupon
Copy

Example III

A customer wants to return battery 10000100 at location sandbox_retail_ch_100001

Request - Return example
Copy

The battery can be returned. The deposit to be reimbursed at the point of sale is CHF 15.

Response - Return example
Copy
Type to search, ESC to discard
Type to search, ESC to discard
Type to search, ESC to discard