Lager API documentation

  1. API keys
  2. Products
  3. Orders
  4. Order items
  5. Deliveries
  6. Invoices and Login
  7. Copier
  8. Code examples
  9. Local Installation

API keys

To request an API key:

GET /api_key?email=[YOUR_EMAIL]

Result:

{
    "data": {
        "key": "6eae78f64e3b6b9bfb2e3904469e8c30"
    }
}

Errors:

{
    "data": {
        "message": "Email address already used for api key.",
        "api_key": "1bdd5c943e664d399f2a298fca0dabfd"
    }
}

An API key is required for all requests except the following:

GET /
GET /api_key?email=[YOUR_EMAIL]

If an API key is not provided the following error is given:

{
    "errors": {
        "status": 401,
        "source": "/products",
        "title": "Valid API key",
        "detail": "No valid API key provided."
    }
}

Products

A product has the following attributes:

id
article_number
name
description
specifiers
stock
location
price
api_key

To get all your products:

GET /products?api_key=[YOUR_API_KEY]

Result:

{
    "data": [
        {
            "id": 1,
            "article_number": "1214-RNT",
            "name": "Skruv M14",
            "description": "Skruv M14, värmförsinkad",
            "specifiers": "{'length' : '60mm', 'width' : '14mm'}",
            "stock": 12,
            "location": "A1B4",
            "price": 10
        },
        {
            "id": 2,
            "article_number": "1212-RNT",
            "name": "Skruv M12",
            "description": "Skruv M12, värmförsinkad",
            "specifiers": "{'length' : '60mm', 'width' : '12mm'}",
            "stock": 14,
            "location": "A1B5",
            "price": 10
        },
        {
            "id": 3,
            "article_number": "1210-RNT",
            "name": "Skruv M10",
            "description": "Skruv M10, värmförsinkad",
            "specifiers": "{'length' : '60mm', 'width' : '10mm'}",
            "stock": 20,
            "location": "A1B6",
            "price": 10
        },
        {
            "id": 4,
            "article_number": "1208-RNT",
            "name": "Skruv M8",
            "description": "Skruv M8, värmförsinkad",
            "specifiers": "{'length' : '60mm', 'width' : '8mm'}",
            "stock": 2,
            "location": "A1B7",
            "price": 10
        },
        {
            "id": 5,
            "article_number": "1206-RNT",
            "name": "Skruv M6",
            "description": "Skruv M6, värmförsinkad",
            "specifiers": "{'length' : '60mm', 'width' : '6mm'}",
            "stock": 6,
            "location": "A1B8",
            "price": 10
        },
        {
            "id": 6,
            "article_number": "1214-TNT",
            "name": "Mutter M14",
            "description": "Mutter M14, värmförsinkad, passar 1214-RNT",
            "specifiers": "{'diameter' : '14mm'}",
            "stock": 13,
            "location": "A1C4",
            "price": 10
        },
        {
            "id": 7,
            "article_number": "1212-TNT",
            "name": "Mutter M12",
            "description": "Mutter M12, värmförsinkad, passar 1212-RNT",
            "specifiers": "{'diameter' : '12mm'}",
            "stock": 23,
            "location": "A1C4",
            "price": 10
        },
        {
            "id": 8,
            "article_number": "1210-TNT",
            "name": "Mutter M10",
            "description": "Mutter M10, värmförsinkad, passar 1210-RNT",
            "specifiers": "{'diameter' : '10mm'}",
            "stock": 12,
            "location": "A1C4",
            "price": 10
        },
        {
            "id": 9,
            "article_number": "1208-TNT",
            "name": "Mutter M8",
            "description": "Mutter M8, värmförsinkad, passar 1208-RNT",
            "specifiers": "{'diameter' : '8mm'}",
            "stock": 4,
            "location": "A1C4",
            "price": 10
        },
        {
            "id": 10,
            "article_number": "1206-TNT",
            "name": "Mutter M6",
            "description": "Mutter M6, värmförsinkad, passar 1206-RNT",
            "specifiers": "{'diameter' : '6mm'}",
            "stock": 1,
            "location": "A1C4",
            "price": 10
        }
    ]
}

