brownie 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.document +5 -0
- data/Gemfile +15 -0
- data/Gemfile.lock +87 -0
- data/LICENSE.txt +20 -0
- data/README.markdown +79 -0
- data/Rakefile +51 -0
- data/VERSION +1 -0
- data/lib/brownie/credentials.rb +5 -0
- data/lib/brownie/ship_from.rb +8 -0
- data/lib/brownie/ship_to.rb +7 -0
- data/lib/brownie/shipper.rb +9 -0
- data/lib/brownie.rb +181 -0
- data/test/helper.rb +34 -0
- data/test/test_brownie.rb +7 -0
- data/xml/ship_confirm.xml +90 -0
- metadata +158 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 38f368076f7a110f8ed59888155b6b148885601f
|
4
|
+
data.tar.gz: 26d1913af8eb7254905bedcd35ad3e446eed70c7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 94ac4dd7a2011244b93817c77790823d029de241cf0ce2d5b9c20b3ce3ba1b73c3e19d8d35f130859c3a4629d70024bddac22ff841b669b1bc6bff6780ae04af
|
7
|
+
data.tar.gz: 4c0c99ef5dc5f4108e77412f804635e55b4ef96c802b6897ccb348425d5e72c211891496371d6cc4f39ed17b9a5213e9f5e7c8111ebce52eff3fc6af66e259b7
|
data/.document
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
gem "activesupport", ">= 3.2.2"
|
5
|
+
gem "rest_client", ">= 1.7"
|
6
|
+
|
7
|
+
# Add dependencies to develop your gem here.
|
8
|
+
# Include everything needed to run rake, tests, features, etc.
|
9
|
+
group :development do
|
10
|
+
gem "shoulda", ">= 0"
|
11
|
+
gem "rdoc", "~> 3.12"
|
12
|
+
gem "bundler", "~> 1.0"
|
13
|
+
gem "jeweler", "~> 2.0.1"
|
14
|
+
gem "simplecov", ">= 0"
|
15
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
activesupport (4.0.4)
|
5
|
+
i18n (~> 0.6, >= 0.6.9)
|
6
|
+
minitest (~> 4.2)
|
7
|
+
multi_json (~> 1.3)
|
8
|
+
thread_safe (~> 0.1)
|
9
|
+
tzinfo (~> 0.3.37)
|
10
|
+
addressable (2.3.6)
|
11
|
+
atomic (1.1.16)
|
12
|
+
builder (3.2.2)
|
13
|
+
descendants_tracker (0.0.4)
|
14
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
15
|
+
docile (1.1.3)
|
16
|
+
faraday (0.9.0)
|
17
|
+
multipart-post (>= 1.2, < 3)
|
18
|
+
git (1.2.6)
|
19
|
+
github_api (0.11.3)
|
20
|
+
addressable (~> 2.3)
|
21
|
+
descendants_tracker (~> 0.0.1)
|
22
|
+
faraday (~> 0.8, < 0.10)
|
23
|
+
hashie (>= 1.2)
|
24
|
+
multi_json (>= 1.7.5, < 2.0)
|
25
|
+
nokogiri (~> 1.6.0)
|
26
|
+
oauth2
|
27
|
+
hashie (2.0.5)
|
28
|
+
highline (1.6.21)
|
29
|
+
i18n (0.6.9)
|
30
|
+
jeweler (2.0.1)
|
31
|
+
builder
|
32
|
+
bundler (>= 1.0)
|
33
|
+
git (>= 1.2.5)
|
34
|
+
github_api
|
35
|
+
highline (>= 1.6.15)
|
36
|
+
nokogiri (>= 1.5.10)
|
37
|
+
rake
|
38
|
+
rdoc
|
39
|
+
json (1.8.1)
|
40
|
+
jwt (0.1.11)
|
41
|
+
multi_json (>= 1.5)
|
42
|
+
mini_portile (0.5.3)
|
43
|
+
minitest (4.7.5)
|
44
|
+
multi_json (1.9.2)
|
45
|
+
multi_xml (0.5.5)
|
46
|
+
multipart-post (2.0.0)
|
47
|
+
netrc (0.7.7)
|
48
|
+
nokogiri (1.6.1)
|
49
|
+
mini_portile (~> 0.5.0)
|
50
|
+
oauth2 (0.9.3)
|
51
|
+
faraday (>= 0.8, < 0.10)
|
52
|
+
jwt (~> 0.1.8)
|
53
|
+
multi_json (~> 1.3)
|
54
|
+
multi_xml (~> 0.5)
|
55
|
+
rack (~> 1.2)
|
56
|
+
rack (1.5.2)
|
57
|
+
rake (10.2.2)
|
58
|
+
rdoc (3.12.2)
|
59
|
+
json (~> 1.4)
|
60
|
+
rest_client (1.7.3)
|
61
|
+
netrc (~> 0.7.7)
|
62
|
+
shoulda (3.5.0)
|
63
|
+
shoulda-context (~> 1.0, >= 1.0.1)
|
64
|
+
shoulda-matchers (>= 1.4.1, < 3.0)
|
65
|
+
shoulda-context (1.1.6)
|
66
|
+
shoulda-matchers (2.5.0)
|
67
|
+
activesupport (>= 3.0.0)
|
68
|
+
simplecov (0.8.2)
|
69
|
+
docile (~> 1.1.0)
|
70
|
+
multi_json
|
71
|
+
simplecov-html (~> 0.8.0)
|
72
|
+
simplecov-html (0.8.0)
|
73
|
+
thread_safe (0.3.1)
|
74
|
+
atomic (>= 1.1.7, < 2)
|
75
|
+
tzinfo (0.3.39)
|
76
|
+
|
77
|
+
PLATFORMS
|
78
|
+
ruby
|
79
|
+
|
80
|
+
DEPENDENCIES
|
81
|
+
activesupport (>= 3.2.2)
|
82
|
+
bundler (~> 1.0)
|
83
|
+
jeweler (~> 2.0.1)
|
84
|
+
rdoc (~> 3.12)
|
85
|
+
rest_client (>= 1.7)
|
86
|
+
shoulda
|
87
|
+
simplecov
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2014 Michael Jaffe
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
# brownie
|
2
|
+
|
3
|
+
Brownie helps you create shipments via UPS.com's developer api. You can create shipments, and labels.
|
4
|
+
|
5
|
+
Future releasess will have address valdation, and tracking
|
6
|
+
|
7
|
+
## Install
|
8
|
+
gem 'brownie', :git => 'https://github.com/mikejaffe/brownie'
|
9
|
+
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
b = Brownie::Shipment.new
|
14
|
+
b.account_number = "YOUR UPS ACCOUNT NUMBER"
|
15
|
+
b.credentials.license_number = "YOUR UPS DEVELOPER API LICENCE NUMBER"
|
16
|
+
b.credentials.user_id = "YOUR UPS LOGIN"
|
17
|
+
b.credentials.password = "YOU UPS PASSWORD"
|
18
|
+
|
19
|
+
b.shipper.account_number = b.account_number
|
20
|
+
b.shipper.name = "Sample Company Name"
|
21
|
+
b.shipper.phone_number = "555-666-7777"
|
22
|
+
b.shipper.tax_identification_number = "1234567890"
|
23
|
+
b.shipper.address_line1 = "123 Test Street"
|
24
|
+
b.shipper.city = "Test Town"
|
25
|
+
b.shipper.state_province_code = "NY"
|
26
|
+
b.shipper.postal_code = "10021"
|
27
|
+
b.shipper.country_code = "US"
|
28
|
+
|
29
|
+
b.ship_to.company_name = "SHIP TO COMPANY/NAME"
|
30
|
+
b.ship_to.attention_name = "SHIP TO NAME"
|
31
|
+
b.ship_to.phone_number = "5556667777"
|
32
|
+
b.ship_to.address_line1 = "555 Test Rd"
|
33
|
+
b.ship_to.city = "Test City"
|
34
|
+
b.ship_to.state_province_code = "CA"
|
35
|
+
b.ship_to.postal_code = "90212"
|
36
|
+
b.ship_to.country_code = "US"
|
37
|
+
|
38
|
+
b.ship_from.company_name = "Sample Company Name"
|
39
|
+
b.ship_from.attention_name = "Sample NAme"
|
40
|
+
b.ship_from.phone_number = "5556667777"
|
41
|
+
b.ship_from.address_line1 = "123 Test Street"
|
42
|
+
b.ship_from.state_province_code = "NY"
|
43
|
+
b.ship_from.city = "Test Town"
|
44
|
+
b.ship_from.postal_code = "07738"
|
45
|
+
b.ship_from.country_code = "US"
|
46
|
+
|
47
|
+
b.service_code = Brownie::ServiceCodes::GROUND
|
48
|
+
b.package_type = Brownie::Package::BOX
|
49
|
+
b.declared_value = 100
|
50
|
+
|
51
|
+
# Confirm and Validate Shipment
|
52
|
+
if b.confirm
|
53
|
+
puts b.tracking_number
|
54
|
+
else
|
55
|
+
puts b.errors
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
# Accept and Download Label
|
60
|
+
b.label(b.shipment_digest,"/path/to/save/label.gif")
|
61
|
+
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
## Contributing to brownie
|
66
|
+
|
67
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
68
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
69
|
+
* Fork the project.
|
70
|
+
* Start a feature/bugfix branch.
|
71
|
+
* Commit and push until you are happy with your contribution.
|
72
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
73
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
74
|
+
|
75
|
+
## Copyright
|
76
|
+
|
77
|
+
Copyright (c) 2014 Michael Jaffe. See LICENSE.txt for
|
78
|
+
further details.
|
79
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
|
17
|
+
gem.name = "brownie"
|
18
|
+
gem.homepage = "http://github.com/mikejaffe/brownie"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = "Creates UPS shipments and labels"
|
21
|
+
gem.description = "Creates UPS shipments and labels via UPS.com's developer api."
|
22
|
+
gem.email = "mike@mikewritescode.com"
|
23
|
+
gem.authors = ["Michael Jaffe"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rake/testtask'
|
29
|
+
Rake::TestTask.new(:test) do |test|
|
30
|
+
test.libs << 'lib' << 'test'
|
31
|
+
test.pattern = 'test/**/test_*.rb'
|
32
|
+
test.verbose = true
|
33
|
+
end
|
34
|
+
|
35
|
+
desc "Code coverage detail"
|
36
|
+
task :simplecov do
|
37
|
+
ENV['COVERAGE'] = "true"
|
38
|
+
Rake::Task['test'].execute
|
39
|
+
end
|
40
|
+
|
41
|
+
task :default => :test
|
42
|
+
|
43
|
+
require 'rdoc/task'
|
44
|
+
Rake::RDocTask.new do |rdoc|
|
45
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
46
|
+
|
47
|
+
rdoc.rdoc_dir = 'rdoc'
|
48
|
+
rdoc.title = "brownie #{version}"
|
49
|
+
rdoc.rdoc_files.include('README*')
|
50
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
51
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/lib/brownie.rb
ADDED
@@ -0,0 +1,181 @@
|
|
1
|
+
require 'active_support/all'
|
2
|
+
require 'rest_client'
|
3
|
+
require 'brownie/credentials'
|
4
|
+
require 'brownie/shipper'
|
5
|
+
require 'brownie/ship_to'
|
6
|
+
require 'brownie/ship_from'
|
7
|
+
module Brownie
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
class Shipment
|
12
|
+
attr_accessor :request,:errors,:account_number,:tracking_number,:shipment_digest,:credentials,:shipper,:ship_to,
|
13
|
+
:ship_from,:response,:service_code,:package_type,:declared_value,:package_weight,:label_binary,:api_domain,:environment
|
14
|
+
|
15
|
+
attr_writer :shipment_data,:shipment_xml
|
16
|
+
|
17
|
+
|
18
|
+
def initialize(shipment=nil)
|
19
|
+
self.shipment_data = shipment if !shipment.nil?
|
20
|
+
self.credentials = Credentials.new
|
21
|
+
self.shipper = Shipper.new
|
22
|
+
self.ship_to = ShipTo.new
|
23
|
+
self.ship_from = ShipFrom.new
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
def confirm
|
30
|
+
test = template_hash
|
31
|
+
shipment = test["ShipmentConfirmRequest"]["Shipment"]
|
32
|
+
|
33
|
+
shipment["PaymentInformation"]["Prepaid"]["BillShipper"]["AccountNumber"] = self.account_number
|
34
|
+
shipment["Service"]["Code"] = self.service_code
|
35
|
+
shipment["Package"]["PackagingType"]["Code"] = self.package_type
|
36
|
+
shipment["Package"]["PackageServiceOptions"]["InsuredValue"]["MonetaryValue"] = self.declared_value.to_s
|
37
|
+
shipment["Package"]["PackageWeight"]["Weight"] = self.package_weight.nil? ? 1.0.to_s : self.package_weight.to_s
|
38
|
+
|
39
|
+
shipment["Shipper"]["Name"] = self.shipper.name
|
40
|
+
shipment["Shipper"]["PhoneNumber"] = self.shipper.phone_number
|
41
|
+
shipment["Shipper"]["ShipperNumber"] = self.account_number
|
42
|
+
shipment["Shipper"]["TaxIdentificationNumber"] = self.shipper.tax_identification_number
|
43
|
+
shipment["Shipper"]["Address"]["AddressLine1"] = self.shipper.address_line1
|
44
|
+
shipment["Shipper"]["Address"]["AddressLine2"] = self.shipper.address_line2 if !self.shipper.address_line2.nil?
|
45
|
+
shipment["Shipper"]["Address"]["City"] = self.shipper.city
|
46
|
+
shipment["Shipper"]["Address"]["StateProvinceCode"] = self.shipper.state_province_code
|
47
|
+
shipment["Shipper"]["Address"]["PostalCode"] = self.shipper.postal_code
|
48
|
+
shipment["Shipper"]["Address"]["CountryCode"] = self.shipper.country_code
|
49
|
+
|
50
|
+
|
51
|
+
shipto = shipment["ShipTo"]
|
52
|
+
shipto["CompanyName"] = self.ship_to.company_name
|
53
|
+
shipto["AttentionName"] = self.ship_to.attention_name
|
54
|
+
shipto["PhoneNumber"] = self.ship_to.phone_number
|
55
|
+
shipto["AttentionName"] = self.ship_to.attention_name
|
56
|
+
shipto["Address"]["AddressLine1"] = self.ship_to.address_line1
|
57
|
+
shipto["Address"]["AddressLine2"] = self.ship_to.address_line2 if !self.ship_to.address_line2.nil?
|
58
|
+
shipto["Address"]["City"] = self.ship_to.city
|
59
|
+
shipto["Address"]["StateProvinceCode"] = self.ship_to.state_province_code
|
60
|
+
shipto["Address"]["PostalCode"] = self.ship_to.postal_code
|
61
|
+
shipto["Address"]["CountryCode"] = self.ship_to.country_code
|
62
|
+
|
63
|
+
|
64
|
+
shipfrom = shipment["ShipFrom"]
|
65
|
+
shipfrom["CompanyName"] = self.ship_from.company_name
|
66
|
+
shipfrom["AttentionName"] = self.ship_from.attention_name
|
67
|
+
shipfrom["PhoneNumber"] = self.ship_from.phone_number
|
68
|
+
shipfrom["AttentionName"] = self.ship_from.attention_name
|
69
|
+
shipfrom["Address"]["AddressLine1"] = self.ship_from.address_line1
|
70
|
+
shipfrom["Address"]["AddressLine2"] = self.ship_from.address_line2 if !self.ship_from.address_line2.nil?
|
71
|
+
shipfrom["Address"]["City"] = self.ship_from.city
|
72
|
+
shipfrom["Address"]["StateProvinceCode"] = self.ship_from.state_province_code
|
73
|
+
shipfrom["Address"]["PostalCode"] = self.ship_from.postal_code
|
74
|
+
shipfrom["Address"]["CountryCode"] = self.ship_from.country_code
|
75
|
+
|
76
|
+
|
77
|
+
shipment_xml_str = test["ShipmentConfirmRequest"].to_xml(:root => "ShipmentConfirmRequest")
|
78
|
+
|
79
|
+
self.response = RestClient.post("https://#{domain}/ups.app/xml/ShipConfirm","#{access_request_header}#{shipment_xml_str}")
|
80
|
+
if self.response.code.eql?(200)
|
81
|
+
response_hash = Hash.from_xml(response)
|
82
|
+
if response_hash["ShipmentConfirmResponse"]["Response"]["ResponseStatusCode"].eql?("0")
|
83
|
+
self.errors = response_hash["ShipmentConfirmResponse"]["Response"]["Error"]
|
84
|
+
return false
|
85
|
+
end
|
86
|
+
|
87
|
+
self.tracking_number = response_hash["ShipmentConfirmResponse"]["ShipmentIdentificationNumber"]
|
88
|
+
self.shipment_digest = response_hash["ShipmentConfirmResponse"]["ShipmentDigest"]
|
89
|
+
return true
|
90
|
+
|
91
|
+
else
|
92
|
+
raise "In-valid request #{response}"
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def label(_shipment_digest,path)
|
97
|
+
shipment_digest = _shipment_digest.nil? ? @shipment_digest : _shipment_digest
|
98
|
+
label_xml = '<?xml version="1.0" encoding="ISO-8859-1"?>
|
99
|
+
<ShipmentAcceptRequest>
|
100
|
+
<Request>
|
101
|
+
<TransactionReference>
|
102
|
+
<CustomerContext></CustomerContext>
|
103
|
+
</TransactionReference>
|
104
|
+
<RequestAction>ShipAccept</RequestAction>
|
105
|
+
<RequestOption>1</RequestOption>
|
106
|
+
</Request>
|
107
|
+
<ShipmentDigest>' + shipment_digest + '</ShipmentDigest>
|
108
|
+
</ShipmentAcceptRequest>'
|
109
|
+
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
label_response = RestClient.post("https://#{domain}/ups.app/xml/ShipAccept","#{access_request_header}#{label_xml}")
|
114
|
+
label_hash = Hash.from_xml(label_response)
|
115
|
+
self.label_binary = label_hash["ShipmentAcceptResponse"]["ShipmentResults"]["PackageResults"]["LabelImage"]["GraphicImage"]
|
116
|
+
File.open(path, 'wb') do|f|
|
117
|
+
f.write(Base64.decode64(self.label_binary))
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
121
|
+
|
122
|
+
|
123
|
+
private
|
124
|
+
def domain
|
125
|
+
if self.environment.nil?
|
126
|
+
"wwwcie.ups.com"
|
127
|
+
elsif self.environment == "production"
|
128
|
+
"onlinetools.ups.com"
|
129
|
+
else
|
130
|
+
"wwwcie.ups.com"
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
def template_hash
|
135
|
+
digest_xml_file = File.open("xml/ship_confirm.xml", "rb")
|
136
|
+
@shipment_xml = digest_xml_file.read
|
137
|
+
Hash.from_xml(@shipment_xml)
|
138
|
+
end
|
139
|
+
|
140
|
+
def access_request_header
|
141
|
+
'<?xml version="1.0"?>
|
142
|
+
<AccessRequest xml:lang="en-US">
|
143
|
+
<AccessLicenseNumber>' + self.credentials.license_number + '</AccessLicenseNumber>
|
144
|
+
<UserId>' + self.credentials.user_id + '</UserId>
|
145
|
+
<Password>' + self.credentials.password + '</Password>
|
146
|
+
</AccessRequest>'
|
147
|
+
end
|
148
|
+
|
149
|
+
end
|
150
|
+
|
151
|
+
|
152
|
+
class Package
|
153
|
+
BAG = "01"
|
154
|
+
BOX = "02"
|
155
|
+
CARTON = "03"
|
156
|
+
CRATE = "04"
|
157
|
+
DRUM = "05"
|
158
|
+
PALLET = "06"
|
159
|
+
ROLL = "07"
|
160
|
+
TUBE = "08"
|
161
|
+
end
|
162
|
+
|
163
|
+
class ServiceCodes
|
164
|
+
STANDARD = "11"
|
165
|
+
GROUND = "03"
|
166
|
+
E3DAYSELECT = "12"
|
167
|
+
E2NDDAYAIR = "02"
|
168
|
+
E2NDDAYAIRAM = "59"
|
169
|
+
NEXTDAYAIRSAVER = "13"
|
170
|
+
NEXTDAYAIR = "01"
|
171
|
+
NEXTDAYAIREARLYAM = "14"
|
172
|
+
UPSWORLDWIDEEXPRESS = "07"
|
173
|
+
WORLDWIDEEXPRESSPLUS = "54"
|
174
|
+
UPSWORDWIDESAVER = "65"
|
175
|
+
UPSWORLDWIDEEXPEDITED = "08"
|
176
|
+
|
177
|
+
end
|
178
|
+
|
179
|
+
|
180
|
+
end
|
181
|
+
|
data/test/helper.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
|
3
|
+
module SimpleCov::Configuration
|
4
|
+
def clean_filters
|
5
|
+
@filters = []
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
SimpleCov.configure do
|
10
|
+
clean_filters
|
11
|
+
load_adapter 'test_frameworks'
|
12
|
+
end
|
13
|
+
|
14
|
+
ENV["COVERAGE"] && SimpleCov.start do
|
15
|
+
add_filter "/.rvm/"
|
16
|
+
end
|
17
|
+
require 'rubygems'
|
18
|
+
require 'bundler'
|
19
|
+
begin
|
20
|
+
Bundler.setup(:default, :development)
|
21
|
+
rescue Bundler::BundlerError => e
|
22
|
+
$stderr.puts e.message
|
23
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
24
|
+
exit e.status_code
|
25
|
+
end
|
26
|
+
require 'test/unit'
|
27
|
+
require 'shoulda'
|
28
|
+
|
29
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
30
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
31
|
+
require 'brownie'
|
32
|
+
|
33
|
+
class Test::Unit::TestCase
|
34
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<ShipmentConfirmRequest xml:lang="en-US">
|
3
|
+
<Request>
|
4
|
+
<TransactionReference>
|
5
|
+
<CustomerContext></CustomerContext>
|
6
|
+
<XpciVersion />
|
7
|
+
</TransactionReference>
|
8
|
+
<RequestAction>ShipConfirm</RequestAction>
|
9
|
+
<RequestOption>validate</RequestOption>
|
10
|
+
</Request>
|
11
|
+
<LabelSpecification>
|
12
|
+
<LabelPrintMethod>
|
13
|
+
<Code>GIF</Code>
|
14
|
+
<Description>gif file</Description>
|
15
|
+
</LabelPrintMethod>
|
16
|
+
<HTTPUserAgent>Mozilla/4.5</HTTPUserAgent>
|
17
|
+
<LabelImageFormat>
|
18
|
+
<Code>GIF</Code>
|
19
|
+
<Description>gif</Description>
|
20
|
+
</LabelImageFormat>
|
21
|
+
</LabelSpecification>
|
22
|
+
<Shipment>
|
23
|
+
<RateInformation>
|
24
|
+
<NegotiatedRatesIndicator />
|
25
|
+
</RateInformation>
|
26
|
+
<Description />
|
27
|
+
<Shipper>
|
28
|
+
<Name></Name>
|
29
|
+
<PhoneNumber></PhoneNumber>
|
30
|
+
<ShipperNumber></ShipperNumber>
|
31
|
+
<TaxIdentificationNumber></TaxIdentificationNumber>
|
32
|
+
<Address>
|
33
|
+
<AddressLine1></AddressLine1>
|
34
|
+
<City></City>
|
35
|
+
<StateProvinceCode></StateProvinceCode>
|
36
|
+
<PostalCode></PostalCode>
|
37
|
+
<PostcodeExtendedLow />
|
38
|
+
<CountryCode></CountryCode>
|
39
|
+
</Address>
|
40
|
+
</Shipper>
|
41
|
+
<ShipTo>
|
42
|
+
<CompanyName></CompanyName>
|
43
|
+
<AttentionName></AttentionName>
|
44
|
+
<PhoneNumber></PhoneNumber>
|
45
|
+
<Address>
|
46
|
+
<AddressLine1></AddressLine1>
|
47
|
+
<City></City>
|
48
|
+
<StateProvinceCode></StateProvinceCode>
|
49
|
+
<PostalCode></PostalCode>
|
50
|
+
<CountryCode></CountryCode>
|
51
|
+
</Address>
|
52
|
+
</ShipTo>
|
53
|
+
<ShipFrom>
|
54
|
+
<CompanyName></CompanyName>
|
55
|
+
<AttentionName></AttentionName>
|
56
|
+
<PhoneNumber></PhoneNumber>
|
57
|
+
<TaxIdentificationNumber></TaxIdentificationNumber>
|
58
|
+
<Address>
|
59
|
+
<AddressLine1></AddressLine1>
|
60
|
+
<City></City>
|
61
|
+
<StateProvinceCode></StateProvinceCode>
|
62
|
+
<PostalCode></PostalCode>
|
63
|
+
<CountryCode></CountryCode>
|
64
|
+
</Address>
|
65
|
+
</ShipFrom>
|
66
|
+
<PaymentInformation>
|
67
|
+
<Prepaid>
|
68
|
+
<BillShipper>
|
69
|
+
<AccountNumber></AccountNumber>
|
70
|
+
</BillShipper>
|
71
|
+
</Prepaid>
|
72
|
+
</PaymentInformation>
|
73
|
+
<Service>
|
74
|
+
<Code></Code>
|
75
|
+
</Service>
|
76
|
+
<Package>
|
77
|
+
<PackagingType>
|
78
|
+
<Code></Code>
|
79
|
+
</PackagingType>
|
80
|
+
<PackageWeight>
|
81
|
+
<Weight></Weight>
|
82
|
+
</PackageWeight>
|
83
|
+
|
84
|
+
<PackageServiceOptions>
|
85
|
+
<InsuredValue> <MonetaryValue></MonetaryValue>
|
86
|
+
</InsuredValue>
|
87
|
+
</PackageServiceOptions>
|
88
|
+
</Package>
|
89
|
+
</Shipment>
|
90
|
+
</ShipmentConfirmRequest>
|
metadata
ADDED
@@ -0,0 +1,158 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: brownie
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Michael Jaffe
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-03-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.2.2
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.2.2
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rest_client
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.7'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.7'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: shoulda
|
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: rdoc
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.12'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.12'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bundler
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: jeweler
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 2.0.1
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ~>
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 2.0.1
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: simplecov
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: Creates UPS shipments and labels via UPS.com's developer api.
|
112
|
+
email: mike@mikewritescode.com
|
113
|
+
executables: []
|
114
|
+
extensions: []
|
115
|
+
extra_rdoc_files:
|
116
|
+
- LICENSE.txt
|
117
|
+
- README.markdown
|
118
|
+
files:
|
119
|
+
- .document
|
120
|
+
- Gemfile
|
121
|
+
- Gemfile.lock
|
122
|
+
- LICENSE.txt
|
123
|
+
- README.markdown
|
124
|
+
- Rakefile
|
125
|
+
- VERSION
|
126
|
+
- lib/brownie.rb
|
127
|
+
- lib/brownie/credentials.rb
|
128
|
+
- lib/brownie/ship_from.rb
|
129
|
+
- lib/brownie/ship_to.rb
|
130
|
+
- lib/brownie/shipper.rb
|
131
|
+
- test/helper.rb
|
132
|
+
- test/test_brownie.rb
|
133
|
+
- xml/ship_confirm.xml
|
134
|
+
homepage: http://github.com/mikejaffe/brownie
|
135
|
+
licenses:
|
136
|
+
- MIT
|
137
|
+
metadata: {}
|
138
|
+
post_install_message:
|
139
|
+
rdoc_options: []
|
140
|
+
require_paths:
|
141
|
+
- lib
|
142
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - '>='
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - '>='
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
152
|
+
requirements: []
|
153
|
+
rubyforge_project:
|
154
|
+
rubygems_version: 2.1.10
|
155
|
+
signing_key:
|
156
|
+
specification_version: 4
|
157
|
+
summary: Creates UPS shipments and labels
|
158
|
+
test_files: []
|