Skip to content

Luna - General Rest API Endpoint Information

Generic non-language specific API information can be found here: Luna General RestAPI - Endpoint Information

Full API browser available at: Luna Rest API Explorer

A PHP client library for consuming the Luna Rest API and enquiry creation.

Supports the creation of enquiries with additional support for providing custom meta data. Which allows the referrer to provide dynamic enquiry details.

Download: Luna - PHP Rest API Library

Testing the API helper library

For example create a credentials file: credentials.php in the examples/* directory or declare the credentials in the example script example.php.

PHP
$credentials = array(
    'url' => "https://*/",
    'user' => "",
    'app_pass' => ""
);

Then run the examples/example_enquiry.php:

Bash
php example_enquiry.php

Import the Luna_WPAPI class and initialise:

PHP
$luna_wpapi = new LunaAPI($credentials['url'], $credentials['user'], $credentials['app_pass']);

You can enable optional debug flag to view various debug related messages/logs. Should only be used in development environment

PHP
$luna_wpapi = new LunaAPI($credentials['url'], $credentials['user'], $credentials['app_pass'], true);

The Luna API allows authorised third-party websites and applications to integrate with the Luna WMS platform. This means developers can create/read data to and from Luna WMS subject to permissions.

This is an API that uses JSON for serialization.

Making A Request

All URLs start with https://luna.oddineers.co.uk/.

Connections are secured with HTTPS. The path is prefixed with the API version. As newer revisions of the API are developed and released the endpoints version number will be incremented when breaking changes are made.

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.

Luna supports logins using:for second factor authentication environments:

  • Username + Password
  • Username + Application Password (for second factor authentication environments)

API Endpoints

For a working example see the included file: examples/example_enquiry.php.

Enquiries

Endpoints in the enquiry group include:

  • /enquiries/create
  • /enquiries/upload

Create Enquiry

POST /enquiries/create:

PHP
// Meta details; provide an array of associative arrays; keys required: id, label, value.
// is: is used to uniquely name a field; tip try to keep id's consistent within a case type. For example; Subsequent x case type submissions use consistent ID's.
// label: use this to define the question you asked.
// value: the value of the field.
$additions = array(
    array(
        "id" => 'test_address',
        "label" => 'Address',
        "value" => '8472 Someplace road, Test Land'
    ),
    array(
        "id" => 'weather',
        "label" => 'Weather that day?',
        "value" => 'Rain'
    ),
    // Repeat entries for additional fields.
);

// The main body of the request
$payload = array(
    'forename' => 'Test',
    'surname' => 'Person',
    'telephone_mobile' => '07000000001',
    'email' => "test@somewhere.com",
    'case_type' => 'example',
    'meta' => $additions,
    'marketing_lead_referer' => 'Luna',
    'marketing_campaign' => 'N/A',
    'marketing_keywords' => '',
    'marketing_detail' => 'Test from Luna_WPAPI (PHP)',
);

// Create an enquiry with the payload
$post_id = $luna_wpapi->create_enquiry($payload);

Upload file to Enquiry

POST /enquiries/upload:

PHP
// Example 1: Single file
$test_file = 'picture_1.jpg'; // Full or Relative Path to file
// Create a file attachment with the enquiry ID returned above or stored in your own system.
$data = $luna_wpapi->upload_enquiry_attachment($post_id, $test_file);

// Example 2: Multiple file
$test_files = array(
    'picture_1.jpg',
    'picture_2.jpg',
    'document_1.pdf',
);

foreach ($test_files as $file) {
    // Create a file attachment with the enquiry ID returned above or stored in your own system.
    $data = $luna_wpapi->upload_enquiry_attachment( $post_id, $test_file );
}