mws-orders 0.5.0 → 0.5.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b05f9a8f9c6d1b3eda7df105bd088572fbe93324682f9902f81a16aa7060b55f
4
- data.tar.gz: 812d86fb8d5e6e4bdf8f5ad1b928394290f26a282b5f2eed67c8054da1d1cef7
3
+ metadata.gz: ade6a5c1c3498da87514f76fb4e6304e1914c0f4a520641e0df1cee2533e97b5
4
+ data.tar.gz: ce196f172eb0cbaf1f0e994151bff632550cabbe5949d1d72abff1dad3d0ad26
5
5
  SHA512:
6
- metadata.gz: 0bcd1463e7bcdf91b937926079202a9ebc93ec783da4a459fcef869c65381b8ad935d654462a3397c7ed5145f55c306f6dff4cc7345096e77f96b6c438bc19d5
7
- data.tar.gz: a8df5632bc2d3132680cdc9e9c45cb91d355400fae60a6479f8b248332ce9afc80623eb51f0262fec54075ffcc77694e43415770fc58b568654beeaa6607e2ea
6
+ metadata.gz: 19cba4b4ceff9c1889611f27272fcb090e818c1f7bf888108ccf5c5e82a488541c1a3b0d8a6fafd1a96af313fa10d795fcacb6d86d24869cd20ac7705f63296b
7
+ data.tar.gz: 493cf6bade595b54da1cee5234e40c79a2de8f01b6281c4843ceb0582ef58327ec0bb4de711dfc229312153b16a530b8df0b0ec38e4ae1687e58fcc9a5928e5e
data/README.md CHANGED
@@ -39,7 +39,7 @@ client.list_orders_by_next_token(orders.next_token).parse
39
39
  Get one or more orders based on their order numbers:
40
40
 
41
41
  ```ruby
42
- response = client.get_order('123-1234567-1234567')
42
+ response = client.get_order('902-3159896-1390916')
43
43
  order = response.parse
44
44
  order.inspect # => #<MWS::Orders::Order 902-3159896-1390916>
45
45
  ```
@@ -49,7 +49,7 @@ order.inspect # => #<MWS::Orders::Order 902-3159896-1390916>
49
49
  List order items:
50
50
 
51
51
  ```ruby
52
- response = client.list_order_items('123-1234567-1234567')
52
+ response = client.list_order_items('902-3159896-1390916')
53
53
  order_items = response.parse
54
54
  ```
55
55
 
@@ -11,17 +11,31 @@ module MWS
11
11
  end
12
12
 
13
13
  def xpath(path)
14
- node.xpath(add_namespace(path))
14
+ node.xpath(add_namespace(path), namespaces)
15
15
  end
16
16
 
17
17
  def at_xpath(path)
18
- node.at_xpath(add_namespace(path))
18
+ node.at_xpath(add_namespace(path), namespaces)
19
19
  end
20
20
 
21
21
  private
22
22
 
23
23
  def add_namespace(path)
24
- path.split('/').map { |attr| "xmlns:#{attr}" }.join('/')
24
+ path.split('/')
25
+ .map { |attr| attr.include?(':') ? attr : "xmlns:#{attr}" }
26
+ .join('/')
27
+ end
28
+
29
+ def namespaces
30
+ @namespaces ||= collect_namespaces
31
+ end
32
+
33
+ def collect_namespaces
34
+ document = node&.document || node
35
+ document.collect_namespaces.each_with_object({}) do |namespace, hsh|
36
+ key, val = namespace
37
+ hsh[key.sub(/^xmlns:/, '')] = val
38
+ end
25
39
  end
26
40
  end
27
41
  end
@@ -62,8 +62,8 @@ module MWS
62
62
  end
63
63
 
64
64
  attribute(:payment_execution_detail) do
65
- xpath('PaymentExecutionDetail/PaymentExecutionDetailItem')
66
- .map { |node| PaymentExecutionDetailItem.new(node) }
65
+ entities('PaymentExecutionDetail/PaymentExecutionDetailItem',
66
+ PaymentExecutionDetailItem)
67
67
  end
68
68
 
69
69
  attribute(:payment_method) do
@@ -11,7 +11,7 @@ module MWS
11
11
  include Tokenable
12
12
 
13
13
  def each
14
- xpath('Orders/Order').map { |node| yield Order.new(node) }
14
+ xpath('Orders/Order').each { |node| yield Order.new(node) }
15
15
  end
16
16
  end
17
17
  end
@@ -20,7 +20,7 @@ module MWS
20
20
  end
21
21
 
22
22
  attribute(:messages) do
23
- xpath('Messages/Message').map { |node| Message.new(node) }
23
+ entities('Messages/Message', Message)
24
24
  end
25
25
  end
26
26
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module MWS
4
4
  module Orders
5
- VERSION = '0.5.0'
5
+ VERSION = '0.5.1'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mws-orders
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hakan Ensari