gun_broker 1.4.4 → 1.4.5
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 +4 -4
- data/lib/gun_broker/item/constants.rb +0 -9
- data/lib/gun_broker/order.rb +5 -0
- data/lib/gun_broker/order/constants.rb +18 -0
- data/lib/gun_broker/user/orders_delegate.rb +24 -3
- data/lib/gun_broker/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3863aa8529ca0b094ac8b6e55dae3662dc8ed7c
|
4
|
+
data.tar.gz: 5df89b9753c627c7923cce828c66b11f9bc3ccf6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6166eabf7ad30445180a92dac8661132ee20403f5438fa8a4e43ae134df0a869ea67956bf6d37308291cbe0d9f723b9c9f86248e7ebe692a3059df326538587d
|
7
|
+
data.tar.gz: 01c86da2dda79b0936e0cdabda65ca0597e332e439cd1737b78b3379bf060a2eb46d812ff4c5d5f4ef716bc723e8e4088c850c0c6fff0f896f505fc48f7011c0
|
@@ -1,6 +1,5 @@
|
|
1
1
|
module GunBroker
|
2
2
|
class Item
|
3
|
-
# Holds constant values for Item.
|
4
3
|
module Constants
|
5
4
|
|
6
5
|
# Options for auto-relisting.
|
@@ -93,14 +92,6 @@ module GunBroker
|
|
93
92
|
16 => 'Use shipping profile',
|
94
93
|
}
|
95
94
|
|
96
|
-
# The carrier responsible for shipping.
|
97
|
-
# The keys of this hash should be sent as the `carrier` param when updating shipping on an Item.
|
98
|
-
SHIPPING_CARRIERS = {
|
99
|
-
1 => 'FedEx',
|
100
|
-
2 => 'UPS',
|
101
|
-
3 => 'USPS',
|
102
|
-
}
|
103
|
-
|
104
95
|
end
|
105
96
|
end
|
106
97
|
end
|
data/lib/gun_broker/order.rb
CHANGED
@@ -96,6 +96,11 @@ module GunBroker
|
|
96
96
|
@attrs['paymentMethod'].values
|
97
97
|
end
|
98
98
|
|
99
|
+
# @return [Integer] Status key for this Order.
|
100
|
+
def status_key
|
101
|
+
@attrs['status'].keys.first.to_i
|
102
|
+
end
|
103
|
+
|
99
104
|
# @param key [String] An Order attribute name (from the JSON response).
|
100
105
|
# @return The value of the given `key` or `nil`.
|
101
106
|
def [](key)
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module GunBroker
|
2
|
+
class Order
|
3
|
+
module Constants
|
4
|
+
|
5
|
+
# The carrier responsible for shipping.
|
6
|
+
# The keys of this hash should be sent as the `carrier` param when updating shipping on an Order.
|
7
|
+
SHIPPING_CARRIERS = {
|
8
|
+
1 => 'FedEx',
|
9
|
+
2 => 'UPS',
|
10
|
+
3 => 'USPS',
|
11
|
+
}
|
12
|
+
|
13
|
+
# The flags that are allowed to be toggled (true/false) on an Order.
|
14
|
+
ACCEPTED_FLAG_KEYS = %i( payment_received ffl_received order_shipped )
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'gun_broker/token_header'
|
2
|
-
require 'gun_broker/
|
2
|
+
require 'gun_broker/order/constants'
|
3
3
|
|
4
4
|
module GunBroker
|
5
5
|
class User
|
@@ -7,7 +7,7 @@ module GunBroker
|
|
7
7
|
class OrdersDelegate
|
8
8
|
|
9
9
|
include GunBroker::TokenHeader
|
10
|
-
include GunBroker::
|
10
|
+
include GunBroker::Order::Constants
|
11
11
|
|
12
12
|
# @param user [User] A {User} instance to scope orders by.
|
13
13
|
def initialize(user)
|
@@ -63,13 +63,34 @@ module GunBroker
|
|
63
63
|
carrier_key = SHIPPING_CARRIERS.find { |k, v| v.casecmp(carrier_name).zero? }.try(:first)
|
64
64
|
params = {
|
65
65
|
'TrackingNumber' => tracking_number,
|
66
|
-
'Carrier'
|
66
|
+
'Carrier' => carrier_key,
|
67
67
|
}
|
68
68
|
|
69
69
|
GunBroker::API.put("/Orders/#{order_id}/Shipping", cleanup_nil_params(params), token_header(@user.token))
|
70
70
|
find!(order_id)
|
71
71
|
end
|
72
72
|
|
73
|
+
# Sets any of 3 available Order flags.
|
74
|
+
# @param order_id [Integer, String] ID of the Order to update.
|
75
|
+
# @param flags [hash] Keys with boolean values of flags to update on Order.
|
76
|
+
# @raise [GunBroker::Error::NotAuthorized] If the {User#token `@user` token} isn't valid.
|
77
|
+
# @raise [GunBroker::Error::RequestError] If the Order attributes are not valid or required attributes are missing.
|
78
|
+
# @return [GunBroker::Order] The updated Order instance.
|
79
|
+
def set_flags!(order_id, flags = {})
|
80
|
+
unless flags.keys.all? { |k| ACCEPTED_FLAG_KEYS.include?(k) }
|
81
|
+
raise ArgumentError.new("Only accepted keys for flag toggling are #{ACCEPTED_FLAG_KEYS.to_sentence}")
|
82
|
+
end
|
83
|
+
|
84
|
+
params = {
|
85
|
+
'PaymentReceived' => flags[:payment_received],
|
86
|
+
'FFLReceived' => flags[:ffl_received],
|
87
|
+
'OrderShipped' => flags[:order_shipped],
|
88
|
+
}
|
89
|
+
|
90
|
+
GunBroker::API.put("/Orders/#{order_id}/Flags", cleanup_nil_params(params), token_header(@user.token))
|
91
|
+
find!(order_id)
|
92
|
+
end
|
93
|
+
|
73
94
|
private
|
74
95
|
|
75
96
|
def fetch_orders(endpoint, params = {})
|
data/lib/gun_broker/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gun_broker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dale Campbell
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-11-
|
11
|
+
date: 2018-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -138,6 +138,7 @@ files:
|
|
138
138
|
- lib/gun_broker/item/constants.rb
|
139
139
|
- lib/gun_broker/items_as_page.rb
|
140
140
|
- lib/gun_broker/order.rb
|
141
|
+
- lib/gun_broker/order/constants.rb
|
141
142
|
- lib/gun_broker/orders_as_page.rb
|
142
143
|
- lib/gun_broker/response.rb
|
143
144
|
- lib/gun_broker/token_header.rb
|