Discounts

A discount record holds the following information:

  • rate
  • type
  • id
  • company_id

Getting Discounts

GET (/api/v2/finance/custom_discounts/:id()

  • statuscode 200

    no error

  • statuscode 404

    does not exist

Using Curl:

curl https://YOUR-SUBDOMAIN.administrateapp.com/api/v2/finance/custom_discounts/4     -k -u (login):(password)

Using PHP:

<?php
$credentials = '(username):(password)';
$url = 'https://YOUR-SUBDOMAIN.administrateapp.com/api/v2/finance/custom_discounts/4';
$options = array(
  'http' => array(
    'method'  => 'GET',
    'header'=>  "Accept: application/json\r\n" .
                "Authorization: Basic " . base64_encode($credentials)
    )
);
$context  = stream_context_create($options);
$result = file_get_contents($url, false, $context);
echo $result;

Using Python:

import json
import requests

response = requests.get('http://YOUR-SUBDOMAIN.administrateapp.com/api/v2/finance/custom_discounts/4',
                         auth=('<username>', '<password>'))

print response.json

Example response:

{
    "rate": 10.0,
    "type": "Discount A",
    "id": 4,
    "company_id": null
}

Getting more than one Discount

GET (/api/v2/finance/custom_discounts()

  • statuscode 200

    no error

  • statuscode 404

    does not exist

Using Curl:

curl https://YOUR-SUBDOMAIN.administrateapp.com/api/v2/finance/custom_discounts     -k -u (login):(password)

Using PHP:

<?php
$credentials = '(username):(password)';
$url = 'https://YOUR-SUBDOMAIN.administrateapp.com/api/v2/finance/custom_discounts';
$options = array(
  'http' => array(
    'method'  => 'GET',
    'header'=>  "Accept: application/json\r\n" .
                "Authorization: Basic " . base64_encode($credentials)
    )
);
$context  = stream_context_create($options);
$result = file_get_contents($url, false, $context);
echo $result;

Using Python:

import json
import requests

response = requests.get('http://YOUR-SUBDOMAIN.administrateapp.com/api/v2/finance/custom_discounts',
                         auth=('<username>', '<password>'))

print response.json

Example response:

[
    {
        "rate": 10.0,
        "type": "Discount A",
        "id": 2,
        "company_id": null
    },
    {
        "rate": 20.0,
        "type": "Discount B",
        "id": 3,
        "company_id": null
    }
]

Filtering

The results for a list of discounts can be filtered. See Filtering.

Creating Discounts

POST (/api/v2/finance/custom_discounts()

Required fields:

  • rate
  • type
  • statuscode 200

    no error

  • statuscode 404

    could not create

Using Curl:

curl https://YOUR-SUBDOMAIN.administrateapp.com/api/v2/finance/custom_discounts     -H "Content-Type: application/json"     -k -u (login):(password)     -X POST     -d '{"rate": 10.0, "type": "Discount A"}'

Using PHP:

<?php
$credentials = '(username):(password)';
$url = 'https://YOUR-SUBDOMAIN.administrateapp.com/api/v2/finance/custom_discounts';
$data = array("rate" => 10.0, "type" => u'Discount A');
$options = array(
'http' => array(
'method'  => 'POST',
'content' => json_encode($data),
'header'=>  "Content-Type: application/json\r\n" .
            "Accept: application/json\r\n" .
            "Authorization: Basic " . base64_encode($credentials)
)
);
$context  = stream_context_create($options);
$result = file_get_contents($url, false, $context);
echo $result;

Using Python:

import json
import requests

data = {u'rate': 10.0, u'type': u'Discount A'}

response = requests.post('http://YOUR-SUBDOMAIN.administrateapp.com/api/v2/finance/custom_discounts',
                        data=json.dumps(data),
                        headers={'content-type': 'application/json'},
                        auth=('<username>', '<password>'))

print response.json

Example response:

{
    "rate": 10.0,
    "type": "Discount A",
    "id": 4,
    "company_id": null
}

Updating Discounts

PUT (/api/v2/finance/custom_discounts/(int: id)

  • statuscode 200

    no error

  • statuscode 404

    does not exist

Using Curl:

curl https://YOUR-SUBDOMAIN.administrateapp.com/api/v2/finance/custom_discounts/6     -H "Content-Type: application/json"     -k -u (login):(password)     -X PUT     -d '{"type": "My new value for type"}'

Using PHP:

<?php
$credentials = '(username):(password)';
$url = 'https://YOUR-SUBDOMAIN.administrateapp.com/api/v2/finance/custom_discounts/6';
$data = array("type" => u'My new value for type');
$options = array(
'http' => array(
'method'  => 'PUT',
'content' => json_encode($data),
'header'=>  "Content-Type: application/json\r\n" .
            "Accept: application/json\r\n" .
            "Authorization: Basic " . base64_encode($credentials)
)
);
$context  = stream_context_create($options);
$result = file_get_contents($url, false, $context);
echo $result;

Using Python:

import json
import requests

data = {u'type': u'My new value for type'}

response = requests.put('http://YOUR-SUBDOMAIN.administrateapp.com/api/v2/finance/custom_discounts/6',
                        data=json.dumps(data),
                        headers={'content-type': 'application/json'},
                        auth=('<username>', '<password>'))

print response.json

Example response:

{
    "rate": 10.0,
    "type": "My new value for type",
    "id": 6,
    "company_id": null
}

Deleting Discounts

DELETE (/api/v2/finance/custom_discounts/(int: id)

  • statuscode 200

    deleted entity successfully

  • statuscode 404

    entity not found

Using Curl:

curl https://YOUR-SUBDOMAIN.administrateapp.com/api/v2/finance/custom_discounts/1     -X DELETE -k -u (login):(password)

Using PHP:

<?php
$credentials = '(username):(password)';
$url = 'https://YOUR-SUBDOMAIN.administrateapp.com/api/v2/finance/custom_discounts/1';
$options = array(
  'http' => array(
    'method'  => 'DELETE',
    'header'=>  "Accept: application/json\r\n" .
                "Authorization: Basic " . base64_encode($credentials)
    )
);
$context  = stream_context_create($options);
$result = file_get_contents($url, false, $context);
echo $result;

Using Python:

import json
import requests

response = requests.delete('http://YOUR-SUBDOMAIN.administrateapp.com/api/v2/finance/custom_discounts/1',
                         auth=('<username>', '<password>'))

print response.json

Example response:

{
    "rate": 10.0,
    "type": "Discount A",
    "id": 1,
    "company_id": null
}