WeSupply API Documentation

The WeSupply API allows you to push arbitrary data into WeSupply system. We built it using REST principles for simplicity.
This API accepts and returns valid JSON for all its methods. Each method uses a standard HTTP verb (GET/POST) and uses standard HTTP response codes for returning statuses.

Authentication

Authentication with the Data Import API is done with a generated token. You can create this token by using your client_id and client_secret params, and "client_credentials" as grant_type

<?php

$url = "https://wesupply_client_url/api/oauth/token";
$clienttoken_post = array(
    "grant_type" => "client_credentials",
    "client_id" => 'your_client_id',
    "client_secret" => 'your_client_secret'
);

$curl = curl_init();
curl_setopt_array($curl, array(
    CURLOPT_URL => $url,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_POSTFIELDS => http_build_query($clienttoken_post),
    CURLOPT_HTTPHEADER => array(
        "cache-control: no-cache",
        "content-type: application/x-www-form-urlencoded"

    ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
    echo "cURL Error #:" . $err;
} else {
    echo $response;
}
?>

Return Codes

Codes in the 2xx range indicate a successful transaction, codes in the 4xx range indicate a bad request, and codes in the 5xx range indicate an error on our end. If errors in the 5xx range persist, please contact RJMetrics support.

400 Bad request - Your request was missing a required parameter.
401 Unauthorized - Authorization failed. Double check your access token.
404 Not Found - The resource you are looking for does not exist.
503 Error - Something wrong with the orders xml structure - you will receive a specific error description pointing out the cause of the error

Pull vs Push Order Data

In WeSupply, you have the option to pull or to push order information from your store to WeSupply app.
Push - you send us the order info from your store whenever you want, by making use of our API solution
Pull - you make the API on your website, and WeSupply pulls the info automatically from there

Order Import API Pull

The API Pull operation allows WeSupply. to retrive order information from your store

GetChangedOrdersByDateRangeAdvanced

The GetChangedOrdersByDateRangeAdvanced operation allows us to retrieve modified customer orders for a specified order date range.

Returns XML containing modified order information, for a specified date range.

This example demonstrates how GetChangedOrdersByDateRangeAdvanced can be used to retrieve modified customer orders for a specified order date range. Customer information will also be returned, if desired.

https://yourdomain.com/GetChangedOrdersByDateRangeAdvanced?ClientName={ClientName}&guid={GUIDValue}&DateStart={DateStart}&DateEnd={DateEnd}
Request Parameters

Request parameters specify the terms of your request and control the output data that is returned to you.
You must include all the parameters in every request.
The following parameters are specific to the GetChangedOrdersByDateRangeAdvanced operation:

Parameter Description Value
ClientName The exact name of the client consuming the method. WeSupply provided and defined. Client Name
Guid The API access key as defined and provided by WeSupply GUID Value
DateStart Start date of query 2017-01-19 10:23:12
DateEnd End date of query 2017-01-19 10:25:12

GetOrderByOrderNumber

The GetOrderByOrderNumber operation allows you to retrieve a specified customer order number or external order id.

This example demonstrates how GetOrderByOrderNumber can be used to retrieve a specified customer order number or external order id.

https://yourdomain.com/GetOrderByOrderNumber?ClientName={ClientName}&guid={GUIDValue}&OrderNumber={OrderNumber}
Request Parameters

Request parameters specify the terms of your request and control the output data that is returned to you.
You must include all the parameters in every request.
The following parameters are specific to the GetOrderByOrderNumber operation:

Parameter Description Value
ClientName The exact name of the client consuming the method. WeSupply provided and defined. Client Name
Guid The API access key as defined and provided by WeSupply GUID Value
OrderNumber One or more Order Numbers or External Order IDs - 1 at a time or delimited by comma if more than 1. 10001

Response

Parameter Description
<Orders>						
	<Order>					
		<StoreId>1</StoreId>				
		<WesupplyUpdatedAt>2018-02-05 20:43:41</WesupplyUpdatedAt>				
		<LastModifiedDate>2018-02-02 16:42:52</LastModifiedDate>				
		<OrderModified>2018-02-02 16:42:52</OrderModified>				
		<OrderPaymentTypeId/>				
		<OrderID>2</OrderID>				
		<OrderNumber>000000002</OrderNumber>				
		<OrderContact>Veronica Costello</OrderContact>				
		<FirstName>Veronica</FirstName>				
		<LastName>Costello</LastName>				
		<OrderDate>2018-02-02 16:42:51</OrderDate>				
		<OrderAmount>32.0000</OrderAmount>				
		<OrderAmountShipping>5.0000</OrderAmountShipping>				
		<OrderAmountTax>2.6400</OrderAmountTax>				
		<OrderAmountTotal>39.6400</OrderAmountTotal>				
		<OrderAmountCoupon>0</OrderAmountCoupon>				
		<OrderAmountGiftCard>0</OrderAmountGiftCard>				
		<OrderAmountCredit>				
		<OrderShippingAddress1>6146 Honey Bluff Parkway</OrderShippingAddress1>				
		<OrderShippingAddress2>				
		<OrderShippingCity>Calder</OrderShippingCity>				
		<OrderShippingStateProvince>Michigan</OrderShippingStateProvince>				
		<OrderShippingZip>49628-7978</OrderShippingZip>				
		<OrderShippingPhone>(555) 229-3326</OrderShippingPhone>				
		<OrderShippingCountry>United States</OrderShippingCountry>				
		<OrderShippingCountryCode>US</OrderShippingCountryCode>				
		<OrderPaymentType>Check / Money order</OrderPaymentType>				
		<OrderCardNumber/>				
		<OrderCardExp/>				
		<OrderCardType/>				
		<OrderGiftCardNumber/>				
		<OrderGiftWrapping>false</OrderGiftWrapping>				
		<OrderGiftWrappingCost>0</OrderGiftWrappingCost>				
		<OrderGiftWrappingMessage/>				
		<OrderDiscountDetailsTotal>0.0000</OrderDiscountDetailsTotal>				
		<OrderExternalOrderID>000000002</OrderExternalOrderID>				
		<OrderComeFrom>				
		<OrderSalesPerson/>				
		<OrderSalesPersonNumber/>				
		<OrderStatus>Closed</OrderStatus>				
		<OrderStatusId>2</OrderStatusId>				
		<OrderCustom1>				
		<OrderCustom2>				
		<OrderCustom3>				
		<OrderCustom4>				
		<OrderCustom5>				
		<OrderNotes>				
			<OrderCustomer>			
				<CustomerCompany>		
				<CustomerName>Veronica Costello</CustomerName>		
				<CustomerFirstName>Veronica</CustomerFirstName>		
				<CustomerLastName>Costello</CustomerLastName>		
				<CustomerAddress1>314 Washington Pl</CustomerAddress1>		
				<CustomerAddress2/>		
				<CustomerCity>Hasbrouck Heights</CustomerCity>		
				<CustomerStateProvince>NJ</CustomerStateProvince>		
				<CustomerPostalCode>49628-7978</CustomerPostalCode>		
				<CustomerCountry>USA</CustomerCountry>		
				<CustomerCountryCode>US</CustomerCountryCode>		
				<CustomerEmail>roni_cost@example.com</CustomerEmail>		
				<CustomerPhone>7327405970</CustomerPhone>		
				<CustomerShippingAddresses>		
					<CustomerShippingAddress>	
						<AddressID>3</AddressID>
						<AddressContact>Veronica Costello</AddressContact>
						<AddressAddress1>6146 Honey Bluff Parkway</AddressAddress1>
						<AddressAddress2>
						<AddressCity>Calder</AddressCity>
						<AddressState>Michigan</AddressState>
						<AddressZip>49628-7978</AddressZip>
						<AddressCountry>United States</AddressCountry>
						<AddressCountryCode>US</AddressCountryCode>
						<AddressPhone>(555) 229-3326</AddressPhone>
					</CustomerShippingAddress>	
				</CustomerShippingAddresses>		
			</OrderCustomer>			
		<OrderItems>				
			<Item>			
				<ItemID>2</ItemID>		
				<ItemName>		
				<ItemSKU>		
				<ItemUPC>		
				<ItemStyleNo>		
				<ItemPrice>32.0000</ItemPrice>		
				<ItemAddressID>3</ItemAddressID>
				<LineItemNumber>		
				<Option1>Size: XS Color: Blue</Option1>		
				<Option2>Color: Blue</Option2>		
				<Option3>		
				<Option4>		
				<Option5>		
					<ItemProduct>	
						<ProductID>1497</ProductID>
						<ProductCode>Minerva LumaTech™ V-Tee</ProductCode>
						<ProductImageURL>1497</ProductImageURL>
						<ProductPartNo>WS08-XS-Blue</ProductPartNo>
						<ProductUPC>
						<ProductStyleNo>
						<ProductXtra1>
						<ProductXtra2>
						<ProductXtra3>
						<ProductXtra4>
						<ProductXtra5>
					</ItemProduct>	
				<ItemQuantity>1.0000</ItemQuantity>		
				<ItemShippingService>UPS SurePost 1 lb or Greater</ItemShippingService>		
				<ItemShippingTracking>1ZY45F73YW99798395</ItemShippingTracking>		
				<ItemTotal>32.0000</ItemTotal>		
				<ItemTax>2.6400</ItemTax>		
				<ItemCouponAmount>0.0000</ItemCouponAmount>		
				<ItemStatus>Refunded</ItemStatus>		
				<ItemStatusId>2</ItemStatusId>		
				<ItemNotes/>		
				<ItemReturnReason/>		
				<ItemReturnStatus/>		
				<ItemReturnType/>		
				<ItemSupplierCode>KicksUSA-Orange</ItemSupplierCode>		
				<ItemLevelSupplierID>1685</ItemLevelSupplierID>		
				<ItemLevelSupplierName>1037</ItemLevelSupplierName>		
				<CustomData1/>		
				<CustomData2/>		
				<CustomData3/>		
				<CustomData4/>		
				<CustomData5/>		
			</Item>			
		</OrderItems>				
	</Order>					
	<Response>					
		<ResponseHasErrors>false</ResponseHasErrors>				
		<ResponseCode>SUCCESS</ResponseCode>				
		<ResponseDescription/>				
	</Response>					
</Orders>						
										


If Multistore set store ID value, ex. 1, 2, 3. else : 1
Last Modified Order Date
Last Modified Order Date
Last Modified Order Date
Payment Type ID
Order ID
Order Number Internal (if inexistent then External)
Customer First and Last Name
Customer First Name
Customer Last Name
Order Creation Date
Order Amount (Subtotal)
Shipping Amount
Order Total Tax Amount
Order Grand Total
Order Coupon Amount (Discount)
Order Gift Card Amount
Order Store Credit Amount
Order Shipping Address Line 1
Order Shipping Address Line 2
Order Shipping City
Order Shipping State
Order Shipping Zip Code
Order Shipping Phone Number
Order Shipping Country
Order Shipping Country Code
Order Payment Type: CC / GC / COD
CC Last 4 digits
CC Expiration Date
CC Type
Gift Card Number
Gift Wrapping
Gift Wrapping Cost
Gift Wrapping Message
Order Discount Amount
Order Number (External order number such as Ecomm platform order number)
Order Source
Order Sales Person
Order Sales Person Number (ID)
Order Status (Processing / Canceled / Shipped / Returned)
Order Status ID
Order Custom Data
Order Custom Data
Order Custom Data
Order Custom Data
Order Custom Data
Order Comments (notes)

Customer Billing Company
Customer Billing First and Last Name
Customer Billing First Name
Customer Billing Last Name
Customer Billing Address 1
Customer Billing Address 2
Customer Billing City
Customer Billing State
Customer Billing Zip Code
Customer Billing Country
Customer Billing Country Code
Customer Billing Email
Customer Billing Phone Number


Customer Shipping Address ID
Customer Shipping Address First and Last Name
Customer Shipping Address Line 1
Customer Shipping Address Line 2
Customer Shipping Address City
Customer Shipping Address State
Customer Shipping Address ZIP
Customer Shipping Address Country
Customer Shipping Address Contry Code
Customer Shipping Address Phone Number





Order Item ID
Order Item Name
Order Item SKU
Order Item UPC
Order Item Style No
Order Item Price
Order Item Shipping Address ID
Order Item Line Item Number
Order Item Variables





Order Item Variable ID
Order Item Variable Name
Order Item Variable Image external URL
Order Item Variant SKU
Order Item Variant UPC
Order Item Variant Style No






Order Item QTY
Order Item Shipping Method
Order Item Shipping Tracking Number
Order Item Total Amount
Order Item Tax Amount
Order Item Discount Amount
Order Item Status
Order Item Status ID
Item Notes
Item Return Reason
Item Return Status
Item Return Type
Item Supplier (shipping location)
Item Supplier ID
Item Supplier Name
Custom Data
Custom Data
Custom Data
Custom Data
Custom Data




If Order Inquiry has error
Order Inquiry response code
Order Inquiry response description


Order Import API Push

The API Push operation allows you to send external orders to WeSupply.

<?php

$accesToken = 'access_token';
$post_array = array('orders'=> '<?xml version="1.0" encoding="utf-8"?>
        <!-- YOUR ORDER XML DATA HERE
	============================================= -->
');

$buildQuery = http_build_query($post_array);
$ch = curl_init();
curl_setopt_array($ch, array(
    CURLOPT_URL => 'https://wesupply_client_url/api/import',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_FOLLOWLOCATION => TRUE,
    CURLOPT_POSTFIELDS => $buildQuery,
    CURLOPT_HTTPHEADER => array("Authorization: Bearer $accesToken")
));

$response = curl_exec($ch);
print_r($response);

?>

Order XML Data

Parameter Description
<Orders>						
	<Order>					
		<StoreId>1</StoreId>				
		<WesupplyUpdatedAt>2018-02-05 20:43:41</WesupplyUpdatedAt>				
		<LastModifiedDate>2018-02-02 16:42:52</LastModifiedDate>				
		<OrderModified>2018-02-02 16:42:52</OrderModified>				
		<OrderPaymentTypeId/>				
		<OrderID>2</OrderID>				
		<OrderNumber>000000002</OrderNumber>				
		<OrderContact>Veronica Costello</OrderContact>				
		<FirstName>Veronica</FirstName>				
		<LastName>Costello</LastName>				
		<OrderDate>2018-02-02 16:42:51</OrderDate>				
		<OrderAmount>32.0000</OrderAmount>				
		<OrderAmountShipping>5.0000</OrderAmountShipping>				
		<OrderAmountTax>2.6400</OrderAmountTax>				
		<OrderAmountTotal>39.6400</OrderAmountTotal>				
		<OrderAmountCoupon>0</OrderAmountCoupon>				
		<OrderAmountGiftCard>0</OrderAmountGiftCard>				
		<OrderAmountCredit>				
		<OrderShippingAddress1>6146 Honey Bluff Parkway</OrderShippingAddress1>				
		<OrderShippingAddress2>				
		<OrderShippingCity>Calder</OrderShippingCity>				
		<OrderShippingStateProvince>Michigan</OrderShippingStateProvince>				
		<OrderShippingZip>49628-7978</OrderShippingZip>				
		<OrderShippingPhone>(555) 229-3326</OrderShippingPhone>				
		<OrderShippingCountry>United States</OrderShippingCountry>				
		<OrderShippingCountryCode>US</OrderShippingCountryCode>				
		<OrderPaymentType>Check / Money order</OrderPaymentType>				
		<OrderCardNumber/>				
		<OrderCardExp/>				
		<OrderCardType/>				
		<OrderGiftCardNumber/>				
		<OrderGiftWrapping>false</OrderGiftWrapping>				
		<OrderGiftWrappingCost>0</OrderGiftWrappingCost>				
		<OrderGiftWrappingMessage/>				
		<OrderDiscountDetailsTotal>0.0000</OrderDiscountDetailsTotal>				
		<OrderExternalOrderID>000000002</OrderExternalOrderID>				
		<OrderComeFrom>				
		<OrderSalesPerson/>				
		<OrderSalesPersonNumber/>				
		<OrderStatus>Closed</OrderStatus>				
		<OrderStatusId>2</OrderStatusId>				
		<OrderCustom1>				
		<OrderCustom2>				
		<OrderCustom3>				
		<OrderCustom4>				
		<OrderCustom5>				
			<OrderCustomer>
				<CustomerID>			
				<CustomerCompany>		
				<CustomerName>Veronica Costello</CustomerName>		
				<CustomerFirstName>Veronica</CustomerFirstName>		
				<CustomerLastName>Costello</CustomerLastName>		
				<CustomerAddress1>314 Washington Pl</CustomerAddress1>		
				<CustomerAddress2/>		
				<CustomerCity>Hasbrouck Heights</CustomerCity>		
				<CustomerStateProvince>NJ</CustomerStateProvince>		
				<CustomerPostalCode>49628-7978</CustomerPostalCode>		
				<CustomerCountry>USA</CustomerCountry>		
				<CustomerCountryCode>US</CustomerCountryCode>		
				<CustomerEmail>roni_cost@example.com</CustomerEmail>		
				<CustomerPhone>7327405970</CustomerPhone>		
				<CustomerShippingAddresses>		
					<CustomerShippingAddress>	
						<AddressID>3</AddressID>
						<AddressContact>Veronica Costello</AddressContact>
						<AddressAddress1>6146 Honey Bluff Parkway</AddressAddress1>
						<AddressAddress2>
						<AddressCity>Calder</AddressCity>
						<AddressState>Michigan</AddressState>
						<AddressZip>49628-7978</AddressZip>
						<AddressCountry>United States</AddressCountry>
						<AddressCountryCode>US</AddressCountryCode>
						<AddressPhone>(555) 229-3326</AddressPhone>
					</CustomerShippingAddress>	
				</CustomerShippingAddresses>		
			</OrderCustomer>			
		<OrderItems>				
			<Item>			
				<ItemID>2</ItemID>
				<ItemPOShipper>FedEx</ItemPOShipper>
				<ItemName>		
				<ItemSKU>		
				<ItemUPC>		
				<ItemStyleNo>		
				<ItemPrice>32.0000</ItemPrice>		
				<ItemAddressID>3</ItemAddressID>
				<LineItemNumber>		
				<Option1>Size: XS Color: Blue</Option1>		
				<Option2>Color: Blue</Option2>		
				<Option3>		
				<Option4>		
				<Option5>		
					<ItemProduct>	
						<ProductID>1497</ProductID>
						<ProductCode>Minerva LumaTech™ V-Tee</ProductCode>
						<ProductImageURL>1497</ProductImageURL>
						<ProductPartNo>WS08-XS-Blue</ProductPartNo>
						<ProductUPC>
						<ProductStyleNo>
						<ProductXtra1>
						<ProductXtra2>
						<ProductXtra3>
						<ProductXtra4>
						<ProductXtra5>
					</ItemProduct>	
				<ItemQuantity>1.0000</ItemQuantity>		
				<ItemShippingService>UPS SurePost 1 lb or Greater</ItemShippingService>		
				<ItemShippingTracking>1ZY45F73YW99798395</ItemShippingTracking>		
				<ItemTotal>32.0000</ItemTotal>		
				<ItemTax>2.6400</ItemTax>		
				<ItemCouponAmount>0.0000</ItemCouponAmount>		
				<ItemStatus>Refunded</ItemStatus>		
				<ItemStatusId>2</ItemStatusId>		
				<ItemNotes/>		
				<ItemReturnReason/>		
				<ItemReturnStatus/>		
				<ItemReturnType/>		
				<ItemSupplierCode>KicksUSA-Orange</ItemSupplierCode>		
				<ItemLevelSupplierID>1685</ItemLevelSupplierID>		
				<ItemLevelSupplierName>1037</ItemLevelSupplierName>		
				<CustomData1/>		
				<CustomData2/>		
				<CustomData3/>		
				<CustomData4/>		
				<CustomData5/>		
			</Item>			
		</OrderItems>				
	</Order>				
	<Response>					
		<ResponseHasErrors>false</ResponseHasErrors>				
		<ResponseCode>SUCCESS</ResponseCode>				
		<ResponseDescription/>				
	</Response>					
</Orders>						
										


If Multistore set store ID value, ex. 1, 2, 3. else : 1
Last Modified Order Date
Last Modified Order Date
Last Modified Order Date
Payment Type ID
Order ID (mandatory)
Order Number Internal (if inexistent then External)
Customer First and Last Name
Customer First Name
Customer Last Name
Order Creation Date (mandatory and valid date format)
Order Amount (Subtotal) (mandatory and numeric)
Shipping Amount
Order Total Tax Amount(mandatory and numeric)
Order Grand Total (mandatory and numeric)
Order Coupon Amount (Discount)
Order Gift Card Amount
Order Store Credit Amount
Order Shipping Address Line 1
Order Shipping Address Line 2
Order Shipping City
Order Shipping State (mandatory)
Order Shipping Zip Code (mandatory)
Order Shipping Phone Number
Order Shipping Country (mandatory)
Order Shipping Country Code
Order Payment Type: CC / GC / COD
CC Last 4 digits
CC Expiration Date
CC Type
Gift Card Number
Gift Wrapping
Gift Wrapping Cost
Gift Wrapping Message
Order Discount Amount
Order Number (External order number such as Ecomm platform order number)(mandatory)
Order Source
Order Sales Person
Order Sales Person Number (ID)
Order Status (Processing / Canceled / Shipped / Returned)
Order Status ID
Order Custom Data
Order Custom Data
Order Custom Data
Order Custom Data
Order Custom Data

Customer Id (mandatory and numeric)
Customer Billing Company
Customer Billing First and Last Name
Customer Billing First Name
Customer Billing Last Name
Customer Billing Address 1
Customer Billing Address 2
Customer Billing City
Customer Billing State
Customer Billing Zip Code
Customer Billing Country
Customer Billing Country Code
Customer Billing Email (mandatory and valid email format)
Customer Billing Phone Number


Customer Shipping Address ID(mandatory and numeric - must be equal to <AddressID>
Customer Shipping Address First and Last Name(leave empty if no info)
Customer Shipping Address Line 1(leave empty if no info)
Customer Shipping Address Line 2
Customer Shipping Address City(leave empty if no info)
Customer Shipping Address State(mandatory)
Customer Shipping Address ZIP(mandatory)
Customer Shipping Address Country(mandatory)
Customer Shipping Address Contry Code(leave empty if no info)
Customer Shipping Address Phone Number(leave empty if no info)





Order Item ID(mandatory and numeric)
Item Shipper(mandatory)
Order Item Name
Order Item SKU
Order Item UPC
Order Item Style No
Order Item Price(mandatory and numeric)
Order Item Shipping Address ID(mandatory and numeric)
Order Item Line Item Number
Order Item Variables





Order Item Variable ID(mandatory and numeric)
Order Item Variable Name(mandatory)
Order Item Variable Image external URL
Order Item Variant SKU
Order Item Variant UPC
Order Item Variant Style No






Order Item QTY(mandatory and numeric)
Order Item Shipping Method
Order Item Shipping Tracking Number
Order Item Total Amount(mandatory and numeric)
Order Item Tax Amount
Order Item Discount Amount
Order Item Status
Order Item Status ID
Item Notes
Item Return Reason
Item Return Status
Item Return Type
Item Supplier (shipping location)
Item Supplier ID
Item Supplier Name(mandatory)
Custom Data
Custom Data
Custom Data
Custom Data
Custom Data




If Order Inquiry has error
Order Inquiry response code
Order Inquiry response description


SMS Signup/Notification API

This API is used for your customers to receive SMS notifications for certain changes that may occur to their orders. You can specifically select which change your customers should be notified of. This option is not available in the Free Plan

Step 1
In your WeSupply account, you have to make sure that SMS notification is enabled. For this, navigate to Settings → Notifications and check the Phone notifications for the desired action type, ex: Shipment received, Shipment in transit, Order received, Order cancelled… etc, and click SAVE

Step 2
Make a simple curl call with params order and phone, right after order placement (preferably from Thank You/ Order Success Page to notify WeSupply. The url of this call is:

https://wesupply_client_url/trackers/phone/enrol
<?php

$params = array("order" => ‘000000198’, "phone" => ‘1234567890’);
$buildQuery = http_build_query($params);

$url = “https://wesupply_client_url/trackers/phone/enrol”;

$curl = curl_init();

curl_setopt_array($curl, 
	array(  
	CURLOPT_URL => $url.’?’.$buildQuery,  
	CURLOPT_RETURNTRANSFER => true,  
	CURLOPT_MAXREDIRS => 10,  
	CURLOPT_TIMEOUT => 30,  
	CURLOPT_CUSTOMREQUEST => "GET",  
	CURLOPT_FOLLOWLOCATION => TRUE  
		));

$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);

if ($err) {  
	echo "cURL Error #:" . $err;
	} else {  
	echo $response;	
	}

?>

Possible Responses:
"true" - the call went ok and WeSupply was successfully notified
“error”:“Parameters missing!” - there are missing parameters in your call (order or phone) or the phone parameter has a length smaller then 10

Estimate delivery date

Estimations based on Shipper replies
To get estimations based on Shipper replies, you will need to provide a list of parameters as follows:
ipAddress - the ip address of the customer (used to identify the customer’s delivery address post code)
supplierId - the id of the store from where the purchase is done
postcode - the post code of the customer, if empty the ipAddress will be used to identify the customer post code
countrycode - the country code of the customer ( must be 2 letter ISO code ex: US, GB, DE, IT ... ), if empty, the ipAddress will be used to identify the customer country code
price - total price in cart
currency - currency of your store
carriers - a list of all available shippers from your store;.
Available shippers at this moment are: UPS, USPS, FedEx

<?php
$accesToken = 'previously_generated';
$carriers = array('UPS');
$params = array('ipAddress' => '91.204.211.38', 'supplierId' => '1', 'postcode' => '', 'price' => '300.0000', 'currency' => 'USD', 'carriers' => $carriers);
$buildQuery = http_build_query($params);

$url = 'https://wesupply_client_url/api/shippingQuotes?'.$buildQuery;

$curl = curl_init();

curl_setopt_array($curl, array(

		CURLOPT_URL => $url,

		CURLOPT_RETURNTRANSFER => true,

		CURLOPT_ENCODING => "",

		CURLOPT_MAXREDIRS => 10,

		CURLOPT_TIMEOUT => 30,

		CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,

		CURLOPT_CUSTOMREQUEST => "GET",

		CURLOPT_FOLLOWLOCATION => TRUE,

		CURLOPT_HTTPHEADER => array("Authorization: Bearer $accesToken")

));

$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);

if ($err) {

	echo "cURL Error #:" . $err;

} else {

	echo $response;

}

?>

You will receive a JSON Object response as follows:

{
	"UPS":{
		"1DM":1542758400,
		"1DA":1542758400,
		"1DP":1542758400,
		"GND":1542758400
		}
}

For each carrier requested you will receive a list of services and estimation arrival date for that service in timestamp format

Grab Returns

This API allows you to get a list of all returns made to your orders, from WeSupply.
Condition - account type must be startup or professional

<?php			

$curl = curl_init();
$url = "https://wesupply_client_url/api/returns";
$accesToken = 'previously_generated'

curl_setopt_array($curl, array(
  CURLOPT_URL => $url,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "Authorization: Bearer $accesToken",
    "Content-Type: application/x-www-form-urlencoded",
    ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
?>

You receive a Json Object as a response as follows:

[
{
        "return_number": "11111",
        "created_at": 1558356599,
        "updated_at": 1558356599,
        "state": "refunded",
        "return_comment": "test 23",
        "return_logic": {
            "id": 1554123772810,
            "name": "Caa",
            "priority": 5,
            "return_window": 348,
            "requires_authorization": {
                "auth_type": "automatic",
                "state": "pending"
            }
        },
        "logistics": {
            "return_store_id": "",
            "return_label_cost": 0,
            "return_location": {
                "address_1": "",
                "address_2": "",
                "city": "",
                "state": "",
                "zip_code": "",
                "country": ""
            },
            "return_shipping_info": {
                "tracking_number": "",
                "return_carrier": "",
                "status": "",
                "at": ""
            }
        },
        "refund_currency": false,
        "refund_cost": "free",
        "refund_control": {
            "refund_cost_value": 0,
            "refund_shipping_fee": "no",
            "refund_shipping_fee_value": 0,
            "refund_type": {
                "type": "refund",
                "total_value": 47.55,
                "refund_status": "Refunded",
                "at": 1558432179
            }
        },
        "customer": {
            "id": "52345",
            "email": "ionuthrive@yahoo.com"
        },
        "order": {
            "created_at": "2019-01-03T08:22:43",
            "number_ext": "KICKS100000000115879",
            "number_int": "68089"
        },
        "items": [
            {
                "id": "117891",
                "name": "Title unavailable",
                "qty": 1,
                "sku": "836277-091",
                "return_reason": "Damaged in Shipment",
                "price": 45.55,
                "restock_item": "False"
            }
        ]
    }
]

Flag Processed Returns

If your application was successful in processing a return, you can notify the WeSupply API so as not to receive that same return in the future.

<?php			

$curl = curl_init();
$url = "https://wesupply_client_url/api/returns";
$accesToken = 'previously_generated'
$params = "references=11111&references=22222",

curl_setopt_array($curl, array(
  CURLOPT_URL => $url,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "PUT",
  CURLOPT_POSTFIELDS => $params,
  CURLOPT_HTTPHEADER => array(
    "Authorization: Bearer $accesToken",
    "Content-Type: application/x-www-form-urlencoded",
    ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
?>

If everything went ok, you will receive a response as follows:

{
    "success": true,
    "references": [
        "11111",
        "22222"
    ]
}