shipping-calc 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,6 @@
1
+ === 0.1.1
2
+ * Usage examples for DHL and FreightQuote in the /examples directory.
3
+
1
4
  === 0.1.0
2
5
  * Proper support for FreightQuote quotes.
3
6
  FreightQuote uses an API that calculates the cost for a freight shipping
data/Manifest.txt CHANGED
@@ -8,3 +8,5 @@ lib/shipping_calc/freight_quote.rb
8
8
  test/test_helper.rb
9
9
  test/dhl/dhl_test.rb
10
10
  test/freight_quote/freight_quote_test.rb
11
+ examples/dhl_example.rb
12
+ examples/fq_example.rb
data/README.txt CHANGED
@@ -14,6 +14,10 @@ carriers (UPS, DHL, FedEX, FreightQuote).
14
14
 
15
15
  == SYNOPSIS:
16
16
 
17
+ You can find an example of each carrier's API under the /examples directory.
18
+
19
+ A simple DHL example:
20
+
17
21
  require 'rubygems'
18
22
  require 'shipping_calc'
19
23
 
@@ -36,8 +40,6 @@ carriers (UPS, DHL, FedEX, FreightQuote).
36
40
  a = d.quote(opts)
37
41
  p a
38
42
 
39
- An example of the other carrier's API can be found under the /examples directory.
40
-
41
43
  == REQUIREMENTS:
42
44
 
43
45
  * You must obtain all the DHL ShipIt data (user, password, key and account) from http://www.dhl-usa.com/TechTools/detail/TTDetail.asp?nav=TechnologyTools/Shipping/OwnSoln
@@ -0,0 +1,36 @@
1
+ require 'rubygems'
2
+ require 'shipping_calc'
3
+ require 'yaml'
4
+ include ShippingCalc
5
+
6
+ # This example requires you to have a .dhl_info.yml file in your home dir to
7
+ # gather the login data. Check the Test secion in README.txt for more information.
8
+ begin
9
+ auth_info = YAML.load_file("/home/#{ENV["USER"]}/.dhl_info.yml")
10
+ rescue Exception
11
+ print "You don't have a .dhl_info.yml file in your home directory. Please
12
+ read the \"Test\" section in README.txt.\n"
13
+ exit
14
+ end
15
+
16
+ api_user = auth_info["api_user"]
17
+ api_pwd = auth_info["api_password"]
18
+ api_key = auth_info["shipping_key"]
19
+ api_accnt_num = auth_info["account_num"]
20
+
21
+ opts = {
22
+ :api_user => api_user,
23
+ :api_password => api_pwd,
24
+ :shipping_key => api_key,
25
+ :account_num => api_accnt_num,
26
+ :date => Time.now,
27
+ :service_code => "E", # check the docs to find out what this means
28
+ :shipment_code => "P", # check the docs to find out what this means
29
+ :weight => 34, # weight in lbs
30
+ :to_zip => 10001,
31
+ :to_state => "NY"
32
+ }
33
+
34
+ d = DHL.new
35
+ q = d.quote(opts)
36
+ puts "Quote: " << q.to_s << "\n"
@@ -0,0 +1,21 @@
1
+ require 'rubygems'
2
+ require 'shipping_calc'
3
+ require 'yaml'
4
+ include ShippingCalc
5
+
6
+ opts = {
7
+ :api_email => "xmltest@FreightQuote.com",
8
+ :api_password => "XML",
9
+ :from_zip => 75042,
10
+ :to_zip => 33166,
11
+ :weight => 150,
12
+ :dimensions => "12x23x12"
13
+ }
14
+
15
+ f = FreightQuote.new
16
+ quotes = f.quote(opts)
17
+ quotes.each do |k,v|
18
+ p k + " - " + v
19
+ end
20
+
21
+
data/lib/shipping_calc.rb CHANGED
@@ -32,7 +32,7 @@ require 'shipping_calc/freight_quote'
32
32
  module ShippingCalc
33
33
  class ShippingCalcError < StandardError
34
34
  end
35
- VERSION = "0.1.0"
35
+ VERSION = "0.1.1"
36
36
 
37
37
  US_STATES = ['AK', 'AL', 'AR', 'AZ', 'CA', 'CO', 'CT', 'DC',
38
38
  'DE', 'FL', 'GA', 'HI', 'IA', 'ID', 'IL', 'IN',
@@ -29,11 +29,13 @@ module ShippingCalc
29
29
  # This API is based on version 03 of the Freight Quote's (FQ) connection test,
30
30
  # release on 2007 (and still used on 2008). When you first create the
31
31
  # account you'll receive a test account that works with your username and
32
- # password. After having a stable system you should e-mail FQ asking for a
32
+ # password.
33
+ #
34
+ # After having a stable system you should e-mail FQ asking for a
33
35
  # production key to the servers. If you want to test with a generic
34
- # username and password you can use: "xmltest@FreightQuote.com" : "XML",
36
+ # username and password you can the user "xmltest@FreightQuote.com" with password "XML",
35
37
  # but this won't give you access to all the debugging info. associated with
36
- # your account.
38
+ # your account (or so they say).
37
39
  class FreightQuote
38
40
 
39
41
  # Obtains some shipping quotes using freight carriers from FQ's site.
@@ -47,10 +49,8 @@ module ShippingCalc
47
49
  # :*from_zip*:: Sender's zip code.
48
50
  # :*to_zip*:: Recipient's zip code.
49
51
  # :*weight*:: Total weight of the order in lbs.
50
- # :*dimensions*:: Length, width and height of the shipment, described as
51
- # a string: "[Length]x[Width]x[Height]" (e.g. "23x32x15").
52
- # :*description*:: Optional - Description of the stuff that's being
53
- # shipped. Defaults to "NODESC".
52
+ # :*dimensions*:: Length, width and height of the shipment, described as a string: "[Length]x[Width]x[Height]" (e.g. "23x32x15").
53
+ # :*description*:: Optional - Description of the stuff that's being shipped. Defaults to "NODESC".
54
54
  def quote(params)
55
55
  required_fields = [:api_email, :api_password, :to_zip, :from_zip,
56
56
  :weight, :dimensions]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shipping-calc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Federico Builes
@@ -43,6 +43,8 @@ files:
43
43
  - test/test_helper.rb
44
44
  - test/dhl/dhl_test.rb
45
45
  - test/freight_quote/freight_quote_test.rb
46
+ - examples/dhl_example.rb
47
+ - examples/fq_example.rb
46
48
  has_rdoc: true
47
49
  homepage: http://github.com/febuiles/shipping_calc/
48
50
  post_install_message: