Help >

NoshPOS API Reference

Requirements

  • A NoshPOS API client ID and secret
  • Composer
  • Smarty

Installation

  1. Require the following packages in your composer:
    1. noshpos/apiwrapper
    2. smarty/smarty
    3. symfony/yaml
  2. Run composer install
  3. Load the wrapper namespace in your code: use NoshPOS\APIWrapper
  4. Instantiate the API wrapper using your client id, secret and project url: $noshpos = new NoshPOS($clientId, $clientSecret, $url).
  5. This is found by default in the noshpos-settings file.

Usage

  1. Now that the API wrapper is instatiated, use the $noshpos variable to start making calls for varying requests.
  2. Set $noshpos->returnDataArray()before making any calls to ensure that a php data array is returned.
  3. $noshPOS->customers()->get($pageSize, $pageIndex). By passing $pageSize 1 and $pageIndex 0, the wrapper would return one customer.

For example:

$products = $noshpos->products()->get();

Structure: $noshpos->[Endpoint Type]->[Request Type]

This would return a data array of all of the products related to the project.

Request Types

The API currently supports 4 types of requests which come at the end of a call. These include:

  • Get ->get()
  • Post ->post()
  • Put ->put()
  • Delete ->delete()

 

Endpoints

Note: When passing parameters through a request type, they should be passed as arrays. This array should be passed through the request as follows:

$productParams['limit'] = 2;
$noshpos->products()->get($productParams);

Otherwise, variables can be passed directly through the endpoint:

$userID = 2;
$userParams['c_firstname'] = 'Joe';
$noshpos->customer($userID)->put($userParams);

Get Something

Products

Get all products

->products()->get()
Route
GET /products

Optional Parameters

Parameter Name Description
limit Limit the number of rows returned
offset How many rows should be passed over

Get a product

->product($productId)->get()
Route
GET /product/{productId}

Product Categories

Get all categories

->categories()->get()
Route
GET /categories

Get a category

->categories($productCategoryId)->get()
Route
GET /categories/{productCategoryId}

Customers

Get all customers

->customers()->get()
Route
GET /customers

Get a Single Customer

->customer($customerID)->get()
Route
GET /customers/{customerID}

Addresses

Get all addresses for a customer

->addresses($customerId)->get()
Route
GET /addresses/{customerId}

Orders

Get all orders for a customer

->orders($customerId)->get()
Route
GET /orders/customer/{customerId}

Get one order

->getOrder($orderId)->get()
Route
GET /orders/{orderId}

Payment Methods

Get all payment methods

->payments()->get()
Route
GET /payments

Delivery Methods

Get all delivery methods

->deliveryMethods()->get()
Route
GET /shipping

Cart

Get the current cart

->cart()->get()
Route
GET /cart

Delivery Timeslots

Get delivery timeslots

->timeSlots()->get($timeslotParams)
Route
GET /timeslots

Modifiers

Get all modifier groups

->modifierGroups()->get()
Route
GET /modifiers

Get a modifier group

->getModifierGroup($modifierGroupId)->get()
Route
GET /modifiers/{modifierGroupId}

Get product modifier groups

->getProductModifierGroups($productId)->get()
Route
GET /modifiers/product/{productId}

Shop

Get shop information

->shop()->get()
Route
GET /shop

Publishing

Get a published post by slug

->getPosts($slug)->get()
Route
GET /publishing/getPosts/{slug}

Post Something

Customers

Customer login

Used to post a login request

->customerLogin()->post($customerParams);
Route
POST /customers/login 

Parameters

                     $customerParams['username']=$username;
                     $customerParams['password']=$password;
                

Create a new customer

->customers()->post($customerParams);
Route
POST /customers 

Parameters

                    $customerParams['c_firstname'] = $firstName; 
                    $customerParams['c_lastname'] = $lastName; 
                    $customerParams['c_email'] = $email; 
                    $customerParams['c_phone'] = $phoneNumber; 
                    $customerParams['c_pwd'] = $encrypted; // password hash, sha256
                    $customerParams['c_language'] = $languageId; // 1: English, 2: Chinese
                    $customerParams['c_date_created'] = date('Y-m-d H:i:s'); 
                    $customerParams['c_nborders'] = 0; 
                    $customerParams['c_comment'] = ''; 
                    $customerParams['c_fapiao'] = '';
                

Addresses

Create a new address

->addresses($customerId)->post($addressParams)
Route
POST /addresses/{customerId}

Parameters

                         $addressParams['client_add'] = $address;
                         $addressParams['client_add_cs'] = $crossStreet;
                    

Wechat Transaction

Store a wechat transaction

->wechatTransaction()->post($wechatTransactionParams)
Route
POST /wechat

Parameters

                        $wechatTransactionParams['order_id'] = $id;
                        $wechatTransactionParams['out_trade_number'] = $outTradeNumber;
                        $wechatTransactionParams['amount'] = $orderTotal;
                    

Orders

Create a new order

->order()->post($orderParams)
Route
POST /orders

Parameters

                        $orderParams  = [];
                        $orderParams['order_total'] = $orderTotal;
                        $orderParams['order_cart']  = $cartId;
                        $orderParams['order_delivery_type_id'] = $typeId;
                        $orderParams['order_password'] = $generatedPass;
                        $orderParams['order_fname'] = $firstName;
                        $orderParams['order_lname'] = $lastName;
                        $orderParams['order_email'] = $email;
                        $orderParams['order_phone'] = $phone;
                        $orderParams['order_add'] = $address;
                        $orderParams['order_add_cs'] = $addressCrossStreet;
                        $orderParams['order_add_note'] = $addressNote;
                        $orderParams['paymentMethodId'] = $paymentMethodId;
                        $orderParams['preorder_date'] = $date;
                        $orderParams['preorder_time_start'] = $startTime;
                        $orderParams['preorder_time_end'] = $endTime;
                        $orderParams['deliveryTimeslotId'] = $timeSlotId;
                        $orderParams['clientId']    = $customerId;
                        $orderParams['order_user']  = $customerId;
                        $orderParams['order_status'] = 0;
                    

Cart

Add items to the cart

->addCartItem($cartId)->post($productParams)
Route
POST /cart/item/{cartId}

Parameters

                        $productParams = []; 
                        $productParams['quantity'] = 1; 
                        $productParams['productId'] = $itemId; 
                        $productParams['add_items'] = $selectedItems; //additional items
                    

Vouchers / Discounts

Add a discount or a voucher to the cart

->addVoucher($cartId,$voucherCode,$customerId)->post()
Route
POST /cart/voucher/{cartId}/{voucherId}/{customerId}

Password Reset

Process password reset

->passwordReset()->post($resetParams)
Route
POST /password/reset

Parameters

                         $resetParams = []; 
                         $resetParams['step'] = $step; // 3 step process
                         $emailParams['email'] = $email;
                         $passwordParams['password_new'] = $password; 
                         $passwordParams['password_new_check'] = $confirm_password;
                    

Send Email

Send a generic email

->sendEmail()->post($emailParams)
Route
POST /email

Parameters

                        $emailParams = []; 
                        $emailParams['body'] = $body; 
                        $emailParams['sendTo'] = $email; 
                        $emailParams['subject'] = $subject;
                    

Put Something

Customers

Update a customer

->customer($customerId)->put($customerParams)
Route
PUT /customers/{$customerId}

Addresses

Update an address

->addresses($addressId)->put($addressParams)
Route
PUT /addresses/{addressId}

Parameters

                        $addressParams = []
                        $addressParams['client_add'] = $clientAddress;
                        $addressParams['client_add_cs'] = $crossStreet;
                        $addressParams['client_add_note'] = $addressNote;
                    

Cart Items

Update a cart item

->cartItem($cartItemId)->put($cartItemParams)
Route
PUT /cart/{cartId}

Parameters

                        $cartItemParams = [];
                        $cartItemParams['item_qt'] = $quantity;
                        $cartItemParams['itemPassword'] = $itemPassword;
                        $cartItemParams['productId'] = $productId;
                        $cartItemParams['cartItemId'] = $cartItemId;
                    

Delete Something

Addresses

Delete an address

->addresses($addressId)->delete()
Route
Delete /addresses/{addressId}

Cart Item

Delete a cart item

->cartItem($cartItemId)->delete()
Route
Delete /cart/item/{cartItemId}
Last updated: 2018-05-03 13:50:22