forked from cardmagic/shipping
-
Notifications
You must be signed in to change notification settings - Fork 6
/
README
74 lines (46 loc) · 2.41 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
== Welcome to Shipping
Shipping is a module that connects APIs for various shippers like UPS and FedEx. Shipping currently supports pricing, shipping, labeling and voiding for UPS and FedEx through their XML APIs.
Tracking is also supported through UPS XML API.
== Download
* gem 'shipping', :git => 'git://github.com/ideaoforder/shipping' (bundler)
* https://github.com/ideaoforder/shipping
=== Usage
There is going to be some data that will persist for all connections. For example, you will not want to repeat the fedex account number every time in your implementation code. To set default values, setup a file called .shipping.yml in the home directory of the user who will be using this library. An example file would be:
fedex_url: https://gatewaybeta.fedex.com/GatewayDC
fedex_account: 1234556
fedex_meter: 387878
ups_url: https://wwwcie.ups.com/ups.app/xml
ups_license_number: 7B4F74E3075AEEFF
ups_user: username
ups_password: password
ups_shipper_number: 855AA0
You can set as many default values as you would like in this file.
require 'shipping'
ups = Shipping::UPS.new :zip => 97202, :state => "OR", :sender_zip => 10001, :weight => 2
ups.price => 5.8
ups.valid_address? => false
ups.city = "Portland"
ups.valid_address? => true
Alternately, you can instantiate the base class and then see both UPS and FedEx information.
ship = Shipping::Base.new :zip => 97202, :state => "OR", :sender_zip => 10001, :weight => 2
ship.ups.price => 5.8
ship.fedex.price => 5.8
ship.city = "Portland"
ship.ups.valid_address? => true
== DEBUGGING
You can debug requests via the logger or the console. Just pass in
:debug => 'logger'
OR
:debug => 'console'
== CONFIG
Shipping will look for a global Hash called SHIPPING_CONFIG. This is an easy way to set your UPS/USPS/FedEx account credentials, the debugger, and other defaults options.
If you're using rails, the easiest way to set this up is via a config file (config/shipping.yml) and an initializer--something like:
SHIPPING_CONFIG = YAML.load_file(File.join(Rails.root, 'config', 'shipping.yml'))[Rails.env].symbolize_keys
== Authors
* Lucas Carlson (mailto:[email protected])
* Jimmy Baker (mailto:[email protected])
* Noah Zoschke (mailto:[email protected])
== Additional Contributors
* Mark Dickson
* David J. Brenes
This library is released under the terms of the GNU LGPL.