orb-billing 0.1.0.pre.alpha.37 → 0.1.0.pre.alpha.38
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 +29 -5
- data/lib/orb/internal/page.rb +6 -2
- data/lib/orb/internal/transport/base_client.rb +2 -2
- data/lib/orb/internal/transport/pooled_net_requester.rb +1 -1
- data/lib/orb/internal/type/array_of.rb +5 -3
- data/lib/orb/internal/type/base_model.rb +12 -6
- data/lib/orb/internal/type/base_page.rb +4 -1
- data/lib/orb/internal/type/{boolean_model.rb → boolean.rb} +2 -2
- data/lib/orb/internal/type/converter.rb +6 -1
- data/lib/orb/internal/type/enum.rb +2 -0
- data/lib/orb/internal/type/hash_of.rb +3 -1
- data/lib/orb/internal/util.rb +28 -45
- data/lib/orb/models/alert.rb +1 -1
- data/lib/orb/models/coupon_list_params.rb +1 -1
- data/lib/orb/models/customer.rb +5 -5
- data/lib/orb/models/customer_create_params.rb +6 -6
- data/lib/orb/models/customer_update_by_external_id_params.rb +6 -6
- data/lib/orb/models/customer_update_params.rb +6 -6
- data/lib/orb/models/customers/credit_list_by_external_id_params.rb +1 -1
- data/lib/orb/models/customers/credit_list_params.rb +1 -1
- data/lib/orb/models/customers/credits/ledger_create_entry_by_external_id_params.rb +2 -2
- data/lib/orb/models/customers/credits/ledger_create_entry_params.rb +2 -2
- data/lib/orb/models/customers/credits/top_up_create_by_external_id_params.rb +2 -2
- data/lib/orb/models/customers/credits/top_up_create_by_external_id_response.rb +2 -2
- data/lib/orb/models/customers/credits/top_up_create_params.rb +2 -2
- data/lib/orb/models/customers/credits/top_up_create_response.rb +2 -2
- data/lib/orb/models/customers/credits/top_up_list_by_external_id_response.rb +2 -2
- data/lib/orb/models/customers/credits/top_up_list_response.rb +2 -2
- data/lib/orb/models/evaluate_price_group.rb +1 -1
- data/lib/orb/models/event_ingest_params.rb +1 -1
- data/lib/orb/models/event_search_response.rb +1 -1
- data/lib/orb/models/events/backfill_close_response.rb +1 -1
- data/lib/orb/models/events/backfill_create_params.rb +1 -1
- data/lib/orb/models/events/backfill_create_response.rb +1 -1
- data/lib/orb/models/events/backfill_fetch_response.rb +1 -1
- data/lib/orb/models/events/backfill_list_response.rb +1 -1
- data/lib/orb/models/events/backfill_revert_response.rb +1 -1
- data/lib/orb/models/invoice.rb +8 -8
- data/lib/orb/models/invoice_create_params.rb +1 -1
- data/lib/orb/models/invoice_fetch_upcoming_response.rb +8 -8
- data/lib/orb/models/invoice_issue_params.rb +1 -1
- data/lib/orb/models/invoice_line_item_create_response.rb +5 -5
- data/lib/orb/models/invoice_list_params.rb +1 -1
- data/lib/orb/models/pagination_metadata.rb +1 -1
- data/lib/orb/models/plan.rb +5 -5
- data/lib/orb/models/plan_create_params.rb +25 -25
- data/lib/orb/models/price.rb +28 -28
- data/lib/orb/models/price_create_params.rb +1 -1
- data/lib/orb/models/subscription.rb +6 -6
- data/lib/orb/models/subscription_cancel_params.rb +1 -1
- data/lib/orb/models/subscription_cancel_response.rb +6 -6
- data/lib/orb/models/subscription_create_params.rb +64 -64
- data/lib/orb/models/subscription_create_response.rb +6 -6
- data/lib/orb/models/subscription_price_intervals_params.rb +35 -35
- data/lib/orb/models/subscription_price_intervals_response.rb +6 -6
- data/lib/orb/models/subscription_schedule_plan_change_params.rb +64 -64
- data/lib/orb/models/subscription_schedule_plan_change_response.rb +6 -6
- data/lib/orb/models/subscription_trigger_phase_params.rb +1 -1
- data/lib/orb/models/subscription_trigger_phase_response.rb +6 -6
- data/lib/orb/models/subscription_unschedule_cancellation_response.rb +6 -6
- data/lib/orb/models/subscription_unschedule_fixed_fee_quantity_updates_response.rb +6 -6
- data/lib/orb/models/subscription_unschedule_pending_plan_changes_response.rb +6 -6
- data/lib/orb/models/subscription_update_fixed_fee_quantity_params.rb +1 -1
- data/lib/orb/models/subscription_update_fixed_fee_quantity_response.rb +6 -6
- data/lib/orb/models/subscription_update_params.rb +1 -1
- data/lib/orb/models/subscription_update_trial_params.rb +1 -1
- data/lib/orb/models/subscription_update_trial_response.rb +6 -6
- data/lib/orb/resources/alerts.rb +6 -1
- data/lib/orb/resources/credit_notes.rb +6 -1
- data/lib/orb/resources/customers/balance_transactions.rb +6 -1
- data/lib/orb/resources/customers/credits/ledger.rb +12 -2
- data/lib/orb/resources/customers.rb +6 -1
- data/lib/orb/resources/invoices.rb +10 -1
- data/lib/orb/resources/metrics.rb +6 -1
- data/lib/orb/resources/plans.rb +6 -1
- data/lib/orb/resources/subscriptions.rb +12 -2
- data/lib/orb/version.rb +1 -1
- data/lib/orb.rb +1 -1
- data/rbi/lib/orb/internal/type/array_of.rbi +2 -2
- data/rbi/lib/orb/internal/type/{boolean_model.rbi → boolean.rbi} +1 -1
- data/rbi/lib/orb/internal/util.rbi +7 -5
- data/rbi/lib/orb/version.rbi +1 -1
- data/sig/orb/internal/type/array_of.rbs +2 -2
- data/sig/orb/internal/type/{boolean_model.rbs → boolean.rbs} +1 -1
- data/sig/orb/internal/util.rbs +5 -5
- data/sig/orb/version.rbs +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 249d2973800ed2fb6c87fe4e0c7b22208082baef56fa69146ebd6b6eb464fd0f
|
4
|
+
data.tar.gz: e3db0fd166e2f0e698bc3487a9e69d6b0461bdab175a105624f43b4b230c150d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce5534719e3cfa2faa48435c2ec0b84910f1f1cfb4e5679c43ae6cbe4d218855479bac17e467d723799ccf1953197a7cfe9a89442f5b904bcb252a66490b9fb8
|
7
|
+
data.tar.gz: fed3c6b0e6311ab74defabad0b7fa99f6b464de6dce1af15f2212e7c4725211eba89aae5fd4747611ebab9b778a5c036a3b7b8a1d808fdf8609f6b2af28869fe
|
data/README.md
CHANGED
@@ -12,10 +12,14 @@ The underlying REST API documentation can be found on [docs.withorb.com](https:/
|
|
12
12
|
|
13
13
|
To use this gem, install via Bundler by adding the following to your application's `Gemfile`:
|
14
14
|
|
15
|
+
<!-- x-release-please-start-version -->
|
16
|
+
|
15
17
|
```ruby
|
16
|
-
gem "orb-billing", "~> 0.1.0.pre.alpha.
|
18
|
+
gem "orb-billing", "~> 0.1.0.pre.alpha.37"
|
17
19
|
```
|
18
20
|
|
21
|
+
<!-- x-release-please-end -->
|
22
|
+
|
19
23
|
To fetch an initial copy of the gem:
|
20
24
|
|
21
25
|
```sh
|
@@ -130,9 +134,23 @@ orb.customers.create(
|
|
130
134
|
|
131
135
|
## LSP Support
|
132
136
|
|
133
|
-
###
|
137
|
+
### Solargraph
|
138
|
+
|
139
|
+
This library includes [Solargraph](https://solargraph.org) support for both auto completion and go to definition.
|
140
|
+
|
141
|
+
```ruby
|
142
|
+
gem "solargraph", group: :development
|
143
|
+
```
|
144
|
+
|
145
|
+
After Solargraph is installed, **you must populate its index** either via the provided editor command, or by running the following in your terminal:
|
134
146
|
|
135
|
-
|
147
|
+
```sh
|
148
|
+
bundle exec solargraph gems
|
149
|
+
```
|
150
|
+
|
151
|
+
Otherwise Solargraph will not be able to provide type information or auto-completion for any non-indexed libraries.
|
152
|
+
|
153
|
+
### Sorbet
|
136
154
|
|
137
155
|
This library is written with [Sorbet type definitions](https://sorbet.org/docs/rbi). However, there is no runtime dependency on the `sorbet-runtime`.
|
138
156
|
|
@@ -143,11 +161,17 @@ Due to limitations with the Sorbet type system, where a method otherwise can tak
|
|
143
161
|
Please follow Sorbet's [setup guides](https://sorbet.org/docs/adopting) for best experience.
|
144
162
|
|
145
163
|
```ruby
|
146
|
-
|
164
|
+
params = Orb::Models::CustomerCreateParams.new(email: "example-customer@withorb.com", name: "My Customer")
|
147
165
|
|
148
|
-
orb.customers.create(**
|
166
|
+
orb.customers.create(**params)
|
149
167
|
```
|
150
168
|
|
169
|
+
Note: **This library emits an intentional warning under the [`tapioca` toolchain](https://github.com/Shopify/tapioca)**. This is normal, and does not impact functionality.
|
170
|
+
|
171
|
+
### Ruby LSP
|
172
|
+
|
173
|
+
The Ruby LSP has [best effort support](https://shopify.github.io/ruby-lsp/#guessed-types) for inferring type information from Ruby code, and as such it may not always be able to provide accurate type information.
|
174
|
+
|
151
175
|
## Advanced
|
152
176
|
|
153
177
|
### Making custom/undocumented requests
|
data/lib/orb/internal/page.rb
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
module Orb
|
4
4
|
module Internal
|
5
|
+
# @generic Elem
|
6
|
+
#
|
5
7
|
# @example
|
6
8
|
# if page.has_next?
|
7
9
|
# page = page.next_page
|
@@ -14,7 +16,7 @@ module Orb
|
|
14
16
|
class Page
|
15
17
|
include Orb::Internal::Type::BasePage
|
16
18
|
|
17
|
-
# @return [Array<
|
19
|
+
# @return [Array<generic<Elem>>, nil]
|
18
20
|
attr_accessor :data
|
19
21
|
|
20
22
|
# @return [PaginationMetadata]
|
@@ -65,6 +67,8 @@ module Orb
|
|
65
67
|
end
|
66
68
|
|
67
69
|
# @param blk [Proc]
|
70
|
+
#
|
71
|
+
# @yieldparam [generic<Elem>]
|
68
72
|
def auto_paging_each(&blk)
|
69
73
|
unless block_given?
|
70
74
|
raise ArgumentError.new("A block must be given to ##{__method__}")
|
@@ -88,7 +92,7 @@ module Orb
|
|
88
92
|
# @!attribute has_more
|
89
93
|
#
|
90
94
|
# @return [Boolean]
|
91
|
-
required :has_more, Orb::Internal::Type::
|
95
|
+
required :has_more, Orb::Internal::Type::Boolean
|
92
96
|
|
93
97
|
# @!attribute next_cursor
|
94
98
|
#
|
@@ -131,7 +131,7 @@ module Orb
|
|
131
131
|
# @api private
|
132
132
|
#
|
133
133
|
# @param status [Integer, Orb::Errors::APIConnectionError]
|
134
|
-
# @param stream [Enumerable
|
134
|
+
# @param stream [Enumerable<String>, nil]
|
135
135
|
def reap_connection!(status, stream:)
|
136
136
|
case status
|
137
137
|
in (..199) | (300..499)
|
@@ -328,7 +328,7 @@ module Orb
|
|
328
328
|
# @param send_retry_header [Boolean]
|
329
329
|
#
|
330
330
|
# @raise [Orb::Errors::APIError]
|
331
|
-
# @return [Array(Integer, Net::HTTPResponse, Enumerable)]
|
331
|
+
# @return [Array(Integer, Net::HTTPResponse, Enumerable<String>)]
|
332
332
|
private def send_request(request, redirect_count:, retry_count:, send_retry_header:)
|
333
333
|
url, headers, max_retries, timeout = request.fetch_values(:url, :headers, :max_retries, :timeout)
|
334
334
|
input = {**request.except(:timeout), deadline: Orb::Internal::Util.monotonic_secs + timeout}
|
@@ -119,7 +119,7 @@ module Orb
|
|
119
119
|
#
|
120
120
|
# @option request [Float] :deadline
|
121
121
|
#
|
122
|
-
# @return [Array(Integer, Net::HTTPResponse, Enumerable)]
|
122
|
+
# @return [Array(Integer, Net::HTTPResponse, Enumerable<String>)]
|
123
123
|
def execute(request)
|
124
124
|
url, deadline = request.fetch_values(:url, :deadline)
|
125
125
|
|
@@ -7,6 +7,8 @@ module Orb
|
|
7
7
|
#
|
8
8
|
# @abstract
|
9
9
|
#
|
10
|
+
# @generic Elem
|
11
|
+
#
|
10
12
|
# Array of items of a given type.
|
11
13
|
class ArrayOf
|
12
14
|
include Orb::Internal::Type::Converter
|
@@ -40,7 +42,7 @@ module Orb
|
|
40
42
|
|
41
43
|
# @api private
|
42
44
|
#
|
43
|
-
# @param value [
|
45
|
+
# @param value [Array<Object>, Object]
|
44
46
|
#
|
45
47
|
# @param state [Hash{Symbol=>Object}] .
|
46
48
|
#
|
@@ -75,7 +77,7 @@ module Orb
|
|
75
77
|
|
76
78
|
# @api private
|
77
79
|
#
|
78
|
-
# @param value [
|
80
|
+
# @param value [Array<Object>, Object]
|
79
81
|
#
|
80
82
|
# @return [Array<Object>, Object]
|
81
83
|
def dump(value)
|
@@ -85,7 +87,7 @@ module Orb
|
|
85
87
|
|
86
88
|
# @api private
|
87
89
|
#
|
88
|
-
# @return [
|
90
|
+
# @return [generic<Elem>]
|
89
91
|
protected def item_type = @item_type_fn.call
|
90
92
|
|
91
93
|
# @api private
|
@@ -168,7 +168,9 @@ module Orb
|
|
168
168
|
# @param other [Object]
|
169
169
|
#
|
170
170
|
# @return [Boolean]
|
171
|
-
def ==(other)
|
171
|
+
def ==(other)
|
172
|
+
other.is_a?(Class) && other <= Orb::Internal::Type::BaseModel && other.fields == fields
|
173
|
+
end
|
172
174
|
end
|
173
175
|
|
174
176
|
# @param other [Object]
|
@@ -256,6 +258,7 @@ module Orb
|
|
256
258
|
return super
|
257
259
|
end
|
258
260
|
|
261
|
+
is_param = singleton_class <= Orb::Internal::Type::RequestParameters::Converter
|
259
262
|
acc = {}
|
260
263
|
|
261
264
|
coerced.each do |key, val|
|
@@ -264,19 +267,21 @@ module Orb
|
|
264
267
|
in nil
|
265
268
|
acc.store(name, super(val))
|
266
269
|
else
|
267
|
-
mode,
|
270
|
+
mode, type_fn = field.fetch_values(:mode, :type_fn)
|
268
271
|
case mode
|
269
272
|
in :coerce
|
270
273
|
next
|
271
274
|
else
|
272
275
|
target = type_fn.call
|
276
|
+
api_name = is_param ? name : field.fetch(:api_name)
|
273
277
|
acc.store(api_name, Orb::Internal::Type::Converter.dump(target, val))
|
274
278
|
end
|
275
279
|
end
|
276
280
|
end
|
277
281
|
|
278
|
-
known_fields.
|
279
|
-
mode,
|
282
|
+
known_fields.each do |name, field|
|
283
|
+
mode, const = field.fetch_values(:mode, :const)
|
284
|
+
api_name = is_param ? name : field.fetch(:api_name)
|
280
285
|
next if mode == :coerce || acc.key?(api_name) || const == Orb::Internal::OMIT
|
281
286
|
acc.store(api_name, const)
|
282
287
|
end
|
@@ -350,7 +355,8 @@ module Orb
|
|
350
355
|
in Hash => coerced
|
351
356
|
@data = coerced
|
352
357
|
else
|
353
|
-
|
358
|
+
message = "Expected a #{Hash} or #{Orb::Internal::Type::BaseModel}, got #{data.inspect}"
|
359
|
+
raise ArgumentError.new(message)
|
354
360
|
end
|
355
361
|
end
|
356
362
|
|
@@ -358,7 +364,7 @@ module Orb
|
|
358
364
|
def inspect
|
359
365
|
rows = self.class.known_fields.keys.map do
|
360
366
|
"#{_1}=#{@data.key?(_1) ? public_send(_1) : ''}"
|
361
|
-
rescue Orb::ConversionError
|
367
|
+
rescue Orb::Errors::ConversionError
|
362
368
|
"#{_1}=#{@data.fetch(_1)}"
|
363
369
|
end
|
364
370
|
"#<#{self.class.name}:0x#{object_id.to_s(16)} #{rows.join(' ')}>"
|
@@ -3,6 +3,8 @@
|
|
3
3
|
module Orb
|
4
4
|
module Internal
|
5
5
|
module Type
|
6
|
+
# @generic Elem
|
7
|
+
#
|
6
8
|
# This module provides a base implementation for paginated responses in the SDK.
|
7
9
|
module BasePage
|
8
10
|
# rubocop:disable Lint/UnusedMethodArgument
|
@@ -16,10 +18,11 @@ module Orb
|
|
16
18
|
|
17
19
|
# @param blk [Proc]
|
18
20
|
#
|
21
|
+
# @yieldparam [generic<Elem>]
|
19
22
|
# @return [void]
|
20
23
|
def auto_paging_each(&blk) = (raise NotImplementedError)
|
21
24
|
|
22
|
-
# @return [Enumerable]
|
25
|
+
# @return [Enumerable<generic<Elem>>]
|
23
26
|
def to_enum = super(:auto_paging_each)
|
24
27
|
|
25
28
|
alias_method :enum_for, :to_enum
|
@@ -8,7 +8,7 @@ module Orb
|
|
8
8
|
# @abstract
|
9
9
|
#
|
10
10
|
# Ruby has no Boolean class; this is something for models to refer to.
|
11
|
-
class
|
11
|
+
class Boolean
|
12
12
|
extend Orb::Internal::Type::Converter
|
13
13
|
|
14
14
|
# @param other [Object]
|
@@ -19,7 +19,7 @@ module Orb
|
|
19
19
|
# @param other [Object]
|
20
20
|
#
|
21
21
|
# @return [Boolean]
|
22
|
-
def self.==(other) = other.is_a?(Class) && other <= Orb::Internal::Type::
|
22
|
+
def self.==(other) = other.is_a?(Class) && other <= Orb::Internal::Type::Boolean
|
23
23
|
|
24
24
|
class << self
|
25
25
|
# @api private
|
@@ -64,7 +64,7 @@ module Orb
|
|
64
64
|
in Hash
|
65
65
|
type_info(spec.slice(:const, :enum, :union).first&.last)
|
66
66
|
in true | false
|
67
|
-
-> { Orb::Internal::Type::
|
67
|
+
-> { Orb::Internal::Type::Boolean }
|
68
68
|
in Orb::Internal::Type::Converter | Class | Symbol
|
69
69
|
-> { spec }
|
70
70
|
in NilClass | Integer | Float
|
@@ -168,6 +168,9 @@ module Orb
|
|
168
168
|
in String | Symbol | Numeric
|
169
169
|
exactness[value.is_a?(Numeric) ? :maybe : :yes] += 1
|
170
170
|
return value.to_s
|
171
|
+
in StringIO
|
172
|
+
exactness[:yes] += 1
|
173
|
+
return value.string
|
171
174
|
else
|
172
175
|
if strictness == :strong
|
173
176
|
message = "no implicit conversion of #{value.class} into #{target.inspect}"
|
@@ -209,7 +212,9 @@ module Orb
|
|
209
212
|
#
|
210
213
|
# @return [Object]
|
211
214
|
def dump(target, value)
|
215
|
+
# rubocop:disable Layout/LineLength
|
212
216
|
target.is_a?(Orb::Internal::Type::Converter) ? target.dump(value) : Orb::Internal::Type::Unknown.dump(value)
|
217
|
+
# rubocop:enable Layout/LineLength
|
213
218
|
end
|
214
219
|
end
|
215
220
|
end
|
@@ -58,7 +58,9 @@ module Orb
|
|
58
58
|
#
|
59
59
|
# @return [Boolean]
|
60
60
|
def ==(other)
|
61
|
+
# rubocop:disable Layout/LineLength
|
61
62
|
other.is_a?(Module) && other.singleton_class <= Orb::Internal::Type::Enum && other.values.to_set == values.to_set
|
63
|
+
# rubocop:enable Layout/LineLength
|
62
64
|
end
|
63
65
|
|
64
66
|
# @api private
|
@@ -7,6 +7,8 @@ module Orb
|
|
7
7
|
#
|
8
8
|
# @abstract
|
9
9
|
#
|
10
|
+
# @generic Elem
|
11
|
+
#
|
10
12
|
# Hash of items of a given type.
|
11
13
|
class HashOf
|
12
14
|
include Orb::Internal::Type::Converter
|
@@ -111,7 +113,7 @@ module Orb
|
|
111
113
|
|
112
114
|
# @api private
|
113
115
|
#
|
114
|
-
# @return [
|
116
|
+
# @return [generic<Elem>]
|
115
117
|
protected def item_type = @item_type_fn.call
|
116
118
|
|
117
119
|
# @api private
|
data/lib/orb/internal/util.rb
CHANGED
@@ -61,7 +61,7 @@ module Orb
|
|
61
61
|
# @return [Boolean]
|
62
62
|
def primitive?(input)
|
63
63
|
case input
|
64
|
-
in true | false |
|
64
|
+
in true | false | Numeric | Symbol | String
|
65
65
|
true
|
66
66
|
else
|
67
67
|
false
|
@@ -70,13 +70,11 @@ module Orb
|
|
70
70
|
|
71
71
|
# @api private
|
72
72
|
#
|
73
|
-
# @param input [
|
73
|
+
# @param input [String, Boolean]
|
74
74
|
#
|
75
75
|
# @return [Boolean, Object]
|
76
76
|
def coerce_boolean(input)
|
77
77
|
case input.is_a?(String) ? input.downcase : input
|
78
|
-
in Numeric
|
79
|
-
input.nonzero?
|
80
78
|
in "true"
|
81
79
|
true
|
82
80
|
in "false"
|
@@ -88,7 +86,7 @@ module Orb
|
|
88
86
|
|
89
87
|
# @api private
|
90
88
|
#
|
91
|
-
# @param input [
|
89
|
+
# @param input [String, Boolean]
|
92
90
|
#
|
93
91
|
# @raise [ArgumentError]
|
94
92
|
# @return [Boolean, nil]
|
@@ -103,34 +101,20 @@ module Orb
|
|
103
101
|
|
104
102
|
# @api private
|
105
103
|
#
|
106
|
-
# @param input [
|
104
|
+
# @param input [String, Integer]
|
107
105
|
#
|
108
106
|
# @return [Integer, Object]
|
109
107
|
def coerce_integer(input)
|
110
|
-
|
111
|
-
in true
|
112
|
-
1
|
113
|
-
in false
|
114
|
-
0
|
115
|
-
else
|
116
|
-
Integer(input, exception: false) || input
|
117
|
-
end
|
108
|
+
Integer(input, exception: false) || input
|
118
109
|
end
|
119
110
|
|
120
111
|
# @api private
|
121
112
|
#
|
122
|
-
# @param input [
|
113
|
+
# @param input [String, Integer, Float]
|
123
114
|
#
|
124
115
|
# @return [Float, Object]
|
125
116
|
def coerce_float(input)
|
126
|
-
|
127
|
-
in true
|
128
|
-
1.0
|
129
|
-
in false
|
130
|
-
0.0
|
131
|
-
else
|
132
|
-
Float(input, exception: false) || input
|
133
|
-
end
|
117
|
+
Float(input, exception: false) || input
|
134
118
|
end
|
135
119
|
|
136
120
|
# @api private
|
@@ -159,12 +143,7 @@ module Orb
|
|
159
143
|
private def deep_merge_lr(lhs, rhs, concat: false)
|
160
144
|
case [lhs, rhs, concat]
|
161
145
|
in [Hash, Hash, _]
|
162
|
-
|
163
|
-
lhs
|
164
|
-
.reject { |key, _| rhs[key] == Orb::Internal::OMIT }
|
165
|
-
.merge(rhs_cleaned) do |_, old_val, new_val|
|
166
|
-
deep_merge_lr(old_val, new_val, concat: concat)
|
167
|
-
end
|
146
|
+
lhs.merge(rhs) { deep_merge_lr(_2, _3, concat: concat) }
|
168
147
|
in [Array, Array, true]
|
169
148
|
lhs.concat(rhs)
|
170
149
|
else
|
@@ -362,7 +341,7 @@ module Orb
|
|
362
341
|
value =
|
363
342
|
case val
|
364
343
|
in Array
|
365
|
-
val.
|
344
|
+
val.filter_map { _1&.to_s&.strip }.join(", ")
|
366
345
|
else
|
367
346
|
val&.to_s&.strip
|
368
347
|
end
|
@@ -419,7 +398,7 @@ module Orb
|
|
419
398
|
|
420
399
|
# @api private
|
421
400
|
#
|
422
|
-
# @param stream [String, IO, StringIO, Enumerable]
|
401
|
+
# @param stream [String, IO, StringIO, Enumerable<String>]
|
423
402
|
# @param blk [Proc]
|
424
403
|
#
|
425
404
|
# @yieldparam [String]
|
@@ -434,7 +413,7 @@ module Orb
|
|
434
413
|
# @param blk [Proc]
|
435
414
|
#
|
436
415
|
# @yieldparam [Enumerator::Yielder]
|
437
|
-
# @return [Enumerable]
|
416
|
+
# @return [Enumerable<String>]
|
438
417
|
def writable_enum(&blk)
|
439
418
|
Enumerator.new do |y|
|
440
419
|
y.define_singleton_method(:write) do
|
@@ -469,7 +448,7 @@ module Orb
|
|
469
448
|
case val
|
470
449
|
in IO
|
471
450
|
y << "Content-Type: application/octet-stream\r\n\r\n"
|
472
|
-
IO.copy_stream(val, y)
|
451
|
+
IO.copy_stream(val.tap(&:rewind), y)
|
473
452
|
in StringIO
|
474
453
|
y << "Content-Type: application/octet-stream\r\n\r\n"
|
475
454
|
y << val.string
|
@@ -490,7 +469,7 @@ module Orb
|
|
490
469
|
#
|
491
470
|
# @param body [Object]
|
492
471
|
#
|
493
|
-
# @return [Array(String, Enumerable)]
|
472
|
+
# @return [Array(String, Enumerable<String>)]
|
494
473
|
private def encode_multipart_streaming(body)
|
495
474
|
boundary = SecureRandom.urlsafe_base64(60)
|
496
475
|
|
@@ -525,7 +504,7 @@ module Orb
|
|
525
504
|
def encode_content(headers, body)
|
526
505
|
content_type = headers["content-type"]
|
527
506
|
case [content_type, body]
|
528
|
-
in [%r{^application/(?:vnd\.api\+)?json},
|
507
|
+
in [%r{^application/(?:vnd\.api\+)?json}, _] unless body.nil?
|
529
508
|
[headers, JSON.fast_generate(body)]
|
530
509
|
in [%r{^application/(?:x-)?jsonl}, Enumerable]
|
531
510
|
[headers, body.lazy.map { JSON.fast_generate(_1) }]
|
@@ -533,8 +512,12 @@ module Orb
|
|
533
512
|
boundary, strio = encode_multipart_streaming(body)
|
534
513
|
headers = {**headers, "content-type" => "#{content_type}; boundary=#{boundary}"}
|
535
514
|
[headers, strio]
|
515
|
+
in [_, IO]
|
516
|
+
[headers, body.tap(&:rewind)]
|
536
517
|
in [_, StringIO]
|
537
518
|
[headers, body.string]
|
519
|
+
in [_, Symbol | Numeric]
|
520
|
+
[headers, body.to_s]
|
538
521
|
else
|
539
522
|
[headers, body]
|
540
523
|
end
|
@@ -543,7 +526,7 @@ module Orb
|
|
543
526
|
# @api private
|
544
527
|
#
|
545
528
|
# @param headers [Hash{String=>String}, Net::HTTPHeader]
|
546
|
-
# @param stream [Enumerable]
|
529
|
+
# @param stream [Enumerable<String>]
|
547
530
|
# @param suppress_error [Boolean]
|
548
531
|
#
|
549
532
|
# @raise [JSON::ParserError]
|
@@ -580,11 +563,11 @@ module Orb
|
|
580
563
|
#
|
581
564
|
# https://doc.rust-lang.org/std/iter/trait.FusedIterator.html
|
582
565
|
#
|
583
|
-
# @param enum [Enumerable]
|
566
|
+
# @param enum [Enumerable<Object>]
|
584
567
|
# @param external [Boolean]
|
585
568
|
# @param close [Proc]
|
586
569
|
#
|
587
|
-
# @return [Enumerable]
|
570
|
+
# @return [Enumerable<Object>]
|
588
571
|
def fused_enum(enum, external: false, &close)
|
589
572
|
fused = false
|
590
573
|
iter = Enumerator.new do |y|
|
@@ -610,7 +593,7 @@ module Orb
|
|
610
593
|
|
611
594
|
# @api private
|
612
595
|
#
|
613
|
-
# @param enum [Enumerable
|
596
|
+
# @param enum [Enumerable<Object>, nil]
|
614
597
|
def close_fused!(enum)
|
615
598
|
return unless enum.is_a?(Enumerator)
|
616
599
|
|
@@ -621,11 +604,11 @@ module Orb
|
|
621
604
|
|
622
605
|
# @api private
|
623
606
|
#
|
624
|
-
# @param enum [Enumerable
|
607
|
+
# @param enum [Enumerable<Object>, nil]
|
625
608
|
# @param blk [Proc]
|
626
609
|
#
|
627
610
|
# @yieldparam [Enumerator::Yielder]
|
628
|
-
# @return [Enumerable]
|
611
|
+
# @return [Enumerable<Object>]
|
629
612
|
def chain_fused(enum, &blk)
|
630
613
|
iter = Enumerator.new { blk.call(_1) }
|
631
614
|
fused_enum(iter) { close_fused!(enum) }
|
@@ -635,9 +618,9 @@ module Orb
|
|
635
618
|
class << self
|
636
619
|
# @api private
|
637
620
|
#
|
638
|
-
# @param enum [Enumerable]
|
621
|
+
# @param enum [Enumerable<String>]
|
639
622
|
#
|
640
|
-
# @return [Enumerable]
|
623
|
+
# @return [Enumerable<String>]
|
641
624
|
def decode_lines(enum)
|
642
625
|
re = /(\r\n|\r|\n)/
|
643
626
|
buffer = String.new.b
|
@@ -671,9 +654,9 @@ module Orb
|
|
671
654
|
#
|
672
655
|
# https://html.spec.whatwg.org/multipage/server-sent-events.html#parsing-an-event-stream
|
673
656
|
#
|
674
|
-
# @param lines [Enumerable]
|
657
|
+
# @param lines [Enumerable<String>]
|
675
658
|
#
|
676
|
-
# @return [Hash{Symbol=>Object}]
|
659
|
+
# @return [Enumerable<Hash{Symbol=>Object}>]
|
677
660
|
def decode_sse(lines)
|
678
661
|
# rubocop:disable Metrics/BlockLength
|
679
662
|
chain_fused(lines) do |y|
|
data/lib/orb/models/alert.rb
CHANGED
data/lib/orb/models/customer.rb
CHANGED
@@ -17,7 +17,7 @@ module Orb
|
|
17
17
|
# @!attribute auto_collection
|
18
18
|
#
|
19
19
|
# @return [Boolean]
|
20
|
-
required :auto_collection, Orb::Internal::Type::
|
20
|
+
required :auto_collection, Orb::Internal::Type::Boolean
|
21
21
|
|
22
22
|
# @!attribute balance
|
23
23
|
# The customer's current balance in their currency.
|
@@ -51,12 +51,12 @@ module Orb
|
|
51
51
|
# @!attribute email_delivery
|
52
52
|
#
|
53
53
|
# @return [Boolean]
|
54
|
-
required :email_delivery, Orb::Internal::Type::
|
54
|
+
required :email_delivery, Orb::Internal::Type::Boolean
|
55
55
|
|
56
56
|
# @!attribute exempt_from_automated_tax
|
57
57
|
#
|
58
58
|
# @return [Boolean, nil]
|
59
|
-
required :exempt_from_automated_tax, Orb::Internal::Type::
|
59
|
+
required :exempt_from_automated_tax, Orb::Internal::Type::Boolean, nil?: true
|
60
60
|
|
61
61
|
# @!attribute external_customer_id
|
62
62
|
# An optional user-defined ID for this customer resource, used throughout the
|
@@ -807,7 +807,7 @@ module Orb
|
|
807
807
|
# @!attribute excluded
|
808
808
|
#
|
809
809
|
# @return [Boolean]
|
810
|
-
required :excluded, Orb::Internal::Type::
|
810
|
+
required :excluded, Orb::Internal::Type::Boolean
|
811
811
|
|
812
812
|
# @!parse
|
813
813
|
# # @param accounting_providers [Array<Orb::Models::Customer::AccountingSyncConfiguration::AccountingProvider>]
|
@@ -858,7 +858,7 @@ module Orb
|
|
858
858
|
# @!attribute exempt
|
859
859
|
#
|
860
860
|
# @return [Boolean]
|
861
|
-
required :exempt, Orb::Internal::Type::
|
861
|
+
required :exempt, Orb::Internal::Type::Boolean
|
862
862
|
|
863
863
|
# @!parse
|
864
864
|
# # @param exempt [Boolean]
|
@@ -42,7 +42,7 @@ module Orb
|
|
42
42
|
# when a payment provider is provided on customer creation.
|
43
43
|
#
|
44
44
|
# @return [Boolean, nil]
|
45
|
-
optional :auto_collection, Orb::Internal::Type::
|
45
|
+
optional :auto_collection, Orb::Internal::Type::Boolean, nil?: true
|
46
46
|
|
47
47
|
# @!attribute billing_address
|
48
48
|
#
|
@@ -59,7 +59,7 @@ module Orb
|
|
59
59
|
# @!attribute email_delivery
|
60
60
|
#
|
61
61
|
# @return [Boolean, nil]
|
62
|
-
optional :email_delivery, Orb::Internal::Type::
|
62
|
+
optional :email_delivery, Orb::Internal::Type::Boolean, nil?: true
|
63
63
|
|
64
64
|
# @!attribute external_customer_id
|
65
65
|
# An optional user-defined ID for this customer resource, used throughout the
|
@@ -292,7 +292,7 @@ module Orb
|
|
292
292
|
# @!attribute excluded
|
293
293
|
#
|
294
294
|
# @return [Boolean, nil]
|
295
|
-
optional :excluded, Orb::Internal::Type::
|
295
|
+
optional :excluded, Orb::Internal::Type::Boolean, nil?: true
|
296
296
|
|
297
297
|
# @!parse
|
298
298
|
# # @param accounting_providers [Array<Orb::Models::CustomerCreateParams::AccountingSyncConfiguration::AccountingProvider>, nil]
|
@@ -420,7 +420,7 @@ module Orb
|
|
420
420
|
# @!attribute exempt
|
421
421
|
#
|
422
422
|
# @return [Boolean]
|
423
|
-
required :exempt, Orb::Internal::Type::
|
423
|
+
required :exempt, Orb::Internal::Type::Boolean
|
424
424
|
|
425
425
|
# @!parse
|
426
426
|
# # @param exempt [Boolean]
|
@@ -487,7 +487,7 @@ module Orb
|
|
487
487
|
# @!attribute tax_exempt
|
488
488
|
#
|
489
489
|
# @return [Boolean]
|
490
|
-
required :tax_exempt, Orb::Internal::Type::
|
490
|
+
required :tax_exempt, Orb::Internal::Type::Boolean
|
491
491
|
|
492
492
|
# @!attribute tax_provider
|
493
493
|
#
|
@@ -513,7 +513,7 @@ module Orb
|
|
513
513
|
# @!attribute tax_exempt
|
514
514
|
#
|
515
515
|
# @return [Boolean]
|
516
|
-
required :tax_exempt, Orb::Internal::Type::
|
516
|
+
required :tax_exempt, Orb::Internal::Type::Boolean
|
517
517
|
|
518
518
|
# @!attribute tax_provider
|
519
519
|
#
|