Skip to content
Boli Guan edited this page Mar 14, 2015 · 2 revisions

Tradewisesolution Platform API service

Getting Started

This document will tell you how to setup your local development environment for Tradewisesolution API service as well as the API list.

API URL

http://webapi.tradewisesolution.com

Crypto

var BASE64 = 'base64',
    UTF8 = 'utf8',
    ALGORITHM = 'aes-256-ecb',
    IV = '',
    aeskey = '{We will provide you with the encryption key}';

/**
* Encryption
*/
function encrypt(data, key) {
    key = new Buffer(key || aeskey, BASE64);
    var cipheriv = crypto.createCipheriv(ALGORITHM, key, IV);
    var cipherivChunks = [
        cipheriv.update(data, UTF8, BASE64),
        cipheriv.final(BASE64)
    ];
    return cipherivChunks.join('');
};

API

1. Customer

1.1 Customer Login

POST /api/customer/login

Example request

POST /api/customer/login HTTP/1.1
Content-Type: application/json
header = {
    "wbhost": "Your site's URL",
    "token": "Encrypt body" 
}
body = {
    "Username": "",
    "Email": "",
    "Password": "",
    "LanguageId": 1
}

Json Parameters:

  • "header.token" encrypt(JSON.stringify(body)) * See Encrypt for details of the Crypto exposed.

Response

{
    "StoreCustomerId":0,
    "Username":"",
    "Email":"",
    "LastLoginDateUtc":0,
    "LastActivityDateUtc":0,
    "ErrorMessage":"",
    "ResultCode":1,
    "LoginToken":""
}

Json Parameters:

  • "StoreCustomerId"(int)
  • "LastLoginDateUtc"(long milliseconds): From counting the number of milliseconds 01/01/1970 0:0:0
  • "LastActivityDateUtc"(long milliseconds): From counting the number of milliseconds 01/01/1970 0:0:0
  • "ErrorMessage"(string): 'ResultCode=2, Authantication Failed'
  • "ResultCode" : 1: success, 2: fail
  • "LoginToken" : Request header token = LoginToken

1.2 Customer Change Password

POST /api/customer/changepassword

Example request

  • headers { wbhost : "Your site's URL", token : login.LoginToken } required
body= {
    "StoreCustomerId": 0,
    "OldPassword": "",
    "NewPassword": "",
    "ConfirmNewPassword": ""
}

Response

{
    "StoreCustomerId":0,
    "Username":"",
    "Email":"",
    "LastLoginDateUtc":0,
    "LastActivityDateUtc":0,
    "ErrorMessage":"",
    "ResultCode":1,
    "LoginToken":""
}

Json Parameters:

  • See login response

2. Vendor

2.1 Vendor Search Shipment Order

POST /api/vendor/searchshipmentorder

Example request

  • headers { wbhost : "Your site's URL", token : login.LoginToken } required
body = {
    "ShipmentCurrentStatus": 0,
    "ShipmentOrderReference": "",
    "PageIndex":0 ,
    "PageSize":1 
}

Json Parameters:

  • "ShipmentCurrentStatus"(int) 0: current, 1: history
  • "ShipmentOrderReference"(string)
  • "PageIndex"(int) Starting from 0

Response

{
    "CurrentPageIndex":0,
    "PageSize":0,
    "TotalCount":0,
    "Response" :{
        "Message":"",
        "ResultCode":"",
        "Success":true
    }, 
    "ShipmentOrders":[{
        "ShipmentCreatedOnUtc":0,
        "ShipmentOrderReference":"",
        "Shipments":[]
    }]
}

Json Parameters:

  • "Response.Message"(string) error message
  • "ResultCode"(string)
  • "Success"(bool) true: success, fasle: fail
  • "ShipmentOrders.ShipmentCreatedOnUtc"(long milliseconds)
  • "ShipmentOrderReference"(string)
  • "Shipments"(Array) See Shipment json

Shipment Json:

