terminal-shop 2.1.0 → 2.1.2

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: fc09a5779386790999a7439865ea22d8e82c09d0048c9116ff0d55a74f9f14ca
4
- data.tar.gz: 15901e6cbfb87f75a4e4c662b22c8de824518353b81529bc6dc14b65b3d84325
3
+ metadata.gz: e9bf917ec73c7cb09ab4763ed8c0413cffd0412def901e7a707aea888d0aac13
4
+ data.tar.gz: f475711c01405690ab9454431ae01ce45b02524c71639fba6cd37968692913f4
5
5
  SHA512:
6
- metadata.gz: 15e48a9e13e6a2ff9afe005aa2663e2c3fd19b2f35490277d2eb4e2578bcc3eb8a26e0693efdc32f03700f485adfaa43bd4c52f87ee11dc3ae4b900fb1940d69
7
- data.tar.gz: 4842e7a98db1fe06a240c121366ad656064e9bca721ffee7c56ecaf12882913aafb9e3785f9078d2b11912f9b5ed59c4479bdc69b9b8a7adb86eaf2acd180ce2
6
+ metadata.gz: 20b336aae8fb897c04a6be94c49b4739ce933aeed033e025a69b2bc15674697fd85546adddff1f8ab2d2baf2d0d1784ad2d313dfb3f36c2bbd6fe42defbbb2c2
7
+ data.tar.gz: 17fb0ad07044975fa2ee8a847c0e6ca8ed4df7c1d08cbc7557d7e6a6d728dfbb01047706bbb483539ccfab33ae035cf9efbcd611510e4f9ce81bda1c389e6a72
data/README.md CHANGED
@@ -15,7 +15,7 @@ The underlying REST API documentation can be found on [terminal.shop](https://te
15
15
  To use this gem, install via Bundler by adding the following to your application's `Gemfile`:
16
16
 
17
17
  ```ruby
18
- gem "terminal-shop", "~> 2.0.0"
18
+ gem "terminal-shop", "~> 2.1.1"
19
19
  ```
20
20
 
21
21
  To fetch an initial copy of the gem:
@@ -117,7 +117,7 @@ Due to limitations with the Sorbet type system, where a method otherwise can tak
117
117
  Please follow Sorbet's [setup guides](https://sorbet.org/docs/adopting) for best experience.
118
118
 
119
119
  ```ruby
120
- model = ProductListParams.new
120
+ model = TerminalShop::Models::ProductListParams.new
121
121
 
122
122
  terminal.product.list(**model)
123
123
  ```
@@ -17,7 +17,7 @@ module TerminalShop
17
17
 
18
18
  # rubocop:disable Style/MutableConstant
19
19
  # @type [Hash{Symbol=>String}]
20
- ENVIRONMENTS = {production: "https://api.terminal.shop/", dev: "https://api.dev.terminal.shop/"}
20
+ ENVIRONMENTS = {production: "https://api.terminal.shop", dev: "https://api.dev.terminal.shop"}
21
21
  # rubocop:enable Style/MutableConstant
22
22
 
23
23
  # @return [String]
@@ -74,8 +74,8 @@ module TerminalShop
74
74
  #
75
75
  # Each environment maps to a different base URL:
76
76
  #
77
- # - `production` corresponds to `https://api.terminal.shop/`
78
- # - `dev` corresponds to `https://api.dev.terminal.shop/`
77
+ # - `production` corresponds to `https://api.terminal.shop`
78
+ # - `dev` corresponds to `https://api.dev.terminal.shop`
79
79
  #
80
80
  # @param base_url [String, nil] Override the default base URL for the API, e.g., `"https://api.example.com/v2/"`
81
81
  #
@@ -65,7 +65,7 @@ module TerminalShop
65
65
  def delete(id, params = {})
66
66
  @client.request(
67
67
  method: :delete,
68
- path: ["address/%0s", id],
68
+ path: ["address/%1$s", id],
69
69
  model: TerminalShop::Models::AddressDeleteResponse,
70
70
  options: params[:request_options]
71
71
  )
@@ -83,7 +83,7 @@ module TerminalShop
83
83
  def get(id, params = {})
84
84
  @client.request(
85
85
  method: :get,
86
- path: ["address/%0s", id],
86
+ path: ["address/%1$s", id],
87
87
  model: TerminalShop::Models::AddressGetResponse,
88
88
  options: params[:request_options]
89
89
  )
@@ -53,7 +53,7 @@ module TerminalShop
53
53
  def delete(id, params = {})
54
54
  @client.request(
55
55
  method: :delete,
56
- path: ["app/%0s", id],
56
+ path: ["app/%1$s", id],
57
57
  model: TerminalShop::Models::AppDeleteResponse,
58
58
  options: params[:request_options]
59
59
  )
@@ -71,7 +71,7 @@ module TerminalShop
71
71
  def get(id, params = {})
72
72
  @client.request(
73
73
  method: :get,
74
- path: ["app/%0s", id],
74
+ path: ["app/%1$s", id],
75
75
  model: TerminalShop::Models::AppGetResponse,
76
76
  options: params[:request_options]
77
77
  )
@@ -52,7 +52,7 @@ module TerminalShop
52
52
  def delete(id, params = {})
53
53
  @client.request(
54
54
  method: :delete,
55
- path: ["card/%0s", id],
55
+ path: ["card/%1$s", id],
56
56
  model: TerminalShop::Models::CardDeleteResponse,
57
57
  options: params[:request_options]
58
58
  )
@@ -87,7 +87,7 @@ module TerminalShop
87
87
  def get(id, params = {})
88
88
  @client.request(
89
89
  method: :get,
90
- path: ["card/%0s", id],
90
+ path: ["card/%1$s", id],
91
91
  model: TerminalShop::Models::CardGetResponse,
92
92
  options: params[:request_options]
93
93
  )
@@ -55,7 +55,7 @@ module TerminalShop
55
55
  def get(id, params = {})
56
56
  @client.request(
57
57
  method: :get,
58
- path: ["order/%0s", id],
58
+ path: ["order/%1$s", id],
59
59
  model: TerminalShop::Models::OrderGetResponse,
60
60
  options: params[:request_options]
61
61
  )
@@ -31,7 +31,7 @@ module TerminalShop
31
31
  def get(id, params = {})
32
32
  @client.request(
33
33
  method: :get,
34
- path: ["product/%0s", id],
34
+ path: ["product/%1$s", id],
35
35
  model: TerminalShop::Models::ProductGetResponse,
36
36
  options: params[:request_options]
37
37
  )
@@ -63,7 +63,7 @@ module TerminalShop
63
63
  def delete(id, params = {})
64
64
  @client.request(
65
65
  method: :delete,
66
- path: ["subscription/%0s", id],
66
+ path: ["subscription/%1$s", id],
67
67
  model: TerminalShop::Models::SubscriptionDeleteResponse,
68
68
  options: params[:request_options]
69
69
  )
@@ -81,7 +81,7 @@ module TerminalShop
81
81
  def get(id, params = {})
82
82
  @client.request(
83
83
  method: :get,
84
- path: ["subscription/%0s", id],
84
+ path: ["subscription/%1$s", id],
85
85
  model: TerminalShop::Models::SubscriptionGetResponse,
86
86
  options: params[:request_options]
87
87
  )
@@ -47,7 +47,7 @@ module TerminalShop
47
47
  def delete(id, params = {})
48
48
  @client.request(
49
49
  method: :delete,
50
- path: ["token/%0s", id],
50
+ path: ["token/%1$s", id],
51
51
  model: TerminalShop::Models::TokenDeleteResponse,
52
52
  options: params[:request_options]
53
53
  )
@@ -65,7 +65,7 @@ module TerminalShop
65
65
  def get(id, params = {})
66
66
  @client.request(
67
67
  method: :get,
68
- path: ["token/%0s", id],
68
+ path: ["token/%1$s", id],
69
69
  model: TerminalShop::Models::TokenGetResponse,
70
70
  options: params[:request_options]
71
71
  )
@@ -54,7 +54,7 @@ module TerminalShop
54
54
  #
55
55
  # @yieldparam [String]
56
56
  # @return [Net::HTTPGenericRequest]
57
- def build_request(request, &)
57
+ def build_request(request, &blk)
58
58
  method, url, headers, body = request.fetch_values(:method, :url, :headers, :body)
59
59
  req = Net::HTTPGenericRequest.new(
60
60
  method.to_s.upcase,
@@ -70,13 +70,13 @@ module TerminalShop
70
70
  nil
71
71
  in String
72
72
  req["content-length"] ||= body.bytesize.to_s unless req["transfer-encoding"]
73
- req.body_stream = TerminalShop::Util::ReadIOAdapter.new(body, &)
73
+ req.body_stream = TerminalShop::Util::ReadIOAdapter.new(body, &blk)
74
74
  in StringIO
75
75
  req["content-length"] ||= body.size.to_s unless req["transfer-encoding"]
76
- req.body_stream = TerminalShop::Util::ReadIOAdapter.new(body, &)
76
+ req.body_stream = TerminalShop::Util::ReadIOAdapter.new(body, &blk)
77
77
  in IO | Enumerator
78
78
  req["transfer-encoding"] ||= "chunked" unless req["content-length"]
79
- req.body_stream = TerminalShop::Util::ReadIOAdapter.new(body, &)
79
+ req.body_stream = TerminalShop::Util::ReadIOAdapter.new(body, &blk)
80
80
  end
81
81
 
82
82
  req
@@ -31,7 +31,9 @@ module TerminalShop
31
31
  # @param other [Object]
32
32
  #
33
33
  # @return [Boolean]
34
- def ==(other) = other.is_a?(TerminalShop::ArrayOf) && other.nilable? == nilable? && other.item_type == item_type
34
+ def ==(other)
35
+ other.is_a?(TerminalShop::ArrayOf) && other.nilable? == nilable? && other.item_type == item_type
36
+ end
35
37
 
36
38
  # @api private
37
39
  #
@@ -101,7 +101,9 @@ module TerminalShop
101
101
  end
102
102
  rescue StandardError
103
103
  cls = self.class.name.split("::").last
104
+ # rubocop:disable Layout/LineLength
104
105
  message = "Failed to parse #{cls}.#{__method__} from #{value.class} to #{target.inspect}. To get the unparsed API response, use #{cls}[:#{__method__}]."
106
+ # rubocop:enable Layout/LineLength
105
107
  raise TerminalShop::ConversionError.new(message)
106
108
  end
107
109
  end
@@ -212,14 +214,13 @@ module TerminalShop
212
214
  instance = new
213
215
  data = instance.to_h
214
216
 
217
+ # rubocop:disable Metrics/BlockLength
215
218
  fields.each do |name, field|
216
219
  mode, required, target = field.fetch_values(:mode, :required, :type)
217
220
  api_name, nilable, const = field.fetch_values(:api_name, :nilable, :const)
218
221
 
219
222
  unless val.key?(api_name)
220
- if const != TerminalShop::Util::OMIT
221
- exactness[:yes] += 1
222
- elsif required && mode != :dump
223
+ if required && mode != :dump && const == TerminalShop::Util::OMIT
223
224
  exactness[nilable ? :maybe : :no] += 1
224
225
  else
225
226
  exactness[:yes] += 1
@@ -245,6 +246,7 @@ module TerminalShop
245
246
  end
246
247
  data.store(name, converted)
247
248
  end
249
+ # rubocop:enable Metrics/BlockLength
248
250
 
249
251
  keys.each { data.store(_1, val.fetch(_1)) }
250
252
  instance
@@ -36,7 +36,7 @@ module TerminalShop
36
36
  # @param blk [Proc]
37
37
  #
38
38
  # @return [void]
39
- def auto_paging_each(&) = (raise NotImplementedError)
39
+ def auto_paging_each(&blk) = (raise NotImplementedError)
40
40
 
41
41
  # @return [Enumerable]
42
42
  def to_enum = super(:auto_paging_each)
@@ -46,7 +46,9 @@ module TerminalShop
46
46
  # @param other [Object]
47
47
  #
48
48
  # @return [Boolean]
49
- def ==(other) = other.is_a?(TerminalShop::HashOf) && other.nilable? == nilable? && other.item_type == item_type
49
+ def ==(other)
50
+ other.is_a?(TerminalShop::HashOf) && other.nilable? == nilable? && other.item_type == item_type
51
+ end
50
52
 
51
53
  # @api private
52
54
  #
@@ -99,7 +99,9 @@ module TerminalShop
99
99
  #
100
100
  # @return [Boolean]
101
101
  def ==(other)
102
+ # rubocop:disable Layout/LineLength
102
103
  other.is_a?(Module) && other.singleton_class <= TerminalShop::Union && other.derefed_variants == derefed_variants
104
+ # rubocop:enable Layout/LineLength
103
105
  end
104
106
 
105
107
  # @api private
@@ -253,9 +253,9 @@ module TerminalShop
253
253
  path
254
254
  in []
255
255
  ""
256
- in [String, *interpolations]
256
+ in [String => p, *interpolations]
257
257
  encoded = interpolations.map { ERB::Util.url_encode(_1) }
258
- path.first % encoded
258
+ format(p, *encoded)
259
259
  end
260
260
  end
261
261
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TerminalShop
4
- VERSION = "2.1.0"
4
+ VERSION = "2.1.2"
5
5
  end
data/lib/terminal-shop.rb CHANGED
@@ -1,21 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # We already ship the preferred sorbet manifests in the package itself.
4
- # `tapioca` currently does not offer us a way to opt out of unnecessary compilation.
5
- if Object.const_defined?(:Tapioca) && caller.chain([$0]).chain(ARGV).grep(/tapioca/)
6
- Warning.warn(
7
- <<~WARN
8
- \n
9
- ⚠️ skipped loading of "terminal-shop" gem under `tapioca`.
10
-
11
- This message is normal and expected if you are running a `tapioca` command, and does not impact `.rbi` generation.
12
- \n
13
- WARN
14
- )
15
- return
16
- end
17
-
18
3
  # Standard libraries.
4
+ require "English"
19
5
  require "cgi"
20
6
  require "date"
21
7
  require "erb"
@@ -30,6 +16,21 @@ require "stringio"
30
16
  require "time"
31
17
  require "uri"
32
18
 
19
+ # We already ship the preferred sorbet manifests in the package itself.
20
+ # `tapioca` currently does not offer us a way to opt out of unnecessary compilation.
21
+ if Object.const_defined?(:Tapioca) && caller.chain([$PROGRAM_NAME]).chain(ARGV).grep(/tapioca/)
22
+ Warning.warn(
23
+ <<~WARN
24
+ \n
25
+ ⚠️ skipped loading of "terminal-shop" gem under `tapioca`.
26
+
27
+ This message is normal and expected if you are running a `tapioca` command, and does not impact `.rbi` generation.
28
+ \n
29
+ WARN
30
+ )
31
+ return
32
+ end
33
+
33
34
  # Gems.
34
35
  require "connection_pool"
35
36
 
data/manifest.yaml CHANGED
@@ -1,4 +1,5 @@
1
1
  dependencies:
2
+ - English
2
3
  - cgi
3
4
  - date
4
5
  - erb
@@ -12,7 +12,7 @@ module TerminalShop
12
12
 
13
13
  ENVIRONMENTS =
14
14
  T.let(
15
- {production: "https://api.terminal.shop/", dev: "https://api.dev.terminal.shop/"},
15
+ {production: "https://api.terminal.shop", dev: "https://api.dev.terminal.shop"},
16
16
  T::Hash[Symbol, String]
17
17
  )
18
18
 
@@ -79,8 +79,8 @@ module TerminalShop
79
79
  #
80
80
  # Each environment maps to a different base URL:
81
81
  #
82
- # - `production` corresponds to `https://api.terminal.shop/`
83
- # - `dev` corresponds to `https://api.dev.terminal.shop/`
82
+ # - `production` corresponds to `https://api.terminal.shop`
83
+ # - `dev` corresponds to `https://api.dev.terminal.shop`
84
84
  environment: nil,
85
85
  # Override the default base URL for the API, e.g., `"https://api.example.com/v2/"`
86
86
  base_url: nil,
@@ -1,5 +1,5 @@
1
1
  # typed: strong
2
2
 
3
3
  module TerminalShop
4
- VERSION = "2.1.0"
4
+ VERSION = "2.1.2"
5
5
  end
@@ -9,8 +9,8 @@ module TerminalShop
9
9
  DEFAULT_MAX_RETRY_DELAY: Float
10
10
 
11
11
  ENVIRONMENTS: {
12
- production: "https://api.terminal.shop/",
13
- dev: "https://api.dev.terminal.shop/"
12
+ production: "https://api.terminal.shop",
13
+ dev: "https://api.dev.terminal.shop"
14
14
  }
15
15
 
16
16
  attr_reader bearer_token: String
@@ -1,3 +1,3 @@
1
1
  module TerminalShop
2
- VERSION: "2.0.0"
2
+ VERSION: "2.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: terminal-shop
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Terminal
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-04-01 00:00:00.000000000 Z
11
+ date: 2025-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: connection_pool