Skip to content

Luna - Enquiry Rest API Library PHP

The Luna API allows third-party websites and applications to integrate with the Luna WMS platform.

Full API browser available at: Luna Rest API Explorer

Making A Request

Requests are POST based using JSON serialised payloads. All connections are secured over HTTPS.

This document outlines how to use the Luna Enquiry API in a generic manner; translating this to your chosen language may require some slight adjustments. The examples are in cURL.

Authentication

A Luna API requires authentication to successfully process your request. API Keys are managed and created by your integration manager; if you have any issues with the API key/secret then please contact a member of the team from Oddineers.

Data

The enquiry data is then sent as POST request to the API.

The Body should be JSON parameters. All available API URLs accept and return JSON data.

API Endpoints

Enquiries

Endpoints in the enquiry group include:

  • https://luna.oddineers.co.uk/wp-json/luna/v1/enquiries/create
  • https://luna.oddineers.co.uk/wp-json/luna/v1/enquiries/upload

Create Enquiry

URL: https://luna.oddineers.co.uk/wp-json/luna/v1/enquiries/create

Creates a new enquiry and returns a post_id on success; you should store store/retain this ID as both a confirmation and to process file submissions.

POST based requests as JSON to /enquiries/create:

Request Headers

A base64-encoded string comprising of your username:password

Text Only
Authorization Basic 

Body raw (json)

JSON
{
    "forename": "Test",
    "surname": "Person",
    "telephone_mobile": "07000000001",
    "email": "test@somewhere.com",
    "case_type": "example",
    "meta": [
        {
            "id": "type",
            "label": "The type",
            "value": "Brick"
        },
        {
            "id": "condition",
            "label": "The condition?",
            "value": "Normal"
        }
    ],
    "marketing_lead_referer": "Luna",
    "marketing_campaign": "N\/A",
    "marketing_keywords": "",
    "marketing_detail": "Extras details here."
}

cURL Example

Bash
curl --location --request POST 'https://luna.oddineers.co.uk/wp-json/luna/v1/enquiries/create' \
--header 'Authorization: Basic ' \
--header 'Content-Type: application/json' \
--data-raw '{
    "forename": "Test",
    "surname": "Person",
    "telephone_mobile": "07000000001",
    "email": "test@somewhere.com",
    "case_type": "example",
    "meta": [
        {
            "id": "test_address",
            "label": "Address",
            "value": "8472 Someplace road, Test Land"
        },
        {
            "id": "weather",
            "label": "Weather that day?",
            "value": "Rain"
        }
    ],
    "marketing_lead_referer": "Luna",
    "marketing_campaign": "N\/A",
    "marketing_keywords": "",
    "marketing_detail": "Extras details here."
}'

Response on success

JSON
{
    "code": 201,
    "status": "Created enquiry",
    "result": 1234
}

Upload a file to an Enquiry

Requires a post_id from a previously submitted enquiry, and a file to upload.

Supported files include: 'pdf', 'png', 'gif', 'jpeg'

There is no support for Audio Video based file types at this time. Where appropriate you should convert files to PDF.

Tip: files should be checked that they exist before being passed to the API client.

POST based requests as JSON to /enquiries/upload:

Request Headers

A base64-encoded string comprising of your username:password

Text Only
Authorization Basic 

Body raw (json)

The value of the contents should be the file data encoded as BASE64 utf8 then encoded JSON:

JSON
{
  "post_id": "some-id",
  "file": {
    "name": "picture_1.jpg",
    "mime": "image/jpeg",
    "postname": "picture_1.jpg"
  },
  "contents": "The file contents should be read to a variable the encoded as UTF8 then encoded as JSON."
}

cURL Example

The contents in this example is a 1px x 1px jpg image encoded as BASE64 utf8 :

Bash
curl --location --request POST 'https://luna.oddineers.co.uk/wp-json/luna/v1/enquiries/upload' \
--header 'Authorization: Basic ' \
--header 'Content-Type: application/json' \
--data-raw '{
    "post_id": "1234",
    "file": {
        "name": "picture_1.jpg",
        "mime": "image\/jpeg",
        "postname": "picture_1.jpg"
    },
    "contents": "\u00ff\u00d8\u00ff\u00e0\u0000\u0010JFIF\u0000\u0001\u0001\u0001\u0000`\u0000`\u0000\u0000\u00ff\u00db\u0000C\u0000\b\u0006\u0006\u0007\u0006\u0005\b\u0007\u0007\u0007\t\t\b\n\f\u0014\r\f\u000b\u000b\f\u0019\u0012\u0013\u000f\u0014\u001d\u001a\u001f\u001e\u001d\u001a\u001c\u001c $.'\'' \",#\u001c\u001c(7),01444\u001f'\''9=82

Response on Success

JSON
{
    "code": 201,
    "status": "Accepted",
    "result": 1235
}

Invalid Responses

Missing required parameters

JSON
{
    "code": 400,
    "status": "Required parameter `forename` missing or empty.",
    "result": false
}

Empty file content

JSON
{
    "code": 400,
    "status": "File content is empty checks encoding on `contents` parameter.",
    "result": false
}

Unauthorised access response

JSON
{
    "code": 401,
    "message": "User Authentication required to access the REST API.",
    "data": {
        "status": "rest_cannot_access"
    }
}