Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
339 lines (291 sloc) 11.1 KB

Assignment

Assignments are planned work, either autogenerated based on Agreements or manually created. Assignments are kept even after work has completed and then functions as a history of the work that has been executed, by whom, when etc.

If the organization is connected to a financial system then Previsto will do bookkeeping in the financial system for the assignments.

The assignment object

Example Response

{
  "id" : "asgmt-klJ23j4L23j43",
  "createdDate" : "2017-05-21T20:22:28.110Z",
  "meta" : { },
  "contactId" : "cont-242342DgHH2lkjkj23",
  "payingContactId" : "cont-242342DgHH2lkjkj23",
  "accountId" : "acct-dfEfdv3342FD",
  "action" : "None",
  "remoteOrderId" : null,
  "location" : [ 10.5286863, 56.8039035 ],
  "status" : "None",
  "plan": {
    "executionTime" : "2017-05-31T08:05",
    "indicativeDate" : "2017-05-29",
    "accountIds" : [],
    "indicativeDateType" : "Optimal",
  },
  "tasks" : [ {
    "agreementId" : "agrmt-DOKwO3VLJ6Sy3YxnlWop",
    "description" : "Pudsning2",
    "amount" : 20000,
    "duration" : 16,
    "workType" : "WindowCleaning"
  } ]
}
Field Type Required Description
id string No -
createdDate date No Date of creation.
contactId string Yes Id of the contact related to this assignment.
payingContactId string No Id of the contact paying for this assignment.
accountId string Yes Id of the account that reflects the worker that is scheduled to execute the assignment.
action string No Action taken on the assignment. None, Skippedor Completed.
remoteOrderId string No Id of the order created in the financial system.
location number[] Yes Array of 2 numbers holding longitude and latitude in specified order according to geojson syntax. (Fx. [11.543540954589844, 56.703469017862034])
status string No Financial status of this assignment. None, AppendedToOrder, Invoiced or Fulfilled.
plan assignment_plan No Planning details for the assignment.
tasks task[] No Array of task elements in this assignments.
timestamp date Yes Deprecated. Use plan.executionTime instead. Will be removed at 2019-04-01.
planningDate date No Deprecated. Use plan.indicativeDate instead. Will be removed at 2019-04-01.
planningDateType string No Deprecated. Use plan.indicativeDateType instead. Will be removed at 2019-04-01.
planningAccountIds string[] No Deprecated. Use plan.accountIds instead. Will be removed at 2019-04-01.

The assignment_plan object

Field Type Required Description
executionTime date Yes The planned time for executing this assignment.
indicativeDate date No Date for guiding planning of executionTime.
indicativeDateType string No Fixed for planning executionTime exact date of indicativeDate or Optimal for flexible planning that allows optimizing routes by planning executionTime some day within the same week as indicativeDate.
accountIds string[] No Ids of accounts reflecting the workers that should handle this assignment. Empty list allows all accounts.

The task object

Field Type Required Description
reference string No Reference for this task, fx the id of the agreement that is the base of this task.
description string No Description of the work.
unitPrice number No The amount to charge in 1⁄100 of the monetary unit (fx. cents or øre) without VAT.
duration number No The duration in minutes of the work. Minimum 3 minutes.
workType string No The type of work. Currently only 'WindowCleaning'.
amount number No Deprecated. Use unitPrice instead. Will be removed at 20190301.
agreementId string No Deprecated. Use reference instead. Will be removed at 20190301.

{% api-method method="post" host="https://api.previsto.io/assignments" path="/" %} {% api-method-summary %} Create an Assignment {% endapi-method-summary %}

{% api-method-description %} Creates a new assignment. Takes the assignment object in the body. {% endapi-method-description %}

{% api-method-spec %} {% api-method-request %} {% api-method-body-parameters %} {% api-method-parameter name="" type="object" required=true %} Assignment object. {% endapi-method-parameter %} {% endapi-method-body-parameters %} {% endapi-method-request %}

{% api-method-response %} {% api-method-response-example httpCode=200 %} {% api-method-response-example-description %}

{% endapi-method-response-example-description %}

{
  "id" : "asgmt-klJ23j4L23j43",
  "createdDate" : "2017-05-21T20:22:28.110Z",
  "meta" : { },
  "contactId" : "cont-242342DgHH2lkjkj23",
  "payingContactId" : "cont-242342DgHH2lkjkj23",
  "accountId" : "acct-dfEfdv3342FD",
  "action" : "None",
  "plan": {
    "executionTime" : "2017-05-31T08:05",
    "indicativeDate" : "2017-05-29",
    "accountIds" : [],
    "indicativeDateType" : "Optimal",
  },
  "remoteOrderId" : null,
  "location" : [ 10.5286863, 56.8039035 ],
  "status" : "None",
  "tasks" : [ ]
}

{% endapi-method-response-example %} {% endapi-method-response %} {% endapi-method-spec %} {% endapi-method %}

{% api-method method="get" host="https://api.previsto.io/assignments" path="/:id" %} {% api-method-summary %} Read an Assignment {% endapi-method-summary %}

{% api-method-description %} Retrieves a specific assignment by id. {% endapi-method-description %}

{% api-method-spec %} {% api-method-request %} {% api-method-path-parameters %} {% api-method-parameter name="id" type="string" required=true %} The id of the assignment to retrieve. {% endapi-method-parameter %} {% endapi-method-path-parameters %} {% endapi-method-request %}

{% api-method-response %} {% api-method-response-example httpCode=200 %} {% api-method-response-example-description %}

