mws-merchant_fulfillment 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rubocop.yml +87 -0
- data/.travis.yml +9 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +117 -0
- data/Guardfile +31 -0
- data/LICENSE +20 -0
- data/README.md +51 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/mws/merchant_fulfillment/available_format_options_for_label.rb +17 -0
- data/lib/mws/merchant_fulfillment/collection.rb +29 -0
- data/lib/mws/merchant_fulfillment/document.rb +26 -0
- data/lib/mws/merchant_fulfillment/entity.rb +50 -0
- data/lib/mws/merchant_fulfillment/parser.rb +44 -0
- data/lib/mws/merchant_fulfillment/rate.rb +17 -0
- data/lib/mws/merchant_fulfillment/shipping_service.rb +56 -0
- data/lib/mws/merchant_fulfillment/shipping_service_option.rb +17 -0
- data/lib/mws/merchant_fulfillment/shipping_services.rb +16 -0
- data/lib/mws/merchant_fulfillment/version.rb +7 -0
- data/lib/mws-merchant-fulfillment.rb +4 -0
- data/mws-merchant_fulfillment.gemspec +48 -0
- metadata +238 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 16d887456e6c304825431e7e152c3401d298389d
|
4
|
+
data.tar.gz: b2158650272db1f10ae5c224118b9b6c85ea2a7e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bd6ffbe1cd4bfecde9e0f518493a878a58e4b472dad2ad09e0e1bf8545b632b70c1e209b6739c951d34709de8e1c852a4afb5a4237896895753b8c6596194f39
|
7
|
+
data.tar.gz: b473c6cc5812a34276c4ba1e6178a4e941a04ec9eb59d08b80ceeae0ead1593f98230119fbc53f4fe5c343e50b28444a25867b85591eec13b3918a1d901c04d8
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
#
|
2
|
+
# For more information see https://github.com/bbatsov/rubocop/blob/master/config/default.yml
|
3
|
+
#
|
4
|
+
# However, do not include entire blocks here just because you want to change them.
|
5
|
+
# Include only the specific lines that you're changing from the defaults.
|
6
|
+
#
|
7
|
+
---
|
8
|
+
require: rubocop-rspec
|
9
|
+
AllCops:
|
10
|
+
Exclude:
|
11
|
+
- 'Gemfile.lock'
|
12
|
+
- 'tmp/**/*'
|
13
|
+
- '*.gemspec'
|
14
|
+
DisplayCopNames: true
|
15
|
+
DisplayStyleGuide: true
|
16
|
+
StyleGuideCopsOnly: false
|
17
|
+
|
18
|
+
Bundler/OrderedGems:
|
19
|
+
Enabled: false
|
20
|
+
Metrics/LineLength:
|
21
|
+
Max: 120
|
22
|
+
Metrics/BlockLength:
|
23
|
+
Exclude:
|
24
|
+
- 'Guardfile'
|
25
|
+
- 'spec/**/*.rb'
|
26
|
+
Style/BracesAroundHashParameters:
|
27
|
+
Enabled: false
|
28
|
+
Style/ClassCheck:
|
29
|
+
Enabled: false
|
30
|
+
Style/RegexpLiteral:
|
31
|
+
Exclude:
|
32
|
+
- 'Guardfile'
|
33
|
+
Style/SymbolArray:
|
34
|
+
MinSize: 3
|
35
|
+
Layout/DotPosition:
|
36
|
+
EnforcedStyle: trailing
|
37
|
+
Layout/IndentHash:
|
38
|
+
EnforcedStyle: consistent
|
39
|
+
Layout/MultilineOperationIndentation:
|
40
|
+
EnforcedStyle: indented
|
41
|
+
Layout/AlignParameters:
|
42
|
+
EnforcedStyle: with_fixed_indentation
|
43
|
+
Layout/IndentArray:
|
44
|
+
EnforcedStyle: consistent
|
45
|
+
Layout/MultilineMethodCallIndentation:
|
46
|
+
EnforcedStyle: indented
|
47
|
+
Lint/AmbiguousBlockAssociation:
|
48
|
+
Exclude:
|
49
|
+
- 'spec/**.rb'
|
50
|
+
Style/BlockDelimiters:
|
51
|
+
EnforcedStyle: semantic
|
52
|
+
Exclude:
|
53
|
+
- 'spec/factories/**/*.rb'
|
54
|
+
- 'spec/**/*.rb'
|
55
|
+
Style/Lambda:
|
56
|
+
EnforcedStyle: literal
|
57
|
+
Style/Semicolon:
|
58
|
+
Exclude:
|
59
|
+
- 'spec/*_spec.rb'
|
60
|
+
Style/StringLiterals:
|
61
|
+
Enabled: false
|
62
|
+
Style/StringLiteralsInInterpolation:
|
63
|
+
Enabled: false
|
64
|
+
Style/TrailingCommaInArrayLiteral:
|
65
|
+
EnforcedStyleForMultiline: comma
|
66
|
+
Style/TrailingCommaInHashLiteral:
|
67
|
+
EnforcedStyleForMultiline: comma
|
68
|
+
Style/TrailingCommaInArguments:
|
69
|
+
EnforcedStyleForMultiline: comma
|
70
|
+
RSpec/ContextWording:
|
71
|
+
Enabled: false
|
72
|
+
RSpec/EmptyLineAfterHook:
|
73
|
+
Enabled: false
|
74
|
+
RSpec/EmptyLineAfterSubject:
|
75
|
+
Enabled: false
|
76
|
+
RSpec/ExampleLength:
|
77
|
+
Enabled: false
|
78
|
+
RSpec/MultipleExpectations:
|
79
|
+
Max: 5
|
80
|
+
RSpec/NestedGroups:
|
81
|
+
Max: 6
|
82
|
+
RSpec/LetSetup:
|
83
|
+
Enabled: false
|
84
|
+
RSpec/ScatteredLet:
|
85
|
+
Enabled: false
|
86
|
+
RSpec/ScatteredSetup:
|
87
|
+
Enabled: false
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
mws-merchant_fulfillment (1.0.0)
|
5
|
+
money (~> 6.0)
|
6
|
+
nokogiri (~> 1.5)
|
7
|
+
peddler (~> 2.0)
|
8
|
+
structure (~> 1.0)
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: http://rubygems.org/
|
12
|
+
specs:
|
13
|
+
ast (2.4.0)
|
14
|
+
coderay (1.1.2)
|
15
|
+
concurrent-ruby (1.1.4)
|
16
|
+
diff-lcs (1.3)
|
17
|
+
excon (0.62.0)
|
18
|
+
ffi (1.10.0)
|
19
|
+
formatador (0.2.5)
|
20
|
+
guard (2.15.0)
|
21
|
+
formatador (>= 0.2.4)
|
22
|
+
listen (>= 2.7, < 4.0)
|
23
|
+
lumberjack (>= 1.0.12, < 2.0)
|
24
|
+
nenv (~> 0.1)
|
25
|
+
notiffany (~> 0.0)
|
26
|
+
pry (>= 0.9.12)
|
27
|
+
shellany (~> 0.0)
|
28
|
+
thor (>= 0.18.1)
|
29
|
+
guard-compat (1.2.1)
|
30
|
+
guard-rspec (4.7.3)
|
31
|
+
guard (~> 2.1)
|
32
|
+
guard-compat (~> 1.1)
|
33
|
+
rspec (>= 2.99.0, < 4.0)
|
34
|
+
guard-rubocop (1.3.0)
|
35
|
+
guard (~> 2.0)
|
36
|
+
rubocop (~> 0.20)
|
37
|
+
i18n (1.5.3)
|
38
|
+
concurrent-ruby (~> 1.0)
|
39
|
+
jaro_winkler (1.5.2)
|
40
|
+
jeff (2.0.0)
|
41
|
+
excon (>= 0.22.1)
|
42
|
+
listen (3.1.5)
|
43
|
+
rb-fsevent (~> 0.9, >= 0.9.4)
|
44
|
+
rb-inotify (~> 0.9, >= 0.9.7)
|
45
|
+
ruby_dep (~> 1.2)
|
46
|
+
lumberjack (1.0.13)
|
47
|
+
method_source (0.9.2)
|
48
|
+
mini_portile2 (2.4.0)
|
49
|
+
money (6.13.2)
|
50
|
+
i18n (>= 0.6.4, <= 2)
|
51
|
+
multi_xml (0.6.0)
|
52
|
+
nenv (0.3.0)
|
53
|
+
nokogiri (1.10.1)
|
54
|
+
mini_portile2 (~> 2.4.0)
|
55
|
+
notiffany (0.1.1)
|
56
|
+
nenv (~> 0.1)
|
57
|
+
shellany (~> 0.0)
|
58
|
+
parallel (1.13.0)
|
59
|
+
parser (2.6.0.0)
|
60
|
+
ast (~> 2.4.0)
|
61
|
+
peddler (2.0.4)
|
62
|
+
excon (>= 0.50.0)
|
63
|
+
jeff (~> 2.0)
|
64
|
+
multi_xml (>= 0.5.0)
|
65
|
+
powerpack (0.1.2)
|
66
|
+
pry (0.12.2)
|
67
|
+
coderay (~> 1.1.0)
|
68
|
+
method_source (~> 0.9.0)
|
69
|
+
rainbow (3.0.0)
|
70
|
+
rake (10.5.0)
|
71
|
+
rb-fsevent (0.10.3)
|
72
|
+
rb-inotify (0.10.0)
|
73
|
+
ffi (~> 1.0)
|
74
|
+
rspec (3.8.0)
|
75
|
+
rspec-core (~> 3.8.0)
|
76
|
+
rspec-expectations (~> 3.8.0)
|
77
|
+
rspec-mocks (~> 3.8.0)
|
78
|
+
rspec-core (3.8.0)
|
79
|
+
rspec-support (~> 3.8.0)
|
80
|
+
rspec-expectations (3.8.2)
|
81
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
82
|
+
rspec-support (~> 3.8.0)
|
83
|
+
rspec-mocks (3.8.0)
|
84
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
85
|
+
rspec-support (~> 3.8.0)
|
86
|
+
rspec-support (3.8.0)
|
87
|
+
rubocop (0.64.0)
|
88
|
+
jaro_winkler (~> 1.5.1)
|
89
|
+
parallel (~> 1.10)
|
90
|
+
parser (>= 2.5, != 2.5.1.1)
|
91
|
+
powerpack (~> 0.1)
|
92
|
+
rainbow (>= 2.2.2, < 4.0)
|
93
|
+
ruby-progressbar (~> 1.7)
|
94
|
+
unicode-display_width (~> 1.4.0)
|
95
|
+
ruby-progressbar (1.10.0)
|
96
|
+
ruby_dep (1.5.0)
|
97
|
+
shellany (0.0.1)
|
98
|
+
structure (1.0.3)
|
99
|
+
thor (0.20.3)
|
100
|
+
unicode-display_width (1.4.1)
|
101
|
+
|
102
|
+
PLATFORMS
|
103
|
+
ruby
|
104
|
+
|
105
|
+
DEPENDENCIES
|
106
|
+
bundler (~> 1.17)
|
107
|
+
guard
|
108
|
+
guard-rspec
|
109
|
+
guard-rubocop
|
110
|
+
mws-merchant_fulfillment!
|
111
|
+
pry
|
112
|
+
rake (~> 10.0)
|
113
|
+
rspec (~> 3.0)
|
114
|
+
rubocop
|
115
|
+
|
116
|
+
BUNDLED WITH
|
117
|
+
1.17.1
|
data/Guardfile
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
group :red_green_refactor_rb, halt_on_fail: true do
|
2
|
+
rspec_options = {
|
3
|
+
all_on_start: false,
|
4
|
+
failed_mode: :keep,
|
5
|
+
}
|
6
|
+
rspec_format = "--format documentation"
|
7
|
+
|
8
|
+
rspec_options[:cmd] = "bin/rspec #{rspec_format}"
|
9
|
+
|
10
|
+
guard 'rspec', rspec_options do
|
11
|
+
watch(%r{spec/spec_helper.rb}) { "spec" }
|
12
|
+
watch(%r{^spec/.+_spec\.rb$})
|
13
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
14
|
+
end
|
15
|
+
|
16
|
+
rubocop_options = {
|
17
|
+
cli: %w[-D --format fuubar],
|
18
|
+
all_on_start: false,
|
19
|
+
keep_failed: false,
|
20
|
+
notification: :failed,
|
21
|
+
}
|
22
|
+
|
23
|
+
guard :rubocop, rubocop_options do
|
24
|
+
watch('Guardfile')
|
25
|
+
watch('Rakefile')
|
26
|
+
watch(/.+\.rb$/)
|
27
|
+
watch(/.+\.rake$/)
|
28
|
+
# Rerun rubocop on everything in the folder or below a .rubocop.yml file
|
29
|
+
watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
|
30
|
+
end
|
31
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
(The MIT License)
|
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 NONINFRINGEMENT.
|
17
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
18
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
19
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
20
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# MWS Merchant Fulfillment
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/flowspace/mws-merchant_fulfillment.svg)](https://travis-ci.org/Flowspace-Team/mws-merchant_fulfillment)
|
4
|
+
|
5
|
+
**MWS Merchant Fulfillment** is a Ruby interface to the [Amazon Marketplace Web Service (MWS) Merchant Fulfillment API](http://docs.developer.amazonservices.com/en_US/merch_fulfill/index.html). With the MWS Merchant Fulfillment API, you can build applications that let sellers purchase shipping for non-Prime and Prime orders using Amazon’s Buy Shipping Services.
|
6
|
+
|
7
|
+
(To use Amazon MWS, you must have an Amazon MWS developer account.)
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
Create a client:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
require "mws-merchant_fulfillment"
|
15
|
+
client = MWS.merchant_fulfillment(marketplace: "ATVPDKIKX0DER",
|
16
|
+
merchant_id: "123")
|
17
|
+
```
|
18
|
+
|
19
|
+
Set up credentials [when instantiating or with environment variables](https://github.com/Flowspace-Team/peddler#usage).
|
20
|
+
|
21
|
+
### Eligible Shipping Services
|
22
|
+
|
23
|
+
List orders created or updated during a time frame you specify:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
response = client.list_orders(created_after: 1.month.ago)
|
27
|
+
request_details = {
|
28
|
+
amazon_order_id: amazon_order_id,
|
29
|
+
item_list: items,
|
30
|
+
ship_from_address: shipping_from,
|
31
|
+
package_dimensions: package_dimensions,
|
32
|
+
weight: weight,
|
33
|
+
shipping_service_options: {
|
34
|
+
delivery_experience: 'DeliveryConfirmationWithoutSignature',
|
35
|
+
carrier_will_pick_up: false,
|
36
|
+
},
|
37
|
+
}
|
38
|
+
|
39
|
+
response = client.get_eligible_shipping_services(request_details)
|
40
|
+
shipping_services = response.parse
|
41
|
+
puts shipping_services.rates.count # => 1
|
42
|
+
puts shipping_services.rates.first.amount # => #<Money fractional:2 currency:USD>
|
43
|
+
```
|
44
|
+
|
45
|
+
### Service Status
|
46
|
+
|
47
|
+
Check the operational status of the API:
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
client.get_service_status.parse
|
51
|
+
```
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "mws/merchant_fulfillment"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'mws/merchant_fulfillment/entity'
|
4
|
+
|
5
|
+
module MWS
|
6
|
+
module MerchantFulfillment
|
7
|
+
class AvailableFormatOptionsForLabel < Entity
|
8
|
+
attribute(:include_packing_slip_with_label) do
|
9
|
+
boolean_at_path('IncludePackingSlipWithLabel')
|
10
|
+
end
|
11
|
+
|
12
|
+
attribute(:label_format) do
|
13
|
+
text_at_xpath('LabelFormat')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'mws/merchant_fulfillment/document'
|
4
|
+
|
5
|
+
module MWS
|
6
|
+
module MerchantFulfillment
|
7
|
+
class Collection < Document
|
8
|
+
include Enumerable
|
9
|
+
|
10
|
+
def each
|
11
|
+
raise NotImplementedError
|
12
|
+
end
|
13
|
+
|
14
|
+
def empty?
|
15
|
+
count.zero?
|
16
|
+
end
|
17
|
+
|
18
|
+
def inspect
|
19
|
+
"#<#{self.class} #{if count > 3
|
20
|
+
"[#{take(3).map(&:inspect).join(', ')}...]"
|
21
|
+
else
|
22
|
+
"[#{map(&:inspect).join(', ')}]"
|
23
|
+
end}>"
|
24
|
+
end
|
25
|
+
|
26
|
+
alias to_s inspect
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module MWS
|
4
|
+
module MerchantFulfillment
|
5
|
+
class Document
|
6
|
+
attr_reader :node
|
7
|
+
|
8
|
+
def initialize(node)
|
9
|
+
@node = node
|
10
|
+
end
|
11
|
+
|
12
|
+
def xpath(path)
|
13
|
+
node.xpath(add_namespace(path))
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def add_namespace(path)
|
19
|
+
path
|
20
|
+
.split('/')
|
21
|
+
.map { |attr| "xmlns:#{attr}" }
|
22
|
+
.join('/')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'cgi'
|
4
|
+
require 'time'
|
5
|
+
require 'money'
|
6
|
+
require 'structure'
|
7
|
+
require 'mws/merchant_fulfillment/document'
|
8
|
+
|
9
|
+
module MWS
|
10
|
+
module MerchantFulfillment
|
11
|
+
class Entity < Document
|
12
|
+
include Structure
|
13
|
+
|
14
|
+
def boolean_at_path(path)
|
15
|
+
text = text_at_xpath(path)
|
16
|
+
text&.downcase == 'true'
|
17
|
+
end
|
18
|
+
|
19
|
+
def float_at_xpath(path)
|
20
|
+
text = text_at_xpath(path)
|
21
|
+
text&.to_f
|
22
|
+
end
|
23
|
+
|
24
|
+
def integer_at_xpath(path)
|
25
|
+
text = text_at_xpath(path)
|
26
|
+
text&.to_i
|
27
|
+
end
|
28
|
+
|
29
|
+
def money_at_xpath(path)
|
30
|
+
amount = float_at_xpath("#{path}/Amount")
|
31
|
+
return unless amount
|
32
|
+
|
33
|
+
currency_code = text_at_xpath("#{path}/CurrencyCode")
|
34
|
+
amount *= 100 unless currency_code == 'JPY'
|
35
|
+
|
36
|
+
Money.new(amount, currency_code)
|
37
|
+
end
|
38
|
+
|
39
|
+
def time_at_xpath(path)
|
40
|
+
text = text_at_xpath(path)
|
41
|
+
Time.zone.parse(CGI.unescape(text)) if text
|
42
|
+
end
|
43
|
+
|
44
|
+
def text_at_xpath(path)
|
45
|
+
node = xpath(path).first
|
46
|
+
node&.text&.strip
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'peddler'
|
4
|
+
require 'nokogiri'
|
5
|
+
require 'mws/merchant_fulfillment/shipping_services'
|
6
|
+
|
7
|
+
module MWS
|
8
|
+
module MerchantFulfillment
|
9
|
+
class Parser
|
10
|
+
include ::Peddler::Headers
|
11
|
+
|
12
|
+
def initialize(response, _encoding)
|
13
|
+
@response = response
|
14
|
+
end
|
15
|
+
|
16
|
+
def parse
|
17
|
+
node = find_result_node
|
18
|
+
|
19
|
+
case node.name
|
20
|
+
when /GetEligibleShippingServices/
|
21
|
+
ShippingServices.new(node)
|
22
|
+
else
|
23
|
+
raise NotImplementedError
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def headers
|
28
|
+
@response.headers
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def find_result_node
|
34
|
+
xml = Nokogiri(@response.body)
|
35
|
+
root = xml.children.first
|
36
|
+
|
37
|
+
root.children.find { |node| node.name.include?('Result') }
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# Override Peddler's default Parser.
|
42
|
+
Client.parser = Parser
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'mws/merchant_fulfillment/entity'
|
4
|
+
|
5
|
+
module MWS
|
6
|
+
module MerchantFulfillment
|
7
|
+
class Rate < Entity
|
8
|
+
attribute(:currency_code) do
|
9
|
+
text_at_xpath('CurrencyCode')
|
10
|
+
end
|
11
|
+
|
12
|
+
attribute(:amount) do
|
13
|
+
float_at_xpath('Amount')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'mws/merchant_fulfillment/entity'
|
4
|
+
require 'mws/merchant_fulfillment/shipping_service_option'
|
5
|
+
require 'mws/merchant_fulfillment/rate'
|
6
|
+
require 'mws/merchant_fulfillment/available_format_options_for_label'
|
7
|
+
|
8
|
+
module MWS
|
9
|
+
module MerchantFulfillment
|
10
|
+
class ShippingService < Entity
|
11
|
+
attribute(:carrier_name) do
|
12
|
+
text_at_xpath('CarrierName')
|
13
|
+
end
|
14
|
+
|
15
|
+
attribute(:shipping_service_options) do
|
16
|
+
xpath('ShippingServiceOptions').map { |node| ShippingServiceOption.new(node) }
|
17
|
+
end
|
18
|
+
|
19
|
+
attribute(:shipping_service_id) do
|
20
|
+
text_at_xpath('ShippingServiceId')
|
21
|
+
end
|
22
|
+
|
23
|
+
attribute(:rates) do
|
24
|
+
xpath('Rate').map { |node| Rate.new(node) }
|
25
|
+
end
|
26
|
+
|
27
|
+
attribute(:latest_estimated_delivery_date) do
|
28
|
+
time_at_xpath('LatestEstimatedDeliveryDate')
|
29
|
+
end
|
30
|
+
|
31
|
+
attribute(:earliest_estimated_delivery_date) do
|
32
|
+
time_at_xpath('EarliestEstimatedDeliveryDate')
|
33
|
+
end
|
34
|
+
|
35
|
+
attribute(:shipping_service_offer_id) do
|
36
|
+
text_at_xpath('ShippingServiceOfferId')
|
37
|
+
end
|
38
|
+
|
39
|
+
attribute(:available_label_formats) do
|
40
|
+
xpath('AvailableLabelFormats/LabelFormat').map { |node|
|
41
|
+
node&.text&.strip
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
45
|
+
attribute(:ship_date) do
|
46
|
+
time_at_xpath('ShipDate')
|
47
|
+
end
|
48
|
+
|
49
|
+
attribute(:available_format_options_for_label) do
|
50
|
+
xpath('AvailableFormatOptionsForLabel/LabelFormatOption').map { |node|
|
51
|
+
AvailableFormatOptionsForLabel.new(node)
|
52
|
+
}
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'mws/merchant_fulfillment/entity'
|
4
|
+
|
5
|
+
module MWS
|
6
|
+
module MerchantFulfillment
|
7
|
+
class ShippingServiceOption < Entity
|
8
|
+
attribute(:carrier_will_pickup) do
|
9
|
+
boolean_at_path('CarrierWillPickUp')
|
10
|
+
end
|
11
|
+
|
12
|
+
attribute(:delivery_experience) do
|
13
|
+
text_at_xpath('DeliveryExperience')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'mws/merchant_fulfillment/collection'
|
4
|
+
require 'mws/merchant_fulfillment/shipping_service'
|
5
|
+
|
6
|
+
module MWS
|
7
|
+
module MerchantFulfillment
|
8
|
+
class ShippingServices < Collection
|
9
|
+
def each
|
10
|
+
xpath('ShippingServiceList/ShippingService').each { |node|
|
11
|
+
yield ShippingService.new(node)
|
12
|
+
}
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path("../lib", __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require "mws/merchant_fulfillment/version"
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = "mws-merchant_fulfillment"
|
9
|
+
spec.version = MWS::MerchantFulfillment::VERSION
|
10
|
+
spec.authors = ['Josh Becker']
|
11
|
+
spec.email = ['beckerbi@gmail.com']
|
12
|
+
|
13
|
+
spec.summary = %q{Wraps the Amazon MWS Merchant Fulfillment API}
|
14
|
+
spec.description = %q{A rich Ruby interface to the Amazon MWS Merchant Fulfillment API.}
|
15
|
+
spec.homepage = 'https://github.com/Flowspace-Team/mws-merchant-fulfillment'
|
16
|
+
spec.license = "MIT"
|
17
|
+
|
18
|
+
if spec.respond_to?(:metadata)
|
19
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
20
|
+
spec.metadata["source_code_uri"] = 'https://github.com/Flowspace-Team/mws-merchant-fulfillment'
|
21
|
+
spec.metadata["changelog_uri"] = 'https://github.com/Flowspace-Team/mws-merchant-fulfillment/releases'
|
22
|
+
end
|
23
|
+
|
24
|
+
# Specify which files should be added to the gem when it is released.
|
25
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
26
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
27
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
28
|
+
end
|
29
|
+
spec.bindir = "exe"
|
30
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
|
+
spec.require_paths = ["lib"]
|
32
|
+
|
33
|
+
spec.add_runtime_dependency 'money', '~> 6.0'
|
34
|
+
spec.add_runtime_dependency 'nokogiri', '~> 1.5'
|
35
|
+
spec.add_runtime_dependency 'peddler', '~> 2.0'
|
36
|
+
spec.add_runtime_dependency 'structure', '~> 1.0'
|
37
|
+
|
38
|
+
spec.required_ruby_version = '>= 2.3'
|
39
|
+
|
40
|
+
spec.add_development_dependency "bundler", "~> 1.17"
|
41
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
42
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
43
|
+
spec.add_development_dependency 'rubocop'
|
44
|
+
spec.add_development_dependency 'guard'
|
45
|
+
spec.add_development_dependency 'guard-rspec'
|
46
|
+
spec.add_development_dependency 'guard-rubocop'
|
47
|
+
spec.add_development_dependency 'pry'
|
48
|
+
end
|
metadata
ADDED
@@ -0,0 +1,238 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mws-merchant_fulfillment
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Josh Becker
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-02-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: money
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '6.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '6.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: nokogiri
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.5'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.5'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: peddler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: structure
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.0'
|
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.17'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.17'
|
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: guard
|
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: guard-rspec
|
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: guard-rubocop
|
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: pry
|
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
|
+
description: A rich Ruby interface to the Amazon MWS Merchant Fulfillment API.
|
182
|
+
email:
|
183
|
+
- beckerbi@gmail.com
|
184
|
+
executables: []
|
185
|
+
extensions: []
|
186
|
+
extra_rdoc_files: []
|
187
|
+
files:
|
188
|
+
- ".gitignore"
|
189
|
+
- ".rubocop.yml"
|
190
|
+
- ".travis.yml"
|
191
|
+
- Gemfile
|
192
|
+
- Gemfile.lock
|
193
|
+
- Guardfile
|
194
|
+
- LICENSE
|
195
|
+
- README.md
|
196
|
+
- Rakefile
|
197
|
+
- bin/console
|
198
|
+
- bin/setup
|
199
|
+
- lib/mws-merchant-fulfillment.rb
|
200
|
+
- lib/mws/merchant_fulfillment/available_format_options_for_label.rb
|
201
|
+
- lib/mws/merchant_fulfillment/collection.rb
|
202
|
+
- lib/mws/merchant_fulfillment/document.rb
|
203
|
+
- lib/mws/merchant_fulfillment/entity.rb
|
204
|
+
- lib/mws/merchant_fulfillment/parser.rb
|
205
|
+
- lib/mws/merchant_fulfillment/rate.rb
|
206
|
+
- lib/mws/merchant_fulfillment/shipping_service.rb
|
207
|
+
- lib/mws/merchant_fulfillment/shipping_service_option.rb
|
208
|
+
- lib/mws/merchant_fulfillment/shipping_services.rb
|
209
|
+
- lib/mws/merchant_fulfillment/version.rb
|
210
|
+
- mws-merchant_fulfillment.gemspec
|
211
|
+
homepage: https://github.com/Flowspace-Team/mws-merchant-fulfillment
|
212
|
+
licenses:
|
213
|
+
- MIT
|
214
|
+
metadata:
|
215
|
+
homepage_uri: https://github.com/Flowspace-Team/mws-merchant-fulfillment
|
216
|
+
source_code_uri: https://github.com/Flowspace-Team/mws-merchant-fulfillment
|
217
|
+
changelog_uri: https://github.com/Flowspace-Team/mws-merchant-fulfillment/releases
|
218
|
+
post_install_message:
|
219
|
+
rdoc_options: []
|
220
|
+
require_paths:
|
221
|
+
- lib
|
222
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
223
|
+
requirements:
|
224
|
+
- - ">="
|
225
|
+
- !ruby/object:Gem::Version
|
226
|
+
version: '2.3'
|
227
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
228
|
+
requirements:
|
229
|
+
- - ">="
|
230
|
+
- !ruby/object:Gem::Version
|
231
|
+
version: '0'
|
232
|
+
requirements: []
|
233
|
+
rubyforge_project:
|
234
|
+
rubygems_version: 2.6.14.1
|
235
|
+
signing_key:
|
236
|
+
specification_version: 4
|
237
|
+
summary: Wraps the Amazon MWS Merchant Fulfillment API
|
238
|
+
test_files: []
|