terminal-shop 1.0.0 → 1.2.0
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/README.md +27 -19
- data/lib/terminal-shop/base_client.rb +2 -0
- data/lib/terminal-shop/base_model.rb +471 -440
- data/lib/terminal-shop/base_page.rb +20 -0
- data/lib/terminal-shop/models/cart.rb +35 -2
- data/lib/terminal-shop/models/cart_convert_params.rb +11 -1
- data/lib/terminal-shop/models/cart_redeem_gift_card_params.rb +24 -0
- data/lib/terminal-shop/models/cart_redeem_gift_card_response.rb +48 -0
- data/lib/terminal-shop/models/cart_remove_gift_card_params.rb +18 -0
- data/lib/terminal-shop/models/cart_remove_gift_card_response.rb +19 -0
- data/lib/terminal-shop/models/product.rb +11 -6
- data/lib/terminal-shop/pooled_net_requester.rb +23 -10
- data/lib/terminal-shop/resources/cart.rb +43 -1
- data/lib/terminal-shop/util.rb +146 -52
- data/lib/terminal-shop/version.rb +1 -1
- data/lib/terminal-shop.rb +4 -0
- data/rbi/lib/terminal-shop/base_client.rbi +23 -21
- data/rbi/lib/terminal-shop/base_model.rbi +235 -217
- data/rbi/lib/terminal-shop/client.rbi +2 -2
- data/rbi/lib/terminal-shop/errors.rbi +8 -8
- data/rbi/lib/terminal-shop/models/address.rbi +2 -2
- data/rbi/lib/terminal-shop/models/address_create_params.rbi +3 -13
- data/rbi/lib/terminal-shop/models/address_create_response.rbi +2 -2
- data/rbi/lib/terminal-shop/models/address_delete_params.rbi +5 -2
- data/rbi/lib/terminal-shop/models/address_delete_response.rbi +2 -2
- data/rbi/lib/terminal-shop/models/address_get_params.rbi +5 -2
- data/rbi/lib/terminal-shop/models/address_get_response.rbi +2 -2
- data/rbi/lib/terminal-shop/models/address_list_params.rbi +5 -2
- data/rbi/lib/terminal-shop/models/address_list_response.rbi +2 -2
- data/rbi/lib/terminal-shop/models/app.rbi +2 -2
- data/rbi/lib/terminal-shop/models/app_create_params.rbi +2 -2
- data/rbi/lib/terminal-shop/models/app_create_response.rbi +4 -4
- data/rbi/lib/terminal-shop/models/app_delete_params.rbi +5 -2
- data/rbi/lib/terminal-shop/models/app_delete_response.rbi +2 -2
- data/rbi/lib/terminal-shop/models/app_get_params.rbi +5 -2
- data/rbi/lib/terminal-shop/models/app_get_response.rbi +2 -2
- data/rbi/lib/terminal-shop/models/app_list_params.rbi +5 -2
- data/rbi/lib/terminal-shop/models/app_list_response.rbi +2 -2
- data/rbi/lib/terminal-shop/models/card.rbi +4 -4
- data/rbi/lib/terminal-shop/models/card_collect_params.rbi +5 -2
- data/rbi/lib/terminal-shop/models/card_collect_response.rbi +4 -4
- data/rbi/lib/terminal-shop/models/card_create_params.rbi +2 -2
- data/rbi/lib/terminal-shop/models/card_create_response.rbi +2 -2
- data/rbi/lib/terminal-shop/models/card_delete_params.rbi +5 -2
- data/rbi/lib/terminal-shop/models/card_delete_response.rbi +2 -2
- data/rbi/lib/terminal-shop/models/card_get_params.rbi +5 -2
- data/rbi/lib/terminal-shop/models/card_get_response.rbi +2 -2
- data/rbi/lib/terminal-shop/models/card_list_params.rbi +5 -2
- data/rbi/lib/terminal-shop/models/card_list_response.rbi +2 -2
- data/rbi/lib/terminal-shop/models/cart.rbi +45 -9
- data/rbi/lib/terminal-shop/models/cart_convert_params.rbi +17 -3
- data/rbi/lib/terminal-shop/models/cart_convert_response.rbi +2 -2
- data/rbi/lib/terminal-shop/models/cart_get_params.rbi +5 -2
- data/rbi/lib/terminal-shop/models/cart_get_response.rbi +2 -2
- data/rbi/lib/terminal-shop/models/cart_redeem_gift_card_params.rbi +32 -0
- data/rbi/lib/terminal-shop/models/cart_redeem_gift_card_response.rbi +66 -0
- data/rbi/lib/terminal-shop/models/cart_remove_gift_card_params.rbi +21 -0
- data/rbi/lib/terminal-shop/models/cart_remove_gift_card_response.rbi +23 -0
- data/rbi/lib/terminal-shop/models/cart_set_address_params.rbi +2 -2
- data/rbi/lib/terminal-shop/models/cart_set_address_response.rbi +2 -2
- data/rbi/lib/terminal-shop/models/cart_set_card_params.rbi +2 -2
- data/rbi/lib/terminal-shop/models/cart_set_card_response.rbi +2 -2
- data/rbi/lib/terminal-shop/models/cart_set_item_params.rbi +2 -2
- data/rbi/lib/terminal-shop/models/cart_set_item_response.rbi +2 -2
- data/rbi/lib/terminal-shop/models/email_create_params.rbi +2 -2
- data/rbi/lib/terminal-shop/models/email_create_response.rbi +2 -2
- data/rbi/lib/terminal-shop/models/order.rbi +10 -10
- data/rbi/lib/terminal-shop/models/order_create_params.rbi +2 -2
- data/rbi/lib/terminal-shop/models/order_create_response.rbi +2 -2
- data/rbi/lib/terminal-shop/models/order_get_params.rbi +5 -2
- data/rbi/lib/terminal-shop/models/order_get_response.rbi +2 -2
- data/rbi/lib/terminal-shop/models/order_list_params.rbi +5 -2
- data/rbi/lib/terminal-shop/models/order_list_response.rbi +2 -2
- data/rbi/lib/terminal-shop/models/product.rbi +29 -14
- data/rbi/lib/terminal-shop/models/product_get_params.rbi +5 -2
- data/rbi/lib/terminal-shop/models/product_get_response.rbi +2 -2
- data/rbi/lib/terminal-shop/models/product_list_params.rbi +5 -2
- data/rbi/lib/terminal-shop/models/product_list_response.rbi +2 -2
- data/rbi/lib/terminal-shop/models/product_variant.rbi +2 -2
- data/rbi/lib/terminal-shop/models/profile.rbi +4 -4
- data/rbi/lib/terminal-shop/models/profile_me_params.rbi +5 -2
- data/rbi/lib/terminal-shop/models/profile_me_response.rbi +2 -2
- data/rbi/lib/terminal-shop/models/profile_update_params.rbi +2 -2
- data/rbi/lib/terminal-shop/models/profile_update_response.rbi +2 -2
- data/rbi/lib/terminal-shop/models/subscription.rbi +15 -13
- data/rbi/lib/terminal-shop/models/subscription_create_params.rbi +5 -2
- data/rbi/lib/terminal-shop/models/subscription_create_response.rbi +2 -2
- data/rbi/lib/terminal-shop/models/subscription_delete_params.rbi +5 -2
- data/rbi/lib/terminal-shop/models/subscription_delete_response.rbi +2 -2
- data/rbi/lib/terminal-shop/models/subscription_get_params.rbi +5 -2
- data/rbi/lib/terminal-shop/models/subscription_get_response.rbi +2 -2
- data/rbi/lib/terminal-shop/models/subscription_list_params.rbi +5 -2
- data/rbi/lib/terminal-shop/models/subscription_list_response.rbi +2 -2
- data/rbi/lib/terminal-shop/models/token.rbi +2 -2
- data/rbi/lib/terminal-shop/models/token_create_params.rbi +5 -2
- data/rbi/lib/terminal-shop/models/token_create_response.rbi +4 -4
- data/rbi/lib/terminal-shop/models/token_delete_params.rbi +5 -2
- data/rbi/lib/terminal-shop/models/token_delete_response.rbi +2 -2
- data/rbi/lib/terminal-shop/models/token_get_params.rbi +5 -2
- data/rbi/lib/terminal-shop/models/token_get_response.rbi +2 -2
- data/rbi/lib/terminal-shop/models/token_list_params.rbi +5 -2
- data/rbi/lib/terminal-shop/models/token_list_response.rbi +2 -2
- data/rbi/lib/terminal-shop/models/view_init_params.rbi +5 -2
- data/rbi/lib/terminal-shop/models/view_init_response.rbi +5 -15
- data/rbi/lib/terminal-shop/pooled_net_requester.rbi +15 -10
- data/rbi/lib/terminal-shop/request_options.rbi +4 -0
- data/rbi/lib/terminal-shop/resources/address.rbi +2 -2
- data/rbi/lib/terminal-shop/resources/app.rbi +2 -2
- data/rbi/lib/terminal-shop/resources/card.rbi +2 -2
- data/rbi/lib/terminal-shop/resources/cart.rbi +24 -4
- data/rbi/lib/terminal-shop/resources/email.rbi +2 -2
- data/rbi/lib/terminal-shop/resources/order.rbi +2 -2
- data/rbi/lib/terminal-shop/resources/product.rbi +2 -2
- data/rbi/lib/terminal-shop/resources/profile.rbi +2 -2
- data/rbi/lib/terminal-shop/resources/subscription.rbi +2 -2
- data/rbi/lib/terminal-shop/resources/token.rbi +2 -2
- data/rbi/lib/terminal-shop/resources/view.rbi +2 -2
- data/rbi/lib/terminal-shop/util.rbi +181 -126
- data/rbi/lib/terminal-shop/version.rbi +1 -1
- data/sig/terminal-shop/models/cart.rbs +27 -2
- data/sig/terminal-shop/models/cart_convert_params.rbs +10 -2
- data/sig/terminal-shop/models/cart_redeem_gift_card_params.rbs +25 -0
- data/sig/terminal-shop/models/cart_redeem_gift_card_response.rbs +47 -0
- data/sig/terminal-shop/models/cart_remove_gift_card_params.rbs +19 -0
- data/sig/terminal-shop/models/cart_remove_gift_card_response.rbs +18 -0
- data/sig/terminal-shop/models/product.rbs +8 -2
- data/sig/terminal-shop/pooled_net_requester.rbs +4 -2
- data/sig/terminal-shop/request_options.rbs +4 -0
- data/sig/terminal-shop/resources/cart.rbs +20 -0
- data/sig/terminal-shop/util.rbs +27 -2
- data/sig/terminal-shop/version.rbs +1 -1
- metadata +14 -2
@@ -5,6 +5,26 @@ module TerminalShop
|
|
5
5
|
#
|
6
6
|
# @abstract
|
7
7
|
#
|
8
|
+
# @example
|
9
|
+
# ```ruby
|
10
|
+
# if page.has_next?
|
11
|
+
# page = page.next_page
|
12
|
+
# end
|
13
|
+
# ```
|
14
|
+
#
|
15
|
+
# @example
|
16
|
+
# ```ruby
|
17
|
+
# page.auto_paging_each do |product|
|
18
|
+
# puts(product)
|
19
|
+
# end
|
20
|
+
# ```
|
21
|
+
#
|
22
|
+
# @example
|
23
|
+
# ```ruby
|
24
|
+
# products = page.to_enum.take(2)
|
25
|
+
#
|
26
|
+
# products => Array
|
27
|
+
# ```
|
8
28
|
module BasePage
|
9
29
|
# @return [Boolean]
|
10
30
|
#
|
@@ -41,6 +41,16 @@ module TerminalShop
|
|
41
41
|
# # @return [String]
|
42
42
|
# attr_writer :card_id
|
43
43
|
|
44
|
+
# @!attribute [r] gift_card_id
|
45
|
+
# ID of the gift card applied to the current user's cart.
|
46
|
+
#
|
47
|
+
# @return [String, nil]
|
48
|
+
optional :gift_card_id, String, api_name: :giftCardID
|
49
|
+
|
50
|
+
# @!parse
|
51
|
+
# # @return [String]
|
52
|
+
# attr_writer :gift_card_id
|
53
|
+
|
44
54
|
# @!attribute [r] shipping
|
45
55
|
# Shipping information for the current user's cart.
|
46
56
|
#
|
@@ -59,9 +69,10 @@ module TerminalShop
|
|
59
69
|
# # @param subtotal [Integer]
|
60
70
|
# # @param address_id [String]
|
61
71
|
# # @param card_id [String]
|
72
|
+
# # @param gift_card_id [String]
|
62
73
|
# # @param shipping [TerminalShop::Models::CartAPI::Shipping]
|
63
74
|
# #
|
64
|
-
# def initialize(amount:, items:, subtotal:, address_id: nil, card_id: nil, shipping: nil, **) = super
|
75
|
+
# def initialize(amount:, items:, subtotal:, address_id: nil, card_id: nil, gift_card_id: nil, shipping: nil, **) = super
|
65
76
|
|
66
77
|
# def initialize: (Hash | TerminalShop::BaseModel) -> void
|
67
78
|
|
@@ -72,6 +83,16 @@ module TerminalShop
|
|
72
83
|
# @return [Integer]
|
73
84
|
required :subtotal, Integer
|
74
85
|
|
86
|
+
# @!attribute [r] gift_card
|
87
|
+
# Amount applied from gift card on the current user's cart, in cents (USD).
|
88
|
+
#
|
89
|
+
# @return [Integer, nil]
|
90
|
+
optional :gift_card, Integer, api_name: :giftCard
|
91
|
+
|
92
|
+
# @!parse
|
93
|
+
# # @return [Integer]
|
94
|
+
# attr_writer :gift_card
|
95
|
+
|
75
96
|
# @!attribute [r] shipping
|
76
97
|
# Shipping amount of the current user's cart, in cents (USD).
|
77
98
|
#
|
@@ -82,13 +103,25 @@ module TerminalShop
|
|
82
103
|
# # @return [Integer]
|
83
104
|
# attr_writer :shipping
|
84
105
|
|
106
|
+
# @!attribute [r] total
|
107
|
+
# Total amount after gift card applied, in cents (USD).
|
108
|
+
#
|
109
|
+
# @return [Integer, nil]
|
110
|
+
optional :total, Integer
|
111
|
+
|
112
|
+
# @!parse
|
113
|
+
# # @return [Integer]
|
114
|
+
# attr_writer :total
|
115
|
+
|
85
116
|
# @!parse
|
86
117
|
# # The subtotal and shipping amounts for the current user's cart.
|
87
118
|
# #
|
88
119
|
# # @param subtotal [Integer]
|
120
|
+
# # @param gift_card [Integer]
|
89
121
|
# # @param shipping [Integer]
|
122
|
+
# # @param total [Integer]
|
90
123
|
# #
|
91
|
-
# def initialize(subtotal:, shipping: nil, **) = super
|
124
|
+
# def initialize(subtotal:, gift_card: nil, shipping: nil, total: nil, **) = super
|
92
125
|
|
93
126
|
# def initialize: (Hash | TerminalShop::BaseModel) -> void
|
94
127
|
end
|
@@ -7,10 +7,20 @@ module TerminalShop
|
|
7
7
|
# extend TerminalShop::RequestParameters::Converter
|
8
8
|
include TerminalShop::RequestParameters
|
9
9
|
|
10
|
+
# @!attribute [r] recipient_email
|
11
|
+
#
|
12
|
+
# @return [String, nil]
|
13
|
+
optional :recipient_email, String, api_name: :recipientEmail
|
14
|
+
|
15
|
+
# @!parse
|
16
|
+
# # @return [String]
|
17
|
+
# attr_writer :recipient_email
|
18
|
+
|
10
19
|
# @!parse
|
20
|
+
# # @param recipient_email [String]
|
11
21
|
# # @param request_options [TerminalShop::RequestOptions, Hash{Symbol=>Object}]
|
12
22
|
# #
|
13
|
-
# def initialize(request_options: {}, **) = super
|
23
|
+
# def initialize(recipient_email: nil, request_options: {}, **) = super
|
14
24
|
|
15
25
|
# def initialize: (Hash | TerminalShop::BaseModel) -> void
|
16
26
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TerminalShop
|
4
|
+
module Models
|
5
|
+
class CartRedeemGiftCardParams < TerminalShop::BaseModel
|
6
|
+
# @!parse
|
7
|
+
# extend TerminalShop::RequestParameters::Converter
|
8
|
+
include TerminalShop::RequestParameters
|
9
|
+
|
10
|
+
# @!attribute gift_card_id
|
11
|
+
#
|
12
|
+
# @return [String]
|
13
|
+
required :gift_card_id, String, api_name: :giftCardID
|
14
|
+
|
15
|
+
# @!parse
|
16
|
+
# # @param gift_card_id [String]
|
17
|
+
# # @param request_options [TerminalShop::RequestOptions, Hash{Symbol=>Object}]
|
18
|
+
# #
|
19
|
+
# def initialize(gift_card_id:, request_options: {}, **) = super
|
20
|
+
|
21
|
+
# def initialize: (Hash | TerminalShop::BaseModel) -> void
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TerminalShop
|
4
|
+
module Models
|
5
|
+
class CartRedeemGiftCardResponse < TerminalShop::BaseModel
|
6
|
+
# @!attribute data
|
7
|
+
# Gift card redemption result
|
8
|
+
#
|
9
|
+
# @return [TerminalShop::Models::CartRedeemGiftCardResponse::Data]
|
10
|
+
required :data, -> { TerminalShop::Models::CartRedeemGiftCardResponse::Data }
|
11
|
+
|
12
|
+
# @!parse
|
13
|
+
# # @param data [TerminalShop::Models::CartRedeemGiftCardResponse::Data]
|
14
|
+
# #
|
15
|
+
# def initialize(data:, **) = super
|
16
|
+
|
17
|
+
# def initialize: (Hash | TerminalShop::BaseModel) -> void
|
18
|
+
|
19
|
+
class Data < TerminalShop::BaseModel
|
20
|
+
# @!attribute applied_amount
|
21
|
+
#
|
22
|
+
# @return [Integer]
|
23
|
+
required :applied_amount, Integer, api_name: :appliedAmount
|
24
|
+
|
25
|
+
# @!attribute gift_card_id
|
26
|
+
#
|
27
|
+
# @return [String]
|
28
|
+
required :gift_card_id, String, api_name: :giftCardID
|
29
|
+
|
30
|
+
# @!attribute remaining_balance
|
31
|
+
#
|
32
|
+
# @return [Integer]
|
33
|
+
required :remaining_balance, Integer, api_name: :remainingBalance
|
34
|
+
|
35
|
+
# @!parse
|
36
|
+
# # Gift card redemption result
|
37
|
+
# #
|
38
|
+
# # @param applied_amount [Integer]
|
39
|
+
# # @param gift_card_id [String]
|
40
|
+
# # @param remaining_balance [Integer]
|
41
|
+
# #
|
42
|
+
# def initialize(applied_amount:, gift_card_id:, remaining_balance:, **) = super
|
43
|
+
|
44
|
+
# def initialize: (Hash | TerminalShop::BaseModel) -> void
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TerminalShop
|
4
|
+
module Models
|
5
|
+
class CartRemoveGiftCardParams < TerminalShop::BaseModel
|
6
|
+
# @!parse
|
7
|
+
# extend TerminalShop::RequestParameters::Converter
|
8
|
+
include TerminalShop::RequestParameters
|
9
|
+
|
10
|
+
# @!parse
|
11
|
+
# # @param request_options [TerminalShop::RequestOptions, Hash{Symbol=>Object}]
|
12
|
+
# #
|
13
|
+
# def initialize(request_options: {}, **) = super
|
14
|
+
|
15
|
+
# def initialize: (Hash | TerminalShop::BaseModel) -> void
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TerminalShop
|
4
|
+
module Models
|
5
|
+
class CartRemoveGiftCardResponse < TerminalShop::BaseModel
|
6
|
+
# @!attribute data
|
7
|
+
#
|
8
|
+
# @return [Symbol, :ok]
|
9
|
+
required :data, const: :ok
|
10
|
+
|
11
|
+
# @!parse
|
12
|
+
# # @param data [Symbol, :ok]
|
13
|
+
# #
|
14
|
+
# def initialize(data: :ok, **) = super
|
15
|
+
|
16
|
+
# def initialize: (Hash | TerminalShop::BaseModel) -> void
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -80,11 +80,6 @@ module TerminalShop
|
|
80
80
|
REQUIRED = :required
|
81
81
|
|
82
82
|
finalize!
|
83
|
-
|
84
|
-
# @!parse
|
85
|
-
# # @return [Array<Symbol>]
|
86
|
-
# #
|
87
|
-
# def self.values; end
|
88
83
|
end
|
89
84
|
|
90
85
|
class Tags < TerminalShop::BaseModel
|
@@ -133,6 +128,15 @@ module TerminalShop
|
|
133
128
|
# # @return [Boolean]
|
134
129
|
# attr_writer :market_na
|
135
130
|
|
131
|
+
# @!attribute [r] type
|
132
|
+
#
|
133
|
+
# @return [String, nil]
|
134
|
+
optional :type, String
|
135
|
+
|
136
|
+
# @!parse
|
137
|
+
# # @return [String]
|
138
|
+
# attr_writer :type
|
139
|
+
|
136
140
|
# @!parse
|
137
141
|
# # Tags for the product.
|
138
142
|
# #
|
@@ -141,8 +145,9 @@ module TerminalShop
|
|
141
145
|
# # @param featured [Boolean]
|
142
146
|
# # @param market_eu [Boolean]
|
143
147
|
# # @param market_na [Boolean]
|
148
|
+
# # @param type [String]
|
144
149
|
# #
|
145
|
-
# def initialize(app: nil, color: nil, featured: nil, market_eu: nil, market_na: nil, **) = super
|
150
|
+
# def initialize(app: nil, color: nil, featured: nil, market_eu: nil, market_na: nil, type: nil, **) = super
|
146
151
|
|
147
152
|
# def initialize: (Hash | TerminalShop::BaseModel) -> void
|
148
153
|
end
|
@@ -48,9 +48,11 @@ module TerminalShop
|
|
48
48
|
#
|
49
49
|
# @option request [Hash{String=>String}] :headers
|
50
50
|
#
|
51
|
+
# @param blk [Proc]
|
52
|
+
#
|
51
53
|
# @return [Net::HTTPGenericRequest]
|
52
54
|
#
|
53
|
-
def build_request(request)
|
55
|
+
def build_request(request, &)
|
54
56
|
method, url, headers, body = request.fetch_values(:method, :url, :headers, :body)
|
55
57
|
req = Net::HTTPGenericRequest.new(
|
56
58
|
method.to_s.upcase,
|
@@ -64,12 +66,14 @@ module TerminalShop
|
|
64
66
|
case body
|
65
67
|
in nil
|
66
68
|
in String
|
67
|
-
req.
|
69
|
+
req["content-length"] ||= body.bytesize.to_s unless req["transfer-encoding"]
|
70
|
+
req.body_stream = TerminalShop::Util::ReadIOAdapter.new(body, &)
|
68
71
|
in StringIO
|
69
|
-
req
|
70
|
-
|
71
|
-
|
72
|
-
req
|
72
|
+
req["content-length"] ||= body.size.to_s unless req["transfer-encoding"]
|
73
|
+
req.body_stream = TerminalShop::Util::ReadIOAdapter.new(body, &)
|
74
|
+
in IO | Enumerator
|
75
|
+
req["transfer-encoding"] ||= "chunked" unless req["content-length"]
|
76
|
+
req.body_stream = TerminalShop::Util::ReadIOAdapter.new(body, &)
|
73
77
|
end
|
74
78
|
|
75
79
|
req
|
@@ -97,7 +101,7 @@ module TerminalShop
|
|
97
101
|
|
98
102
|
pool =
|
99
103
|
@mutex.synchronize do
|
100
|
-
@pools[origin] ||= ConnectionPool.new(size:
|
104
|
+
@pools[origin] ||= ConnectionPool.new(size: @size) do
|
101
105
|
self.class.connect(url)
|
102
106
|
end
|
103
107
|
end
|
@@ -128,7 +132,6 @@ module TerminalShop
|
|
128
132
|
#
|
129
133
|
def execute(request)
|
130
134
|
url, deadline = request.fetch_values(:url, :deadline)
|
131
|
-
req = self.class.build_request(request)
|
132
135
|
|
133
136
|
eof = false
|
134
137
|
finished = false
|
@@ -136,6 +139,10 @@ module TerminalShop
|
|
136
139
|
with_pool(url) do |conn|
|
137
140
|
next if finished
|
138
141
|
|
142
|
+
req = self.class.build_request(request) do
|
143
|
+
self.class.calibrate_socket_timeout(conn, deadline)
|
144
|
+
end
|
145
|
+
|
139
146
|
self.class.calibrate_socket_timeout(conn, deadline)
|
140
147
|
conn.start unless conn.started?
|
141
148
|
|
@@ -156,19 +163,25 @@ module TerminalShop
|
|
156
163
|
end
|
157
164
|
|
158
165
|
conn, response = enum.next
|
159
|
-
body = TerminalShop::Util.fused_enum(enum) do
|
166
|
+
body = TerminalShop::Util.fused_enum(enum, external: true) do
|
160
167
|
finished = true
|
161
168
|
tap do
|
162
169
|
enum.next
|
163
170
|
rescue StopIteration
|
171
|
+
nil
|
164
172
|
end
|
165
173
|
conn.finish if !eof && conn&.started?
|
166
174
|
end
|
167
175
|
[response, (response.body = body)]
|
168
176
|
end
|
169
177
|
|
170
|
-
|
178
|
+
# @private
|
179
|
+
#
|
180
|
+
# @param size [Integer]
|
181
|
+
#
|
182
|
+
def initialize(size: Etc.nprocessors)
|
171
183
|
@mutex = Mutex.new
|
184
|
+
@size = size
|
172
185
|
@pools = {}
|
173
186
|
end
|
174
187
|
end
|
@@ -7,16 +7,20 @@ module TerminalShop
|
|
7
7
|
#
|
8
8
|
# @param params [TerminalShop::Models::CartConvertParams, Hash{Symbol=>Object}] .
|
9
9
|
#
|
10
|
+
# @option params [String] :recipient_email
|
11
|
+
#
|
10
12
|
# @option params [TerminalShop::RequestOptions, Hash{Symbol=>Object}, nil] :request_options
|
11
13
|
#
|
12
14
|
# @return [TerminalShop::Models::CartConvertResponse]
|
13
15
|
#
|
14
16
|
def convert(params = {})
|
17
|
+
parsed, options = TerminalShop::Models::CartConvertParams.dump_request(params)
|
15
18
|
@client.request(
|
16
19
|
method: :post,
|
17
20
|
path: "cart/convert",
|
21
|
+
body: parsed,
|
18
22
|
model: TerminalShop::Models::CartConvertResponse,
|
19
|
-
options:
|
23
|
+
options: options
|
20
24
|
)
|
21
25
|
end
|
22
26
|
|
@@ -37,6 +41,44 @@ module TerminalShop
|
|
37
41
|
)
|
38
42
|
end
|
39
43
|
|
44
|
+
# Apply a gift card to the current user's cart.
|
45
|
+
#
|
46
|
+
# @param params [TerminalShop::Models::CartRedeemGiftCardParams, Hash{Symbol=>Object}] .
|
47
|
+
#
|
48
|
+
# @option params [String] :gift_card_id
|
49
|
+
#
|
50
|
+
# @option params [TerminalShop::RequestOptions, Hash{Symbol=>Object}, nil] :request_options
|
51
|
+
#
|
52
|
+
# @return [TerminalShop::Models::CartRedeemGiftCardResponse]
|
53
|
+
#
|
54
|
+
def redeem_gift_card(params)
|
55
|
+
parsed, options = TerminalShop::Models::CartRedeemGiftCardParams.dump_request(params)
|
56
|
+
@client.request(
|
57
|
+
method: :put,
|
58
|
+
path: "cart/gift-card",
|
59
|
+
body: parsed,
|
60
|
+
model: TerminalShop::Models::CartRedeemGiftCardResponse,
|
61
|
+
options: options
|
62
|
+
)
|
63
|
+
end
|
64
|
+
|
65
|
+
# Remove the gift card from the current user's cart.
|
66
|
+
#
|
67
|
+
# @param params [TerminalShop::Models::CartRemoveGiftCardParams, Hash{Symbol=>Object}] .
|
68
|
+
#
|
69
|
+
# @option params [TerminalShop::RequestOptions, Hash{Symbol=>Object}, nil] :request_options
|
70
|
+
#
|
71
|
+
# @return [TerminalShop::Models::CartRemoveGiftCardResponse]
|
72
|
+
#
|
73
|
+
def remove_gift_card(params = {})
|
74
|
+
@client.request(
|
75
|
+
method: :delete,
|
76
|
+
path: "cart/gift-card",
|
77
|
+
model: TerminalShop::Models::CartRemoveGiftCardResponse,
|
78
|
+
options: params[:request_options]
|
79
|
+
)
|
80
|
+
end
|
81
|
+
|
40
82
|
# Set the shipping address for the current user's cart.
|
41
83
|
#
|
42
84
|
# @param params [TerminalShop::Models::CartSetAddressParams, Hash{Symbol=>Object}] .
|