To get a specific product:

GET /product/:product_id?api_key=[YOUR_API_KEY]

Result:

{
    "data": {
        "id": 1,
        "article_number": "1214-RNT",
        "name": "Skruv M14",
        "description": "Skruv M14, värmförsinkad",
        "specifiers": "{'length' : '60mm', 'width' : '14mm'}",
        "stock": 12,
        "location": "A1B4",
        "price": 10
    }
}

To search for a product:

GET /product/search/:query?api_key=[YOUR_API_KEY]

Result (search query was m14):

{
    "data": [
        {
            "id": 1,
            "article_number": "1214-RNT",
            "name": "Skruv M14",
            "description": "Skruv M14, värmförsinkad",
            "specifiers": "{'length' : '60mm', 'width' : '14mm'}",
            "stock": 12,
            "location": "A1B4",
            "price": 10
        },
        {
            "id": 6,
            "article_number": "1214-TNT",
            "name": "Mutter M14",
            "description": "Mutter M14, värmförsinkad, passar 1214-RNT",
            "specifiers": "{'diameter' : '14mm'}",
            "stock": 13,
            "location": "A1C4",
            "price": 10
        }
    ]
}

To add a product:

POST /product

Required parameters:

id
name
api_key

Optional parameters:

article_number
description
specifiers
stock
location
price

To update a product:

PUT /product

Required parameters:

id
name
api_key

Optional parameters:

name
article_number
description
specifiers
stock
location
price

N.B. All attributes are updated, send an entire product object.

Result:

HTTP Status Code 204 No Content

Possible error, besides errors returned from database:

{
    "errors": {
        "status": 400,
        "detail": "Required attribute product id (id) was not included in the request."
    }
}

To delete a product:

DELETE /product

Required parameters:

id
api_key

Result:

HTTP Status Code 204 No Content

Possible error, besides errors returned from database:

{
    "errors": {
        "status": 400,
        "detail": "Required attribute product id (id) was not included in the request."
    }
}

Orders

An order has the following attributes:

id
name
address
zip
city
country
status_id
api_key

Status

All orders have a status, it can take the following numeric values, corresponding to the descriptions. Orders have a default status value of 100.

100: "Ny"
200: "Packad"
400: "Skickad"
600: "Fakturerad"
800: "Retur"
900: "Återbetald"

To get all your orders and associated order items:

GET /orders?api_key=[YOUR_API_KEY]

Result:

{
  "data": [
    {
      "id": 1,
      "name": "Anders Andersson",
      "address": "Andersgatan 1",
      "zip": "12345",
      "city": "Anderstorp",
      "country": "Sweden",
      "status": "Ny",
      "status_id": 100,
      "order_items": [
        {
          "product_id": 1,
          "amount": 2,
          "article_number": "1214-RNT",
          "name": "Skruv M14",
          "description": "Skruv M14, värmförsinkad",
          "specifiers": "{'length' : '60mm', 'width' : '14mm'}",
          "stock": 12,
          "location": "A1B4",
          "price": 10
        },
        {
          "product_id": 2,
          "amount": 3,
          "article_number": "1212-RNT",
          "name": "Skruv M12",
          "description": "Skruv M12, värmförsinkad",
          "specifiers": "{'length' : '60mm', 'width' : '12mm'}",
          "stock": 14,
          "location": "A1B5",
          "price": 10
        }
      ]
    },
    {
      "id": 2,
      "name": "Bengt Bengtsson",
      "address": "Bengtsgatan 2",
      "zip": "23457",
      "city": "Bengtfors",
      "country": "Sweden",
      "status": "Ny",
      "status_id": 100,
      "order_items": [
        {
          "product_id": 3,
          "amount": 4,
          "article_number": "1210-RNT",
          "name": "Skruv M10",
          "description": "Skruv M10, värmförsinkad",
          "specifiers": "{'length' : '60mm', 'width' : '10mm'}",
          "stock": 20,
          "location": "A1B6",
          "price": 10
        }
      ]
    },
    {
      "id": 3,
      "name": "Carl Carlsson",
      "address": "Carlsgatan 3",
      "zip": "34567",
      "city": "Karlstad",
      "country": "Sweden",
      "status": "Ny",
      "status_id": 100,
      "order_items": [
        {
          "product_id": 6,
          "amount": 5,
          "article_number": "1214-TNT",
          "name": "Mutter M14",
          "description": "Mutter M14, värmförsinkad, passar 1214-RNT",
          "specifiers": "{'diameter' : '14mm'}",
          "stock": 13,
          "location": "A1C4",
          "price": 10
        }
      ]
    },
    {
      "id": 4,
      "name": "David Davidsson",
      "address": "Davidsallén 4",
      "zip": "45678",
      "city": "Davidstorp",
      "country": "Sweden",
      "status": "Ny",
      "status_id": 100,
      "order_items": [
        {
          "product_id": 8,
          "amount": 6,
          "article_number": "1210-TNT",
          "name": "Mutter M10",
          "description": "Mutter M10, värmförsinkad, passar 1210-RNT",
          "specifiers": "{'diameter' : '10mm'}",
          "stock": 12,
          "location": "A1C4",
          "price": 10
        }
      ]
    }
  ]
}

To get a specific order and associated order items:

GET /order/:order_id?api_key=[YOUR_API_KEY]

Result:

{
  "data": {
    "id": 1,
    "name": "Anders Andersson",
    "address": "Andersgatan 1",
    "zip": "12345",
    "city": "Anderstorp",
    "country": "Sweden",
    "status": "Ny",
    "status_id": 100,
    "order_items": [
      {
        "product_id": 1,
        "amount": 2,
        "article_number": "1214-RNT",
        "name": "Skruv M14",
        "description": "Skruv M14, värmförsinkad",
        "specifiers": "{'length' : '60mm', 'width' : '14mm'}",
        "stock": 12,
        "location": "A1B4",
        "price": 10
      },
      {
        "product_id": 2,
        "amount": 3,
        "article_number": "1212-RNT",
        "name": "Skruv M12",
        "description": "Skruv M12, värmförsinkad",
        "specifiers": "{'length' : '60mm', 'width' : '12mm'}",
        "stock": 14,
        "location": "A1B5",
        "price": 10
      }
    ]
  }
}

To search for an order and associated order items:

You can search on the following parameters: name, address, zip, city and country.

GET /order/search/:query?api_key=[YOUR_API_KEY]

Result (search query was anders):

{
  "data": [
    {
      "id": 1,
      "name": "Anders Andersson",
      "address": "Andersgatan 1",
      "zip": "12345",
      "city": "Anderstorp",
      "country": "Sweden",
      "status": "Ny",
      "status_id": 100,
      "order_items": [
        {
          "product_id": 1,
          "amount": 2,
          "article_number": "1214-RNT",
          "name": "Skruv M14",
          "description": "Skruv M14, värmförsinkad",
          "specifiers": "{'length' : '60mm', 'width' : '14mm'}",
          "stock": 12,
          "location": "A1B4",
          "price": 10
        },
        {
          "product_id": 2,
          "amount": 3,
          "article_number": "1212-RNT",
          "name": "Skruv M12",
          "description": "Skruv M12, värmförsinkad",
          "specifiers": "{'length' : '60mm', 'width' : '12mm'}",
          "stock": 14,
          "location": "A1B5",
          "price": 10
        }
      ]
    }
  ]
}

To add an order:

POST /order

Required parameters:

id
name
api_key

Optional parameters:

address
zip
city
country
status_id (default value of 100)