{% endapi-method-response-example-description %}

{
  "id" : "asgmt-klJ23j4L23j43",
  "createdDate" : "2017-05-21T20:22:28.110Z",
  "meta" : { },
  "contactId" : "cont-242342DgHH2lkjkj23",
  "payingContactId" : "cont-242342DgHH2lkjkj23",
  "accountId" : "acct-dfEfdv3342FD",
  "action" : "None",
  "plan": {
    "executionTime" : "2017-05-31T08:05",
    "indicativeDate" : "2017-05-29",
    "accountIds" : [],
    "indicativeDateType" : "Optimal",
  },
  "remoteOrderId" : null,
  "location" : [ 10.5286863, 56.8039035 ],
  "status" : "None",
  "tasks" : [ ]
}

{% endapi-method-response-example %} {% endapi-method-response %} {% endapi-method-spec %} {% endapi-method %}

{% api-method method="put" host="https://api.previsto.io/assignments" path="/:id" %} {% api-method-summary %} Update an Assignment {% endapi-method-summary %}

{% api-method-description %} Updates a specific assignment. Any parameters not provided will be left unchanged. {% endapi-method-description %}

{% api-method-spec %} {% api-method-request %} {% api-method-path-parameters %} {% api-method-parameter name="id" type="string" required=true %} The id of the assignment to update. {% endapi-method-parameter %} {% endapi-method-path-parameters %}

{% api-method-body-parameters %} {% api-method-parameter name="." type="object" required=false %} Assignment object. {% endapi-method-parameter %} {% endapi-method-body-parameters %} {% endapi-method-request %}

{% api-method-response %} {% api-method-response-example httpCode=200 %} {% api-method-response-example-description %}

{% endapi-method-response-example-description %}

{
  "id" : "asgmt-klJ23j4L23j43",
  "createdDate" : "2017-05-21T20:22:28.110Z",
  "meta" : { },
  "contactId" : "cont-242342DgHH2lkjkj23",
  "payingContactId" : "cont-242342DgHH2lkjkj23",
  "accountId" : "acct-dfEfdv3342FD",
  "action" : "None",
  "plan": {
    "executionTime" : "2017-05-31T08:05",
    "indicativeDate" : "2017-05-29",
    "accountIds" : [],
    "indicativeDateType" : "Optimal",
  },
  "remoteOrderId" : null,
  "location" : [ 10.5286863, 56.8039035 ],
  "status" : "None",
  "tasks" : [ {
    "agreementId" : "agrmt-DOKwO3VLJ6Sy3YxnlWop",
    "description" : "Pudsning2",
    "amount" : 20000,
    "duration" : 16,
    "workType" : "WindowCleaning"
  } ]
}

{% endapi-method-response-example %} {% endapi-method-response %} {% endapi-method-spec %} {% endapi-method %}

{% api-method method="delete" host="https://api.previsto.io/assignments" path="/:id" %} {% api-method-summary %} Delete an Assignment {% endapi-method-summary %}

{% api-method-description %} Deletes a specific assignment specified by id. {% endapi-method-description %}

{% api-method-spec %} {% api-method-request %} {% api-method-path-parameters %} {% api-method-parameter name="id" type="string" required=true %} Id of assignment to delete. {% endapi-method-parameter %} {% endapi-method-path-parameters %} {% endapi-method-request %}

{% api-method-response %} {% api-method-response-example httpCode=200 %} {% api-method-response-example-description %}

{% endapi-method-response-example-description %}


{% endapi-method-response-example %} {% endapi-method-response %} {% endapi-method-spec %} {% endapi-method %}

{% api-method method="get" host="https://api.previsto.io/assignments" path="/" %} {% api-method-summary %} List all assignments {% endapi-method-summary %}

{% api-method-description %} Retrieves an array of assignment objects. {% endapi-method-description %}

{% api-method-spec %} {% api-method-request %} {% api-method-path-parameters %} {% api-method-parameter name="page" type="number" required=false %} A zero-based cursor for use in pagination.Page is a number that defines your place in the list. {% endapi-method-parameter %}

{% api-method-parameter name="size" type="number" required=false %} A limit on the number of objects to return. Size can range between 1 and 100. Default is 20. {% endapi-method-parameter %} {% endapi-method-path-parameters %} {% endapi-method-request %}

{% api-method-response %} {% api-method-response-example httpCode=200 %} {% api-method-response-example-description %}

{% endapi-method-response-example-description %}

[
    {
        "id" : "asgmt-klJ23j4L23j43",
        "createdDate" : "2017-05-21T20:22:28.110Z",
        "meta" : { },
        "contactId" : "cont-242342DgHH2lkjkj23",
        "payingContactId" : "cont-242342DgHH2lkjkj23",
        "accountId" : "acct-dfEfdv3342FD",
        "action" : "None",
        "remoteOrderId" : null,
        "timestamp" : "2017-05-31T08:05",
        "location" : [ 10.5286863, 56.8039035 ],
        "status" : "None",
        "planningDate" : "2017-05-29",
        "planningAccountIds" : [],
        "planningDateType" : "Optimal",
        "tasks" : [ {
            "agreementId" : "agrmt-DOKwO3VLJ6Sy3YxnlWop",
            "description" : "Pudsning2",
            "amount" : 20000,
            "duration" : 16,
            "workType" : "WindowCleaning"
        } ]
    },
    {  },
    {  },
    "... And then as many results as available or requested"

]

{% endapi-method-response-example %} {% endapi-method-response %} {% endapi-method-spec %} {% endapi-method %}