fedex_label_service 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/.rspec +2 -0
- data/.rubocop.yml +1 -0
- data/.rubocop_todo.yml +43 -0
- data/.travis.yml +5 -0
- data/Gemfile +8 -0
- data/Guardfile +72 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +8 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/fedex_label_service.gemspec +48 -0
- data/lib/fedex_label_service.rb +59 -0
- data/lib/fedex_label_service/configuration.rb +21 -0
- data/lib/fedex_label_service/ground_message.rb +110 -0
- data/lib/fedex_label_service/smartpost_message.rb +115 -0
- data/lib/fedex_label_service/version.rb +5 -0
- metadata +245 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d9bfe6aa641c960e08a224a9ee57fb1e58a62699164715a58e1ee6f9d1c52ef6
|
4
|
+
data.tar.gz: 456c88b8f7b3e29624f4b7f4025429467afc239cc556c1631c5f925b13caf486
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bdc2e60f8d0d47cea3873a83b0bef7c2cd0e7c768a4d1744f0e03bfa545ef719ece595f8371847fcdcffe444771dbc483f4d331a7121f166a933139b89f1d46f
|
7
|
+
data.tar.gz: fca2a5432e31250bdd2cda8d277d69eaab4de36202a518fcd938ef1bcd2e0f085ba92a6bd86b89de3fea36607d33f5db3b1f4a5e1af0bdf6fe6ae7034645b834
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
inherit_from: .rubocop_todo.yml
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2018-09-27 10:28:17 -0400 using RuboCop version 0.59.2.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 2
|
10
|
+
Metrics/AbcSize:
|
11
|
+
Max: 36
|
12
|
+
|
13
|
+
# Offense count: 5
|
14
|
+
# Configuration parameters: CountComments, ExcludedMethods.
|
15
|
+
# ExcludedMethods: refine
|
16
|
+
Metrics/BlockLength:
|
17
|
+
Max: 84
|
18
|
+
|
19
|
+
# Offense count: 2
|
20
|
+
# Configuration parameters: CountComments.
|
21
|
+
Metrics/ClassLength:
|
22
|
+
Max: 108
|
23
|
+
|
24
|
+
# Offense count: 2
|
25
|
+
# Configuration parameters: CountComments, ExcludedMethods.
|
26
|
+
Metrics/MethodLength:
|
27
|
+
Max: 106
|
28
|
+
|
29
|
+
# Offense count: 4
|
30
|
+
Style/Documentation:
|
31
|
+
Exclude:
|
32
|
+
- 'spec/**/*'
|
33
|
+
- 'test/**/*'
|
34
|
+
- 'lib/fedex_label_service.rb'
|
35
|
+
- 'lib/fedex_label_service/configuration.rb'
|
36
|
+
- 'lib/fedex_label_service/ground_message.rb'
|
37
|
+
- 'lib/fedex_label_service/smartpost_message.rb'
|
38
|
+
|
39
|
+
# Offense count: 31
|
40
|
+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
41
|
+
# URISchemes: http, https
|
42
|
+
Metrics/LineLength:
|
43
|
+
Max: 170
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# A sample Guardfile
|
4
|
+
# More info at https://github.com/guard/guard#readme
|
5
|
+
|
6
|
+
## Uncomment and set this to only include directories you want to watch
|
7
|
+
# directories %w(app lib config test spec features) \
|
8
|
+
# .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
|
9
|
+
|
10
|
+
## Note: if you are using the `directories` clause above and you are not
|
11
|
+
## watching the project directory ('.'), then you will want to move
|
12
|
+
## the Guardfile to a watched dir and symlink it back, e.g.
|
13
|
+
#
|
14
|
+
# $ mkdir config
|
15
|
+
# $ mv Guardfile config/
|
16
|
+
# $ ln -s config/Guardfile .
|
17
|
+
#
|
18
|
+
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
19
|
+
|
20
|
+
# Note: The cmd option is now required due to the increasing number of ways
|
21
|
+
# rspec may be run, below are examples of the most common uses.
|
22
|
+
# * bundler: 'bundle exec rspec'
|
23
|
+
# * bundler binstubs: 'bin/rspec'
|
24
|
+
# * spring: 'bin/rspec' (This will use spring if running and you have
|
25
|
+
# installed the spring binstubs per the docs)
|
26
|
+
# * zeus: 'zeus rspec' (requires the server to be started separately)
|
27
|
+
# * 'just' rspec: 'rspec'
|
28
|
+
|
29
|
+
guard :rspec, cmd: 'bundle exec rspec' do
|
30
|
+
require 'guard/rspec/dsl'
|
31
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
32
|
+
|
33
|
+
# Feel free to open issues for suggestions and improvements
|
34
|
+
|
35
|
+
# RSpec files
|
36
|
+
rspec = dsl.rspec
|
37
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
38
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
39
|
+
watch(rspec.spec_files)
|
40
|
+
|
41
|
+
# Ruby files
|
42
|
+
ruby = dsl.ruby
|
43
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
44
|
+
|
45
|
+
# Rails files
|
46
|
+
rails = dsl.rails(view_extensions: %w[erb haml slim])
|
47
|
+
dsl.watch_spec_files_for(rails.app_files)
|
48
|
+
dsl.watch_spec_files_for(rails.views)
|
49
|
+
|
50
|
+
watch(rails.controllers) do |m|
|
51
|
+
[
|
52
|
+
rspec.spec.call("routing/#{m[1]}_routing"),
|
53
|
+
rspec.spec.call("controllers/#{m[1]}_controller"),
|
54
|
+
rspec.spec.call("acceptance/#{m[1]}")
|
55
|
+
]
|
56
|
+
end
|
57
|
+
|
58
|
+
# Rails config changes
|
59
|
+
watch(rails.spec_helper) { rspec.spec_dir }
|
60
|
+
watch(rails.routes) { "#{rspec.spec_dir}/routing" }
|
61
|
+
watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
|
62
|
+
|
63
|
+
# Capybara features specs
|
64
|
+
watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
|
65
|
+
watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") }
|
66
|
+
|
67
|
+
# Turnip features and steps
|
68
|
+
watch(%r{^spec/acceptance/(.+)\.feature$})
|
69
|
+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
|
70
|
+
Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance'
|
71
|
+
end
|
72
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Casey Ellett
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# FedexLabelService
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/label_service`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'label_service'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install label_service
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/label_service.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'fedex_label_service'
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require 'irb'
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'fedex_label_service/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'fedex_label_service'
|
9
|
+
spec.version = FedexLabelService::VERSION
|
10
|
+
spec.authors = ['odin - (Casey Ellett)']
|
11
|
+
spec.email = ['casey.ellett@gmail.com']
|
12
|
+
|
13
|
+
spec.summary = 'Interface for FedEx Label Services API.'
|
14
|
+
spec.homepage = 'https://github.com/odin/fedex_label_service'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
21
|
+
else
|
22
|
+
raise 'RubyGems 2.0 or newer is required to protect against ' \
|
23
|
+
'public gem pushes.'
|
24
|
+
end
|
25
|
+
|
26
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
27
|
+
f.match(%r{^(test|spec|features)/})
|
28
|
+
end
|
29
|
+
|
30
|
+
spec.bindir = 'exe'
|
31
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
32
|
+
spec.require_paths = ['lib']
|
33
|
+
|
34
|
+
spec.add_development_dependency 'awesome_print'
|
35
|
+
spec.add_development_dependency 'bundler', '~> 1.15'
|
36
|
+
spec.add_development_dependency 'dotenv'
|
37
|
+
spec.add_development_dependency 'guard'
|
38
|
+
spec.add_development_dependency 'guard-rspec'
|
39
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
40
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
41
|
+
spec.add_development_dependency 'rubocop'
|
42
|
+
spec.add_development_dependency 'simplecov'
|
43
|
+
spec.add_development_dependency 'terminal-notifier-guard'
|
44
|
+
spec.add_development_dependency 'vcr'
|
45
|
+
spec.add_development_dependency 'webmock'
|
46
|
+
|
47
|
+
spec.add_dependency 'savon'
|
48
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'fedex_label_service/version'
|
4
|
+
require 'fedex_label_service/configuration'
|
5
|
+
require 'fedex_label_service/ground_message'
|
6
|
+
require 'fedex_label_service/smartpost_message'
|
7
|
+
|
8
|
+
require 'savon'
|
9
|
+
|
10
|
+
module FedexLabelService
|
11
|
+
class << self
|
12
|
+
attr_writer :configuration
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.configuration
|
16
|
+
@configuration ||= Configuration.new
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.reset
|
20
|
+
@configuration = Configuration.new
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.configure
|
24
|
+
yield(configuration)
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.root
|
28
|
+
Pathname.new File.expand_path('..', __dir__)
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.message(service, sender_attributes, recipient_attributes)
|
32
|
+
if service == 'smartpost'
|
33
|
+
message = FedexLabelService::SmartpostMessage.build(sender_attributes, recipient_attributes)
|
34
|
+
elsif service == 'ground'
|
35
|
+
message = FedexLabelService::GroundMessage.build(sender_attributes, recipient_attributes)
|
36
|
+
end
|
37
|
+
|
38
|
+
message
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.call(message)
|
42
|
+
client = Savon.client(wsdl: FedexLabelService.configuration.wsdl)
|
43
|
+
|
44
|
+
begin
|
45
|
+
@response = client.call(:process_shipment, message: message)
|
46
|
+
rescue Savon::SOAPFault => error
|
47
|
+
puts error.http.inspect
|
48
|
+
end
|
49
|
+
|
50
|
+
@response
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.parsed_response(response)
|
54
|
+
{
|
55
|
+
tracking_number: response.body[:process_shipment_reply][:completed_shipment_detail][:completed_package_details][:tracking_ids][:tracking_number],
|
56
|
+
label_data: response.body[:process_shipment_reply][:completed_shipment_detail][:completed_package_details][:label][:parts][:image]
|
57
|
+
}
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module FedexLabelService
|
4
|
+
class Configuration
|
5
|
+
attr_accessor :wsdl
|
6
|
+
attr_accessor :key
|
7
|
+
attr_accessor :password
|
8
|
+
attr_accessor :account_number
|
9
|
+
attr_accessor :meter_number
|
10
|
+
attr_accessor :hub_id
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
@wsdl = nil
|
14
|
+
@key = nil
|
15
|
+
@password = nil
|
16
|
+
@account_number = nil
|
17
|
+
@meter_number = nil
|
18
|
+
@hub_id = nil
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module FedexLabelService
|
4
|
+
class GroundMessage
|
5
|
+
def self.build(sender_attributes, recipient_attributes)
|
6
|
+
recipient_street = "#{recipient_attributes[:address_one]} #{recipient_attributes[:address_two]}"
|
7
|
+
sender_street = "#{sender_attributes[:address_one]} #{sender_attributes[:address_two]}"
|
8
|
+
sender_name = "#{sender_attributes[:first_name]} #{sender_attributes[:last_name]}"
|
9
|
+
|
10
|
+
{
|
11
|
+
'WebAuthenticationDetail' => [
|
12
|
+
'ParentCredential' => [
|
13
|
+
'Key' => FedexLabelService.configuration.key,
|
14
|
+
'Password' => FedexLabelService.configuration.password
|
15
|
+
],
|
16
|
+
'UserCredential' => [
|
17
|
+
'Key' => FedexLabelService.configuration.key,
|
18
|
+
'Password' => FedexLabelService.configuration.password
|
19
|
+
]
|
20
|
+
],
|
21
|
+
'ClientDetail' => [
|
22
|
+
'AccountNumber' => FedexLabelService.configuration.account_number,
|
23
|
+
'MeterNumber' => FedexLabelService.configuration.meter_number
|
24
|
+
],
|
25
|
+
'TransactionDetail' => [
|
26
|
+
'CustomerTransactionId' => 'label_service gem Ground Request'
|
27
|
+
],
|
28
|
+
'Version' => [
|
29
|
+
'ServiceId' => 'ship',
|
30
|
+
'Major' => '21',
|
31
|
+
'Intermediate' => '0',
|
32
|
+
'Minor' => '0'
|
33
|
+
],
|
34
|
+
'RequestedShipment' => [
|
35
|
+
'ShipTimestamp' => Time.now.iso8601,
|
36
|
+
'DropoffType' => 'BUSINESS_SERVICE_CENTER',
|
37
|
+
'ServiceType' => 'FEDEX_GROUND',
|
38
|
+
'PackagingType' => 'YOUR_PACKAGING',
|
39
|
+
'Shipper' => [
|
40
|
+
'Contact' => [
|
41
|
+
'PersonName' => sender_name,
|
42
|
+
'CompanyName' => sender_name,
|
43
|
+
'PhoneNumber' => sender_attributes[:phone]
|
44
|
+
],
|
45
|
+
'Address' => [
|
46
|
+
'StreetLines' => [
|
47
|
+
sender_street
|
48
|
+
],
|
49
|
+
'City' => sender_attributes[:city],
|
50
|
+
'StateOrProvinceCode' => sender_attributes[:state],
|
51
|
+
'PostalCode' => sender_attributes[:postal_code],
|
52
|
+
'CountryCode' => 'US'
|
53
|
+
]
|
54
|
+
],
|
55
|
+
'Recipient' => [
|
56
|
+
'Contact' => [
|
57
|
+
'PersonName' => recipient_attributes[:name],
|
58
|
+
'CompanyName' => recipient_attributes[:company],
|
59
|
+
'PhoneNumber' => recipient_attributes[:phone]
|
60
|
+
],
|
61
|
+
'Address' => [
|
62
|
+
'StreetLines' => [
|
63
|
+
recipient_street
|
64
|
+
],
|
65
|
+
'City' => recipient_attributes[:city],
|
66
|
+
'StateOrProvinceCode' => recipient_attributes[:state],
|
67
|
+
'PostalCode' => recipient_attributes[:postal_code],
|
68
|
+
'CountryCode' => 'US'
|
69
|
+
]
|
70
|
+
],
|
71
|
+
'ShippingChargesPayment' => [
|
72
|
+
'PaymentType' => 'SENDER',
|
73
|
+
'Payor' => [
|
74
|
+
'ResponsibleParty' => [
|
75
|
+
'AccountNumber' => FedexLabelService.configuration.account_number,
|
76
|
+
'Contact' => [],
|
77
|
+
'Address' => [
|
78
|
+
'CountryCode' => 'US'
|
79
|
+
]
|
80
|
+
]
|
81
|
+
]
|
82
|
+
],
|
83
|
+
'SpecialServicesRequested' => [
|
84
|
+
'SpecialServiceTypes' => 'RETURN_SHIPMENT',
|
85
|
+
'ReturnShipmentDetail' => [
|
86
|
+
'ReturnType' => 'PRINT_RETURN_LABEL'
|
87
|
+
]
|
88
|
+
],
|
89
|
+
'LabelSpecification' => [
|
90
|
+
'LabelFormatType' => 'COMMON2D',
|
91
|
+
'ImageType' => 'PNG',
|
92
|
+
'LabelStockType' => 'PAPER_4X6'
|
93
|
+
],
|
94
|
+
'PackageCount' => 1,
|
95
|
+
'RequestedPackageLineItems' => [
|
96
|
+
'SequenceNumber' => 1,
|
97
|
+
'Weight' => [
|
98
|
+
'Units' => 'LB',
|
99
|
+
'Value' => 2.0
|
100
|
+
],
|
101
|
+
'CustomerReferences' => [
|
102
|
+
'CustomerReferenceType' => 'CUSTOMER_REFERENCE',
|
103
|
+
'Value' => sender_attributes[:customer_reference]
|
104
|
+
]
|
105
|
+
]
|
106
|
+
]
|
107
|
+
}
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
@@ -0,0 +1,115 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module FedexLabelService
|
4
|
+
class SmartpostMessage
|
5
|
+
def self.build(sender_attributes, recipient_attributes)
|
6
|
+
recipient_street = "#{recipient_attributes[:address_one]} #{recipient_attributes[:address_two]}"
|
7
|
+
sender_street = "#{sender_attributes[:address_one]} #{sender_attributes[:address_two]}"
|
8
|
+
sender_name = "#{sender_attributes[:first_name]} #{sender_attributes[:last_name]}"
|
9
|
+
|
10
|
+
{
|
11
|
+
'WebAuthenticationDetail' => [
|
12
|
+
'ParentCredential' => [
|
13
|
+
'Key' => FedexLabelService.configuration.key,
|
14
|
+
'Password' => FedexLabelService.configuration.password
|
15
|
+
],
|
16
|
+
'UserCredential' => [
|
17
|
+
'Key' => FedexLabelService.configuration.key,
|
18
|
+
'Password' => FedexLabelService.configuration.password
|
19
|
+
]
|
20
|
+
],
|
21
|
+
'ClientDetail' => [
|
22
|
+
'AccountNumber' => FedexLabelService.configuration.account_number,
|
23
|
+
'MeterNumber' => FedexLabelService.configuration.meter_number
|
24
|
+
],
|
25
|
+
'TransactionDetail' => [
|
26
|
+
'CustomerTransactionId' => 'label_service gem SmartPost Request'
|
27
|
+
],
|
28
|
+
'Version' => [
|
29
|
+
'ServiceId' => 'ship',
|
30
|
+
'Major' => '21',
|
31
|
+
'Intermediate' => '0',
|
32
|
+
'Minor' => '0'
|
33
|
+
],
|
34
|
+
'RequestedShipment' => [
|
35
|
+
'ShipTimestamp' => Time.now.iso8601,
|
36
|
+
'DropoffType' => 'BUSINESS_SERVICE_CENTER',
|
37
|
+
'ServiceType' => 'SMART_POST',
|
38
|
+
'PackagingType' => 'YOUR_PACKAGING',
|
39
|
+
'Shipper' => [
|
40
|
+
'Contact' => [
|
41
|
+
'PersonName' => sender_name,
|
42
|
+
'CompanyName' => sender_name,
|
43
|
+
'PhoneNumber' => sender_attributes[:phone]
|
44
|
+
],
|
45
|
+
'Address' => [
|
46
|
+
'StreetLines' => [
|
47
|
+
sender_street
|
48
|
+
],
|
49
|
+
'City' => sender_attributes[:city],
|
50
|
+
'StateOrProvinceCode' => sender_attributes[:state],
|
51
|
+
'PostalCode' => sender_attributes[:postal_code],
|
52
|
+
'CountryCode' => 'US'
|
53
|
+
]
|
54
|
+
],
|
55
|
+
'Recipient' => [
|
56
|
+
'Contact' => [
|
57
|
+
'PersonName' => recipient_attributes[:name],
|
58
|
+
'CompanyName' => recipient_attributes[:company],
|
59
|
+
'PhoneNumber' => recipient_attributes[:phone]
|
60
|
+
],
|
61
|
+
'Address' => [
|
62
|
+
'StreetLines' => [
|
63
|
+
recipient_street
|
64
|
+
],
|
65
|
+
'City' => recipient_attributes[:city],
|
66
|
+
'StateOrProvinceCode' => recipient_attributes[:state],
|
67
|
+
'PostalCode' => recipient_attributes[:postal_code],
|
68
|
+
'CountryCode' => 'US'
|
69
|
+
]
|
70
|
+
],
|
71
|
+
'ShippingChargesPayment' => [
|
72
|
+
'PaymentType' => 'SENDER',
|
73
|
+
'Payor' => [
|
74
|
+
'ResponsibleParty' => [
|
75
|
+
'AccountNumber' => FedexLabelService.configuration.account_number,
|
76
|
+
'Contact' => [],
|
77
|
+
'Address' => [
|
78
|
+
'CountryCode' => 'US'
|
79
|
+
]
|
80
|
+
]
|
81
|
+
]
|
82
|
+
],
|
83
|
+
'SpecialServicesRequested' => [
|
84
|
+
'SpecialServiceTypes' => 'RETURN_SHIPMENT',
|
85
|
+
'ReturnShipmentDetail' => [
|
86
|
+
'ReturnType' => 'PRINT_RETURN_LABEL'
|
87
|
+
]
|
88
|
+
],
|
89
|
+
'SmartPostDetail' => [
|
90
|
+
'Indicia' => 'PARCEL_RETURN',
|
91
|
+
'AncillaryEndorsement' => 'RETURN_SERVICE',
|
92
|
+
'HubId' => FedexLabelService.configuration.hub_id
|
93
|
+
],
|
94
|
+
'LabelSpecification' => [
|
95
|
+
'LabelFormatType' => 'COMMON2D',
|
96
|
+
'ImageType' => 'PNG',
|
97
|
+
'LabelStockType' => 'PAPER_4X6'
|
98
|
+
],
|
99
|
+
'PackageCount' => 1,
|
100
|
+
'RequestedPackageLineItems' => [
|
101
|
+
'SequenceNumber' => 1,
|
102
|
+
'Weight' => [
|
103
|
+
'Units' => 'LB',
|
104
|
+
'Value' => 2.0
|
105
|
+
],
|
106
|
+
'CustomerReferences' => [
|
107
|
+
'CustomerReferenceType' => 'CUSTOMER_REFERENCE',
|
108
|
+
'Value' => sender_attributes[:customer_reference]
|
109
|
+
]
|
110
|
+
]
|
111
|
+
]
|
112
|
+
}
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
metadata
ADDED
@@ -0,0 +1,245 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fedex_label_service
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- odin - (Casey Ellett)
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-09-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: awesome_print
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.15'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.15'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: dotenv
|
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: guard
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: guard-rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '10.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '10.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rspec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '3.0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '3.0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rubocop
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: simplecov
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: terminal-notifier-guard
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: vcr
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: webmock
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: savon
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ">="
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
type: :runtime
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - ">="
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
195
|
+
description:
|
196
|
+
email:
|
197
|
+
- casey.ellett@gmail.com
|
198
|
+
executables: []
|
199
|
+
extensions: []
|
200
|
+
extra_rdoc_files: []
|
201
|
+
files:
|
202
|
+
- ".gitignore"
|
203
|
+
- ".rspec"
|
204
|
+
- ".rubocop.yml"
|
205
|
+
- ".rubocop_todo.yml"
|
206
|
+
- ".travis.yml"
|
207
|
+
- Gemfile
|
208
|
+
- Guardfile
|
209
|
+
- LICENSE.txt
|
210
|
+
- README.md
|
211
|
+
- Rakefile
|
212
|
+
- bin/console
|
213
|
+
- bin/setup
|
214
|
+
- fedex_label_service.gemspec
|
215
|
+
- lib/fedex_label_service.rb
|
216
|
+
- lib/fedex_label_service/configuration.rb
|
217
|
+
- lib/fedex_label_service/ground_message.rb
|
218
|
+
- lib/fedex_label_service/smartpost_message.rb
|
219
|
+
- lib/fedex_label_service/version.rb
|
220
|
+
homepage: https://github.com/odin/fedex_label_service
|
221
|
+
licenses:
|
222
|
+
- MIT
|
223
|
+
metadata:
|
224
|
+
allowed_push_host: https://rubygems.org
|
225
|
+
post_install_message:
|
226
|
+
rdoc_options: []
|
227
|
+
require_paths:
|
228
|
+
- lib
|
229
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
230
|
+
requirements:
|
231
|
+
- - ">="
|
232
|
+
- !ruby/object:Gem::Version
|
233
|
+
version: '0'
|
234
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
235
|
+
requirements:
|
236
|
+
- - ">="
|
237
|
+
- !ruby/object:Gem::Version
|
238
|
+
version: '0'
|
239
|
+
requirements: []
|
240
|
+
rubyforge_project:
|
241
|
+
rubygems_version: 2.7.6
|
242
|
+
signing_key:
|
243
|
+
specification_version: 4
|
244
|
+
summary: Interface for FedEx Label Services API.
|
245
|
+
test_files: []
|