Make a delivery

Ok! this is a sequence of api calls to do a complete delivery.
To integrate into a sandbox environment our base url will be: https://api.sandbox.harborlockers.com
To integrate into a production environment it will be: https://api.harborlockers.com
  1. Let’s authenticate our Harbor API calls by getting an access token with scope service_provider as showed in Get Access Tokens

2. We’ll make sure our mobile app will be able to communicate with the Tower, so let’s get an access token with scope tower_access , also showed in Get Access Tokens .

Note

Mobile SDK is responsible for using this token to create a session with a Tower.

3. Let’s suppose one of your users wants to do a drop-off. The user probably wants to find a nearby location. So let the user select between all the nearby locations. Let’s get the list of locations.

# Query parameters => ?start=34.0,-118.0&end=35.0,-119.0
GET /api/v1/locations/in-area

Where start and end are two points form a rectangular area where to look at. The response will give us the list of locations with the information of availability too. So we will know how many lockers available are in every location.

4. Once the user selected a location. We should ask the user what kind of locker we want. Then you may want to reserve a locker to give him time to reach the location, let’s say 5 minutes

# first let's get a list of lockers with their status for the location
GET /api/v1/locations/{location_id}/lockers

# from the list, we select a locker_id and tower_id and make a reservation for 300 sec (5�min)
# Json request body => {'duration':300}. Number of seconds for the reservation
POST /api/v1/towers/{tower_id}/lockers/{locker_id}/reservations

4. Ok now we want to give the user the key to open the locker. Let’s give to the token life other 5 minutes.

# Json request body => {'duration':300, 'client_info':'info to associate with token'}
POST /api/v1/towers/{tower_id}/lockers/{locker_id}/dropoff-locker-tokens

Attention

If the token is not used, the locker will be in your possession until the token expires. So you may not want to exaggerate the token duration request

  1. Now the mobile SDK is responsible for connecting with the tower and using the token. Mobile SDKs

  2. The locker opens, the user puts the item inside, and closes the locker.

Note

Now the locker state is ‘occupied’ and will be in your possession until someone picks up the item.

7. Now the same or other user wants to pick up the item.

# Json request body => {'duration':300, 'client_info':'info to associate with token'}
POST /api/v1/towers/{tower_id}/lockers/{locker_id}/pickup-locker-tokens
  1. idem step 5

  2. The locker gets open, the user removes the item and closes the locker.

Congratulations! You had just made your first delivery!

Tip

You can always check all lockers in your possession with GET /api/v1/users/me/assigned-lockers