Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

Introduction

For integration purposes there are some APIs that are useful to import data into Plan & Go and also to be able to export.

Security / authentication

For each session, first get authenticated with /auth/generate/, then use the received token in the header for all the other calls. Like this:

curl https://dev-planandgo.di.no/pl/api/v-1/routePlan 
-H "Content-Type:application/json" 
-H "X-API-Token:olof:5f9a3609a5a295eff861d930a0c75bbee7991842" 
-d "{
    \"companyId\": 1,
    \"date\": '2015-12-04T00:00:00.000+0100',
    \"name\": \"Asker\"
}"

API-methods

# MethodURLDescriptionExample - RequestExample - Response
1

🔓

POST/auth/generate

Fetches an login-token that the application can use to gain access to the API.

Get the username/password from DI.

{
    "username": "olof",
    "password": "secret123"
}
{
	"token": "olof:5f9a3609a5a295eff861d930a0c75bbee7991842",
	"userId": 23432,
	"customerSystemId": 233,
	"roles: [...]
}
2

🔒

POST/routePlan

Create an empty route plan (for a given distribution date).

Create a route plan for each area (each plan has a given start-point).

{
    companyId: 1,
    date: '2015-12-04T00:00:00.000+0100',
    name: 'Asker'
}
{
	id: 344,
	date: '2015-12-04T00:00:00.000+0100',
	name: 'Asker',
	...
}
3🔒POST/routePlan/<rp_id>/customerSystem/<cs_id>

Create an empty file (prepare for a file-upload).

Step 1 in file upload.

{
    name: 'my-file-name.csv'
}
{
	id: 6722,
	name: 'my-file-name.csv',
	...
}
4🔒POST/file/<f_id>

Upload the content of the file you have prepared.

Filetypes supported:

  • .csv
  • .xls
  • .xlsx

Mimetype: multipart/form-data

Name the file-field: "file"

Step 2 in file upload.

 
{
	status: 'ok'
}
5🔒GET/customerSystem/<cs_id>/publishedDeliveries/<yyyy-mm-dd>

(warning) TODO

Fetch the published deliveries including the routename of each deliveries.

This will return deliveries across many routePlans, but only from published plans for the given distribution-date.

(question) What should be the key to recognise each delivery?

 

List of deliveries

[
	{
		orderId: '12452',
		routeName: 'Asker 1',
		...
	},
	...
]

Usage

When the deliveries are ready on your end

  • Generate a token for the session
  • Create an empty routeplan, to get a fresh routePlanId (do this for each area that has it's own starting point)
  • Create an empty file, to get a fresh fileId
  • Generate a file (using our file-spec) and post it with the fresh fileId
  • Look for status: 'ok' or handle errors

When the plan is optimized and published - at a agreed time

  • Generate a token for the session

  • Fetch the deliveries and extract the routename from there (for a given customerSystem and distribution-date)
  • No labels