Discount positions API

Introduction

Discount positions can be used on the following resources: estimates, orders and invoices. The resource URL is built like this:

/%parent_resource%/%parent_id%/kb_position_discount

If you have an invoice with ID 4 you should replace the placeholder %parent_resource% with kb_invoice and replace the placeholder %parent_id% with 4. Estimates will be used in the upcomming examples.

List discount positions

GET /kb_offer/1/kb_position_discount
Accept: application/json
Authorization: Bearer 677a1598d208d6c303fa5ca1c774709250e21749
Name Required Type Description
order_by optional string Sorting
limit optional integer Limit
offset optional integer Offset
callback optional string Javascript callback

The following sort parameters may be applied:

  • id

The following scopes are needed:

  • kb_invoice_edit
  • kb_offer_edit
  • kb_order_edit
  • kb_bill_edit
Status: 200 OK
X-Authenticated-User: apiextract_1
Content-Length: 245
Content-Type: application/json
[
  {
    "id": 1,
    "type": "KbPositionDiscount",
    "text": "Rabatt 10%",
    "is_percentual": true,
    "value": "10.0000",
    "discount_total": "1.9770"
  },
  {
    "id": 8,
    "type": "KbPositionDiscount",
    "text": "10% Rabatt",
    "is_percentual": true,
    "value": "10.0000",
    "discount_total": "1.7793"
  }
]

Search discount positions

POST /kb_offer/1/kb_position_discount/search
Accept: application/json
Authorization: Bearer 677a1598d208d6c303fa5ca1c774709250e21749
[
  {
    "field": "is_percentual",
    "value": true
  }
]
Name Required Type Description
order_by optional string Sorting
limit optional integer Limit
offset optional integer Offset
callback optional string Javascript callback

The following sort parameters may be applied:

  • id
Name Required Type Description
value optional string
is_percentual optional string
text optional string

The following scopes are needed:

  • kb_invoice_edit
  • kb_offer_edit
  • kb_order_edit
  • kb_bill_edit
Status: 200 OK
X-Authenticated-User: apiextract_1
Content-Length: 2
Content-Type: application/json
[

]

Show discount position

GET /kb_offer/1/kb_position_discount/8
Accept: application/json
Authorization: Bearer 677a1598d208d6c303fa5ca1c774709250e21749
Name Required Type Description
callback optional string Javascript callback

The following scopes are needed:

  • kb_invoice_edit
  • kb_offer_edit
  • kb_order_edit
  • kb_bill_edit
Status: 200 OK
X-Authenticated-User: apiextract_1
Content-Length: 121
Content-Type: application/json
{
  "id": 8,
  "type": "KbPositionDiscount",
  "text": "10% Rabatt",
  "is_percentual": true,
  "value": "10.0000",
  "discount_total": "1.7793"
}

Create discount position

POST /kb_offer/1/kb_position_discount
Accept: application/json
Authorization: Bearer 677a1598d208d6c303fa5ca1c774709250e21749
{
  "is_percentual": true,
  "value": 10,
  "text": "10% Rabatt"
}
Name Required Type Description
callback optional string Javascript callback
Name Required Type Description
value required decimal
is_percentual optional boolean
text optional string (500)

The following scopes are needed:

  • kb_invoice_edit
  • kb_offer_edit
  • kb_order_edit
  • kb_bill_edit
Status: 201 Created
X-Authenticated-User: apiextract_1
Content-Length: 116
Content-Type: application/json
{
  "id": 8,
  "type": "KbPositionDiscount",
  "text": "10% Rabatt",
  "is_percentual": true,
  "value": "10",
  "discount_total": "1.7793"
}

Overwrite discount position

PUT /kb_offer/1/kb_position_discount/8
Accept: application/json
Authorization: Bearer 677a1598d208d6c303fa5ca1c774709250e21749
{
  "is_percentual": true,
  "value": 10,
  "text": "10% Rabatt"
}
Name Required Type Description
callback optional string
Name Required Type Description
value required decimal
is_percentual optional boolean
text optional string (500)

The following scopes are needed:

  • kb_invoice_edit
  • kb_offer_edit
  • kb_order_edit
  • kb_bill_edit
Status: 200 OK
X-Authenticated-User: apiextract_1
Content-Length: 116
Content-Type: application/json
{
  "id": 8,
  "type": "KbPositionDiscount",
  "text": "10% Rabatt",
  "is_percentual": true,
  "value": "10",
  "discount_total": "1.7793"
}

Edit discount position

POST /kb_offer/1/kb_position_discount/8
Accept: application/json
Authorization: Bearer 677a1598d208d6c303fa5ca1c774709250e21749
{
  "is_percentual": false,
  "text": "10 CHF Rabatt"
}
Name Required Type Description
callback optional string Javascript callback
Name Required Type Description
is_percentual optional boolean
text optional string (500)
value optional decimal

The following scopes are needed:

  • kb_invoice_edit
  • kb_offer_edit
  • kb_order_edit
  • kb_bill_edit
Status: 200 OK
X-Authenticated-User: apiextract_1
Content-Length: 126
Content-Type: application/json
{
  "id": 8,
  "type": "KbPositionDiscount",
  "text": "10 CHF Rabatt",
  "is_percentual": false,
  "value": "10.0000",
  "discount_total": "10.0000"
}

Delete discount position

DELETE /kb_offer/1/kb_position_discount/8
Accept: application/json
Authorization: Bearer 677a1598d208d6c303fa5ca1c774709250e21749
Name Required Type Description
callback optional string Javascript callback

The following scopes are needed:

  • kb_invoice_edit
  • kb_offer_edit
  • kb_order_edit
  • kb_bill_edit
Status: 200 OK
X-Authenticated-User: apiextract_1
Content-Length: 16
Content-Type: application/json
{
  "success": true
}