NB! Use a numeric status_id value to add status.

To update an order:

PUT /order

Required parameters:

id
name
api_key

Optional parameters:

name
address
zip
city
country
status_id (default value of 100)

NB! Use a numeric status_id value to update status.

N.B. All attributes are updated, send an entire order object. Send only the order parameters when updating an order. order_items are updated seperately, see order items

Result:

HTTP Status Code 204 No Content

Possible error, besides errors returned from database:

{
    "errors": {
        "status": 400,
        "detail": "Required attribute order id (id) was not included in the request."
    }
}

To delete an order and associated order items:

DELETE /order

Required parameters:

id
api_key

Result:

HTTP Status Code 204 No Content

Possible error, besides errors returned from database:

{
    "errors": {
        "status": 400,
        "detail": "Required attribute order id (id) was not included in the request."
    }
}

Order items

An order item has the following attributes:

order_id
product_id
amount
api_key

To add an order item to an order:

POST /order_item

Required parameters:

order_id
product_id
amount
api_key

To update an order item:

PUT /order

Required parameters:

order_id
product_id
api_key

Optional parameter:

amount

N.B. All attributes are updated, send an entire order object.

Result:

HTTP Status Code 204 No Content

Possible error, besides errors returned from database:

{
    "errors": {
        "status": 400,
        "detail": "Required attributes order_id and product_id was not included in the request."
    }
}

To delete an order item:

DELETE /order

Required parameters:

order_id
product_id
api_key

Result:

HTTP Status Code 204 No Content

Possible error, besides errors returned from database:

{
    "errors": {
        "status": 400,
        "detail": "Required attribute order id and product id was not included in the request."
    }
}

Deliveries

A delivery has the following attributes:

id
product_id
amount
delivery_date
comment
api_key

Get all deliveries

GET /deliveries?api_key=[YOUR_API_KEY]

Result

{
    "data": [
        {
            "id": 1,
            "product_id": 2,
            "amount": 10,
            "delivery_date": "2018-02-14",
            "comment": "Inleverans för Alla Hjärtans dag"
        }
    ]
}

Add a delivery

POST /delivery

Required parameters:

id
product_id
amount
delivery_date
api_key

Optional parameter:

comment

Result:

{
    "data": {
        "api_key": "...",
        "id": "1",
        "product_id": "2",
        "amount": "10",
        "delivery_date": "2018-02-14",
        "comment": "Inleverans för Alla Hjärtans dag"
    }
}

Invoices and Login

An invoice has the following attributes:

id
order_id
total_price
api_key

To use the following routes, you need a valid JSON Web Token (JWT) set in the HTTP-header.
The 'x-access-token' header should contain the JWT.

GET /invoices?api_key=[YOUR_API_KEY]
GET /invoice/:invoice_id?api_key=[YOUR_API_KEY]
POST /invoice

Register

POST /register

Required paramters:

api_key
email
password

Result:

{
    "data": {
        "message": "User successfully registered."
    }
}

Login

POST /login
api_key
email
password

Result:

{
    "data": {
        "type": "success",
        "message": "User logged in",
        "user": {
            "api_key": "...",
            "email": "unknown@example.com"
        },
        "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.ey..."
    }
}

N.B. The access token expires after 24 hours.

Get all invoices

GET /invoices?api_key=[YOUR_API_KEY]

Result:

{
    "data": [
        {
            "id": 1,
            "order_id": 1,
            "name": "Anders Andersson",
            "address": "Andersgatan 1",
            "zip": "12345",
            "city": "Anderstorp",
            "country": "Sweden",
            "total_price": 100
        }
    ]
}

Get specific invoice

GET /invoice/:invoice_id?api_key=[YOUR_API_KEY]

Result:

{
    "data": {
        "id": 1,
        "order_id": 1,
        "name": "Anders Andersson",
        "address": "Andersgatan 1",
        "zip": "12345",
        "city": "Anderstorp",
        "country": "Sweden",
        "total_price": 100
    }
}

