#shipping-ups
Install
npm install shipping-ups
Usage
var upsAPI = require('shipping-ups');
var ups = new upsAPI({
environment: 'sandbox',
username: 'UPSUSERNAME',
password: 'UPSPASSWORD',
access_key: 'UPSACCESSTOKEN',
imperial: true
});
ups.time_in_transit(..., function(err, res) {
...
});
ups.address_validation(..., function(err, result) {
...
});
ups.track(..., function(err, result) {
...
});
ups.rates(..., function(err, result) {
...
});
ups.confirm(..., function(err, result) {
...
});
ups.accept(..., function(err, result) {
...
});
ups.void(..., function(err, result) {
...
});
new upsAPI(options)
Initialize your API bindings
options = {
imperial: true,
currency: 'USD',
environment: 'sandbox',
access_key: '',
username: '',
password: '',
pretty: false,
user_agent: 'uh-sem-blee, Co | typefoo',
debug: false
}
time_in_transit(data, callback)
Calculate the time in transit for a shipment
data = {
from: {
city: 'Dover',
state_code: 'OH',
postal_code: '44622',
country_code: 'US'
},
to: {
city: 'Charlotte',
state_code: 'NC',
postal_code: '28205',
country_code: 'US'
},
weight: 10,
pickup_date: 'YYYYMMDD',
total_packages: 1,
value: 999999999.99,
}
address_validation(data, callback)
Validates an address
data = {
request_option: 3,
name: 'Customer Name',
company: 'Company Name',
address_line_1: 'Address Line 1',
address_line_2: 'Address Line 2',
address_line_3: 'Address Line 3',
city: 'Dover',
state_code: 'OH',
postal_code: '44622',
country_code: 'US'
}
track(tracking_number, [options], callback)
Get a shipment's tracking information with tracking_number as the ID
options = {
latest: true
}
rates(data, callback)
Get a list of shipping rates
data = {
pickup_type: 'daily_pickup',
pickup_type_code: '02',
customer_classification: '00',
shipper: {
name: 'Type Foo',
shipper_number: 'SHIPPER_NUMBER',
phone_number: '',
address: {
address_line_1: '123 Fake Address',
city: 'Dover',
state_code: 'OH',
country_code: 'US',
postal_code: '44622'
}
},
ship_to: {
name: 'John Doe',
company_name: 'Uhsem Blee',
attention_name: '',
phone_number: '',
address: {
address_line_1: '3456 Fake Address',
city: 'Charlotte',
state_code: 'NC',
country_code: 'US',
postal_code: '28205'
}
},
ship_from: {
name: 'Alternate Name',
phone_number: '',
address: {
address_line_1: '123 Fake Address',
city: 'Dover',
state_code: 'OH',
country_code: 'US',
postal_code: '44622'
}
},
service: '03'
services: [
'03'
],
packages: [
{
packaging_type: '02',
weight: 10,
description: 'My Package',
delivery_confirmation_type: 2,
insured_value: 1000.00,
dimensions: {
length: 12,
width: 12,
height: 24
}
}
]
}
confirm(data, callback)
Pick a shipping rate
data = {
service_code: '03',
pickup_type: 'daily_pickup',
pickup_type_code: '02',
customer_classification: '00',
shipper: {
name: 'Type Foo',
shipper_number: 'SHIPPER_NUMBER',
phone_number: '',
address: {
address_line_1: '123 Fake Address',
city: 'Dover',
state_code: 'OH',
country_code: 'US',
postal_code: '44622'
}
},
ship_to: {
name: 'John Doe',
company_name: 'Uhsem Blee',
attention_name: '',
phone_number: '',
address: {
address_line_1: '3456 Fake Address',
city: 'Charlotte',
state_code: 'NC',
country_code: 'US',
postal_code: '28205'
}
},
ship_from: {
name: 'Alternate Name',
phone_number: '',
address: {
address_line_1: '123 Fake Address',
city: 'Dover',
state_code: 'OH',
country_code: 'US',
postal_code: '44622'
}
},
packages: [
{
packaging_type: '02',
weight: 10,
description: 'My Package',
delivery_confirmation_type: 2,
insured_value: 1000.00,
dimensions: {
length: 12,
width: 12,
height: 24
},
reference_number: 'ABC123'
reference_number: {
code: 'PM',
value: 'ABC123'
},
reference_number: [
'ABC123',
'WWWABC123'
]
}
]
}
accept(shipment_digest, callback)
Purchase a shipping label and tracking number
shipment_digest = 'SHIPMENTDIGEST';
void(data, callback)
data = '1ZTRACKINGNUMBER';
OR
data = {
shipment_identification_number: '1ZSHIPMENTIDNUMBER',
tracking_numbers: ['1ZTRACKINGNUMBER', '1ZTRACKINGNUMBER']
}
Void a previously created order
See example/index.js for a working sample.
License
(The MIT License)
Copyright 2014 uh-sem-blee, Co. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.