Deal routes: advance, assign, lose
The Deal Verbs advance, assign, lose as api.sb routes, with inputs, result, refusals and an example.
Reference for Deal, one group of Deal routes.
Deal.advance
Advance moves a Deal to its next stage once every field that stage requires is filled. Verb page.
POST /{namespace}/ deals/ {deal}/ advancePath: deal. Body, as JSON: the other inputs. Emits Deal.advanced.
Inputs
| Input | Type | Required | Description |
|---|---|---|---|
deal | Deal | required | The Deal. |
stage | string | The target stage; omitted, the next one. |
Returns
| Output | Type | Required | Description |
|---|---|---|---|
deal | Deal | required | The Deal in its new stage. |
Refuses when
| Check | Error | Fix | Then call |
|---|---|---|---|
| The key is valid, but its scopes do not allow this operation. | forbidden | Use a key whose scopes cover the operation, or ask an owner of the namespace to grant them. | None. |
Example
curl -X POST https: //api.sb/ leaseline.app/ deals/ deal_NgACZ6DcII/ advance \
-H "Authorization: Bearer $STARTUP_BUILDER_API_KEY"{
"api": "https: //api.sb/ leaseline.app",
"deal": {
"$id": "https: //api.sb/ leaseline.app/ deals/ deal_NgACZ6DcII",
"$type": "Deal",
"status": "Open"
},
"action": {
"$id": "https: //api.sb/ leaseline.app/ actions/ act_br07HsG8MG",
"operation": "Deal.advance",
"status": "done"
},
"links": {
"self": "https: //api.sb/ leaseline.app/ actions/ act_br07HsG8MG"
}
}Deal.assign
Assign gives a Deal one owner Worker, who carries its next step until it is won or lost. Verb page.
POST /{namespace}/ deals/ {deal}/ assignPath: deal. Body, as JSON: the other inputs. Emits Deal.assigned.
Inputs
| Input | Type | Required | Description |
|---|---|---|---|
deal | Deal | required | The Deal. |
owner | Worker | The Worker to own it; omitted, the routing Policy picks. |
Returns
| Output | Type | Required | Description |
|---|---|---|---|
deal | Deal | required | The Deal, with its owner. |
Refuses when
| Check | Error | Fix | Then call |
|---|---|---|---|
| The key is valid, but its scopes do not allow this operation. | forbidden | Use a key whose scopes cover the operation, or ask an owner of the namespace to grant them. | None. |
Example
curl -X POST https: //api.sb/ leaseline.app/ deals/ deal_NgACZ6DcII/ assign \
-H "Authorization: Bearer $STARTUP_BUILDER_API_KEY"{
"api": "https: //api.sb/ leaseline.app",
"deal": {
"$id": "https: //api.sb/ leaseline.app/ deals/ deal_NgACZ6DcII",
"$type": "Deal",
"status": "Open"
},
"action": {
"$id": "https: //api.sb/ leaseline.app/ actions/ act_br07HsG8MG",
"operation": "Deal.assign",
"status": "done"
},
"links": {
"self": "https: //api.sb/ leaseline.app/ actions/ act_br07HsG8MG"
}
}Deal.lose
Lose closes a Deal as lost and records the reason the buyer gave. Verb page.
POST /{namespace}/ deals/ {deal}/ losePath: deal. Body, as JSON: the other inputs. Emits Deal.lost.
Inputs
| Input | Type | Required | Description |
|---|---|---|---|
deal | Deal | required | The open Deal. |
reason | text | required | Why the buyer passed. |
Returns
| Output | Type | Required | Description |
|---|---|---|---|
deal | Deal | required | The lost Deal. |
Refuses when
| Check | Error | Fix | Then call |
|---|---|---|---|
| The key is valid, but its scopes do not allow this operation. | forbidden | Use a key whose scopes cover the operation, or ask an owner of the namespace to grant them. | None. |
| The record is not in a state that allows this Verb, so the call is refused. | refused | Read the record, run the Verb that moves it to an allowed state, then retry. | None. |
Example
curl -X POST https: //api.sb/ leaseline.app/ deals/ deal_NgACZ6DcII/ lose \
-H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
-H "Content-Type: application/ json" \
-d '{"reason": "Example reason"}'{
"api": "https: //api.sb/ leaseline.app",
"deal": {
"$id": "https: //api.sb/ leaseline.app/ deals/ deal_NgACZ6DcII",
"$type": "Deal",
"status": "Lost"
},
"action": {
"$id": "https: //api.sb/ leaseline.app/ actions/ act_br07HsG8MG",
"operation": "Deal.lose",
"status": "done"
},
"links": {
"self": "https: //api.sb/ leaseline.app/ actions/ act_br07HsG8MG"
}
}