Add invoice

POST /invoice

Required parameters:

id
order_id
total_price
api_key

Result:

{
    "data": {
        "api_key": "...",
        "id": "1",
        "order_id": "1",
        "total_price": "100"
    }
}

Copier

As always 'api_key' is a required parameter.

Copy products

POST /copy_products

Result:

{
    "data": [
        {
            "id": 1,
            "article_number": "1214-RNT",
            "name": "Skruv M14",
            "description": "Skruv M14, värmförsinkad",
            "specifiers": "{'length' : '60mm', 'width' : '14mm'}",
            "stock": 12,
            "location": "A1B4",
            "price": 10
        },
        {
            "id": 2,
            "article_number": "1212-RNT",
            "name": "Skruv M12",
            "description": "Skruv M12, värmförsinkad",
            "specifiers": "{'length' : '60mm', 'width' : '12mm'}",
            "stock": 14,
            "location": "A1B5",
            "price": 10
        },
        {
            "id": 3,
            "article_number": "1210-RNT",
            "name": "Skruv M10",
            "description": "Skruv M10, värmförsinkad",
            "specifiers": "{'length' : '60mm', 'width' : '10mm'}",
            "stock": 20,
            "location": "A1B6",
            "price": 10
        },
        {
            "id": 4,
            "article_number": "1208-RNT",
            "name": "Skruv M8",
            "description": "Skruv M8, värmförsinkad",
            "specifiers": "{'length' : '60mm', 'width' : '8mm'}",
            "stock": 2,
            "location": "A1B7",
            "price": 10
        },
        {
            "id": 5,
            "article_number": "1206-RNT",
            "name": "Skruv M6",
            "description": "Skruv M6, värmförsinkad",
            "specifiers": "{'length' : '60mm', 'width' : '6mm'}",
            "stock": 6,
            "location": "A1B8",
            "price": 10
        },
        {
            "id": 6,
            "article_number": "1214-TNT",
            "name": "Mutter M14",
            "description": "Mutter M14, värmförsinkad, passar 1214-RNT",
            "specifiers": "{'diameter' : '14mm'}",
            "stock": 13,
            "location": "A1C4",
            "price": 10
        },
        {
            "id": 7,
            "article_number": "1212-TNT",
            "name": "Mutter M12",
            "description": "Mutter M12, värmförsinkad, passar 1212-RNT",
            "specifiers": "{'diameter' : '12mm'}",
            "stock": 23,
            "location": "A1C4",
            "price": 10
        },
        {
            "id": 8,
            "article_number": "1210-TNT",
            "name": "Mutter M10",
            "description": "Mutter M10, värmförsinkad, passar 1210-RNT",
            "specifiers": "{'diameter' : '10mm'}",
            "stock": 12,
            "location": "A1C4",
            "price": 10
        },
        {
            "id": 9,
            "article_number": "1208-TNT",
            "name": "Mutter M8",
            "description": "Mutter M8, värmförsinkad, passar 1208-RNT",
            "specifiers": "{'diameter' : '8mm'}",
            "stock": 4,
            "location": "A1C4",
            "price": 10
        },
        {
            "id": 10,
            "article_number": "1206-TNT",
            "name": "Mutter M6",
            "description": "Mutter M6, värmförsinkad, passar 1206-RNT",
            "specifiers": "{'diameter' : '6mm'}",
            "stock": 1,
            "location": "A1C4",
            "price": 10
        }
    ]
}

Copy orders

POST /copy_orders

Result:

