schematichq 1.5.4 → 1.5.5
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/.fern/metadata.json +4 -4
- data/.fern/replay.lock +7 -1
- data/WASM_VERSION +1 -1
- data/lib/schematic/billing/client.rb +423 -0
- data/lib/schematic/billing/types/count_native_invoices_params.rb +20 -0
- data/lib/schematic/billing/types/count_native_invoices_request.rb +19 -0
- data/lib/schematic/billing/types/count_native_invoices_response.rb +13 -0
- data/lib/schematic/billing/types/finalize_native_invoice_response.rb +13 -0
- data/lib/schematic/billing/types/get_company_native_subscription_response.rb +13 -0
- data/lib/schematic/billing/types/get_native_invoice_response.rb +13 -0
- data/lib/schematic/billing/types/list_native_invoices_params.rb +20 -0
- data/lib/schematic/billing/types/list_native_invoices_request.rb +19 -0
- data/lib/schematic/billing/types/list_native_invoices_response.rb +13 -0
- data/lib/schematic/billing/types/mark_invoice_paid_request_body.rb +19 -0
- data/lib/schematic/billing/types/mark_native_invoice_paid_response.rb +13 -0
- data/lib/schematic/billing/types/void_native_invoice_response.rb +13 -0
- data/lib/schematic/client.rb +1 -1
- data/lib/schematic/features/client.rb +0 -2
- data/lib/schematic/internal/iterators/cursor_item_iterator.rb +2 -2
- data/lib/schematic/internal/iterators/cursor_page_iterator.rb +11 -2
- data/lib/schematic/internal/iterators/item_iterator.rb +11 -2
- data/lib/schematic/internal/iterators/offset_item_iterator.rb +2 -2
- data/lib/schematic/internal/iterators/offset_page_iterator.rb +15 -6
- data/lib/schematic/internal/types/model.rb +17 -1
- data/lib/schematic/plans/client.rb +61 -5
- data/lib/schematic/plans/types/list_custom_plan_billings_params.rb +4 -0
- data/lib/schematic/plans/types/list_custom_plan_billings_request.rb +4 -0
- data/lib/schematic/plans/types/preview_publish_plan_version_response.rb +13 -0
- data/lib/schematic/types/amendment_proration_lands_on.rb +13 -0
- data/lib/schematic/types/billing_invoice_detail_response_data.rb +49 -0
- data/lib/schematic/types/billing_invoice_line_response_data.rb +27 -0
- data/lib/schematic/types/billing_invoice_response_data.rb +43 -0
- data/lib/schematic/types/billing_invoice_settlement_response_data.rb +17 -0
- data/lib/schematic/types/billing_invoice_terms_response_data.rb +19 -0
- data/lib/schematic/types/billing_native_subscription_change_response_data.rb +15 -0
- data/lib/schematic/types/billing_native_subscription_line_response_data.rb +47 -0
- data/lib/schematic/types/billing_native_subscription_response_data.rb +31 -0
- data/lib/schematic/types/billing_statement_line_response_data.rb +21 -0
- data/lib/schematic/types/billing_statement_response_data.rb +19 -0
- data/lib/schematic/types/charge_timing.rb +12 -0
- data/lib/schematic/types/collector.rb +13 -0
- data/lib/schematic/types/company_billing_profile_response_data.rb +12 -0
- data/lib/schematic/types/company_credit_balance.rb +4 -0
- data/lib/schematic/types/create_flag_request_body.rb +1 -1
- data/lib/schematic/types/create_or_update_flag_request_body.rb +1 -1
- data/lib/schematic/types/credit_spend_policy.rb +2 -0
- data/lib/schematic/types/event_body_inference.rb +4 -0
- data/lib/schematic/types/flag_detail_response_data.rb +1 -1
- data/lib/schematic/types/flag_in_plan_response_data.rb +1 -1
- data/lib/schematic/types/flag_response_data.rb +1 -1
- data/lib/schematic/types/invoice_collection_state.rb +17 -0
- data/lib/schematic/types/invoice_document_state.rb +14 -0
- data/lib/schematic/types/invoice_line_kind.rb +15 -0
- data/lib/schematic/types/line_kind.rb +13 -0
- data/lib/schematic/types/payment_gating.rb +12 -0
- data/lib/schematic/types/preflight_event_quantities_request_body.rb +13 -0
- data/lib/schematic/types/preflight_request_body.rb +2 -0
- data/lib/schematic/types/publish_plan_version_request_body.rb +43 -0
- data/lib/schematic/types/publish_preview_pay_in_advance_response_data.rb +15 -0
- data/lib/schematic/types/publish_preview_payment_method_response_data.rb +15 -0
- data/lib/schematic/types/publish_preview_proration_line_response_data.rb +19 -0
- data/lib/schematic/types/publish_preview_response_data.rb +53 -0
- data/lib/schematic/types/rulesengine_credit_spend_policy.rb +2 -0
- data/lib/schematic/types/subscription_change_action.rb +14 -0
- data/lib/schematic/version.rb +1 -1
- data/lib/schematic/wasm/rulesengine.wasm +0 -0
- data/lib/schematic.rb +42 -5
- data/reference.md +586 -103
- metadata +40 -3
- data/lib/schematic/plans/types/publish_plan_version_request_body.rb +0 -47
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Schematic
|
|
4
|
+
module Billing
|
|
5
|
+
module Types
|
|
6
|
+
class VoidNativeInvoiceResponse < Internal::Types::Model
|
|
7
|
+
field :data, -> { Schematic::Types::BillingInvoiceDetailResponseData }, optional: false, nullable: false
|
|
8
|
+
|
|
9
|
+
field :params, -> { Internal::Types::Hash[String, Object] }, optional: false, nullable: false
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
data/lib/schematic/client.rb
CHANGED
|
@@ -43,7 +43,7 @@ module Schematic
|
|
|
43
43
|
@raw_client = Schematic::Internal::Http::RawClient.new(
|
|
44
44
|
base_url: base_url || Schematic::Environment::DEFAULT,
|
|
45
45
|
headers: {
|
|
46
|
-
"User-Agent" => "schematichq/1.5.
|
|
46
|
+
"User-Agent" => "schematichq/1.5.5",
|
|
47
47
|
"X-Fern-Language" => "Ruby",
|
|
48
48
|
"X-Schematic-Api-Key" => api_key.to_s
|
|
49
49
|
},
|
|
@@ -462,7 +462,6 @@ module Schematic
|
|
|
462
462
|
#
|
|
463
463
|
# @example
|
|
464
464
|
# client.features.create_flag(
|
|
465
|
-
# default_value: true,
|
|
466
465
|
# description: "description",
|
|
467
466
|
# flag_type: "boolean",
|
|
468
467
|
# key: "key",
|
|
@@ -555,7 +554,6 @@ module Schematic
|
|
|
555
554
|
# @example
|
|
556
555
|
# client.features.update_flag(
|
|
557
556
|
# flag_id: "flag_id",
|
|
558
|
-
# default_value: true,
|
|
559
557
|
# description: "description",
|
|
560
558
|
# flag_type: "boolean",
|
|
561
559
|
# key: "key",
|
|
@@ -6,8 +6,8 @@ module Schematic
|
|
|
6
6
|
# Instantiates a CursorItemIterator, an Enumerable class which wraps calls to a cursor-based paginated API and yields individual items from it.
|
|
7
7
|
#
|
|
8
8
|
# @param initial_cursor [String] The initial cursor to use when iterating, if any.
|
|
9
|
-
# @param cursor_field [Symbol] The field in API responses to extract the next cursor from.
|
|
10
|
-
# @param item_field [Symbol] The field in API responses to extract the items to iterate over.
|
|
9
|
+
# @param cursor_field [Symbol, Array<Symbol>] The field (or nested path) in API responses to extract the next cursor from.
|
|
10
|
+
# @param item_field [Symbol, Array<Symbol>] The field (or nested path) in API responses to extract the items to iterate over.
|
|
11
11
|
# @param block [Proc] A block which is responsible for receiving a cursor to use and returning the given page from the API.
|
|
12
12
|
# @return [Schematic::Internal::CursorItemIterator]
|
|
13
13
|
def initialize(initial_cursor:, cursor_field:, item_field:, &block)
|
|
@@ -12,7 +12,7 @@ module Schematic
|
|
|
12
12
|
# Instantiates a CursorPageIterator, an Enumerable class which wraps calls to a cursor-based paginated API and yields pages of items.
|
|
13
13
|
#
|
|
14
14
|
# @param initial_cursor [String] The initial cursor to use when iterating, if any.
|
|
15
|
-
# @param cursor_field [Symbol] The name of the field in API responses to extract the next cursor from.
|
|
15
|
+
# @param cursor_field [Symbol, Array<Symbol>] The name (or nested path) of the field in API responses to extract the next cursor from.
|
|
16
16
|
# @param block [Proc] A block which is responsible for receiving a cursor to use and returning the given page from the API.
|
|
17
17
|
# The block should return a two-element array: [parsed_page, raw_http_response].
|
|
18
18
|
# @return [Schematic::Internal::CursorPageIterator]
|
|
@@ -93,7 +93,7 @@ module Schematic
|
|
|
93
93
|
end
|
|
94
94
|
@at_first_page = false
|
|
95
95
|
@need_initial_load = false
|
|
96
|
-
@cursor = page
|
|
96
|
+
@cursor = read_field(page, @cursor_field)
|
|
97
97
|
page
|
|
98
98
|
end
|
|
99
99
|
|
|
@@ -112,6 +112,15 @@ module Schematic
|
|
|
112
112
|
@http_response = raw_response
|
|
113
113
|
fetched_page
|
|
114
114
|
end
|
|
115
|
+
|
|
116
|
+
# Reads a field from an API response, walking through enclosing objects when the field is nested.
|
|
117
|
+
#
|
|
118
|
+
# @param value [Object, nil] The API response.
|
|
119
|
+
# @param field [Symbol, Array<Symbol>] The field name, or the path of field names for a nested field.
|
|
120
|
+
# @return [Object, nil]
|
|
121
|
+
def read_field(value, field)
|
|
122
|
+
Array(field).reduce(value) { |object, name| object&.send(name) }
|
|
123
|
+
end
|
|
115
124
|
end
|
|
116
125
|
end
|
|
117
126
|
end
|
|
@@ -21,7 +21,7 @@ module Schematic
|
|
|
21
21
|
# share a position with each other or with `next_element`.
|
|
22
22
|
pass = @item_pages.dup.tap(&:rewind)
|
|
23
23
|
while (page = pass.next_page)
|
|
24
|
-
(page
|
|
24
|
+
(read_field(page, @item_field) || []).each(&)
|
|
25
25
|
end
|
|
26
26
|
nil
|
|
27
27
|
end
|
|
@@ -86,7 +86,7 @@ module Schematic
|
|
|
86
86
|
def cached_page_items
|
|
87
87
|
return [] unless @page
|
|
88
88
|
|
|
89
|
-
@page
|
|
89
|
+
read_field(@page, @item_field) || []
|
|
90
90
|
end
|
|
91
91
|
|
|
92
92
|
def next_item_from_cached_page
|
|
@@ -106,6 +106,15 @@ module Schematic
|
|
|
106
106
|
@page = @item_pages.next_page
|
|
107
107
|
@item_index = 0
|
|
108
108
|
end
|
|
109
|
+
|
|
110
|
+
# Reads a field from an API response, walking through enclosing objects when the field is nested.
|
|
111
|
+
#
|
|
112
|
+
# @param value [Object, nil] The API response.
|
|
113
|
+
# @param field [Symbol, Array<Symbol>] The field name, or the path of field names for a nested field.
|
|
114
|
+
# @return [Object, nil]
|
|
115
|
+
def read_field(value, field)
|
|
116
|
+
Array(field).reduce(value) { |object, name| object&.send(name) }
|
|
117
|
+
end
|
|
109
118
|
end
|
|
110
119
|
end
|
|
111
120
|
end
|
|
@@ -6,8 +6,8 @@ module Schematic
|
|
|
6
6
|
# Instantiates an OffsetItemIterator, an Enumerable class which wraps calls to an offset-based paginated API and yields the individual items from it.
|
|
7
7
|
#
|
|
8
8
|
# @param initial_page [Integer] The initial page or offset to start from when iterating.
|
|
9
|
-
# @param item_field [Symbol] The name of the field in API responses to extract the items to iterate over.
|
|
10
|
-
# @param has_next_field [Symbol] The name of the field in API responses containing a boolean of whether another page exists.
|
|
9
|
+
# @param item_field [Symbol, Array<Symbol>] The name (or nested path) of the field in API responses to extract the items to iterate over.
|
|
10
|
+
# @param has_next_field [Symbol, Array<Symbol>] The name (or nested path) of the field in API responses containing a boolean of whether another page exists.
|
|
11
11
|
# @param step [Boolean] If true, treats the page number as a true offset (i.e. increments the page number by the number of items returned from each call rather than just 1)
|
|
12
12
|
# @param block [Proc] A block which is responsible for receiving a page number to use and returning the given page from the API.
|
|
13
13
|
#
|
|
@@ -12,8 +12,8 @@ module Schematic
|
|
|
12
12
|
# Instantiates an OffsetPageIterator, an Enumerable class which wraps calls to an offset-based paginated API and yields pages of items from it.
|
|
13
13
|
#
|
|
14
14
|
# @param initial_page [Integer] The initial page to use when iterating, if any.
|
|
15
|
-
# @param item_field [Symbol] The field to pull the list of items to iterate over.
|
|
16
|
-
# @param has_next_field [Symbol] The field to pull the boolean of whether a next page exists from, if any.
|
|
15
|
+
# @param item_field [Symbol, Array<Symbol>] The field (or nested path) to pull the list of items to iterate over.
|
|
16
|
+
# @param has_next_field [Symbol, Array<Symbol>] The field (or nested path) to pull the boolean of whether a next page exists from, if any.
|
|
17
17
|
# @param step [Boolean] If true, treats the page number as a true offset (i.e. increments the page number by the number of items returned from each call rather than just 1)
|
|
18
18
|
# @param block [Proc] A block which is responsible for receiving a page number to use and returning the given page from the API.
|
|
19
19
|
# The block should return a two-element array: [parsed_page, raw_http_response].
|
|
@@ -89,7 +89,7 @@ module Schematic
|
|
|
89
89
|
return @has_next_page = false if @next_page
|
|
90
90
|
|
|
91
91
|
fetched_page = fetch_page(@page_number)
|
|
92
|
-
fetched_page_items = fetched_page
|
|
92
|
+
fetched_page_items = read_field(fetched_page, @item_field)
|
|
93
93
|
if fetched_page_items.nil? || fetched_page_items.empty?
|
|
94
94
|
@has_next_page = false
|
|
95
95
|
else
|
|
@@ -109,9 +109,9 @@ module Schematic
|
|
|
109
109
|
this_page = fetch_page(@page_number)
|
|
110
110
|
end
|
|
111
111
|
|
|
112
|
-
@has_next_page = this_page
|
|
112
|
+
@has_next_page = read_field(this_page, @has_next_field) if @has_next_field
|
|
113
113
|
|
|
114
|
-
items = this_page
|
|
114
|
+
items = read_field(this_page, @item_field)
|
|
115
115
|
if items.nil? || items.empty?
|
|
116
116
|
@page_number = nil
|
|
117
117
|
return nil
|
|
@@ -131,7 +131,7 @@ module Schematic
|
|
|
131
131
|
private
|
|
132
132
|
|
|
133
133
|
def page_has_items?(page)
|
|
134
|
-
items = page
|
|
134
|
+
items = read_field(page, @item_field)
|
|
135
135
|
!items.nil? && !items.empty?
|
|
136
136
|
end
|
|
137
137
|
|
|
@@ -146,6 +146,15 @@ module Schematic
|
|
|
146
146
|
result
|
|
147
147
|
end
|
|
148
148
|
end
|
|
149
|
+
|
|
150
|
+
# Reads a field from an API response, walking through enclosing objects when the field is nested.
|
|
151
|
+
#
|
|
152
|
+
# @param value [Object, nil] The API response.
|
|
153
|
+
# @param field [Symbol, Array<Symbol>] The field name, or the path of field names for a nested field.
|
|
154
|
+
# @return [Object, nil]
|
|
155
|
+
def read_field(value, field)
|
|
156
|
+
Array(field).reduce(value) { |object, name| object&.send(name) }
|
|
157
|
+
end
|
|
149
158
|
end
|
|
150
159
|
end
|
|
151
160
|
end
|
|
@@ -94,6 +94,18 @@ module Schematic
|
|
|
94
94
|
define_setter(name)
|
|
95
95
|
end
|
|
96
96
|
|
|
97
|
+
# Whether an unknown input key is dropped instead of kept as an extra field: it matches a declared
|
|
98
|
+
# field's name or API name, ignoring case
|
|
99
|
+
#
|
|
100
|
+
# @api private
|
|
101
|
+
#
|
|
102
|
+
# @param key [Symbol, String]
|
|
103
|
+
# @return [Boolean]
|
|
104
|
+
def drop_extra_key?(key)
|
|
105
|
+
key = key.to_s
|
|
106
|
+
fields.any? { |name, field| name.to_s.casecmp?(key) || field.api_name.to_s.casecmp?(key) }
|
|
107
|
+
end
|
|
108
|
+
|
|
97
109
|
# @api private
|
|
98
110
|
private def define_accessor(name)
|
|
99
111
|
method_name = name.to_sym
|
|
@@ -163,8 +175,12 @@ module Schematic
|
|
|
163
175
|
@data[field_name] = Utils.coerce(field.type, field_value)
|
|
164
176
|
end
|
|
165
177
|
|
|
166
|
-
# Any remaining values in the input become extra fields
|
|
178
|
+
# Any remaining values in the input become extra fields, except keys that match a declared field
|
|
179
|
+
# case-insensitively (e.g. `VALUE` next to `value`): re-emitting those would let a case-insensitive
|
|
180
|
+
# JSON decoder downstream read the extra key instead of the declared field.
|
|
167
181
|
values.each do |name, value|
|
|
182
|
+
next if self.class.drop_extra_key?(name)
|
|
183
|
+
|
|
168
184
|
self.class.add_extra_field_definition(name: name, type: value.class)
|
|
169
185
|
|
|
170
186
|
@data[name.to_sym] = value
|
|
@@ -70,7 +70,9 @@ module Schematic
|
|
|
70
70
|
# @option request_options [Integer] :timeout_in_seconds
|
|
71
71
|
# @option params [String, nil] :company_id
|
|
72
72
|
# @option params [String, nil] :plan_id
|
|
73
|
+
# @option params [String, nil] :plan_version_id
|
|
73
74
|
# @option params [Schematic::Types::PlanBillingSource, nil] :plan_billing_source
|
|
75
|
+
# @option params [Schematic::Types::PlanBillingSource, nil] :plan_billing_sources
|
|
74
76
|
# @option params [Schematic::Types::CustomPlanBillingStatus, nil] :status
|
|
75
77
|
# @option params [Schematic::Types::CustomPlanBillingStatus, nil] :statuses
|
|
76
78
|
# @option params [Integer, nil] :limit
|
|
@@ -80,7 +82,9 @@ module Schematic
|
|
|
80
82
|
# client.plans.list_custom_plan_billings(
|
|
81
83
|
# company_id: "company_id",
|
|
82
84
|
# plan_id: "plan_id",
|
|
85
|
+
# plan_version_id: "plan_version_id",
|
|
83
86
|
# plan_billing_source: "amendment",
|
|
87
|
+
# plan_billing_sources: ["amendment"],
|
|
84
88
|
# status: "active",
|
|
85
89
|
# statuses: ["active"],
|
|
86
90
|
# limit: 1000000,
|
|
@@ -93,7 +97,9 @@ module Schematic
|
|
|
93
97
|
query_params = {}
|
|
94
98
|
query_params["company_id"] = params[:company_id] if params.key?(:company_id)
|
|
95
99
|
query_params["plan_id"] = params[:plan_id] if params.key?(:plan_id)
|
|
100
|
+
query_params["plan_version_id"] = params[:plan_version_id] if params.key?(:plan_version_id)
|
|
96
101
|
query_params["plan_billing_source"] = params[:plan_billing_source] if params.key?(:plan_billing_source)
|
|
102
|
+
query_params["plan_billing_sources"] = params[:plan_billing_sources] if params.key?(:plan_billing_sources)
|
|
97
103
|
query_params["status"] = params[:status] if params.key?(:status)
|
|
98
104
|
query_params["statuses"] = params[:statuses] if params.key?(:statuses)
|
|
99
105
|
query_params["limit"] = params[:limit] if params.key?(:limit)
|
|
@@ -1044,7 +1050,7 @@ module Schematic
|
|
|
1044
1050
|
end
|
|
1045
1051
|
|
|
1046
1052
|
# @param request_options [Hash]
|
|
1047
|
-
# @param params [Schematic::
|
|
1053
|
+
# @param params [Schematic::Types::PublishPlanVersionRequestBody]
|
|
1048
1054
|
# @option request_options [String] :base_url
|
|
1049
1055
|
# @option request_options [Hash{String => Object}] :additional_headers
|
|
1050
1056
|
# @option request_options [Hash{String => Object}] :additional_query_parameters
|
|
@@ -1062,15 +1068,14 @@ module Schematic
|
|
|
1062
1068
|
# @return [Schematic::Plans::Types::PublishPlanVersionResponse]
|
|
1063
1069
|
def publish_plan_version(request_options: {}, **params)
|
|
1064
1070
|
params = Schematic::Internal::Types::Utils.normalize_keys(params)
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
body = request_data.except(*non_body_param_names)
|
|
1071
|
+
path_param_names = %i[plan_version_id]
|
|
1072
|
+
body_params = params.except(*path_param_names)
|
|
1068
1073
|
|
|
1069
1074
|
request = Schematic::Internal::JSON::Request.new(
|
|
1070
1075
|
base_url: request_options[:base_url],
|
|
1071
1076
|
method: "PUT",
|
|
1072
1077
|
path: "plans/version/#{URI.encode_uri_component(params[:plan_version_id].to_s)}/publish",
|
|
1073
|
-
body:
|
|
1078
|
+
body: Schematic::Types::PublishPlanVersionRequestBody.new(body_params).to_h,
|
|
1074
1079
|
request_options: request_options
|
|
1075
1080
|
)
|
|
1076
1081
|
begin
|
|
@@ -1094,6 +1099,57 @@ module Schematic
|
|
|
1094
1099
|
raise error_class.new(response.body, code: code, body: error_body)
|
|
1095
1100
|
end
|
|
1096
1101
|
end
|
|
1102
|
+
|
|
1103
|
+
# @param request_options [Hash]
|
|
1104
|
+
# @param params [Schematic::Types::PublishPlanVersionRequestBody]
|
|
1105
|
+
# @option request_options [String] :base_url
|
|
1106
|
+
# @option request_options [Hash{String => Object}] :additional_headers
|
|
1107
|
+
# @option request_options [Hash{String => Object}] :additional_query_parameters
|
|
1108
|
+
# @option request_options [Hash{String => Object}] :additional_body_parameters
|
|
1109
|
+
# @option request_options [Integer] :timeout_in_seconds
|
|
1110
|
+
# @option params [String] :plan_version_id
|
|
1111
|
+
#
|
|
1112
|
+
# @example
|
|
1113
|
+
# client.plans.preview_publish_plan_version(
|
|
1114
|
+
# plan_version_id: "plan_version_id",
|
|
1115
|
+
# excluded_company_ids: ["excluded_company_ids"],
|
|
1116
|
+
# migration_strategy: "end_of_billing_period"
|
|
1117
|
+
# )
|
|
1118
|
+
#
|
|
1119
|
+
# @return [Schematic::Plans::Types::PreviewPublishPlanVersionResponse]
|
|
1120
|
+
def preview_publish_plan_version(request_options: {}, **params)
|
|
1121
|
+
params = Schematic::Internal::Types::Utils.normalize_keys(params)
|
|
1122
|
+
path_param_names = %i[plan_version_id]
|
|
1123
|
+
body_params = params.except(*path_param_names)
|
|
1124
|
+
|
|
1125
|
+
request = Schematic::Internal::JSON::Request.new(
|
|
1126
|
+
base_url: request_options[:base_url],
|
|
1127
|
+
method: "POST",
|
|
1128
|
+
path: "plans/version/#{URI.encode_uri_component(params[:plan_version_id].to_s)}/publish-preview",
|
|
1129
|
+
body: Schematic::Types::PublishPlanVersionRequestBody.new(body_params).to_h,
|
|
1130
|
+
request_options: request_options
|
|
1131
|
+
)
|
|
1132
|
+
begin
|
|
1133
|
+
response = @client.send(request)
|
|
1134
|
+
rescue Net::HTTPRequestTimeout
|
|
1135
|
+
raise Schematic::Errors::TimeoutError
|
|
1136
|
+
end
|
|
1137
|
+
code = response.code.to_i
|
|
1138
|
+
if code.between?(200, 299)
|
|
1139
|
+
(response.body.to_s.empty? ? nil : Schematic::Plans::Types::PreviewPublishPlanVersionResponse.load(response.body))
|
|
1140
|
+
else
|
|
1141
|
+
error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
|
|
1142
|
+
error_types = {
|
|
1143
|
+
400 => Schematic::Types::ApiError,
|
|
1144
|
+
401 => Schematic::Types::ApiError,
|
|
1145
|
+
403 => Schematic::Types::ApiError,
|
|
1146
|
+
404 => Schematic::Types::ApiError,
|
|
1147
|
+
500 => Schematic::Types::ApiError
|
|
1148
|
+
}
|
|
1149
|
+
error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types)
|
|
1150
|
+
raise error_class.new(response.body, code: code, body: error_body)
|
|
1151
|
+
end
|
|
1152
|
+
end
|
|
1097
1153
|
end
|
|
1098
1154
|
end
|
|
1099
1155
|
end
|
|
@@ -13,8 +13,12 @@ module Schematic
|
|
|
13
13
|
|
|
14
14
|
field :plan_billing_source, -> { Schematic::Types::PlanBillingSource }, optional: true, nullable: false
|
|
15
15
|
|
|
16
|
+
field :plan_billing_sources, -> { Internal::Types::Array[Schematic::Types::PlanBillingSource] }, optional: true, nullable: false
|
|
17
|
+
|
|
16
18
|
field :plan_id, -> { String }, optional: true, nullable: false
|
|
17
19
|
|
|
20
|
+
field :plan_version_id, -> { String }, optional: true, nullable: false
|
|
21
|
+
|
|
18
22
|
field :status, -> { Schematic::Types::CustomPlanBillingStatus }, optional: true, nullable: false
|
|
19
23
|
|
|
20
24
|
field :statuses, -> { Internal::Types::Array[Schematic::Types::CustomPlanBillingStatus] }, optional: true, nullable: false
|
|
@@ -8,8 +8,12 @@ module Schematic
|
|
|
8
8
|
|
|
9
9
|
field :plan_id, -> { String }, optional: true, nullable: false
|
|
10
10
|
|
|
11
|
+
field :plan_version_id, -> { String }, optional: true, nullable: false
|
|
12
|
+
|
|
11
13
|
field :plan_billing_source, -> { Schematic::Types::PlanBillingSource }, optional: true, nullable: false
|
|
12
14
|
|
|
15
|
+
field :plan_billing_sources, -> { Schematic::Types::PlanBillingSource }, optional: true, nullable: false
|
|
16
|
+
|
|
13
17
|
field :status, -> { Schematic::Types::CustomPlanBillingStatus }, optional: true, nullable: false
|
|
14
18
|
|
|
15
19
|
field :statuses, -> { Schematic::Types::CustomPlanBillingStatus }, optional: true, nullable: false
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Schematic
|
|
4
|
+
module Plans
|
|
5
|
+
module Types
|
|
6
|
+
class PreviewPublishPlanVersionResponse < Internal::Types::Model
|
|
7
|
+
field :data, -> { Schematic::Types::PublishPreviewResponseData }, optional: false, nullable: false
|
|
8
|
+
|
|
9
|
+
field :params, -> { Internal::Types::Hash[String, Object] }, optional: false, nullable: false
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Schematic
|
|
4
|
+
module Types
|
|
5
|
+
module AmendmentProrationLandsOn
|
|
6
|
+
extend Schematic::Internal::Types::Enum
|
|
7
|
+
|
|
8
|
+
IMMEDIATE_INVOICE = "immediate_invoice"
|
|
9
|
+
NEXT_INVOICE = "next_invoice"
|
|
10
|
+
NONE = "none"
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Schematic
|
|
4
|
+
module Types
|
|
5
|
+
class BillingInvoiceDetailResponseData < Internal::Types::Model
|
|
6
|
+
field :amount_paid, -> { Integer }, optional: false, nullable: false
|
|
7
|
+
|
|
8
|
+
field :amount_remaining, -> { Integer }, optional: false, nullable: false
|
|
9
|
+
|
|
10
|
+
field :collection_state, -> { Schematic::Types::InvoiceCollectionState }, optional: true, nullable: false
|
|
11
|
+
|
|
12
|
+
field :collector, -> { Schematic::Types::Collector }, optional: true, nullable: false
|
|
13
|
+
|
|
14
|
+
field :company_id, -> { String }, optional: false, nullable: false
|
|
15
|
+
|
|
16
|
+
field :contract_id, -> { String }, optional: false, nullable: false
|
|
17
|
+
|
|
18
|
+
field :created_at, -> { String }, optional: false, nullable: false
|
|
19
|
+
|
|
20
|
+
field :currency, -> { Schematic::Types::Currency }, optional: false, nullable: false
|
|
21
|
+
|
|
22
|
+
field :document_state, -> { Schematic::Types::InvoiceDocumentState }, optional: false, nullable: false
|
|
23
|
+
|
|
24
|
+
field :due_at, -> { String }, optional: true, nullable: false
|
|
25
|
+
|
|
26
|
+
field :finalized_at, -> { String }, optional: true, nullable: false
|
|
27
|
+
|
|
28
|
+
field :id, -> { String }, optional: false, nullable: false
|
|
29
|
+
|
|
30
|
+
field :lines, -> { Internal::Types::Array[Schematic::Types::BillingInvoiceLineResponseData] }, optional: false, nullable: false
|
|
31
|
+
|
|
32
|
+
field :number, -> { String }, optional: true, nullable: false
|
|
33
|
+
|
|
34
|
+
field :period_end, -> { String }, optional: false, nullable: false
|
|
35
|
+
|
|
36
|
+
field :period_start, -> { String }, optional: false, nullable: false
|
|
37
|
+
|
|
38
|
+
field :settlements, -> { Internal::Types::Array[Schematic::Types::BillingInvoiceSettlementResponseData] }, optional: false, nullable: false
|
|
39
|
+
|
|
40
|
+
field :status, -> { Schematic::Types::InvoiceStatus }, optional: false, nullable: false
|
|
41
|
+
|
|
42
|
+
field :subtotal, -> { Integer }, optional: false, nullable: false
|
|
43
|
+
|
|
44
|
+
field :terms, -> { Schematic::Types::BillingInvoiceTermsResponseData }, optional: true, nullable: false
|
|
45
|
+
|
|
46
|
+
field :total, -> { Integer }, optional: false, nullable: false
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Schematic
|
|
4
|
+
module Types
|
|
5
|
+
class BillingInvoiceLineResponseData < Internal::Types::Model
|
|
6
|
+
field :amount, -> { Integer }, optional: false, nullable: false
|
|
7
|
+
|
|
8
|
+
field :charge_ids, -> { Internal::Types::Array[String] }, optional: false, nullable: false
|
|
9
|
+
|
|
10
|
+
field :id, -> { String }, optional: false, nullable: false
|
|
11
|
+
|
|
12
|
+
field :kind, -> { Schematic::Types::InvoiceLineKind }, optional: false, nullable: false
|
|
13
|
+
|
|
14
|
+
field :period_end, -> { String }, optional: true, nullable: false
|
|
15
|
+
|
|
16
|
+
field :period_start, -> { String }, optional: true, nullable: false
|
|
17
|
+
|
|
18
|
+
field :quantity, -> { Integer }, optional: true, nullable: false
|
|
19
|
+
|
|
20
|
+
field :subscription_line_id, -> { String }, optional: true, nullable: false
|
|
21
|
+
|
|
22
|
+
field :taxable, -> { Internal::Types::Boolean }, optional: false, nullable: false
|
|
23
|
+
|
|
24
|
+
field :unit_amount, -> { Integer }, optional: true, nullable: false
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Schematic
|
|
4
|
+
module Types
|
|
5
|
+
class BillingInvoiceResponseData < Internal::Types::Model
|
|
6
|
+
field :amount_paid, -> { Integer }, optional: false, nullable: false
|
|
7
|
+
|
|
8
|
+
field :amount_remaining, -> { Integer }, optional: false, nullable: false
|
|
9
|
+
|
|
10
|
+
field :collection_state, -> { Schematic::Types::InvoiceCollectionState }, optional: true, nullable: false
|
|
11
|
+
|
|
12
|
+
field :collector, -> { Schematic::Types::Collector }, optional: true, nullable: false
|
|
13
|
+
|
|
14
|
+
field :company_id, -> { String }, optional: false, nullable: false
|
|
15
|
+
|
|
16
|
+
field :contract_id, -> { String }, optional: false, nullable: false
|
|
17
|
+
|
|
18
|
+
field :created_at, -> { String }, optional: false, nullable: false
|
|
19
|
+
|
|
20
|
+
field :currency, -> { Schematic::Types::Currency }, optional: false, nullable: false
|
|
21
|
+
|
|
22
|
+
field :document_state, -> { Schematic::Types::InvoiceDocumentState }, optional: false, nullable: false
|
|
23
|
+
|
|
24
|
+
field :due_at, -> { String }, optional: true, nullable: false
|
|
25
|
+
|
|
26
|
+
field :finalized_at, -> { String }, optional: true, nullable: false
|
|
27
|
+
|
|
28
|
+
field :id, -> { String }, optional: false, nullable: false
|
|
29
|
+
|
|
30
|
+
field :number, -> { String }, optional: true, nullable: false
|
|
31
|
+
|
|
32
|
+
field :period_end, -> { String }, optional: false, nullable: false
|
|
33
|
+
|
|
34
|
+
field :period_start, -> { String }, optional: false, nullable: false
|
|
35
|
+
|
|
36
|
+
field :status, -> { Schematic::Types::InvoiceStatus }, optional: false, nullable: false
|
|
37
|
+
|
|
38
|
+
field :subtotal, -> { Integer }, optional: false, nullable: false
|
|
39
|
+
|
|
40
|
+
field :total, -> { Integer }, optional: false, nullable: false
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Schematic
|
|
4
|
+
module Types
|
|
5
|
+
class BillingInvoiceSettlementResponseData < Internal::Types::Model
|
|
6
|
+
field :amount, -> { Integer }, optional: false, nullable: false
|
|
7
|
+
|
|
8
|
+
field :collector, -> { Schematic::Types::Collector }, optional: false, nullable: false
|
|
9
|
+
|
|
10
|
+
field :id, -> { String }, optional: false, nullable: false
|
|
11
|
+
|
|
12
|
+
field :reference, -> { String }, optional: true, nullable: false
|
|
13
|
+
|
|
14
|
+
field :settled_at, -> { String }, optional: false, nullable: false
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Schematic
|
|
4
|
+
module Types
|
|
5
|
+
class BillingInvoiceTermsResponseData < Internal::Types::Model
|
|
6
|
+
field :collection_method, -> { Schematic::Types::BillingCollectionMethod }, optional: false, nullable: false
|
|
7
|
+
|
|
8
|
+
field :collector, -> { Schematic::Types::Collector }, optional: false, nullable: false
|
|
9
|
+
|
|
10
|
+
field :currency, -> { Schematic::Types::Currency }, optional: true, nullable: false
|
|
11
|
+
|
|
12
|
+
field :days_until_due, -> { Integer }, optional: true, nullable: false
|
|
13
|
+
|
|
14
|
+
field :payment_gating, -> { Schematic::Types::PaymentGating }, optional: false, nullable: false
|
|
15
|
+
|
|
16
|
+
field :purchase_order, -> { String }, optional: true, nullable: false
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Schematic
|
|
4
|
+
module Types
|
|
5
|
+
class BillingNativeSubscriptionChangeResponseData < Internal::Types::Model
|
|
6
|
+
field :action, -> { Schematic::Types::SubscriptionChangeAction }, optional: false, nullable: false
|
|
7
|
+
|
|
8
|
+
field :effective_at, -> { String }, optional: false, nullable: false
|
|
9
|
+
|
|
10
|
+
field :line, -> { Schematic::Types::BillingNativeSubscriptionLineResponseData }, optional: true, nullable: false
|
|
11
|
+
|
|
12
|
+
field :replaces, -> { Schematic::Types::BillingNativeSubscriptionLineResponseData }, optional: true, nullable: false
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Schematic
|
|
4
|
+
module Types
|
|
5
|
+
class BillingNativeSubscriptionLineResponseData < Internal::Types::Model
|
|
6
|
+
field :anchor, -> { String }, optional: false, nullable: false
|
|
7
|
+
|
|
8
|
+
field :anchor_day, -> { Integer }, optional: false, nullable: false
|
|
9
|
+
|
|
10
|
+
field :base, -> { Internal::Types::Boolean }, optional: false, nullable: false
|
|
11
|
+
|
|
12
|
+
field :cadence_count, -> { Integer }, optional: false, nullable: false
|
|
13
|
+
|
|
14
|
+
field :cadence_unit, -> { Schematic::Types::BillingProductPriceInterval }, optional: false, nullable: false
|
|
15
|
+
|
|
16
|
+
field :currency, -> { Schematic::Types::Currency }, optional: false, nullable: false
|
|
17
|
+
|
|
18
|
+
field :current_period_end, -> { String }, optional: true, nullable: false
|
|
19
|
+
|
|
20
|
+
field :current_period_start, -> { String }, optional: true, nullable: false
|
|
21
|
+
|
|
22
|
+
field :effective_from, -> { String }, optional: false, nullable: false
|
|
23
|
+
|
|
24
|
+
field :effective_to, -> { String }, optional: true, nullable: false
|
|
25
|
+
|
|
26
|
+
field :id, -> { String }, optional: false, nullable: false
|
|
27
|
+
|
|
28
|
+
field :kind, -> { Schematic::Types::LineKind }, optional: false, nullable: false
|
|
29
|
+
|
|
30
|
+
field :quantity, -> { Integer }, optional: false, nullable: false
|
|
31
|
+
|
|
32
|
+
field :source_id, -> { String }, optional: false, nullable: false
|
|
33
|
+
|
|
34
|
+
field :source_name, -> { String }, optional: true, nullable: false
|
|
35
|
+
|
|
36
|
+
field :source_plan_type, -> { Schematic::Types::PlanType }, optional: true, nullable: false
|
|
37
|
+
|
|
38
|
+
field :taxable, -> { Internal::Types::Boolean }, optional: false, nullable: false
|
|
39
|
+
|
|
40
|
+
field :tiers_mode, -> { Schematic::Types::BillingTiersMode }, optional: true, nullable: false
|
|
41
|
+
|
|
42
|
+
field :timing, -> { Schematic::Types::ChargeTiming }, optional: false, nullable: false
|
|
43
|
+
|
|
44
|
+
field :unit_amount, -> { Integer }, optional: true, nullable: false
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Schematic
|
|
4
|
+
module Types
|
|
5
|
+
class BillingNativeSubscriptionResponseData < Internal::Types::Model
|
|
6
|
+
field :cancel_at, -> { String }, optional: true, nullable: false
|
|
7
|
+
|
|
8
|
+
field :company_id, -> { String }, optional: false, nullable: false
|
|
9
|
+
|
|
10
|
+
field :currency, -> { Schematic::Types::Currency }, optional: false, nullable: false
|
|
11
|
+
|
|
12
|
+
field :id, -> { String }, optional: false, nullable: false
|
|
13
|
+
|
|
14
|
+
field :lines, -> { Internal::Types::Array[Schematic::Types::BillingNativeSubscriptionLineResponseData] }, optional: false, nullable: false
|
|
15
|
+
|
|
16
|
+
field :period_end, -> { String }, optional: false, nullable: false
|
|
17
|
+
|
|
18
|
+
field :period_start, -> { String }, optional: false, nullable: false
|
|
19
|
+
|
|
20
|
+
field :scheduled_changes, -> { Internal::Types::Array[Schematic::Types::BillingNativeSubscriptionChangeResponseData] }, optional: false, nullable: false
|
|
21
|
+
|
|
22
|
+
field :started_at, -> { String }, optional: true, nullable: false
|
|
23
|
+
|
|
24
|
+
field :statement, -> { Schematic::Types::BillingStatementResponseData }, optional: true, nullable: false
|
|
25
|
+
|
|
26
|
+
field :status, -> { Schematic::Types::SubscriptionStatus }, optional: false, nullable: false
|
|
27
|
+
|
|
28
|
+
field :terms, -> { Schematic::Types::BillingInvoiceTermsResponseData }, optional: true, nullable: false
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|