odfl 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f323ec7e95ba78efebe77045e9042a7688b05e9c
4
+ data.tar.gz: f3093f6feb856e80fbd44790631872dde953e8b3
5
+ SHA512:
6
+ metadata.gz: 895f2bc15695ce1effdd72b089744976abee8b5c67fe40186a12b1da78f51276d742ee1fdd44b2c651df46fe6abce456c746687ba7721508ca012a39209b18eb
7
+ data.tar.gz: f9e95ea14cc4b2b8a9d81abef3f096b5705c75b3b83a9f49cf3cddbcd538c204f3f4fca8733f570ef114f196efed48d355676658670c909625bbc30f416c86f5
data/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /.idea
4
+ /Gemfile.lock
5
+ /_yardoc/
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
11
+ *.bundle
12
+ *.so
13
+ *.o
14
+ *.a
15
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in odfl.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Robert Evans
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # Odfl
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'odfl'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install odfl
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/[my-github-username]/odfl/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new
5
+
6
+ task :default => :spec
7
+ task :test => :spec
data/lib/odfl.rb ADDED
@@ -0,0 +1,269 @@
1
+ require "odfl/version"
2
+ require 'savon'
3
+
4
+ class Odfl
5
+
6
+ attr_reader :originPostalCode, :originCountry, :destinationPostalCode, :destinationCountry,
7
+ :totalCubicVolume, :cubicUnits, :pickupDateTime, :deliveryDateTime, :codAmount
8
+ attr_accessor :client, :response, :request, :freight, :accessorials, :currencyFormat
9
+
10
+ # 1 Character Alpha Either O (outbound) or I (inbound). Defaults to "O"
11
+ attr_accessor :movement
12
+ # Required for ODFL Customer Account Pricing
13
+ attr_accessor :odfl4MeUser, :odfl4MePassword, :odflCustomerAccount
14
+ # Tariff Code for Quote Request
15
+ # Defaults to 559
16
+ #
17
+ # ==== Acceptable values
18
+ # * *559* Standard LTL (default)
19
+ # * *698* Security Divider- Requires Linear Feet
20
+ # * *688* Household Services Home Move
21
+ attr_accessor :tariff
22
+ # Mexico Service Center
23
+ # Use for shipments to and from mexico
24
+ #
25
+ # ==== Acceptable values
26
+ # * *TUS* Tulsa AZ
27
+ # * *LRD* Laredo TX
28
+ attr_accessor :mexicoServiceCenter
29
+ # Get a reference number for the current quote request
30
+ # Only use if you are actually planning to ship
31
+ attr_accessor :requestReferenceNumber
32
+ # Set the weight units
33
+ # Defaults to LBS for pounds
34
+ attr_accessor :weightUnits
35
+ # Set the linear feet
36
+ # Required for tariff 698- Security Divider
37
+ attr_accessor :linearFeet
38
+ # Number of stackable pallets
39
+ attr_accessor :numberStackablePallets
40
+ # Shipment Type
41
+ # Defaults to LTL with optional guaranteed returned
42
+ #
43
+ # ==== Acceptable Values
44
+ # * *LTL* Standard LTL rate only returned
45
+ # * *GTD* Guaranteed rate only returned
46
+ # * *GTO* Expedited delivery rate returned (requires pickup and delivery date/time)
47
+ attr_accessor :shipType
48
+ # Insurance amount
49
+ # Required for IND or INH accessorials
50
+ attr_accessor :insuranceAmount
51
+ # Number of Loose Pieces
52
+ attr_accessor :loosePieces
53
+ # Customer Email Address
54
+ attr_accessor :email
55
+ # Send email offers to customer
56
+ # Defaults to false
57
+ attr_accessor :sendEmailOffers
58
+ # Customers first and last name
59
+ attr_accessor :firstName, :lastName
60
+
61
+ def initialize #:notnew: stops RDoc from seeing the initialize method
62
+ @client = Savon.client(wsdl: 'https://www.odfl.com/wsRate_v3/services/Rate/wsdl/Rate.wsdl', ssl_verify_mode: :none,
63
+ log: true, log_level: :debug, pretty_print_xml: true)
64
+ self.freight = Array.new
65
+ self.accessorials = Array.new
66
+ self.tariff = 559
67
+ self.currencyFormat = "USD"
68
+ self.requestReferenceNumber = false
69
+ self.weightUnits = "LBS"
70
+ self.sendEmailOffers = false
71
+ end
72
+
73
+ # Allows the user to set the origin zip and country of the shipment
74
+ #
75
+ # ==== Attributes
76
+ # * +zip+ - the zip code of the shipment origin
77
+ # * +country+ - the country of the shipment origin defaults to USA
78
+ #
79
+ # ==== Usage
80
+ #
81
+ # 1. Example usage 2
82
+ # quote = Odfl.new
83
+ # quote.set_origin(20602)
84
+ # 2. Example usage 2
85
+ # quote = Odfl.new
86
+ # quote.set_origin(90210, "USA")
87
+ def set_origin(zip, country = "USA")
88
+ @originPostalCode = zip
89
+ @originCountry = country
90
+ end
91
+
92
+ # Allows the user to set the destination zip and country of the shipment
93
+ #
94
+ # ==== Attributes
95
+ # * +zip+ - the zip code of the shipment destination
96
+ # * +country+ - the country of the shipment destination defaults to USA
97
+ #
98
+ # ==== Usage
99
+ #
100
+ # 1. Example Usage 1
101
+ # quote = Odfl.new
102
+ # quote.set_destination(20602)
103
+ # 2. Example Usage 2
104
+ # quote = Odfl.new
105
+ # quote.set_destination(90210, "USA")
106
+ def set_destination(zip, country="USA")
107
+ @destinationPostalCode = zip
108
+ @destinationCountry = country
109
+ end
110
+
111
+ # Adds freight items to the current quote
112
+ # *Note:* Either before or during the addFreight call
113
+ # you must call the to_hash method on the freight object
114
+ #
115
+ # ==== Usage
116
+ # quote = Odfl.new
117
+ # quote.addFreight(pallet.to_hash)
118
+ def addFreight(pallet)
119
+ self.freight.push(pallet)
120
+ end
121
+
122
+ # Allows the user to add additional services also called accessorials
123
+ #
124
+ # ==== Valid Options
125
+ # * *ARN* Arrival Notification
126
+ # * *HYD* Lift Gate Service
127
+ # * *COD* COD - Requires COD Amount
128
+ # * *CA* Appointment
129
+ # * *IND* Insurance- Requires Insurance Amount
130
+ # * *IDC* Inside Pickup/Delivery
131
+ # * *OVL* Overlength Article- 12' but less than 20'
132
+ # * *RDC* Residential/Non-Commercial Pickup/Delivery
133
+ # * *CSD* Construction Site Pickup/Delivery
134
+ # * *CDC* Schools, Colleges, Churches Pickup/Delivery
135
+ # * *LDC* Secured or Limited Access Pickup/Delivery
136
+ # * *SWD* Self Storage Delivery
137
+ # * *PFF* Protect From Freezing
138
+ # * *HAZ* Hazardous Material
139
+ # * *OV2* Overlength Article - 20' to 28'
140
+ # * *DSM* Delivery Service to Mines
141
+ # * *HSO* Scale Tickets Per Military Move (Home Moves Only)
142
+ # * *INH* Home Move Insurance (Home Moves Only)
143
+ #
144
+ # ==== Usage
145
+ # quote = Odfl.new
146
+ # quote.addAccessorial("HYD")
147
+ def addAccessorial(accessorial)
148
+ if !self.accessorials.include?(accessorial)
149
+ self.accessorials.push(accessorial)
150
+ end
151
+ end
152
+
153
+ # Sets cubic volume for rate request
154
+ #
155
+ # ==== Attributes
156
+ # * +totalCubicVolume+ - the total volume of the shipment
157
+ # * +cubicUnits+ (optional)- the unit of measure for cubic volume defaults to CF for cubic feet
158
+ #
159
+ # ==== Usage
160
+ #
161
+ # 1. Example Usage 1
162
+ # quote = Odfl.new
163
+ # quote.setCubicVolume(100)
164
+ # 2. Example Usage 2
165
+ # quote = Odfl.new
166
+ # quote.setCubicVolume(100, "CF")
167
+ def setCubicVolume(totalCubicVolume, cubicUnits = "CF")
168
+ @totalCubicVolume = totalCubicVolume
169
+ @cubicUnits = cubicUnits
170
+ end
171
+
172
+ # Set the pickup date and time
173
+ # Required for Expedited GTO rates
174
+ #
175
+ # ==== Attributes
176
+ # * +month+ Pickup Month 1-12
177
+ # * +day+ Pickup Day 1-31
178
+ # * +year+ Pickup Year (4 digit year)
179
+ # * +hour+ Pickup Hour 0-23
180
+ # * +minute+ Pickup Minute 0-59
181
+ #
182
+ # ==== Usage
183
+ # quote = Odfl.new
184
+ # quote.setPickupDateTime(12,25,2014,12,30)
185
+ def setPickupDateTime(month, day, year, hour, minute)
186
+ month = month<10 ? "0#{month}" : "#{month}"
187
+ day = day<10 ? "0#{day}" : "#{day}"
188
+ hour = hour<10 ? "0#{hour}" : "#{hour}"
189
+ minute = minute<10 ? "0#{minute}" : "#{minute}"
190
+ second = '00'
191
+
192
+ @pickupDateTime = "#{year}-#{month}-#{day}T#{hour}:#{minute}:#{second}"
193
+ end
194
+
195
+ # Set the delivery date and time
196
+ # Required for Expedited GTO rates
197
+ #
198
+ # ==== Attributes
199
+ # * +month+ Delivery Month 1-12
200
+ # * +day+ Delivery Day 1-31
201
+ # * +year+ Delivery Year (4 digit year)
202
+ # * +hour+ Delivery Hour 0-23
203
+ # * +minute+ Delivery Minute 0-59
204
+ #
205
+ # ==== Usage
206
+ # quote = Odfl.new
207
+ # quote.setDeliveryDateTime(12,25,2014,12,30)
208
+ def setDeliveryDateTime(month, day, year, hour, minute)
209
+ month = month<10 ? "0#{month}" : "#{month}"
210
+ day = day<10 ? "0#{day}" : "#{day}"
211
+ hour = hour<10 ? "0#{hour}" : "#{hour}"
212
+ minute = minute<10 ? "0#{minute}" : "#{minute}"
213
+ second = '00'
214
+
215
+ @deliveryDateTime = "#{year}-#{month}-#{day}T#{hour}:#{minute}:#{second}"
216
+ end
217
+
218
+ # Set an amount for COD
219
+ # This will also automatically add the COD accessorial
220
+ #
221
+ # ==== Attributes
222
+ # * *amount* The COD amount
223
+ #
224
+ # ==== Usage
225
+ # quote = Odfl.new
226
+ # quote.setCODAmount(100.53)
227
+ def setCODAmount(amount)
228
+ @codAmount = amount
229
+ self.addAccessorial('COD')
230
+ end
231
+
232
+ def get_rates
233
+ @response = @client.call(:get_rate_estimate, message: { originPostalCode: @originPostalCode,
234
+ originCountry: @originCountry,
235
+ destinationPostalCode: @destinationPostalCode,
236
+ destinationCountry: @destinationCountry,
237
+ odfl4MeUser: self.odfl4MeUser,
238
+ odfl4MePassword: self.odfl4MePassword,
239
+ odflCustomerAccount: self.odflCustomerAccount,
240
+ tariff: self.tariff,
241
+ movement: self.movement,
242
+ mexicoServiceCenter: self.mexicoServiceCenter,
243
+ currencyFormat: self.currencyFormat,
244
+ requestReferenceNumber: self.requestReferenceNumber,
245
+ freightItems: {
246
+ Freight: self.freight
247
+ },
248
+ weightUnits: self.weightUnits,
249
+ numberPallets: self.freight.count,
250
+ linearFeet: self.linearFeet,
251
+ accessorials: {
252
+ string: self.accessorials
253
+ },
254
+ totalCubicVolume: @totalCubicVolume,
255
+ cubicUnits: @cubicUnits,
256
+ numberStackablePallets: self.numberStackablePallets,
257
+ pickupDateTime: @pickupDateTime,
258
+ deliveryDateTime: @deliveryDateTime,
259
+ shipType: self.shipType,
260
+ codAmount: @codAmount,
261
+ insuranceAmount: self.insuranceAmount,
262
+ loosePieces: self.loosePieces,
263
+ email: self.email,
264
+ sendEmailOffers: self.sendEmailOffers,
265
+ firstName: self.firstName,
266
+ lastName: self.lastName
267
+ })
268
+ end
269
+ end
@@ -0,0 +1,3 @@
1
+ class Odfl
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,19 @@
1
+ class OdflFreight
2
+ attr_accessor :ratedClass, :nmfc, :nmfcsub, :weight, :length, :width, :height, :numberOfUnits, :dimensionUnits, :actualClass
3
+
4
+ def to_hash
5
+ hash = {}
6
+ instance_variables.each {|var| hash[var.to_s.delete("@")] = instance_variable_get(var) }
7
+ hash
8
+ end
9
+
10
+ def to_soap_array
11
+ result=Array.new
12
+
13
+ instance_variables.each do |var|
14
+ result.push({var.to_s.delete("@") => Integer(instance_variable_get(var))})
15
+ end
16
+
17
+ result
18
+ end
19
+ end
data/odfl.gemspec ADDED
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'odfl/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "odfl"
8
+ spec.version = Odfl::VERSION
9
+ spec.authors = ["Robert Evans"]
10
+ spec.email = ["robertevans@robertevansmb.com"]
11
+ spec.summary = %q{Get freight quotes from Old Dominion Freight Line}
12
+ spec.description = %q{Get freight quotes form ODFL. A valid odfl account is required.}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency 'rspec'
24
+
25
+ spec.add_dependency 'savon'
26
+ end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe Odfl do
4
+ quote = Odfl.new
5
+
6
+ it 'should set the origin zip code and country' do
7
+ quote.set_origin(29579)
8
+ expect(quote).not_to be_nil
9
+ expect(quote.originPostalCode).to eq(29579)
10
+ expect(quote.originCountry).to eq('USA')
11
+ end
12
+
13
+ it 'should set the destination zip code and country' do
14
+ quote.set_destination(20602)
15
+ expect(quote).not_to be_nil
16
+ expect(quote.destinationPostalCode).to eq(20602)
17
+ expect(quote.destinationCountry).to eq('USA')
18
+ end
19
+
20
+ it 'should set the movement of the shipment' do
21
+ quote.movement = 'O'
22
+ expect(quote).not_to be_nil
23
+ expect(quote.movement).to eq('O')
24
+ end
25
+
26
+ end
@@ -0,0 +1 @@
1
+ require 'odfl'
metadata ADDED
@@ -0,0 +1,113 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: odfl
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Robert Evans
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: savon
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Get freight quotes form ODFL. A valid odfl account is required.
70
+ email:
71
+ - robertevans@robertevansmb.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - Gemfile
78
+ - LICENSE.txt
79
+ - README.md
80
+ - Rakefile
81
+ - lib/odfl.rb
82
+ - lib/odfl/version.rb
83
+ - lib/odfl_freight.rb
84
+ - odfl.gemspec
85
+ - spec/lib/odfl_spec.rb
86
+ - spec/spec_helper.rb
87
+ homepage: ''
88
+ licenses:
89
+ - MIT
90
+ metadata: {}
91
+ post_install_message:
92
+ rdoc_options: []
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ requirements: []
106
+ rubyforge_project:
107
+ rubygems_version: 2.4.4
108
+ signing_key:
109
+ specification_version: 4
110
+ summary: Get freight quotes from Old Dominion Freight Line
111
+ test_files:
112
+ - spec/lib/odfl_spec.rb
113
+ - spec/spec_helper.rb