{
    "data": [
        {
            "id": 1,
            "name": "Anders Andersson",
            "address": "Andersgatan 1",
            "zip": "12345",
            "city": "Anderstorp",
            "country": "Sweden",
            "status": "Ny",
            "order_items": [
                {
                    "product_id": 1,
                    "amount": 2,
                    "article_number": "1214-RNT",
                    "name": "Skruv M14",
                    "description": "Skruv M14, värmförsinkad",
                    "specifiers": "{'length' : '60mm', 'width' : '14mm'}",
                    "stock": 12,
                    "location": "A1B4",
                    "price": 10
                },
                {
                    "product_id": 2,
                    "amount": 3,
                    "article_number": "1212-RNT",
                    "name": "Skruv M12",
                    "description": "Skruv M12, värmförsinkad",
                    "specifiers": "{'length' : '60mm', 'width' : '12mm'}",
                    "stock": 14,
                    "location": "A1B5",
                    "price": 10
                }
            ]
        },
        {
            "id": 2,
            "name": "Bengt Bengtsson",
            "address": "Bengtsgatan 2",
            "zip": "23457",
            "city": "Bengtfors",
            "country": "Sweden",
            "status": "Ny",
            "order_items": [
                {
                    "product_id": 3,
                    "amount": 4,
                    "article_number": "1210-RNT",
                    "name": "Skruv M10",
                    "description": "Skruv M10, värmförsinkad",
                    "specifiers": "{'length' : '60mm', 'width' : '10mm'}",
                    "stock": 20,
                    "location": "A1B6",
                    "price": 10
                }
            ]
        },
        {
            "id": 3,
            "name": "Carl Carlsson",
            "address": "Carlsgatan 3",
            "zip": "34567",
            "city": "Karlstad",
            "country": "Sweden",
            "status": "Ny",
            "order_items": [
                {
                    "product_id": 6,
                    "amount": 5,
                    "article_number": "1214-TNT",
                    "name": "Mutter M14",
                    "description": "Mutter M14, värmförsinkad, passar 1214-RNT",
                    "specifiers": "{'diameter' : '14mm'}",
                    "stock": 13,
                    "location": "A1C4",
                    "price": 10
                }
            ]
        },
        {
            "id": 4,
            "name": "David Davidsson",
            "address": "Davidsallén 4",
            "zip": "45678",
            "city": "Davidstorp",
            "country": "Sweden",
            "status": "Ny",
            "order_items": [
                {
                    "product_id": 8,
                    "amount": 6,
                    "article_number": "1210-TNT",
                    "name": "Mutter M10",
                    "description": "Mutter M10, värmförsinkad, passar 1210-RNT",
                    "specifiers": "{'diameter' : '10mm'}",
                    "stock": 12,
                    "location": "A1C4",
                    "price": 10
                }
            ]
        }
    ]
}

Copy products & orders

POST /copy_all

Result:

{
    "data": {
        "message": "Products and orders have been copied"
    }
}

Code Examples

All examples below show the following API calls:

GET /products
PUT /order
GET /invoices
  1. XMLHttpRequest
  2. fetch
  3. mithril m.request
  4. PHP curl
  5. curl

XMLHttpRequest

GET /products
                    var request = new XMLHttpRequest();

request.addEventListener("load", [callbackFunction]);
request.open("GET", "https://lager.emilfolino.se/products?api_key=[YOUR_API_KEY]");
request.send();
                
PUT /order
                    // Updating status for order, setting 200 as new status
var order = {
    id: 1,
    name: "Anders Andersson",
    address: "Andersgatan 1",
    zip: "12345",
    city: "Anderstorp",
    country: "Sweden",
    status_id: 200,
    api_key: [YOUR_API_KEY]
};
var json = JSON.stringify(order);

var request = new XMLHttpRequest();
request.addEventListener("load", [callbackFunction]);
request.open("PUT", "https://lager.emilfolino.se/order");
request.setRequestHeader('Content-type','application/json; charset=utf-8');
request.send(json);
                
POST /delivery
                    // Creating new delivery with id: 1
var delivery = {
    id: 1,
    product_id: 2,
    amount: 12,
    delivery_date: "2018-02-14",
    comment: "Delivery for Valentines Day",
    api_key: [YOUR_API_KEY]
};
var json = JSON.stringify(delivery);

