terminal-shop 1.2.0 → 1.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 974257e90aeb93cf152e34de6ea7351f727f6e6ee95e04415b290b90f648a251
4
- data.tar.gz: 7de2c3d22ad41f81fe735d5fb3018b99a9a15350c4faa35b4f316f4ab0ae822a
3
+ metadata.gz: f91cfa1e00fc8a0a26c3703491d703dabfd5a6c9d709c50429c48ab5dbf8b394
4
+ data.tar.gz: 0c80157694b08e03b3b270467ff554715316afb09f6b9bacadc27cf69790f156
5
5
  SHA512:
6
- metadata.gz: 8f6a23136217de3ea26e0bed3db6f7ca39ced5bd099b681fd3f61cc50fdc8b4eb8d3c48591049a7d19e21c107cf7abc576a1bc714bf012ec35a4fa7eda2a46cb
7
- data.tar.gz: e8145d5a065574cf2f972f33978247fc21a1a9f9c935ced9d30aaae9d346aed51bc52f6e71b1555cbc089628dfb97c5d740aa2b2a8c2a43752c21253cd2afdd7
6
+ metadata.gz: a7bab3c748805fb493481b64dc6c85721eca4383d123ab26f64010c095bcf3f04c3a9e8d891379b0f4043e0ca5cea37588f778e625c1ccf1f388b4e3a0bc7eaa
7
+ data.tar.gz: f08c6af441c4d685582103ce6f5575a8ca441df8b04a6e91754c277b1a25c965b15af4964e605c7b2ded1336c6f3cf290b48fe2d77bc059459a3ffbc3d69d0b9
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TerminalShop
4
+ module Models
5
+ class CartClearParams < 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 CartClearResponse < 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
@@ -85,20 +85,8 @@ module TerminalShop
85
85
  # @param url [URI::Generic]
86
86
  # @param blk [Proc]
87
87
  #
88
- private def with_pool(url, &blk)
88
+ private def with_pool(url, &)
89
89
  origin = TerminalShop::Util.uri_origin(url)
90
- th = Thread.current
91
- key = :"#{object_id}-#{self.class.name}-connection_in_use_for_#{origin}"
92
-
93
- if th[key]
94
- tap do
95
- conn = self.class.connect(url)
96
- return blk.call(conn)
97
- ensure
98
- conn.finish if conn&.started?
99
- end
100
- end
101
-
102
90
  pool =
103
91
  @mutex.synchronize do
104
92
  @pools[origin] ||= ConnectionPool.new(size: @size) do
@@ -106,12 +94,7 @@ module TerminalShop
106
94
  end
107
95
  end
108
96
 
109
- pool.with do |conn|
110
- th[key] = true
111
- blk.call(conn)
112
- ensure
113
- th[key] = nil
114
- end
97
+ pool.with(&)
115
98
  end
116
99
 
117
100
  # @private
@@ -3,6 +3,23 @@
3
3
  module TerminalShop
4
4
  module Resources
5
5
  class Cart
6
+ # Clear the current user's cart.
7
+ #
8
+ # @param params [TerminalShop::Models::CartClearParams, Hash{Symbol=>Object}] .
9
+ #
10
+ # @option params [TerminalShop::RequestOptions, Hash{Symbol=>Object}, nil] :request_options
11
+ #
12
+ # @return [TerminalShop::Models::CartClearResponse]
13
+ #
14
+ def clear(params = {})
15
+ @client.request(
16
+ method: :delete,
17
+ path: "cart",
18
+ model: TerminalShop::Models::CartClearResponse,
19
+ options: params[:request_options]
20
+ )
21
+ end
22
+
6
23
  # Convert the current user's cart to an order.
7
24
  #
8
25
  # @param params [TerminalShop::Models::CartConvertParams, Hash{Symbol=>Object}] .
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TerminalShop
4
- VERSION = "1.2.0"
4
+ VERSION = "1.3.0"
5
5
  end
data/lib/terminal-shop.rb CHANGED
@@ -59,6 +59,8 @@ require_relative "terminal-shop/models/card_get_response"
59
59
  require_relative "terminal-shop/models/card_list_params"
60
60
  require_relative "terminal-shop/models/card_list_response"
61
61
  require_relative "terminal-shop/models/cart"
62
+ require_relative "terminal-shop/models/cart_clear_params"
63
+ require_relative "terminal-shop/models/cart_clear_response"
62
64
  require_relative "terminal-shop/models/cart_convert_params"
63
65
  require_relative "terminal-shop/models/cart_convert_response"
64
66
  require_relative "terminal-shop/models/cart_get_params"
@@ -0,0 +1,21 @@
1
+ # typed: strong
2
+
3
+ module TerminalShop
4
+ module Models
5
+ class CartClearParams < TerminalShop::BaseModel
6
+ extend TerminalShop::RequestParameters::Converter
7
+ include TerminalShop::RequestParameters
8
+
9
+ sig do
10
+ params(request_options: T.any(TerminalShop::RequestOptions, T::Hash[Symbol, T.anything]))
11
+ .returns(T.attached_class)
12
+ end
13
+ def self.new(request_options: {})
14
+ end
15
+
16
+ sig { override.returns({request_options: TerminalShop::RequestOptions}) }
17
+ def to_hash
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,23 @@
1
+ # typed: strong
2
+
3
+ module TerminalShop
4
+ module Models
5
+ class CartClearResponse < TerminalShop::BaseModel
6
+ sig { returns(Symbol) }
7
+ def data
8
+ end
9
+
10
+ sig { params(_: Symbol).returns(Symbol) }
11
+ def data=(_)
12
+ end
13
+
14
+ sig { params(data: Symbol).returns(T.attached_class) }
15
+ def self.new(data: :ok)
16
+ end
17
+
18
+ sig { override.returns({data: Symbol}) }
19
+ def to_hash
20
+ end
21
+ end
22
+ end
23
+ end
@@ -3,6 +3,13 @@
3
3
  module TerminalShop