{
    "ShipmentItems": [],
    "ShipmentNotes": [],
    "StoreCustomerId": 1901,
    "PurchaseOrderNumber": "",
    "OrderActualWeight": 7,
    "OrderDimensionWeight": 0,
    "OrderChargableWeight": 7,
    "OrderTotalPrice": 25,
    "OrderTotalValue": 59.94,
    "OrderTotalDiscount": 0,
    "DiscountDescription": null,
    "OrderTotalPaid": 25,
    "ExchangeRate": 0,
    "PackageType": 2,
    "ServiceProviderId": 4,
    "UKServiceProviderId": 0,
    "ShippingStatusId": 10,
    "PickupTypeId": -3,
    "ExtraInsuranceId": 0,
    "ShipFromName": "kaka-london",
    "ShipFromEmail": "[email protected]",
    "ShipFromPhone": "",
    "ShipFromCellPhone": "07446837092",
    "ShipFromAddress": "B1 Oyo Business Units",
    "ShipFromAddress2": "Crabtree Manorway North",
    "ShipFromAddress3": "",
    "ShipFromCity": "BELVEDERE",
    "ShipFromProvince": "",
    "ShipFromPostalCode": "DA17 6AX",
    "ShipFromCountry": "UK",
    "ShipToName": "王娜",
    "ShipToAddress": "西营门外大街华安北里5-3-401",
    "ShipToCity": "天津市",
    "ShipToProvince": "",
    "ShipToPostalCode": "30010",
    "ShipToCountry": "China",
    "ShipToIDCardType": 0,
    "ShipToIDCardNumber": "",
    "ShipToQQ": "",
    "ShipToWechat": "",
    "ShipToEmail": "[email protected]",
    "ShipToPhone": null,
    "ShipToCellPhone": "13672108124",
    "ShippingDate": 635362272000000000,
    "ReferenceOrderId": "2011-02-01",
    "PaymentUniqueId": null,
    "PaidDateUtc": 0,
    "ShippedDateUtc": 0,
    "TrackingNumber": "",
    "UKTrackingNumber": null,
    "DeliveryDateUtc": 0,
    "InWarehouseDateUtc": 0,
    "Notes": "",
    "CreatedOnUtc": 635361418975200000,
    "URL_ChineseAddressLabel": "",
    "URL_UKLabel": null,
    "URL_InternationalLabel": null,
    "URL_CN23Label": "http://server.51parcel.com/51parcel/files/ExportImport/2011-02-01_CustomerDocument.pdf",
    "URL_Invoice": "http://server.51parcel.com/51parcel/files/ExportImport/2011-02-01_CommercialInvoice.pdf",
    "URL_CollectionReceipt": "",
    "Id": 0
}

Json Parameters:

  • "ShipmentItems"(Array) See ShipmentItem json When ShipmentOrderReference request parameter is equal to the empty array
  • "URL_ChineseAddressLabel"(string) Download Chinese address pdf
  • "URL_UKLabel"(string) Download within the waybill pdf
  • "URL_InternationalLabel"(string) Download international waybills pdf
  • "URL_CN23Label"(string) Download declarations pdf
  • "URL_Invoice"(string) Download commercial invoices pdf
  • "URL_CollectionReceipt"(string) Download receipts pickup pdf

ShipmentItem json

{
    "ShipmentItemDetails": [
      {
        "ShipmentId": 0,
        "ShipmentItemId": 343648,
        "ProductId": 0,
        "ProductName": "服装服饰",
        "ProductEnglishName": "Clothing",
        "UnitPrice": 40.99,
        "Quantity": 2,
        "UnitWeight": 0,
        "Notes": null,
        "Id": 0
      }
    ],
    "ShipmentId": 265954,
    "ItemType": 2,
    "Weight": 1.25,
    "DimensionWeight": 0,
    "Length": 28,
    "Width": 21,
    "Height": 9,
    "TrackingNumber": "",
    "Notes": "",
    "Id": 0
}

2.2 Vendor Export Products to excel

POST /api/vendor/exportproductstoexcel

Example request

  • headers { wbhost : "Your site's URL", token : login.LoginToken } required
body = {
    "OrderReferences": [],
    "ShipmentOrderReference": ""
}

Json Parameters:

  • "OrderReferences"(Array) Values are Shipment.ReferenceOrderId ...
  • "ShipmentOrderReferences"(String) Value is ShipmentOrderReference

Response

	string : Download Excel url 

2.3 Vendor batch shipment ready to ship

POST /api/vendor/batchshipmentreadytoship

Example request

  • headers { wbhost : "Your site's URL", token : login.LoginToken } required
body = {
    "OrderReferences": [],
    "ShipmentOrderReferences": [],
    "ShippingDate": ""
}

Json Parameters:

  • "OrderReferences"(Array) Values are Shipment.ReferenceOrderId ...
  • "ShipmentOrderReferences"(Array) Values are ShipmentOrderReference ...
  • "ShippingDate"(String) Date format 'yyyyMMdd', Date can not be less than today. Not including weekends and holidays

Response

{
	"Fail":[{
		"Success":false,
		"ResultCode":"",
		"Message":"",
		"OrderReference":"",
		"ShippingDate":""
	}],
	"Success":[{
		"Success":true,
		"ResultCode":"",
		"Message":"",
		"OrderReference":"",
		"ShippingDate":""
	}]
}

3. Shipment

3.1 Shipment Search byreference

POST /api/shipment/searchbyreference

Example request

  • headers { wbhost : "Your site's URL", token : login.LoginToken } required
body = {
	"ReferenceOrderId": ""
}

Response

See Shipment json