var request = new XMLHttpRequest();
request.addEventListener("load", [callbackFunction]);
request.open("POST", "https://lager.emilfolino.se/delivery");
request.setRequestHeader('Content-type','application/json; charset=utf-8');
request.send(json);
                
GET /invoices
                    var token = [TOKEN]; // Token received during login
var request = new XMLHttpRequest();
request.addEventListener("load", [callbackFunction]);
request.open("GET", "https://lager.emilfolino.se/invoices?api_key=[YOUR_API_KEY]");
request.setRequestHeader('x-access-token', token);
request.send();
                

fetch

GET /products
                    fetch("https://lager.emilfolino.se/products?api_key=[YOUR_API_KEY]")
.then(function (response) {
    return response.json();
}).then(function(data) {

});
                
PUT /order
                    var order = {
    id: 1,
    name: "Anders Andersson",
    address: "Andersgatan 1",
    zip: "12345",
    city: "Anderstorp",
    country: "Sweden",
    status_id: 200,
    api_key: [YOUR_API_KEY]
};

fetch("https://lager.emilfolino.se/order", {
    body: JSON.stringify(order),
    headers: {
      'content-type': 'application/json'
    },
    method: 'PUT'
})
.then(function (response) {

});
                
POST /delivery
                    var delivery = {
    id: 1,
    product_id: 2,
    amount: 12,
    delivery_date: "2018-02-14",
    comment: "Delivery for Valentines Day",
    api_key: [YOUR_API_KEY]
};

fetch("https://lager.emilfolino.se/delivery", {
    body: JSON.stringify(delivery),
    headers: {
      'content-type': 'application/json'
    },
    method: 'POST'
})
.then(function (response) {

});
                
GET /invoices
                    fetch("https://lager.emilfolino.se/invoices?api_key=[YOUR_API_KEY]", {
    headers: {
      'x-access-token': [TOKEN]
    },
})
.then(function (response) {
    return response.json();
}).then(function(data) {

});
                

mithril m.request

GET /products
                    m.request({
    method: "GET",
    url: "https://lager.emilfolino.se/products?api_key=[YOUR_API_KEY]"
})
.then(function(result) {

});
                
PUT /order
                    var order = {
    id: 1,
    name: "Anders Andersson",
    address: "Andersgatan 1",
    zip: "12345",
    city: "Anderstorp",
    country: "Sweden",
    status_id: 200,
    api_key: [YOUR_API_KEY]
};

m.request({
    method: "PUT",
    url: "https://lager.emilfolino.se/order",
    data: order
});
                
POST /delivery
                    var delivery = {
    id: 1,
    product_id: 2,
    amount: 12,
    delivery_date: "2018-02-14",
    comment: "Delivery for Valentines Day",
    api_key: [YOUR_API_KEY]
};

m.request({
    method: "POST",
    url: "https://lager.emilfolino.se/delivery",
    data: delivery
});
                
GET /invoices
                    m.request({
    method: "GET",
    url: "https://lager.emilfolino.se/invoices?api_key=[YOUR_API_KEY]",
    headers: {
        'x-access-token': [TOKEN]
    }
})
.then(function(result) {

});
                

PHP curl

GET /products
                    $request = curl_init();

curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
curl_setopt($request, CURLOPT_URL, "https://lager.emilfolino.se/products?api_key=[YOUR_API_KEY]");
$result = curl_exec($request);
curl_close($request);

$obj = json_decode($result);
                

curl

GET /products
                    curl https://lager.emilfolino.se/products?api_key=[YOUR_API_KEY]
                

Local Installation

To get up and running do the following:

  1. Create the file db/orders.sqlite.
  2. Read the db/migrate.sql file into the db/orders.sqlite db.
  3. Optional: Read the db/seed.sql and db/status_seed.sql file into the db/orders.sqlite db.
  4. Run: npm install
  5. Run: npm start