4
4
  module Resources
5
5
  class Cart
6
+ sig do
7
+ params(request_options: T.nilable(T.any(TerminalShop::RequestOptions, T::Hash[Symbol, T.anything])))
8
+ .returns(TerminalShop::Models::CartClearResponse)
9
+ end
10
+ def clear(request_options: {})
11
+ end
12
+
6
13
  sig do
7
14
  params(
8
15
  recipient_email: String,
@@ -1,5 +1,5 @@
1
1
  # typed: strong
2
2
 
3
3
  module TerminalShop
4
- VERSION = "1.2.0"
4
+ VERSION = "1.3.0"
5
5
  end
@@ -0,0 +1,19 @@
1
+ module TerminalShop
2
+ module Models
3
+ type cart_clear_params = { } & TerminalShop::request_parameters
4
+
5
+ class CartClearParams < TerminalShop::BaseModel
6
+ extend TerminalShop::RequestParameters::Converter
7
+ include TerminalShop::RequestParameters
8
+
9
+ def initialize:
10
+ (request_options: TerminalShop::request_opts) -> void
11
+ | (
12
+ ?TerminalShop::Models::cart_clear_params
13
+ | TerminalShop::BaseModel data
14
+ ) -> void
15
+
16
+ def to_hash: -> TerminalShop::Models::cart_clear_params
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,18 @@
1
+ module TerminalShop
2
+ module Models
3
+ type cart_clear_response = { data: :ok }
4
+
5
+ class CartClearResponse < TerminalShop::BaseModel
6
+ attr_accessor data: :ok
7
+
8
+ def initialize:
9
+ (data: :ok) -> void
10
+ | (
11
+ ?TerminalShop::Models::cart_clear_response
12
+ | TerminalShop::BaseModel data
13
+ ) -> void
14
+
15
+ def to_hash: -> TerminalShop::Models::cart_clear_response
16
+ end
17
+ end
18
+ end
@@ -1,6 +1,14 @@
1
1
  module TerminalShop
2
2
  module Resources
3
3
  class Cart
4
+ def clear:
5
+ (
6
+ ?TerminalShop::Models::CartClearParams | ::Hash[Symbol, top] params
7
+ ) -> TerminalShop::Models::CartClearResponse
8
+ | (
9
+ request_options: TerminalShop::request_opts
10
+ ) -> TerminalShop::Models::CartClearResponse
11
+
4
12
  def convert:
5
13
  (
6
14
  ?TerminalShop::Models::CartConvertParams | ::Hash[Symbol, top] params
@@ -1,3 +1,3 @@
1
1
  module TerminalShop
2
- VERSION: "1.1.0"
2
+ VERSION: "1.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: terminal-shop
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Terminal
@@ -69,6 +69,8 @@ files:
69
69
  - lib/terminal-shop/models/card_list_params.rb
70
70
  - lib/terminal-shop/models/card_list_response.rb
71
71
  - lib/terminal-shop/models/cart.rb
72
+ - lib/terminal-shop/models/cart_clear_params.rb
73
+ - lib/terminal-shop/models/cart_clear_response.rb
72
74
  - lib/terminal-shop/models/cart_convert_params.rb
73
75
  - lib/terminal-shop/models/cart_convert_response.rb
74
76
  - lib/terminal-shop/models/cart_get_params.rb
@@ -175,6 +177,8 @@ files:
175
177
  - rbi/lib/terminal-shop/models/card_list_params.rbi
176
178
  - rbi/lib/terminal-shop/models/card_list_response.rbi
177
179
  - rbi/lib/terminal-shop/models/cart.rbi
180
+ - rbi/lib/terminal-shop/models/cart_clear_params.rbi
181
+ - rbi/lib/terminal-shop/models/cart_clear_response.rbi
178
182
  - rbi/lib/terminal-shop/models/cart_convert_params.rbi
179
183
  - rbi/lib/terminal-shop/models/cart_convert_response.rbi
180
184
  - rbi/lib/terminal-shop/models/cart_get_params.rbi
@@ -280,6 +284,8 @@ files:
280
284
  - sig/terminal-shop/models/card_list_params.rbs
281
285
  - sig/terminal-shop/models/card_list_response.rbs
282
286
  - sig/terminal-shop/models/cart.rbs
287
+ - sig/terminal-shop/models/cart_clear_params.rbs
288
+ - sig/terminal-shop/models/cart_clear_response.rbs
283
289
  - sig/terminal-shop/models/cart_convert_params.rbs
284
290
  - sig/terminal-shop/models/cart_convert_response.rbs
285
291
  - sig/terminal-shop/models/cart_get_params.rbs