Skip to content

Commit e6134d2

Browse files
chore: move examples into tests (#108)
1 parent c5992c6 commit e6134d2

File tree

85 files changed

+5211
-12491
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+5211
-12491
lines changed

lib/orb/base_model.rb

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,31 @@ def self.try_strict_coerce(value)
294294
#
295295
# We can therefore convert string values to Symbols, but can't convert other
296296
# values safely.
297+
#
298+
# @example
299+
# ```ruby
300+
# # `billing_cycle_relative_date` is a `Orb::Models::BillingCycleRelativeDate`
301+
# case billing_cycle_relative_date
302+
# when Orb::Models::BillingCycleRelativeDate::START_OF_TERM
303+
# # ...
304+
# when Orb::Models::BillingCycleRelativeDate::END_OF_TERM
305+
# # ...
306+
# else
307+
# # ...
308+
# end
309+
# ```
310+
#
311+
# @example
312+
# ```ruby
313+
# case billing_cycle_relative_date
314+
# in :start_of_term
315+
# # ...
316+
# in :end_of_term
317+
# # ...
318+
# else
319+
# # ...
320+
# end
321+
# ```
297322
class Enum
298323
extend Orb::Converter
299324

@@ -369,6 +394,56 @@ def self.try_strict_coerce(value)
369394
#
370395
# @abstract
371396
#
397+
# @example
398+
# ```ruby
399+
# # `discount` is a `Orb::Models::Discount`
400+
# case discount
401+
# when Orb::Models::PercentageDiscount
402+
# # ...
403+
# when Orb::Models::TrialDiscount
404+
# # ...
405+
# when Orb::Models::UsageDiscount
406+
# # ...
407+
# else
408+
# # ...
409+
# end
410+
# ```
411+
#
412+
# @example
413+
# ```ruby
414+
# case discount
415+
# in {
416+
# discount_type: :percentage,
417+
# applies_to_price_ids: applies_to_price_ids,
418+
# percentage_discount: percentage_discount,
419+
# reason: reason
420+
# }
421+
# # ...
422+
# in {
423+
# discount_type: :trial,
424+
# applies_to_price_ids: applies_to_price_ids,
425+
# reason: reason,
426+
# trial_amount_discount: trial_amount_discount
427+
# }
428+
# # ...
429+
# in {
430+
# discount_type: :usage,
431+
# applies_to_price_ids: applies_to_price_ids,
432+
# usage_discount: usage_discount,
433+
# reason: reason
434+
# }
435+
# # ...
436+
# in {
437+
# discount_type: :amount,
438+
# amount_discount: amount_discount,
439+
# applies_to_price_ids: applies_to_price_ids,
440+
# reason: reason
441+
# }
442+
# # ...
443+
# else
444+
# # ...
445+
# end
446+
# ```
372447
class Union
373448
extend Orb::Converter
374449

@@ -839,6 +914,15 @@ def initialize(type_info, spec = {})
839914
#
840915
# @abstract
841916
#
917+
# @example
918+
# ```ruby
919+
# # `amount_discount` is a `Orb::Models::AmountDiscount`
920+
# amount_discount => {
921+
# amount_discount: amount_discount,
922+
# applies_to_price_ids: applies_to_price_ids,
923+
# discount_type: discount_type
924+
# }
925+
# ```
842926
class BaseModel
843927
extend Orb::Converter
844928

lib/orb/models/alert.rb

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -200,22 +200,6 @@ class Threshold < Orb::BaseModel
200200
# @abstract
201201
#
202202
# The type of alert. This must be a valid alert type.
203-
#
204-
# @example
205-
# ```ruby
206-
# case type
207-
# in :usage_exceeded
208-
# # ...
209-
# in :cost_exceeded
210-
# # ...
211-
# in :credit_balance_depleted
212-
# # ...
213-
# in :credit_balance_dropped
214-
# # ...
215-
# in :credit_balance_recovered
216-
# # ...
217-
# end
218-
# ```
219203
class Type < Orb::Enum
220204
USAGE_EXCEEDED = :usage_exceeded
221205
COST_EXCEEDED = :cost_exceeded

lib/orb/models/alert_create_for_customer_params.rb

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,6 @@ class AlertCreateForCustomerParams < Orb::BaseModel
4040
# @abstract
4141
#
4242
# The type of alert to create. This must be a valid alert type.
43-
#
44-
# @example
45-
# ```ruby
46-
# case type
47-
# in :usage_exceeded
48-
# # ...
49-
# in :cost_exceeded
50-
# # ...
51-
# in :credit_balance_depleted
52-
# # ...
53-
# in :credit_balance_dropped
54-
# # ...
55-
# in :credit_balance_recovered
56-
# # ...
57-
# end
58-
# ```
5943
class Type < Orb::Enum
6044
USAGE_EXCEEDED = :usage_exceeded
6145
COST_EXCEEDED = :cost_exceeded

lib/orb/models/alert_create_for_external_customer_params.rb

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,6 @@ class AlertCreateForExternalCustomerParams < Orb::BaseModel
4040
# @abstract
4141
#
4242
# The type of alert to create. This must be a valid alert type.
43-
#
44-
# @example
45-
# ```ruby
46-
# case type
47-
# in :usage_exceeded
48-
# # ...
49-
# in :cost_exceeded
50-
# # ...
51-
# in :credit_balance_depleted
52-
# # ...
53-
# in :credit_balance_dropped
54-
# # ...
55-
# in :credit_balance_recovered
56-
# # ...
57-
# end
58-
# ```
5943
class Type < Orb::Enum
6044
USAGE_EXCEEDED = :usage_exceeded
6145
COST_EXCEEDED = :cost_exceeded

lib/orb/models/alert_create_for_subscription_params.rb

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -58,22 +58,6 @@ class Threshold < Orb::BaseModel
5858
# @abstract
5959
#
6060
# The type of alert to create. This must be a valid alert type.
61-
#
62-
# @example
63-
# ```ruby
64-
# case type
65-
# in :usage_exceeded
66-
# # ...
67-
# in :cost_exceeded
68-
# # ...
69-
# in :credit_balance_depleted
70-
# # ...
71-
# in :credit_balance_dropped
72-
# # ...
73-
# in :credit_balance_recovered
74-
# # ...
75-
# end
76-
# ```
7761
class Type < Orb::Enum
7862
USAGE_EXCEEDED = :usage_exceeded
7963
COST_EXCEEDED = :cost_exceeded

lib/orb/models/amount_discount.rb

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,6 @@ class AmountDiscount < Orb::BaseModel
3838

3939
# @abstract
4040
#
41-
# @example
42-
# ```ruby
43-
# case discount_type
44-
# in :amount
45-
# # ...
46-
# end
47-
# ```
4841
class DiscountType < Orb::Enum
4942
AMOUNT = :amount
5043

lib/orb/models/billable_metric.rb

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,6 @@ class BillableMetric < Orb::BaseModel
5858

5959
# @abstract
6060
#
61-
# @example
62-
# ```ruby
63-
# case status
64-
# in :active
65-
# # ...
66-
# in :draft
67-
# # ...
68-
# in :archived
69-
# # ...
70-
# end
71-
# ```
7261
class Status < Orb::Enum
7362
ACTIVE = :active
7463
DRAFT = :draft

lib/orb/models/billing_cycle_relative_date.rb

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,6 @@ module Orb
44
module Models
55
# @abstract
66
#
7-
# @example
8-
# ```ruby
9-
# case billing_cycle_relative_date
10-
# in :start_of_term
11-
# # ...
12-
# in :end_of_term
13-
# # ...
14-
# end
15-
# ```
167
class BillingCycleRelativeDate < Orb::Enum
178
START_OF_TERM = :start_of_term
189
END_OF_TERM = :end_of_term

lib/orb/models/coupon.rb

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -68,30 +68,6 @@ class Coupon < Orb::BaseModel
6868

6969
# @abstract
7070
#
71-
# @example
72-
# ```ruby
73-
# case discount
74-
# in {
75-
# discount_type: "percentage",
76-
# applies_to_price_ids: ^(Orb::ArrayOf[String]),
77-
# percentage_discount: Float,
78-
# reason: String
79-
# }
80-
# # Orb::Models::PercentageDiscount ...
81-
# in {discount_type: "amount", amount_discount: String, applies_to_price_ids: ^(Orb::ArrayOf[String]), reason: String}
82-
# # Orb::Models::AmountDiscount ...
83-
# end
84-
# ```
85-
#
86-
# @example
87-
# ```ruby
88-
# case discount
89-
# in Orb::Models::PercentageDiscount
90-
# # ...
91-
# in Orb::Models::AmountDiscount
92-
# # ...
93-
# end
94-
# ```
9571
class Discount < Orb::Union
9672
discriminator :discount_type
9773

lib/orb/models/coupon_create_params.rb

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -45,25 +45,6 @@ class CouponCreateParams < Orb::BaseModel
4545

4646
# @abstract
4747
#
48-
# @example
49-
# ```ruby
50-
# case discount
51-
# in {discount_type: "percentage", percentage_discount: Float}
52-
# # Orb::Models::CouponCreateParams::Discount::NewCouponPercentageDiscount ...
53-
# in {discount_type: "amount", amount_discount: String}
54-
# # Orb::Models::CouponCreateParams::Discount::NewCouponAmountDiscount ...
55-
# end
56-
# ```
57-
#
58-
# @example
59-
# ```ruby
60-
# case discount
61-
# in Orb::Models::CouponCreateParams::Discount::NewCouponPercentageDiscount
62-
# # ...
63-
# in Orb::Models::CouponCreateParams::Discount::NewCouponAmountDiscount
64-
# # ...
65-
# end
66-
# ```
6748
class Discount < Orb::Union
6849
discriminator :discount_type
6950

0 commit comments

Comments
 (0)