diff --git a/.fern/metadata.json b/.fern/metadata.json index 84843fc..eb28cff 100644 --- a/.fern/metadata.json +++ b/.fern/metadata.json @@ -1,7 +1,7 @@ { "cliVersion": "5.50.0", "generatorName": "fernapi/fern-ruby-sdk", - "generatorVersion": "1.38.1", + "generatorVersion": "1.39.1", "generatorConfig": { "module": "SchematicHQ", "rubocopVariableNumberStyle": "disabled", @@ -13,10 +13,10 @@ "webrick": ">= 1.0" } }, - "originGitCommit": "32d45f2e03c55876e040549ec59d6cdd7a39625a", + "originGitCommit": "5df5ee39faba7ee0d2fd40aa455ee0a1b1a00034", "originGitCommitIsDirty": false, "invokedBy": "ci", - "requestedVersion": "1.5.4", + "requestedVersion": "1.5.5", "ciProvider": "github", - "sdkVersion": "1.5.4" + "sdkVersion": "1.5.5" } \ No newline at end of file diff --git a/.fern/replay.lock b/.fern/replay.lock index c9a5ec6..9da7293 100644 --- a/.fern/replay.lock +++ b/.fern/replay.lock @@ -126,5 +126,11 @@ generations: cli_version: unknown generator_versions: fernapi/fern-ruby-sdk: 1.38.1 -current_generation: 0ee9b7004b9ec21c5c07e28948b2d2a3798235e7 + - commit_sha: 60825ceebf79189539133a284ec196b6fbf2288a + tree_hash: a16b642da4f1a16eb902cc855ed189a7bf0cb1d0 + timestamp: 2026-10-19T10:02:37.303Z + cli_version: unknown + generator_versions: + fernapi/fern-ruby-sdk: 1.39.1 +current_generation: 60825ceebf79189539133a284ec196b6fbf2288a patches: [] diff --git a/lib/schematic.rb b/lib/schematic.rb index bd952b0..041c858 100644 --- a/lib/schematic.rb +++ b/lib/schematic.rb @@ -149,6 +149,8 @@ require_relative "schematic/billing/types/count_billing_products_response" require_relative "schematic/billing/types/list_company_billing_profiles_params" require_relative "schematic/types/billing_collection_method" +require_relative "schematic/types/collector" +require_relative "schematic/types/payment_gating" require_relative "schematic/types/proration_behavior" require_relative "schematic/types/company_billing_profile_response_data" require_relative "schematic/billing/types/list_company_billing_profiles_response" @@ -159,6 +161,33 @@ require_relative "schematic/types/billing_subscription_trial_end_setting" require_relative "schematic/types/billing_subscription_response_data" require_relative "schematic/billing/types/upsert_billing_subscription_response" +require_relative "schematic/types/billing_invoice_terms_response_data" +require_relative "schematic/types/charge_timing" +require_relative "schematic/types/line_kind" +require_relative "schematic/types/plan_type" +require_relative "schematic/types/billing_native_subscription_line_response_data" +require_relative "schematic/types/subscription_change_action" +require_relative "schematic/types/billing_native_subscription_change_response_data" +require_relative "schematic/types/invoice_line_kind" +require_relative "schematic/types/billing_statement_line_response_data" +require_relative "schematic/types/billing_statement_response_data" +require_relative "schematic/types/subscription_status" +require_relative "schematic/types/billing_native_subscription_response_data" +require_relative "schematic/billing/types/get_company_native_subscription_response" +require_relative "schematic/types/invoice_document_state" +require_relative "schematic/billing/types/list_native_invoices_params" +require_relative "schematic/types/invoice_collection_state" +require_relative "schematic/types/billing_invoice_response_data" +require_relative "schematic/billing/types/list_native_invoices_response" +require_relative "schematic/types/billing_invoice_line_response_data" +require_relative "schematic/types/billing_invoice_settlement_response_data" +require_relative "schematic/types/billing_invoice_detail_response_data" +require_relative "schematic/billing/types/get_native_invoice_response" +require_relative "schematic/billing/types/finalize_native_invoice_response" +require_relative "schematic/billing/types/mark_native_invoice_paid_response" +require_relative "schematic/billing/types/void_native_invoice_response" +require_relative "schematic/billing/types/count_native_invoices_params" +require_relative "schematic/billing/types/count_native_invoices_response" require_relative "schematic/credits/types/list_billing_credits_params" require_relative "schematic/types/billing_credit_burn_strategy" require_relative "schematic/types/billing_credit_expiry_unit" @@ -307,7 +336,6 @@ require_relative "schematic/types/plan_catalog_membership_response_data" require_relative "schematic/types/plan_currency_prices_response_data" require_relative "schematic/types/plan_icon" -require_relative "schematic/types/plan_type" require_relative "schematic/types/plan_response_data" require_relative "schematic/types/warning_tier_response_data" require_relative "schematic/types/plan_entitlement_response_data" @@ -389,7 +417,6 @@ require_relative "schematic/checkout/types/preview_manage_plan_response" require_relative "schematic/checkout/types/cancel_subscription_response" require_relative "schematic/checkout/types/update_customer_subscription_trial_end_response" -require_relative "schematic/types/subscription_status" require_relative "schematic/types/subscription_type" require_relative "schematic/companies/types/list_companies_params" require_relative "schematic/companies/types/list_companies_response" @@ -581,6 +608,12 @@ require_relative "schematic/types/plan_version_diff_response_data" require_relative "schematic/plans/types/get_plan_version_diff_response" require_relative "schematic/plans/types/publish_plan_version_response" +require_relative "schematic/types/amendment_proration_lands_on" +require_relative "schematic/types/publish_preview_pay_in_advance_response_data" +require_relative "schematic/types/publish_preview_payment_method_response_data" +require_relative "schematic/types/publish_preview_proration_line_response_data" +require_relative "schematic/types/publish_preview_response_data" +require_relative "schematic/plans/types/preview_publish_plan_version_response" require_relative "schematic/components/types/list_components_params" require_relative "schematic/types/component_entity_type" require_relative "schematic/types/component_state" @@ -837,6 +870,7 @@ require_relative "schematic/types/update_pay_in_advance_request_body" require_relative "schematic/types/change_subscription_internal_request_body" require_relative "schematic/types/change_subscription_request_body" +require_relative "schematic/types/preflight_event_quantities_request_body" require_relative "schematic/types/preflight_event_usage_request_body" require_relative "schematic/types/preflight_request_body" require_relative "schematic/types/check_flag_request_body" @@ -906,6 +940,9 @@ require_relative "schematic/types/plan_bundle_credit_grant_request_body" require_relative "schematic/types/plan_bundle_entitlement_request_body" require_relative "schematic/types/plan_currency_price_request_body" +require_relative "schematic/types/tax_id_type" +require_relative "schematic/types/tax_id_input" +require_relative "schematic/types/publish_plan_version_request_body" require_relative "schematic/types/rule_condition_group_response_data" require_relative "schematic/types/rule_condition_response_data" require_relative "schematic/types/rule_response_data" @@ -936,8 +973,6 @@ require_relative "schematic/types/rulesengine_flag" require_relative "schematic/types/rulesengine_user" require_relative "schematic/types/scheduled_downgrade_config_behavior" -require_relative "schematic/types/tax_id_type" -require_relative "schematic/types/tax_id_input" require_relative "schematic/types/temporary_access_token_response_data" require_relative "schematic/types/update_entitlement_req_common" require_relative "schematic/types/update_plan_request_body" @@ -989,6 +1024,9 @@ require_relative "schematic/billing/types/update_company_billing_profile_request_body" require_relative "schematic/billing/types/update_billing_settings_request_body" require_relative "schematic/billing/types/create_billing_subscription_request_body" +require_relative "schematic/billing/types/list_native_invoices_request" +require_relative "schematic/billing/types/mark_invoice_paid_request_body" +require_relative "schematic/billing/types/count_native_invoices_request" require_relative "schematic/credits/client" require_relative "schematic/credits/types/list_billing_credits_request" require_relative "schematic/credits/types/create_billing_credit_request_body" @@ -1094,7 +1132,6 @@ require_relative "schematic/plans/types/list_plan_issues_request" require_relative "schematic/plans/types/delete_plan_version_request" require_relative "schematic/plans/types/get_plan_version_diff_request" -require_relative "schematic/plans/types/publish_plan_version_request_body" require_relative "schematic/components/client" require_relative "schematic/components/types/list_components_request" require_relative "schematic/components/types/create_component_request_body" diff --git a/lib/schematic/billing/client.rb b/lib/schematic/billing/client.rb index 5ca5c28..0cccd3c 100644 --- a/lib/schematic/billing/client.rb +++ b/lib/schematic/billing/client.rb @@ -1607,6 +1607,429 @@ def upsert_billing_subscription(request_options: {}, **params) raise error_class.new(response.body, code: code, body: error_body) end end + + # @param request_options [Hash] + # @param params [Hash] + # @option request_options [String] :base_url + # @option request_options [Hash{String => Object}] :additional_headers + # @option request_options [Hash{String => Object}] :additional_query_parameters + # @option request_options [Hash{String => Object}] :additional_body_parameters + # @option request_options [Integer] :timeout_in_seconds + # @option params [String] :company_id + # + # @example + # client.billing.get_company_native_subscription(company_id: "company_id") + # + # @return [Schematic::Billing::Types::GetCompanyNativeSubscriptionResponse] + def get_company_native_subscription(request_options: {}, **params) + params = Schematic::Internal::Types::Utils.normalize_keys(params) + request = Schematic::Internal::JSON::Request.new( + base_url: request_options[:base_url], + method: "GET", + path: "companies/#{URI.encode_uri_component(params[:company_id].to_s)}/native-subscription", + request_options: request_options + ) + begin + response = @client.send(request) + rescue Net::HTTPRequestTimeout + raise Schematic::Errors::TimeoutError + end + code = response.code.to_i + if code.between?(200, 299) + (response.body.to_s.empty? ? nil : Schematic::Billing::Types::GetCompanyNativeSubscriptionResponse.load(response.body)) + else + error_class = Schematic::Errors::ResponseError.subclass_for_code(code) + error_types = { + 401 => Schematic::Types::ApiError, + 403 => Schematic::Types::ApiError, + 404 => Schematic::Types::ApiError, + 500 => Schematic::Types::ApiError + } + error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types) + raise error_class.new(response.body, code: code, body: error_body) + end + end + + # @param request_options [Hash] + # @param params [Hash] + # @option request_options [String] :base_url + # @option request_options [Hash{String => Object}] :additional_headers + # @option request_options [Hash{String => Object}] :additional_query_parameters + # @option request_options [Hash{String => Object}] :additional_body_parameters + # @option request_options [Integer] :timeout_in_seconds + # @option params [String, nil] :company_id + # @option params [String, nil] :contract_id + # @option params [Schematic::Types::InvoiceDocumentState, nil] :document_state + # @option params [Integer, nil] :limit + # @option params [Integer, nil] :offset + # + # @example + # client.billing.list_native_invoices( + # company_id: "company_id", + # contract_id: "contract_id", + # document_state: "credited", + # limit: 1000000, + # offset: 1000000 + # ) + # + # @return [Schematic::Billing::Types::ListNativeInvoicesResponse] + def list_native_invoices(request_options: {}, **params) + params = Schematic::Internal::Types::Utils.normalize_keys(params) + query_params = {} + query_params["company_id"] = params[:company_id] if params.key?(:company_id) + query_params["contract_id"] = params[:contract_id] if params.key?(:contract_id) + query_params["document_state"] = params[:document_state] if params.key?(:document_state) + query_params["limit"] = params[:limit] if params.key?(:limit) + query_params["offset"] = params[:offset] if params.key?(:offset) + + request = Schematic::Internal::JSON::Request.new( + base_url: request_options[:base_url], + method: "GET", + path: "invoices", + query: query_params, + request_options: request_options + ) + begin + response = @client.send(request) + rescue Net::HTTPRequestTimeout + raise Schematic::Errors::TimeoutError + end + code = response.code.to_i + if code.between?(200, 299) + (response.body.to_s.empty? ? nil : Schematic::Billing::Types::ListNativeInvoicesResponse.load(response.body)) + else + error_class = Schematic::Errors::ResponseError.subclass_for_code(code) + error_types = { + 400 => Schematic::Types::ApiError, + 401 => Schematic::Types::ApiError, + 403 => Schematic::Types::ApiError, + 404 => Schematic::Types::ApiError, + 500 => Schematic::Types::ApiError + } + error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types) + raise error_class.new(response.body, code: code, body: error_body) + end + end + + # @param request_options [Hash] + # @param params [Hash] + # @option request_options [String] :base_url + # @option request_options [Hash{String => Object}] :additional_headers + # @option request_options [Hash{String => Object}] :additional_query_parameters + # @option request_options [Hash{String => Object}] :additional_body_parameters + # @option request_options [Integer] :timeout_in_seconds + # @option params [String] :invoice_id + # + # @example + # client.billing.get_native_invoice(invoice_id: "invoice_id") + # + # @return [Schematic::Billing::Types::GetNativeInvoiceResponse] + def get_native_invoice(request_options: {}, **params) + params = Schematic::Internal::Types::Utils.normalize_keys(params) + request = Schematic::Internal::JSON::Request.new( + base_url: request_options[:base_url], + method: "GET", + path: "invoices/#{URI.encode_uri_component(params[:invoice_id].to_s)}", + request_options: request_options + ) + begin + response = @client.send(request) + rescue Net::HTTPRequestTimeout + raise Schematic::Errors::TimeoutError + end + code = response.code.to_i + if code.between?(200, 299) + (response.body.to_s.empty? ? nil : Schematic::Billing::Types::GetNativeInvoiceResponse.load(response.body)) + else + error_class = Schematic::Errors::ResponseError.subclass_for_code(code) + error_types = { + 401 => Schematic::Types::ApiError, + 403 => Schematic::Types::ApiError, + 404 => Schematic::Types::ApiError, + 500 => Schematic::Types::ApiError + } + error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types) + raise error_class.new(response.body, code: code, body: error_body) + end + end + + # @param request_options [Hash] + # @param params [Hash] + # @option request_options [String] :base_url + # @option request_options [Hash{String => Object}] :additional_headers + # @option request_options [Hash{String => Object}] :additional_query_parameters + # @option request_options [Hash{String => Object}] :additional_body_parameters + # @option request_options [Integer] :timeout_in_seconds + # @option params [String] :invoice_id + # + # @example + # client.billing.export_native_invoice(invoice_id: "invoice_id") + # + # @return [String] + def export_native_invoice(request_options: {}, **params) + params = Schematic::Internal::Types::Utils.normalize_keys(params) + request = Schematic::Internal::JSON::Request.new( + base_url: request_options[:base_url], + method: "GET", + path: "invoices/#{URI.encode_uri_component(params[:invoice_id].to_s)}/export", + request_options: request_options + ) + begin + response = @client.send(request) + rescue Net::HTTPRequestTimeout + raise Schematic::Errors::TimeoutError + end + code = response.code.to_i + return response.body if code.between?(200, 299) + + error_class = Schematic::Errors::ResponseError.subclass_for_code(code) + error_types = { + 401 => Schematic::Types::ApiError, + 403 => Schematic::Types::ApiError, + 404 => Schematic::Types::ApiError, + 500 => Schematic::Types::ApiError + } + error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types) + raise error_class.new(response.body, code: code, body: error_body) + end + + # @param request_options [Hash] + # @param params [Hash] + # @option request_options [String] :base_url + # @option request_options [Hash{String => Object}] :additional_headers + # @option request_options [Hash{String => Object}] :additional_query_parameters + # @option request_options [Hash{String => Object}] :additional_body_parameters + # @option request_options [Integer] :timeout_in_seconds + # @option params [String] :invoice_id + # + # @example + # client.billing.finalize_native_invoice(invoice_id: "invoice_id") + # + # @return [Schematic::Billing::Types::FinalizeNativeInvoiceResponse] + def finalize_native_invoice(request_options: {}, **params) + params = Schematic::Internal::Types::Utils.normalize_keys(params) + request = Schematic::Internal::JSON::Request.new( + base_url: request_options[:base_url], + method: "POST", + path: "invoices/#{URI.encode_uri_component(params[:invoice_id].to_s)}/finalize", + request_options: request_options + ) + begin + response = @client.send(request) + rescue Net::HTTPRequestTimeout + raise Schematic::Errors::TimeoutError + end + code = response.code.to_i + if code.between?(200, 299) + (response.body.to_s.empty? ? nil : Schematic::Billing::Types::FinalizeNativeInvoiceResponse.load(response.body)) + else + error_class = Schematic::Errors::ResponseError.subclass_for_code(code) + error_types = { + 400 => Schematic::Types::ApiError, + 401 => Schematic::Types::ApiError, + 403 => Schematic::Types::ApiError, + 404 => Schematic::Types::ApiError, + 500 => Schematic::Types::ApiError + } + error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types) + raise error_class.new(response.body, code: code, body: error_body) + end + end + + # @param request_options [Hash] + # @param params [Schematic::Billing::Types::MarkInvoicePaidRequestBody] + # @option request_options [String] :base_url + # @option request_options [Hash{String => Object}] :additional_headers + # @option request_options [Hash{String => Object}] :additional_query_parameters + # @option request_options [Hash{String => Object}] :additional_body_parameters + # @option request_options [Integer] :timeout_in_seconds + # @option params [String] :invoice_id + # + # @example + # client.billing.mark_native_invoice_paid( + # invoice_id: "invoice_id", + # idempotency_key: "idempotency_key" + # ) + # + # @return [Schematic::Billing::Types::MarkNativeInvoicePaidResponse] + def mark_native_invoice_paid(request_options: {}, **params) + params = Schematic::Internal::Types::Utils.normalize_keys(params) + request_data = Schematic::Billing::Types::MarkInvoicePaidRequestBody.new(params).to_h + non_body_param_names = %w[invoice_id] + body = request_data.except(*non_body_param_names) + + request = Schematic::Internal::JSON::Request.new( + base_url: request_options[:base_url], + method: "POST", + path: "invoices/#{URI.encode_uri_component(params[:invoice_id].to_s)}/mark-paid", + body: body, + request_options: request_options + ) + begin + response = @client.send(request) + rescue Net::HTTPRequestTimeout + raise Schematic::Errors::TimeoutError + end + code = response.code.to_i + if code.between?(200, 299) + (response.body.to_s.empty? ? nil : Schematic::Billing::Types::MarkNativeInvoicePaidResponse.load(response.body)) + else + error_class = Schematic::Errors::ResponseError.subclass_for_code(code) + error_types = { + 400 => Schematic::Types::ApiError, + 401 => Schematic::Types::ApiError, + 403 => Schematic::Types::ApiError, + 404 => Schematic::Types::ApiError, + 500 => Schematic::Types::ApiError + } + error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types) + raise error_class.new(response.body, code: code, body: error_body) + end + end + + # @param request_options [Hash] + # @param params [Hash] + # @option request_options [String] :base_url + # @option request_options [Hash{String => Object}] :additional_headers + # @option request_options [Hash{String => Object}] :additional_query_parameters + # @option request_options [Hash{String => Object}] :additional_body_parameters + # @option request_options [Integer] :timeout_in_seconds + # @option params [String] :invoice_id + # + # @example + # client.billing.download_native_invoice_pdf(invoice_id: "invoice_id") + # + # @return [String] + def download_native_invoice_pdf(request_options: {}, **params) + params = Schematic::Internal::Types::Utils.normalize_keys(params) + request = Schematic::Internal::JSON::Request.new( + base_url: request_options[:base_url], + method: "GET", + path: "invoices/#{URI.encode_uri_component(params[:invoice_id].to_s)}/pdf", + request_options: request_options + ) + begin + response = @client.send(request) + rescue Net::HTTPRequestTimeout + raise Schematic::Errors::TimeoutError + end + code = response.code.to_i + return response.body if code.between?(200, 299) + + error_class = Schematic::Errors::ResponseError.subclass_for_code(code) + error_types = { + 401 => Schematic::Types::ApiError, + 403 => Schematic::Types::ApiError, + 404 => Schematic::Types::ApiError, + 500 => Schematic::Types::ApiError + } + error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types) + raise error_class.new(response.body, code: code, body: error_body) + end + + # @param request_options [Hash] + # @param params [Hash] + # @option request_options [String] :base_url + # @option request_options [Hash{String => Object}] :additional_headers + # @option request_options [Hash{String => Object}] :additional_query_parameters + # @option request_options [Hash{String => Object}] :additional_body_parameters + # @option request_options [Integer] :timeout_in_seconds + # @option params [String] :invoice_id + # + # @example + # client.billing.void_native_invoice(invoice_id: "invoice_id") + # + # @return [Schematic::Billing::Types::VoidNativeInvoiceResponse] + def void_native_invoice(request_options: {}, **params) + params = Schematic::Internal::Types::Utils.normalize_keys(params) + request = Schematic::Internal::JSON::Request.new( + base_url: request_options[:base_url], + method: "POST", + path: "invoices/#{URI.encode_uri_component(params[:invoice_id].to_s)}/void", + request_options: request_options + ) + begin + response = @client.send(request) + rescue Net::HTTPRequestTimeout + raise Schematic::Errors::TimeoutError + end + code = response.code.to_i + if code.between?(200, 299) + (response.body.to_s.empty? ? nil : Schematic::Billing::Types::VoidNativeInvoiceResponse.load(response.body)) + else + error_class = Schematic::Errors::ResponseError.subclass_for_code(code) + error_types = { + 400 => Schematic::Types::ApiError, + 401 => Schematic::Types::ApiError, + 403 => Schematic::Types::ApiError, + 404 => Schematic::Types::ApiError, + 500 => Schematic::Types::ApiError + } + error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types) + raise error_class.new(response.body, code: code, body: error_body) + end + end + + # @param request_options [Hash] + # @param params [Hash] + # @option request_options [String] :base_url + # @option request_options [Hash{String => Object}] :additional_headers + # @option request_options [Hash{String => Object}] :additional_query_parameters + # @option request_options [Hash{String => Object}] :additional_body_parameters + # @option request_options [Integer] :timeout_in_seconds + # @option params [String, nil] :company_id + # @option params [String, nil] :contract_id + # @option params [Schematic::Types::InvoiceDocumentState, nil] :document_state + # @option params [Integer, nil] :limit + # @option params [Integer, nil] :offset + # + # @example + # client.billing.count_native_invoices( + # company_id: "company_id", + # contract_id: "contract_id", + # document_state: "credited", + # limit: 1000000, + # offset: 1000000 + # ) + # + # @return [Schematic::Billing::Types::CountNativeInvoicesResponse] + def count_native_invoices(request_options: {}, **params) + params = Schematic::Internal::Types::Utils.normalize_keys(params) + query_params = {} + query_params["company_id"] = params[:company_id] if params.key?(:company_id) + query_params["contract_id"] = params[:contract_id] if params.key?(:contract_id) + query_params["document_state"] = params[:document_state] if params.key?(:document_state) + query_params["limit"] = params[:limit] if params.key?(:limit) + query_params["offset"] = params[:offset] if params.key?(:offset) + + request = Schematic::Internal::JSON::Request.new( + base_url: request_options[:base_url], + method: "GET", + path: "invoices/count", + query: query_params, + request_options: request_options + ) + begin + response = @client.send(request) + rescue Net::HTTPRequestTimeout + raise Schematic::Errors::TimeoutError + end + code = response.code.to_i + if code.between?(200, 299) + (response.body.to_s.empty? ? nil : Schematic::Billing::Types::CountNativeInvoicesResponse.load(response.body)) + else + error_class = Schematic::Errors::ResponseError.subclass_for_code(code) + error_types = { + 400 => Schematic::Types::ApiError, + 401 => Schematic::Types::ApiError, + 403 => Schematic::Types::ApiError, + 404 => Schematic::Types::ApiError, + 500 => Schematic::Types::ApiError + } + error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types) + raise error_class.new(response.body, code: code, body: error_body) + end + end end end end diff --git a/lib/schematic/billing/types/count_native_invoices_params.rb b/lib/schematic/billing/types/count_native_invoices_params.rb new file mode 100644 index 0000000..bdfbc2e --- /dev/null +++ b/lib/schematic/billing/types/count_native_invoices_params.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +module Schematic + module Billing + module Types + # Input parameters + class CountNativeInvoicesParams < Internal::Types::Model + field :company_id, -> { String }, optional: true, nullable: false + + field :contract_id, -> { String }, optional: true, nullable: false + + field :document_state, -> { Schematic::Types::InvoiceDocumentState }, optional: true, nullable: false + + field :limit, -> { Integer }, optional: true, nullable: false + + field :offset, -> { Integer }, optional: true, nullable: false + end + end + end +end diff --git a/lib/schematic/billing/types/count_native_invoices_request.rb b/lib/schematic/billing/types/count_native_invoices_request.rb new file mode 100644 index 0000000..66f0b28 --- /dev/null +++ b/lib/schematic/billing/types/count_native_invoices_request.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +module Schematic + module Billing + module Types + class CountNativeInvoicesRequest < Internal::Types::Model + field :company_id, -> { String }, optional: true, nullable: false + + field :contract_id, -> { String }, optional: true, nullable: false + + field :document_state, -> { Schematic::Types::InvoiceDocumentState }, optional: true, nullable: false + + field :limit, -> { Integer }, optional: true, nullable: false + + field :offset, -> { Integer }, optional: true, nullable: false + end + end + end +end diff --git a/lib/schematic/billing/types/count_native_invoices_response.rb b/lib/schematic/billing/types/count_native_invoices_response.rb new file mode 100644 index 0000000..113c65a --- /dev/null +++ b/lib/schematic/billing/types/count_native_invoices_response.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module Schematic + module Billing + module Types + class CountNativeInvoicesResponse < Internal::Types::Model + field :data, -> { Schematic::Types::CountResponse }, optional: false, nullable: false + + field :params, -> { Schematic::Billing::Types::CountNativeInvoicesParams }, optional: false, nullable: false + end + end + end +end diff --git a/lib/schematic/billing/types/finalize_native_invoice_response.rb b/lib/schematic/billing/types/finalize_native_invoice_response.rb new file mode 100644 index 0000000..60086da --- /dev/null +++ b/lib/schematic/billing/types/finalize_native_invoice_response.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module Schematic + module Billing + module Types + class FinalizeNativeInvoiceResponse < Internal::Types::Model + field :data, -> { Schematic::Types::BillingInvoiceDetailResponseData }, optional: false, nullable: false + + field :params, -> { Internal::Types::Hash[String, Object] }, optional: false, nullable: false + end + end + end +end diff --git a/lib/schematic/billing/types/get_company_native_subscription_response.rb b/lib/schematic/billing/types/get_company_native_subscription_response.rb new file mode 100644 index 0000000..0b48502 --- /dev/null +++ b/lib/schematic/billing/types/get_company_native_subscription_response.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module Schematic + module Billing + module Types + class GetCompanyNativeSubscriptionResponse < Internal::Types::Model + field :data, -> { Schematic::Types::BillingNativeSubscriptionResponseData }, optional: false, nullable: false + + field :params, -> { Internal::Types::Hash[String, Object] }, optional: false, nullable: false + end + end + end +end diff --git a/lib/schematic/billing/types/get_native_invoice_response.rb b/lib/schematic/billing/types/get_native_invoice_response.rb new file mode 100644 index 0000000..cba39a2 --- /dev/null +++ b/lib/schematic/billing/types/get_native_invoice_response.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module Schematic + module Billing + module Types + class GetNativeInvoiceResponse < Internal::Types::Model + field :data, -> { Schematic::Types::BillingInvoiceDetailResponseData }, optional: false, nullable: false + + field :params, -> { Internal::Types::Hash[String, Object] }, optional: false, nullable: false + end + end + end +end diff --git a/lib/schematic/billing/types/list_native_invoices_params.rb b/lib/schematic/billing/types/list_native_invoices_params.rb new file mode 100644 index 0000000..973f66a --- /dev/null +++ b/lib/schematic/billing/types/list_native_invoices_params.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +module Schematic + module Billing + module Types + # Input parameters + class ListNativeInvoicesParams < Internal::Types::Model + field :company_id, -> { String }, optional: true, nullable: false + + field :contract_id, -> { String }, optional: true, nullable: false + + field :document_state, -> { Schematic::Types::InvoiceDocumentState }, optional: true, nullable: false + + field :limit, -> { Integer }, optional: true, nullable: false + + field :offset, -> { Integer }, optional: true, nullable: false + end + end + end +end diff --git a/lib/schematic/billing/types/list_native_invoices_request.rb b/lib/schematic/billing/types/list_native_invoices_request.rb new file mode 100644 index 0000000..7409e2e --- /dev/null +++ b/lib/schematic/billing/types/list_native_invoices_request.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +module Schematic + module Billing + module Types + class ListNativeInvoicesRequest < Internal::Types::Model + field :company_id, -> { String }, optional: true, nullable: false + + field :contract_id, -> { String }, optional: true, nullable: false + + field :document_state, -> { Schematic::Types::InvoiceDocumentState }, optional: true, nullable: false + + field :limit, -> { Integer }, optional: true, nullable: false + + field :offset, -> { Integer }, optional: true, nullable: false + end + end + end +end diff --git a/lib/schematic/billing/types/list_native_invoices_response.rb b/lib/schematic/billing/types/list_native_invoices_response.rb new file mode 100644 index 0000000..fe4155b --- /dev/null +++ b/lib/schematic/billing/types/list_native_invoices_response.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module Schematic + module Billing + module Types + class ListNativeInvoicesResponse < Internal::Types::Model + field :data, -> { Internal::Types::Array[Schematic::Types::BillingInvoiceResponseData] }, optional: false, nullable: false + + field :params, -> { Schematic::Billing::Types::ListNativeInvoicesParams }, optional: false, nullable: false + end + end + end +end diff --git a/lib/schematic/billing/types/mark_invoice_paid_request_body.rb b/lib/schematic/billing/types/mark_invoice_paid_request_body.rb new file mode 100644 index 0000000..caef2b5 --- /dev/null +++ b/lib/schematic/billing/types/mark_invoice_paid_request_body.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +module Schematic + module Billing + module Types + class MarkInvoicePaidRequestBody < Internal::Types::Model + field :invoice_id, -> { String }, optional: false, nullable: false + + field :amount, -> { Integer }, optional: true, nullable: false + + field :idempotency_key, -> { String }, optional: false, nullable: false + + field :reference, -> { String }, optional: true, nullable: false + + field :settled_at, -> { String }, optional: true, nullable: false + end + end + end +end diff --git a/lib/schematic/billing/types/mark_native_invoice_paid_response.rb b/lib/schematic/billing/types/mark_native_invoice_paid_response.rb new file mode 100644 index 0000000..44e2abc --- /dev/null +++ b/lib/schematic/billing/types/mark_native_invoice_paid_response.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module Schematic + module Billing + module Types + class MarkNativeInvoicePaidResponse < Internal::Types::Model + field :data, -> { Schematic::Types::BillingInvoiceDetailResponseData }, optional: false, nullable: false + + field :params, -> { Internal::Types::Hash[String, Object] }, optional: false, nullable: false + end + end + end +end diff --git a/lib/schematic/billing/types/void_native_invoice_response.rb b/lib/schematic/billing/types/void_native_invoice_response.rb new file mode 100644 index 0000000..f34b246 --- /dev/null +++ b/lib/schematic/billing/types/void_native_invoice_response.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module Schematic + module Billing + module Types + class VoidNativeInvoiceResponse < Internal::Types::Model + field :data, -> { Schematic::Types::BillingInvoiceDetailResponseData }, optional: false, nullable: false + + field :params, -> { Internal::Types::Hash[String, Object] }, optional: false, nullable: false + end + end + end +end diff --git a/lib/schematic/client.rb b/lib/schematic/client.rb index f4337b7..09c54af 100644 --- a/lib/schematic/client.rb +++ b/lib/schematic/client.rb @@ -43,7 +43,7 @@ def initialize(api_key:, base_url: nil, max_retries: 2, timeout: 60) @raw_client = Schematic::Internal::Http::RawClient.new( base_url: base_url || Schematic::Environment::DEFAULT, headers: { - "User-Agent" => "schematichq/1.5.4", + "User-Agent" => "schematichq/1.5.5", "X-Fern-Language" => "Ruby", "X-Schematic-Api-Key" => api_key.to_s }, diff --git a/lib/schematic/features/client.rb b/lib/schematic/features/client.rb index 98c1c22..9cb8a30 100644 --- a/lib/schematic/features/client.rb +++ b/lib/schematic/features/client.rb @@ -462,7 +462,6 @@ def list_flags(request_options: {}, **params) # # @example # client.features.create_flag( - # default_value: true, # description: "description", # flag_type: "boolean", # key: "key", @@ -555,7 +554,6 @@ def get_flag(request_options: {}, **params) # @example # client.features.update_flag( # flag_id: "flag_id", - # default_value: true, # description: "description", # flag_type: "boolean", # key: "key", diff --git a/lib/schematic/internal/iterators/cursor_item_iterator.rb b/lib/schematic/internal/iterators/cursor_item_iterator.rb index 41fe678..1a44f1c 100644 --- a/lib/schematic/internal/iterators/cursor_item_iterator.rb +++ b/lib/schematic/internal/iterators/cursor_item_iterator.rb @@ -6,8 +6,8 @@ class CursorItemIterator < ItemIterator # Instantiates a CursorItemIterator, an Enumerable class which wraps calls to a cursor-based paginated API and yields individual items from it. # # @param initial_cursor [String] The initial cursor to use when iterating, if any. - # @param cursor_field [Symbol] The field in API responses to extract the next cursor from. - # @param item_field [Symbol] The field in API responses to extract the items to iterate over. + # @param cursor_field [Symbol, Array] The field (or nested path) in API responses to extract the next cursor from. + # @param item_field [Symbol, Array] The field (or nested path) in API responses to extract the items to iterate over. # @param block [Proc] A block which is responsible for receiving a cursor to use and returning the given page from the API. # @return [Schematic::Internal::CursorItemIterator] def initialize(initial_cursor:, cursor_field:, item_field:, &block) diff --git a/lib/schematic/internal/iterators/cursor_page_iterator.rb b/lib/schematic/internal/iterators/cursor_page_iterator.rb index 741329f..228ec9c 100644 --- a/lib/schematic/internal/iterators/cursor_page_iterator.rb +++ b/lib/schematic/internal/iterators/cursor_page_iterator.rb @@ -12,7 +12,7 @@ class CursorPageIterator # Instantiates a CursorPageIterator, an Enumerable class which wraps calls to a cursor-based paginated API and yields pages of items. # # @param initial_cursor [String] The initial cursor to use when iterating, if any. - # @param cursor_field [Symbol] The name of the field in API responses to extract the next cursor from. + # @param cursor_field [Symbol, Array] The name (or nested path) of the field in API responses to extract the next cursor from. # @param block [Proc] A block which is responsible for receiving a cursor to use and returning the given page from the API. # The block should return a two-element array: [parsed_page, raw_http_response]. # @return [Schematic::Internal::CursorPageIterator] @@ -93,7 +93,7 @@ def next_page end @at_first_page = false @need_initial_load = false - @cursor = page.send(@cursor_field) + @cursor = read_field(page, @cursor_field) page end @@ -112,6 +112,15 @@ def fetch_page(cursor) @http_response = raw_response fetched_page end + + # Reads a field from an API response, walking through enclosing objects when the field is nested. + # + # @param value [Object, nil] The API response. + # @param field [Symbol, Array] The field name, or the path of field names for a nested field. + # @return [Object, nil] + def read_field(value, field) + Array(field).reduce(value) { |object, name| object&.send(name) } + end end end end diff --git a/lib/schematic/internal/iterators/item_iterator.rb b/lib/schematic/internal/iterators/item_iterator.rb index a1f90a5..d8df0d8 100644 --- a/lib/schematic/internal/iterators/item_iterator.rb +++ b/lib/schematic/internal/iterators/item_iterator.rb @@ -21,7 +21,7 @@ def each(&) # share a position with each other or with `next_element`. pass = @item_pages.dup.tap(&:rewind) while (page = pass.next_page) - (page.send(@item_field) || []).each(&) + (read_field(page, @item_field) || []).each(&) end nil end @@ -86,7 +86,7 @@ def track_http_responses(get_page) def cached_page_items return [] unless @page - @page.send(@item_field) || [] + read_field(@page, @item_field) || [] end def next_item_from_cached_page @@ -106,6 +106,15 @@ def load_next_page @page = @item_pages.next_page @item_index = 0 end + + # Reads a field from an API response, walking through enclosing objects when the field is nested. + # + # @param value [Object, nil] The API response. + # @param field [Symbol, Array] The field name, or the path of field names for a nested field. + # @return [Object, nil] + def read_field(value, field) + Array(field).reduce(value) { |object, name| object&.send(name) } + end end end end diff --git a/lib/schematic/internal/iterators/offset_item_iterator.rb b/lib/schematic/internal/iterators/offset_item_iterator.rb index eef6324..e85ed88 100644 --- a/lib/schematic/internal/iterators/offset_item_iterator.rb +++ b/lib/schematic/internal/iterators/offset_item_iterator.rb @@ -6,8 +6,8 @@ class OffsetItemIterator < ItemIterator # Instantiates an OffsetItemIterator, an Enumerable class which wraps calls to an offset-based paginated API and yields the individual items from it. # # @param initial_page [Integer] The initial page or offset to start from when iterating. - # @param item_field [Symbol] The name of the field in API responses to extract the items to iterate over. - # @param has_next_field [Symbol] The name of the field in API responses containing a boolean of whether another page exists. + # @param item_field [Symbol, Array] The name (or nested path) of the field in API responses to extract the items to iterate over. + # @param has_next_field [Symbol, Array] The name (or nested path) of the field in API responses containing a boolean of whether another page exists. # @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) # @param block [Proc] A block which is responsible for receiving a page number to use and returning the given page from the API. # diff --git a/lib/schematic/internal/iterators/offset_page_iterator.rb b/lib/schematic/internal/iterators/offset_page_iterator.rb index b72eac2..72d414d 100644 --- a/lib/schematic/internal/iterators/offset_page_iterator.rb +++ b/lib/schematic/internal/iterators/offset_page_iterator.rb @@ -12,8 +12,8 @@ class OffsetPageIterator # Instantiates an OffsetPageIterator, an Enumerable class which wraps calls to an offset-based paginated API and yields pages of items from it. # # @param initial_page [Integer] The initial page to use when iterating, if any. - # @param item_field [Symbol] The field to pull the list of items to iterate over. - # @param has_next_field [Symbol] The field to pull the boolean of whether a next page exists from, if any. + # @param item_field [Symbol, Array] The field (or nested path) to pull the list of items to iterate over. + # @param has_next_field [Symbol, Array] The field (or nested path) to pull the boolean of whether a next page exists from, if any. # @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) # @param block [Proc] A block which is responsible for receiving a page number to use and returning the given page from the API. # The block should return a two-element array: [parsed_page, raw_http_response]. @@ -89,7 +89,7 @@ def next? return @has_next_page = false if @next_page fetched_page = fetch_page(@page_number) - fetched_page_items = fetched_page&.send(@item_field) + fetched_page_items = read_field(fetched_page, @item_field) if fetched_page_items.nil? || fetched_page_items.empty? @has_next_page = false else @@ -109,9 +109,9 @@ def next_page this_page = fetch_page(@page_number) end - @has_next_page = this_page&.send(@has_next_field) if @has_next_field + @has_next_page = read_field(this_page, @has_next_field) if @has_next_field - items = this_page.send(@item_field) + items = read_field(this_page, @item_field) if items.nil? || items.empty? @page_number = nil return nil @@ -131,7 +131,7 @@ def next_page private def page_has_items?(page) - items = page.send(@item_field) + items = read_field(page, @item_field) !items.nil? && !items.empty? end @@ -146,6 +146,15 @@ def fetch_page(page_number) result end end + + # Reads a field from an API response, walking through enclosing objects when the field is nested. + # + # @param value [Object, nil] The API response. + # @param field [Symbol, Array] The field name, or the path of field names for a nested field. + # @return [Object, nil] + def read_field(value, field) + Array(field).reduce(value) { |object, name| object&.send(name) } + end end end end diff --git a/lib/schematic/internal/types/model.rb b/lib/schematic/internal/types/model.rb index 321f434..717ad17 100644 --- a/lib/schematic/internal/types/model.rb +++ b/lib/schematic/internal/types/model.rb @@ -94,6 +94,18 @@ def add_extra_field_definition(name:, type:) define_setter(name) end + # Whether an unknown input key is dropped instead of kept as an extra field: it matches a declared + # field's name or API name, ignoring case + # + # @api private + # + # @param key [Symbol, String] + # @return [Boolean] + def drop_extra_key?(key) + key = key.to_s + fields.any? { |name, field| name.to_s.casecmp?(key) || field.api_name.to_s.casecmp?(key) } + end + # @api private private def define_accessor(name) method_name = name.to_sym @@ -163,8 +175,12 @@ def initialize(values = {}) @data[field_name] = Utils.coerce(field.type, field_value) end - # Any remaining values in the input become extra fields + # Any remaining values in the input become extra fields, except keys that match a declared field + # case-insensitively (e.g. `VALUE` next to `value`): re-emitting those would let a case-insensitive + # JSON decoder downstream read the extra key instead of the declared field. values.each do |name, value| + next if self.class.drop_extra_key?(name) + self.class.add_extra_field_definition(name: name, type: value.class) @data[name.to_sym] = value diff --git a/lib/schematic/plans/client.rb b/lib/schematic/plans/client.rb index cdcef89..fd09b9d 100644 --- a/lib/schematic/plans/client.rb +++ b/lib/schematic/plans/client.rb @@ -70,7 +70,9 @@ def update_company_plans(request_options: {}, **params) # @option request_options [Integer] :timeout_in_seconds # @option params [String, nil] :company_id # @option params [String, nil] :plan_id + # @option params [String, nil] :plan_version_id # @option params [Schematic::Types::PlanBillingSource, nil] :plan_billing_source + # @option params [Schematic::Types::PlanBillingSource, nil] :plan_billing_sources # @option params [Schematic::Types::CustomPlanBillingStatus, nil] :status # @option params [Schematic::Types::CustomPlanBillingStatus, nil] :statuses # @option params [Integer, nil] :limit @@ -80,7 +82,9 @@ def update_company_plans(request_options: {}, **params) # client.plans.list_custom_plan_billings( # company_id: "company_id", # plan_id: "plan_id", + # plan_version_id: "plan_version_id", # plan_billing_source: "amendment", + # plan_billing_sources: ["amendment"], # status: "active", # statuses: ["active"], # limit: 1000000, @@ -93,7 +97,9 @@ def list_custom_plan_billings(request_options: {}, **params) query_params = {} query_params["company_id"] = params[:company_id] if params.key?(:company_id) query_params["plan_id"] = params[:plan_id] if params.key?(:plan_id) + query_params["plan_version_id"] = params[:plan_version_id] if params.key?(:plan_version_id) query_params["plan_billing_source"] = params[:plan_billing_source] if params.key?(:plan_billing_source) + query_params["plan_billing_sources"] = params[:plan_billing_sources] if params.key?(:plan_billing_sources) query_params["status"] = params[:status] if params.key?(:status) query_params["statuses"] = params[:statuses] if params.key?(:statuses) query_params["limit"] = params[:limit] if params.key?(:limit) @@ -1044,7 +1050,7 @@ def get_plan_version_diff(request_options: {}, **params) end # @param request_options [Hash] - # @param params [Schematic::Plans::Types::PublishPlanVersionRequestBody] + # @param params [Schematic::Types::PublishPlanVersionRequestBody] # @option request_options [String] :base_url # @option request_options [Hash{String => Object}] :additional_headers # @option request_options [Hash{String => Object}] :additional_query_parameters @@ -1062,15 +1068,14 @@ def get_plan_version_diff(request_options: {}, **params) # @return [Schematic::Plans::Types::PublishPlanVersionResponse] def publish_plan_version(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) - request_data = Schematic::Plans::Types::PublishPlanVersionRequestBody.new(params).to_h - non_body_param_names = %w[plan_version_id] - body = request_data.except(*non_body_param_names) + path_param_names = %i[plan_version_id] + body_params = params.except(*path_param_names) request = Schematic::Internal::JSON::Request.new( base_url: request_options[:base_url], method: "PUT", path: "plans/version/#{URI.encode_uri_component(params[:plan_version_id].to_s)}/publish", - body: body, + body: Schematic::Types::PublishPlanVersionRequestBody.new(body_params).to_h, request_options: request_options ) begin @@ -1094,6 +1099,57 @@ def publish_plan_version(request_options: {}, **params) raise error_class.new(response.body, code: code, body: error_body) end end + + # @param request_options [Hash] + # @param params [Schematic::Types::PublishPlanVersionRequestBody] + # @option request_options [String] :base_url + # @option request_options [Hash{String => Object}] :additional_headers + # @option request_options [Hash{String => Object}] :additional_query_parameters + # @option request_options [Hash{String => Object}] :additional_body_parameters + # @option request_options [Integer] :timeout_in_seconds + # @option params [String] :plan_version_id + # + # @example + # client.plans.preview_publish_plan_version( + # plan_version_id: "plan_version_id", + # excluded_company_ids: ["excluded_company_ids"], + # migration_strategy: "end_of_billing_period" + # ) + # + # @return [Schematic::Plans::Types::PreviewPublishPlanVersionResponse] + def preview_publish_plan_version(request_options: {}, **params) + params = Schematic::Internal::Types::Utils.normalize_keys(params) + path_param_names = %i[plan_version_id] + body_params = params.except(*path_param_names) + + request = Schematic::Internal::JSON::Request.new( + base_url: request_options[:base_url], + method: "POST", + path: "plans/version/#{URI.encode_uri_component(params[:plan_version_id].to_s)}/publish-preview", + body: Schematic::Types::PublishPlanVersionRequestBody.new(body_params).to_h, + request_options: request_options + ) + begin + response = @client.send(request) + rescue Net::HTTPRequestTimeout + raise Schematic::Errors::TimeoutError + end + code = response.code.to_i + if code.between?(200, 299) + (response.body.to_s.empty? ? nil : Schematic::Plans::Types::PreviewPublishPlanVersionResponse.load(response.body)) + else + error_class = Schematic::Errors::ResponseError.subclass_for_code(code) + error_types = { + 400 => Schematic::Types::ApiError, + 401 => Schematic::Types::ApiError, + 403 => Schematic::Types::ApiError, + 404 => Schematic::Types::ApiError, + 500 => Schematic::Types::ApiError + } + error_body = Schematic::Errors::ResponseError.load_error_body(code, response.body, error_types) + raise error_class.new(response.body, code: code, body: error_body) + end + end end end end diff --git a/lib/schematic/plans/types/list_custom_plan_billings_params.rb b/lib/schematic/plans/types/list_custom_plan_billings_params.rb index 69efa4e..8f48e37 100644 --- a/lib/schematic/plans/types/list_custom_plan_billings_params.rb +++ b/lib/schematic/plans/types/list_custom_plan_billings_params.rb @@ -13,8 +13,12 @@ class ListCustomPlanBillingsParams < Internal::Types::Model field :plan_billing_source, -> { Schematic::Types::PlanBillingSource }, optional: true, nullable: false + field :plan_billing_sources, -> { Internal::Types::Array[Schematic::Types::PlanBillingSource] }, optional: true, nullable: false + field :plan_id, -> { String }, optional: true, nullable: false + field :plan_version_id, -> { String }, optional: true, nullable: false + field :status, -> { Schematic::Types::CustomPlanBillingStatus }, optional: true, nullable: false field :statuses, -> { Internal::Types::Array[Schematic::Types::CustomPlanBillingStatus] }, optional: true, nullable: false diff --git a/lib/schematic/plans/types/list_custom_plan_billings_request.rb b/lib/schematic/plans/types/list_custom_plan_billings_request.rb index bc01197..fc29cbd 100644 --- a/lib/schematic/plans/types/list_custom_plan_billings_request.rb +++ b/lib/schematic/plans/types/list_custom_plan_billings_request.rb @@ -8,8 +8,12 @@ class ListCustomPlanBillingsRequest < Internal::Types::Model field :plan_id, -> { String }, optional: true, nullable: false + field :plan_version_id, -> { String }, optional: true, nullable: false + field :plan_billing_source, -> { Schematic::Types::PlanBillingSource }, optional: true, nullable: false + field :plan_billing_sources, -> { Schematic::Types::PlanBillingSource }, optional: true, nullable: false + field :status, -> { Schematic::Types::CustomPlanBillingStatus }, optional: true, nullable: false field :statuses, -> { Schematic::Types::CustomPlanBillingStatus }, optional: true, nullable: false diff --git a/lib/schematic/plans/types/preview_publish_plan_version_response.rb b/lib/schematic/plans/types/preview_publish_plan_version_response.rb new file mode 100644 index 0000000..504c710 --- /dev/null +++ b/lib/schematic/plans/types/preview_publish_plan_version_response.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module Schematic + module Plans + module Types + class PreviewPublishPlanVersionResponse < Internal::Types::Model + field :data, -> { Schematic::Types::PublishPreviewResponseData }, optional: false, nullable: false + + field :params, -> { Internal::Types::Hash[String, Object] }, optional: false, nullable: false + end + end + end +end diff --git a/lib/schematic/plans/types/publish_plan_version_request_body.rb b/lib/schematic/plans/types/publish_plan_version_request_body.rb deleted file mode 100644 index 2bfa233..0000000 --- a/lib/schematic/plans/types/publish_plan_version_request_body.rb +++ /dev/null @@ -1,47 +0,0 @@ -# frozen_string_literal: true - -module Schematic - module Plans - module Types - class PublishPlanVersionRequestBody < Internal::Types::Model - field :plan_version_id, -> { String }, optional: false, nullable: false - - field :activation_strategy, -> { Schematic::Types::CustomPlanActivationStrategy }, optional: true, nullable: false - - field :address, -> { Schematic::Types::CustomerBillingAddress }, optional: true, nullable: false - - field :billing_cycle_anchor, -> { String }, optional: true, nullable: false - - field :billing_start_date, -> { String }, optional: true, nullable: false - - field :collection_method, -> { Schematic::Types::BillingCollectionMethod }, optional: true, nullable: false - - field :coupon_external_id, -> { String }, optional: true, nullable: false - - field :custom_field_values, -> { Internal::Types::Array[Schematic::Types::CheckoutFieldValue] }, optional: true, nullable: false - - field :customer_email, -> { String }, optional: true, nullable: false - - field :days_until_due, -> { Integer }, optional: true, nullable: false - - field :excluded_company_ids, -> { Internal::Types::Array[String] }, optional: false, nullable: false - - field :migration_strategy, -> { Schematic::Types::PlanVersionMigrationStrategy }, optional: false, nullable: false - - field :phone, -> { String }, optional: true, nullable: false - - field :prorate_first_period, -> { Internal::Types::Boolean }, optional: true, nullable: false - - field :proration_behavior, -> { Schematic::Types::MigrationProrationBehavior }, optional: true, nullable: false - - field :require_no_migration, -> { Internal::Types::Boolean }, optional: true, nullable: false - - field :scheduled_at, -> { String }, optional: true, nullable: false - - field :send_invoice, -> { Internal::Types::Boolean }, optional: true, nullable: false - - field :tax_id, -> { Schematic::Types::TaxIdInput }, optional: true, nullable: false - end - end - end -end diff --git a/lib/schematic/types/amendment_proration_lands_on.rb b/lib/schematic/types/amendment_proration_lands_on.rb new file mode 100644 index 0000000..6fcfdbd --- /dev/null +++ b/lib/schematic/types/amendment_proration_lands_on.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module Schematic + module Types + module AmendmentProrationLandsOn + extend Schematic::Internal::Types::Enum + + IMMEDIATE_INVOICE = "immediate_invoice" + NEXT_INVOICE = "next_invoice" + NONE = "none" + end + end +end diff --git a/lib/schematic/types/billing_invoice_detail_response_data.rb b/lib/schematic/types/billing_invoice_detail_response_data.rb new file mode 100644 index 0000000..b58acb5 --- /dev/null +++ b/lib/schematic/types/billing_invoice_detail_response_data.rb @@ -0,0 +1,49 @@ +# frozen_string_literal: true + +module Schematic + module Types + class BillingInvoiceDetailResponseData < Internal::Types::Model + field :amount_paid, -> { Integer }, optional: false, nullable: false + + field :amount_remaining, -> { Integer }, optional: false, nullable: false + + field :collection_state, -> { Schematic::Types::InvoiceCollectionState }, optional: true, nullable: false + + field :collector, -> { Schematic::Types::Collector }, optional: true, nullable: false + + field :company_id, -> { String }, optional: false, nullable: false + + field :contract_id, -> { String }, optional: false, nullable: false + + field :created_at, -> { String }, optional: false, nullable: false + + field :currency, -> { Schematic::Types::Currency }, optional: false, nullable: false + + field :document_state, -> { Schematic::Types::InvoiceDocumentState }, optional: false, nullable: false + + field :due_at, -> { String }, optional: true, nullable: false + + field :finalized_at, -> { String }, optional: true, nullable: false + + field :id, -> { String }, optional: false, nullable: false + + field :lines, -> { Internal::Types::Array[Schematic::Types::BillingInvoiceLineResponseData] }, optional: false, nullable: false + + field :number, -> { String }, optional: true, nullable: false + + field :period_end, -> { String }, optional: false, nullable: false + + field :period_start, -> { String }, optional: false, nullable: false + + field :settlements, -> { Internal::Types::Array[Schematic::Types::BillingInvoiceSettlementResponseData] }, optional: false, nullable: false + + field :status, -> { Schematic::Types::InvoiceStatus }, optional: false, nullable: false + + field :subtotal, -> { Integer }, optional: false, nullable: false + + field :terms, -> { Schematic::Types::BillingInvoiceTermsResponseData }, optional: true, nullable: false + + field :total, -> { Integer }, optional: false, nullable: false + end + end +end diff --git a/lib/schematic/types/billing_invoice_line_response_data.rb b/lib/schematic/types/billing_invoice_line_response_data.rb new file mode 100644 index 0000000..a126f2a --- /dev/null +++ b/lib/schematic/types/billing_invoice_line_response_data.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +module Schematic + module Types + class BillingInvoiceLineResponseData < Internal::Types::Model + field :amount, -> { Integer }, optional: false, nullable: false + + field :charge_ids, -> { Internal::Types::Array[String] }, optional: false, nullable: false + + field :id, -> { String }, optional: false, nullable: false + + field :kind, -> { Schematic::Types::InvoiceLineKind }, optional: false, nullable: false + + field :period_end, -> { String }, optional: true, nullable: false + + field :period_start, -> { String }, optional: true, nullable: false + + field :quantity, -> { Integer }, optional: true, nullable: false + + field :subscription_line_id, -> { String }, optional: true, nullable: false + + field :taxable, -> { Internal::Types::Boolean }, optional: false, nullable: false + + field :unit_amount, -> { Integer }, optional: true, nullable: false + end + end +end diff --git a/lib/schematic/types/billing_invoice_response_data.rb b/lib/schematic/types/billing_invoice_response_data.rb new file mode 100644 index 0000000..a62709b --- /dev/null +++ b/lib/schematic/types/billing_invoice_response_data.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +module Schematic + module Types + class BillingInvoiceResponseData < Internal::Types::Model + field :amount_paid, -> { Integer }, optional: false, nullable: false + + field :amount_remaining, -> { Integer }, optional: false, nullable: false + + field :collection_state, -> { Schematic::Types::InvoiceCollectionState }, optional: true, nullable: false + + field :collector, -> { Schematic::Types::Collector }, optional: true, nullable: false + + field :company_id, -> { String }, optional: false, nullable: false + + field :contract_id, -> { String }, optional: false, nullable: false + + field :created_at, -> { String }, optional: false, nullable: false + + field :currency, -> { Schematic::Types::Currency }, optional: false, nullable: false + + field :document_state, -> { Schematic::Types::InvoiceDocumentState }, optional: false, nullable: false + + field :due_at, -> { String }, optional: true, nullable: false + + field :finalized_at, -> { String }, optional: true, nullable: false + + field :id, -> { String }, optional: false, nullable: false + + field :number, -> { String }, optional: true, nullable: false + + field :period_end, -> { String }, optional: false, nullable: false + + field :period_start, -> { String }, optional: false, nullable: false + + field :status, -> { Schematic::Types::InvoiceStatus }, optional: false, nullable: false + + field :subtotal, -> { Integer }, optional: false, nullable: false + + field :total, -> { Integer }, optional: false, nullable: false + end + end +end diff --git a/lib/schematic/types/billing_invoice_settlement_response_data.rb b/lib/schematic/types/billing_invoice_settlement_response_data.rb new file mode 100644 index 0000000..3812f7b --- /dev/null +++ b/lib/schematic/types/billing_invoice_settlement_response_data.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +module Schematic + module Types + class BillingInvoiceSettlementResponseData < Internal::Types::Model + field :amount, -> { Integer }, optional: false, nullable: false + + field :collector, -> { Schematic::Types::Collector }, optional: false, nullable: false + + field :id, -> { String }, optional: false, nullable: false + + field :reference, -> { String }, optional: true, nullable: false + + field :settled_at, -> { String }, optional: false, nullable: false + end + end +end diff --git a/lib/schematic/types/billing_invoice_terms_response_data.rb b/lib/schematic/types/billing_invoice_terms_response_data.rb new file mode 100644 index 0000000..68dce8d --- /dev/null +++ b/lib/schematic/types/billing_invoice_terms_response_data.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +module Schematic + module Types + class BillingInvoiceTermsResponseData < Internal::Types::Model + field :collection_method, -> { Schematic::Types::BillingCollectionMethod }, optional: false, nullable: false + + field :collector, -> { Schematic::Types::Collector }, optional: false, nullable: false + + field :currency, -> { Schematic::Types::Currency }, optional: true, nullable: false + + field :days_until_due, -> { Integer }, optional: true, nullable: false + + field :payment_gating, -> { Schematic::Types::PaymentGating }, optional: false, nullable: false + + field :purchase_order, -> { String }, optional: true, nullable: false + end + end +end diff --git a/lib/schematic/types/billing_native_subscription_change_response_data.rb b/lib/schematic/types/billing_native_subscription_change_response_data.rb new file mode 100644 index 0000000..3de6cfb --- /dev/null +++ b/lib/schematic/types/billing_native_subscription_change_response_data.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +module Schematic + module Types + class BillingNativeSubscriptionChangeResponseData < Internal::Types::Model + field :action, -> { Schematic::Types::SubscriptionChangeAction }, optional: false, nullable: false + + field :effective_at, -> { String }, optional: false, nullable: false + + field :line, -> { Schematic::Types::BillingNativeSubscriptionLineResponseData }, optional: true, nullable: false + + field :replaces, -> { Schematic::Types::BillingNativeSubscriptionLineResponseData }, optional: true, nullable: false + end + end +end diff --git a/lib/schematic/types/billing_native_subscription_line_response_data.rb b/lib/schematic/types/billing_native_subscription_line_response_data.rb new file mode 100644 index 0000000..a73099d --- /dev/null +++ b/lib/schematic/types/billing_native_subscription_line_response_data.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +module Schematic + module Types + class BillingNativeSubscriptionLineResponseData < Internal::Types::Model + field :anchor, -> { String }, optional: false, nullable: false + + field :anchor_day, -> { Integer }, optional: false, nullable: false + + field :base, -> { Internal::Types::Boolean }, optional: false, nullable: false + + field :cadence_count, -> { Integer }, optional: false, nullable: false + + field :cadence_unit, -> { Schematic::Types::BillingProductPriceInterval }, optional: false, nullable: false + + field :currency, -> { Schematic::Types::Currency }, optional: false, nullable: false + + field :current_period_end, -> { String }, optional: true, nullable: false + + field :current_period_start, -> { String }, optional: true, nullable: false + + field :effective_from, -> { String }, optional: false, nullable: false + + field :effective_to, -> { String }, optional: true, nullable: false + + field :id, -> { String }, optional: false, nullable: false + + field :kind, -> { Schematic::Types::LineKind }, optional: false, nullable: false + + field :quantity, -> { Integer }, optional: false, nullable: false + + field :source_id, -> { String }, optional: false, nullable: false + + field :source_name, -> { String }, optional: true, nullable: false + + field :source_plan_type, -> { Schematic::Types::PlanType }, optional: true, nullable: false + + field :taxable, -> { Internal::Types::Boolean }, optional: false, nullable: false + + field :tiers_mode, -> { Schematic::Types::BillingTiersMode }, optional: true, nullable: false + + field :timing, -> { Schematic::Types::ChargeTiming }, optional: false, nullable: false + + field :unit_amount, -> { Integer }, optional: true, nullable: false + end + end +end diff --git a/lib/schematic/types/billing_native_subscription_response_data.rb b/lib/schematic/types/billing_native_subscription_response_data.rb new file mode 100644 index 0000000..53a55c0 --- /dev/null +++ b/lib/schematic/types/billing_native_subscription_response_data.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +module Schematic + module Types + class BillingNativeSubscriptionResponseData < Internal::Types::Model + field :cancel_at, -> { String }, optional: true, nullable: false + + field :company_id, -> { String }, optional: false, nullable: false + + field :currency, -> { Schematic::Types::Currency }, optional: false, nullable: false + + field :id, -> { String }, optional: false, nullable: false + + field :lines, -> { Internal::Types::Array[Schematic::Types::BillingNativeSubscriptionLineResponseData] }, optional: false, nullable: false + + field :period_end, -> { String }, optional: false, nullable: false + + field :period_start, -> { String }, optional: false, nullable: false + + field :scheduled_changes, -> { Internal::Types::Array[Schematic::Types::BillingNativeSubscriptionChangeResponseData] }, optional: false, nullable: false + + field :started_at, -> { String }, optional: true, nullable: false + + field :statement, -> { Schematic::Types::BillingStatementResponseData }, optional: true, nullable: false + + field :status, -> { Schematic::Types::SubscriptionStatus }, optional: false, nullable: false + + field :terms, -> { Schematic::Types::BillingInvoiceTermsResponseData }, optional: true, nullable: false + end + end +end diff --git a/lib/schematic/types/billing_statement_line_response_data.rb b/lib/schematic/types/billing_statement_line_response_data.rb new file mode 100644 index 0000000..1ab687b --- /dev/null +++ b/lib/schematic/types/billing_statement_line_response_data.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +module Schematic + module Types + class BillingStatementLineResponseData < Internal::Types::Model + field :amount, -> { Integer }, optional: false, nullable: false + + field :kind, -> { Schematic::Types::InvoiceLineKind }, optional: false, nullable: false + + field :period_end, -> { String }, optional: true, nullable: false + + field :period_start, -> { String }, optional: true, nullable: false + + field :quantity, -> { Integer }, optional: true, nullable: false + + field :subscription_line_id, -> { String }, optional: true, nullable: false + + field :unit_amount, -> { Integer }, optional: true, nullable: false + end + end +end diff --git a/lib/schematic/types/billing_statement_response_data.rb b/lib/schematic/types/billing_statement_response_data.rb new file mode 100644 index 0000000..549caa7 --- /dev/null +++ b/lib/schematic/types/billing_statement_response_data.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +module Schematic + module Types + class BillingStatementResponseData < Internal::Types::Model + field :currency, -> { Schematic::Types::Currency }, optional: false, nullable: false + + field :lines, -> { Internal::Types::Array[Schematic::Types::BillingStatementLineResponseData] }, optional: false, nullable: false + + field :period_end, -> { String }, optional: false, nullable: false + + field :period_start, -> { String }, optional: false, nullable: false + + field :subtotal, -> { Integer }, optional: false, nullable: false + + field :total, -> { Integer }, optional: false, nullable: false + end + end +end diff --git a/lib/schematic/types/charge_timing.rb b/lib/schematic/types/charge_timing.rb new file mode 100644 index 0000000..1aef203 --- /dev/null +++ b/lib/schematic/types/charge_timing.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +module Schematic + module Types + module ChargeTiming + extend Schematic::Internal::Types::Enum + + IN_ADVANCE = "in_advance" + IN_ARREARS = "in_arrears" + end + end +end diff --git a/lib/schematic/types/collector.rb b/lib/schematic/types/collector.rb new file mode 100644 index 0000000..dc6c338 --- /dev/null +++ b/lib/schematic/types/collector.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module Schematic + module Types + module Collector + extend Schematic::Internal::Types::Enum + + EXTERNAL = "external" + STRIPE_INVOICE = "stripe_invoice" + STRIPE_PAYMENTS = "stripe_payments" + end + end +end diff --git a/lib/schematic/types/company_billing_profile_response_data.rb b/lib/schematic/types/company_billing_profile_response_data.rb index 4333b59..f49c9dc 100644 --- a/lib/schematic/types/company_billing_profile_response_data.rb +++ b/lib/schematic/types/company_billing_profile_response_data.rb @@ -9,26 +9,38 @@ class CompanyBillingProfileResponseData < Internal::Types::Model field :collection_method, -> { Schematic::Types::BillingCollectionMethod }, optional: false, nullable: false + field :collector, -> { Schematic::Types::Collector }, optional: true, nullable: false + field :company_id, -> { String }, optional: false, nullable: false field :created_at, -> { String }, optional: false, nullable: false + field :currency, -> { Schematic::Types::Currency }, optional: true, nullable: false + field :days_until_due, -> { Integer }, optional: true, nullable: false field :environment_id, -> { String }, optional: false, nullable: false + field :gating_days, -> { Integer }, optional: false, nullable: false + field :id, -> { String }, optional: false, nullable: false field :is_default, -> { Internal::Types::Boolean }, optional: false, nullable: false field :name, -> { String }, optional: true, nullable: false + field :overdraft_limit, -> { Integer }, optional: true, nullable: false + + field :payment_gating, -> { Schematic::Types::PaymentGating }, optional: false, nullable: false + field :payment_method_id, -> { String }, optional: true, nullable: false field :proration_behavior, -> { Schematic::Types::ProrationBehavior }, optional: true, nullable: false field :provider_type, -> { Schematic::Types::BillingProviderType }, optional: false, nullable: false + field :purchase_order, -> { String }, optional: true, nullable: false + field :updated_at, -> { String }, optional: false, nullable: false end end diff --git a/lib/schematic/types/company_credit_balance.rb b/lib/schematic/types/company_credit_balance.rb index 30591c4..0a35ae7 100644 --- a/lib/schematic/types/company_credit_balance.rb +++ b/lib/schematic/types/company_credit_balance.rb @@ -3,6 +3,10 @@ module Schematic module Types class CompanyCreditBalance < Internal::Types::Model + field :overdraft_limit, -> { Float }, optional: true, nullable: false + + field :postpaid, -> { Internal::Types::Boolean }, optional: false, nullable: false + field :remaining, -> { Float }, optional: false, nullable: false field :reserved, -> { Float }, optional: false, nullable: false diff --git a/lib/schematic/types/create_flag_request_body.rb b/lib/schematic/types/create_flag_request_body.rb index ec752c7..4c18901 100644 --- a/lib/schematic/types/create_flag_request_body.rb +++ b/lib/schematic/types/create_flag_request_body.rb @@ -3,7 +3,7 @@ module Schematic module Types class CreateFlagRequestBody < Internal::Types::Model - field :default_value, -> { Internal::Types::Boolean }, optional: false, nullable: false + field :default_value, -> { Internal::Types::Boolean }, optional: true, nullable: false field :description, -> { String }, optional: false, nullable: false diff --git a/lib/schematic/types/create_or_update_flag_request_body.rb b/lib/schematic/types/create_or_update_flag_request_body.rb index bf8b1d7..be79848 100644 --- a/lib/schematic/types/create_or_update_flag_request_body.rb +++ b/lib/schematic/types/create_or_update_flag_request_body.rb @@ -3,7 +3,7 @@ module Schematic module Types class CreateOrUpdateFlagRequestBody < Internal::Types::Model - field :default_value, -> { Internal::Types::Boolean }, optional: false, nullable: false + field :default_value, -> { Internal::Types::Boolean }, optional: true, nullable: false field :description, -> { String }, optional: false, nullable: false diff --git a/lib/schematic/types/credit_spend_policy.rb b/lib/schematic/types/credit_spend_policy.rb index 87d55b7..e03a363 100644 --- a/lib/schematic/types/credit_spend_policy.rb +++ b/lib/schematic/types/credit_spend_policy.rb @@ -3,6 +3,8 @@ module Schematic module Types class CreditSpendPolicy < Internal::Types::Model + field :company_id, -> { String }, optional: true, nullable: false + field :consumed, -> { Float }, optional: true, nullable: false field :credit_id, -> { String }, optional: false, nullable: false diff --git a/lib/schematic/types/event_body_inference.rb b/lib/schematic/types/event_body_inference.rb index 012cd26..4534771 100644 --- a/lib/schematic/types/event_body_inference.rb +++ b/lib/schematic/types/event_body_inference.rb @@ -17,6 +17,8 @@ class EventBodyInference < Internal::Types::Model field :input_tokens, -> { Integer }, optional: false, nullable: false + field :lease_id, -> { String }, optional: true, nullable: false + field :operation, -> { String }, optional: true, nullable: false field :output_tokens, -> { Integer }, optional: false, nullable: false @@ -29,6 +31,8 @@ class EventBodyInference < Internal::Types::Model field :requests, -> { Integer }, optional: true, nullable: false + field :reservation_id, -> { String }, optional: true, nullable: false + field :response_model, -> { String }, optional: false, nullable: false field :user, -> { Internal::Types::Hash[String, String] }, optional: true, nullable: false diff --git a/lib/schematic/types/flag_detail_response_data.rb b/lib/schematic/types/flag_detail_response_data.rb index 67ac5a2..de202b6 100644 --- a/lib/schematic/types/flag_detail_response_data.rb +++ b/lib/schematic/types/flag_detail_response_data.rb @@ -5,7 +5,7 @@ module Types class FlagDetailResponseData < Internal::Types::Model field :created_at, -> { String }, optional: false, nullable: false - field :default_value, -> { Internal::Types::Boolean }, optional: false, nullable: false + field :default_value, -> { Internal::Types::Boolean }, optional: true, nullable: false field :description, -> { String }, optional: false, nullable: false diff --git a/lib/schematic/types/flag_in_plan_response_data.rb b/lib/schematic/types/flag_in_plan_response_data.rb index d0277ad..06e8ee2 100644 --- a/lib/schematic/types/flag_in_plan_response_data.rb +++ b/lib/schematic/types/flag_in_plan_response_data.rb @@ -5,7 +5,7 @@ module Types class FlagInPlanResponseData < Internal::Types::Model field :created_at, -> { String }, optional: false, nullable: false - field :default_value, -> { Internal::Types::Boolean }, optional: false, nullable: false + field :default_value, -> { Internal::Types::Boolean }, optional: true, nullable: false field :description, -> { String }, optional: false, nullable: false diff --git a/lib/schematic/types/flag_response_data.rb b/lib/schematic/types/flag_response_data.rb index c785688..90aeeaa 100644 --- a/lib/schematic/types/flag_response_data.rb +++ b/lib/schematic/types/flag_response_data.rb @@ -5,7 +5,7 @@ module Types class FlagResponseData < Internal::Types::Model field :created_at, -> { String }, optional: false, nullable: false - field :default_value, -> { Internal::Types::Boolean }, optional: false, nullable: false + field :default_value, -> { Internal::Types::Boolean }, optional: true, nullable: false field :description, -> { String }, optional: false, nullable: false diff --git a/lib/schematic/types/invoice_collection_state.rb b/lib/schematic/types/invoice_collection_state.rb new file mode 100644 index 0000000..0f4f344 --- /dev/null +++ b/lib/schematic/types/invoice_collection_state.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +module Schematic + module Types + module InvoiceCollectionState + extend Schematic::Internal::Types::Enum + + EXPORTED = "exported" + PAID = "paid" + PARTIALLY_PAID = "partially_paid" + PAST_DUE = "past_due" + PAYMENT_FAILED = "payment_failed" + QUEUED = "queued" + SENT = "sent" + end + end +end diff --git a/lib/schematic/types/invoice_document_state.rb b/lib/schematic/types/invoice_document_state.rb new file mode 100644 index 0000000..3021916 --- /dev/null +++ b/lib/schematic/types/invoice_document_state.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module Schematic + module Types + module InvoiceDocumentState + extend Schematic::Internal::Types::Enum + + CREDITED = "credited" + DRAFT = "draft" + FINALIZED = "finalized" + VOID = "void" + end + end +end diff --git a/lib/schematic/types/invoice_line_kind.rb b/lib/schematic/types/invoice_line_kind.rb new file mode 100644 index 0000000..c7b265d --- /dev/null +++ b/lib/schematic/types/invoice_line_kind.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +module Schematic + module Types + module InvoiceLineKind + extend Schematic::Internal::Types::Enum + + ADJUSTMENT = "adjustment" + PURCHASE = "purchase" + RECONCILIATION = "reconciliation" + SUBSCRIPTION = "subscription" + TRUE_UP = "true_up" + end + end +end diff --git a/lib/schematic/types/line_kind.rb b/lib/schematic/types/line_kind.rb new file mode 100644 index 0000000..9161791 --- /dev/null +++ b/lib/schematic/types/line_kind.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module Schematic + module Types + module LineKind + extend Schematic::Internal::Types::Enum + + ALLOWANCE = "allowance" + CAPACITY = "capacity" + RATE = "rate" + end + end +end diff --git a/lib/schematic/types/payment_gating.rb b/lib/schematic/types/payment_gating.rb new file mode 100644 index 0000000..6a3e742 --- /dev/null +++ b/lib/schematic/types/payment_gating.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +module Schematic + module Types + module PaymentGating + extend Schematic::Internal::Types::Enum + + KEEP_SERVING = "keep_serving" + REVOKE_AFTER = "revoke_after" + end + end +end diff --git a/lib/schematic/types/preflight_event_quantities_request_body.rb b/lib/schematic/types/preflight_event_quantities_request_body.rb new file mode 100644 index 0000000..ce91db9 --- /dev/null +++ b/lib/schematic/types/preflight_event_quantities_request_body.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module Schematic + module Types + class PreflightEventQuantitiesRequestBody < Internal::Types::Model + field :event_subtype, -> { String }, optional: false, nullable: false + + field :quantities, -> { Internal::Types::Hash[String, Float] }, optional: true, nullable: false + + field :quantity, -> { Float }, optional: true, nullable: false + end + end +end diff --git a/lib/schematic/types/preflight_request_body.rb b/lib/schematic/types/preflight_request_body.rb index 2417edb..be3dccd 100644 --- a/lib/schematic/types/preflight_request_body.rb +++ b/lib/schematic/types/preflight_request_body.rb @@ -5,6 +5,8 @@ module Types class PreflightRequestBody < Internal::Types::Model field :credit_cost, -> { Internal::Types::Hash[String, Float] }, optional: true, nullable: false + field :event_quantities, -> { Schematic::Types::PreflightEventQuantitiesRequestBody }, optional: true, nullable: false + field :event_usage, -> { Schematic::Types::PreflightEventUsageRequestBody }, optional: true, nullable: false field :usage, -> { Integer }, optional: true, nullable: false diff --git a/lib/schematic/types/publish_plan_version_request_body.rb b/lib/schematic/types/publish_plan_version_request_body.rb new file mode 100644 index 0000000..cfe9ab4 --- /dev/null +++ b/lib/schematic/types/publish_plan_version_request_body.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +module Schematic + module Types + class PublishPlanVersionRequestBody < Internal::Types::Model + field :activation_strategy, -> { Schematic::Types::CustomPlanActivationStrategy }, optional: true, nullable: false + + field :address, -> { Schematic::Types::CustomerBillingAddress }, optional: true, nullable: false + + field :billing_cycle_anchor, -> { String }, optional: true, nullable: false + + field :billing_start_date, -> { String }, optional: true, nullable: false + + field :collection_method, -> { Schematic::Types::BillingCollectionMethod }, optional: true, nullable: false + + field :coupon_external_id, -> { String }, optional: true, nullable: false + + field :custom_field_values, -> { Internal::Types::Array[Schematic::Types::CheckoutFieldValue] }, optional: true, nullable: false + + field :customer_email, -> { String }, optional: true, nullable: false + + field :days_until_due, -> { Integer }, optional: true, nullable: false + + field :excluded_company_ids, -> { Internal::Types::Array[String] }, optional: false, nullable: false + + field :migration_strategy, -> { Schematic::Types::PlanVersionMigrationStrategy }, optional: false, nullable: false + + field :phone, -> { String }, optional: true, nullable: false + + field :prorate_first_period, -> { Internal::Types::Boolean }, optional: true, nullable: false + + field :proration_behavior, -> { Schematic::Types::MigrationProrationBehavior }, optional: true, nullable: false + + field :require_no_migration, -> { Internal::Types::Boolean }, optional: true, nullable: false + + field :scheduled_at, -> { String }, optional: true, nullable: false + + field :send_invoice, -> { Internal::Types::Boolean }, optional: true, nullable: false + + field :tax_id, -> { Schematic::Types::TaxIdInput }, optional: true, nullable: false + end + end +end diff --git a/lib/schematic/types/publish_preview_pay_in_advance_response_data.rb b/lib/schematic/types/publish_preview_pay_in_advance_response_data.rb new file mode 100644 index 0000000..8174d0a --- /dev/null +++ b/lib/schematic/types/publish_preview_pay_in_advance_response_data.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +module Schematic + module Types + class PublishPreviewPayInAdvanceResponseData < Internal::Types::Model + field :committed_quantity, -> { Integer }, optional: false, nullable: false + + field :current_quantity, -> { Integer }, optional: true, nullable: false + + field :effective_quantity, -> { Integer }, optional: false, nullable: false + + field :feature_id, -> { String }, optional: false, nullable: false + end + end +end diff --git a/lib/schematic/types/publish_preview_payment_method_response_data.rb b/lib/schematic/types/publish_preview_payment_method_response_data.rb new file mode 100644 index 0000000..892222a --- /dev/null +++ b/lib/schematic/types/publish_preview_payment_method_response_data.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +module Schematic + module Types + class PublishPreviewPaymentMethodResponseData < Internal::Types::Model + field :card_brand, -> { String }, optional: true, nullable: false + + field :card_last_4, -> { String }, optional: true, nullable: false, api_name: "card_last4" + + field :has_default, -> { Internal::Types::Boolean }, optional: false, nullable: false + + field :payment_method_type, -> { String }, optional: true, nullable: false + end + end +end diff --git a/lib/schematic/types/publish_preview_proration_line_response_data.rb b/lib/schematic/types/publish_preview_proration_line_response_data.rb new file mode 100644 index 0000000..ecfcc49 --- /dev/null +++ b/lib/schematic/types/publish_preview_proration_line_response_data.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +module Schematic + module Types + class PublishPreviewProrationLineResponseData < Internal::Types::Model + field :amount, -> { Integer }, optional: false, nullable: false + + field :description, -> { String }, optional: false, nullable: false + + field :period_end, -> { String }, optional: false, nullable: false + + field :period_start, -> { String }, optional: false, nullable: false + + field :price_external_id, -> { String }, optional: true, nullable: false + + field :quantity, -> { Integer }, optional: false, nullable: false + end + end +end diff --git a/lib/schematic/types/publish_preview_response_data.rb b/lib/schematic/types/publish_preview_response_data.rb new file mode 100644 index 0000000..2c9bcdf --- /dev/null +++ b/lib/schematic/types/publish_preview_response_data.rb @@ -0,0 +1,53 @@ +# frozen_string_literal: true + +module Schematic + module Types + class PublishPreviewResponseData < Internal::Types::Model + field :billing_email, -> { String }, optional: true, nullable: false + + field :currency, -> { Schematic::Types::Currency }, optional: true, nullable: false + + field :current_period_end, -> { String }, optional: true, nullable: false + + field :current_period_start, -> { String }, optional: true, nullable: false + + field :default_collection_method, -> { Schematic::Types::BillingCollectionMethod }, optional: false, nullable: false + + field :default_days_until_due, -> { Integer }, optional: false, nullable: false + + field :default_send_invoice, -> { Internal::Types::Boolean }, optional: false, nullable: false + + field :effective_at, -> { String }, optional: true, nullable: false + + field :has_billing_changes, -> { Internal::Types::Boolean }, optional: false, nullable: false + + field :immediate_invoice_amount, -> { Integer }, optional: true, nullable: false + + field :lands_on, -> { Schematic::Types::AmendmentProrationLandsOn }, optional: false, nullable: false + + field :new_recurring_amount, -> { Integer }, optional: true, nullable: false + + field :next_invoice_amount, -> { Integer }, optional: true, nullable: false + + field :next_invoice_at, -> { String }, optional: true, nullable: false + + field :note, -> { String }, optional: true, nullable: false + + field :pay_in_advance, -> { Internal::Types::Array[Schematic::Types::PublishPreviewPayInAdvanceResponseData] }, optional: false, nullable: false + + field :payment_method, -> { Schematic::Types::PublishPreviewPaymentMethodResponseData }, optional: false, nullable: false + + field :proration_charge, -> { Integer }, optional: false, nullable: false + + field :proration_credit, -> { Integer }, optional: false, nullable: false + + field :proration_lines, -> { Internal::Types::Array[Schematic::Types::PublishPreviewProrationLineResponseData] }, optional: false, nullable: false + + field :proration_total, -> { Integer }, optional: false, nullable: false + + field :will_update_subscription, -> { Internal::Types::Boolean }, optional: false, nullable: false + + field :would_fail, -> { Internal::Types::Boolean }, optional: false, nullable: false + end + end +end diff --git a/lib/schematic/types/rulesengine_credit_spend_policy.rb b/lib/schematic/types/rulesengine_credit_spend_policy.rb index 08651f6..a11288e 100644 --- a/lib/schematic/types/rulesengine_credit_spend_policy.rb +++ b/lib/schematic/types/rulesengine_credit_spend_policy.rb @@ -3,6 +3,8 @@ module Schematic module Types class RulesengineCreditSpendPolicy < Internal::Types::Model + field :company_id, -> { String }, optional: true, nullable: false + field :consumed, -> { Float }, optional: true, nullable: false field :credit_id, -> { String }, optional: false, nullable: false diff --git a/lib/schematic/types/subscription_change_action.rb b/lib/schematic/types/subscription_change_action.rb new file mode 100644 index 0000000..e7dae77 --- /dev/null +++ b/lib/schematic/types/subscription_change_action.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module Schematic + module Types + module SubscriptionChangeAction + extend Schematic::Internal::Types::Enum + + ADD = "add" + CANCEL = "cancel" + REMOVE = "remove" + REPLACE = "replace" + end + end +end diff --git a/lib/schematic/version.rb b/lib/schematic/version.rb index 367f817..eba69ba 100644 --- a/lib/schematic/version.rb +++ b/lib/schematic/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Schematic - VERSION = "1.5.4" + VERSION = "1.5.5" end diff --git a/reference.md b/reference.md index 1a5a0cd..7441430 100644 --- a/reference.md +++ b/reference.md @@ -4334,6 +4334,549 @@ client.billing.upsert_billing_subscription( + + + + +
client.billing.get_company_native_subscription(company_id:) -> Schematic::Billing::Types::GetCompanyNativeSubscriptionResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```ruby +client.billing.get_company_native_subscription(company_id: "company_id") +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**company_id:** `String` — company_id + +
+
+ +
+
+ +**request_options:** `Schematic::Billing::RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.billing.list_native_invoices() -> Schematic::Billing::Types::ListNativeInvoicesResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```ruby +client.billing.list_native_invoices( + company_id: "company_id", + contract_id: "contract_id", + document_state: "credited", + limit: 1000000, + offset: 1000000 +) +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**company_id:** `String` + +
+
+ +
+
+ +**contract_id:** `String` + +
+
+ +
+
+ +**document_state:** `Schematic::Types::InvoiceDocumentState` + +
+
+ +
+
+ +**limit:** `Integer` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Integer` — Page offset (default 0) + +
+
+ +
+
+ +**request_options:** `Schematic::Billing::RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.billing.get_native_invoice(invoice_id:) -> Schematic::Billing::Types::GetNativeInvoiceResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```ruby +client.billing.get_native_invoice(invoice_id: "invoice_id") +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**invoice_id:** `String` — invoice_id + +
+
+ +
+
+ +**request_options:** `Schematic::Billing::RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.billing.export_native_invoice(invoice_id:) -> String +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```ruby +client.billing.export_native_invoice(invoice_id: "invoice_id") +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**invoice_id:** `String` — invoice_id + +
+
+ +
+
+ +**request_options:** `Schematic::Billing::RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.billing.finalize_native_invoice(invoice_id:) -> Schematic::Billing::Types::FinalizeNativeInvoiceResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```ruby +client.billing.finalize_native_invoice(invoice_id: "invoice_id") +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**invoice_id:** `String` — invoice_id + +
+
+ +
+
+ +**request_options:** `Schematic::Billing::RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.billing.mark_native_invoice_paid(invoice_id:, request) -> Schematic::Billing::Types::MarkNativeInvoicePaidResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```ruby +client.billing.mark_native_invoice_paid( + invoice_id: "invoice_id", + idempotency_key: "idempotency_key" +) +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**invoice_id:** `String` — invoice_id + +
+
+ +
+
+ +**amount:** `Integer` — Amount paid, in minor units of the invoice's currency. Leave empty to mark the whole remaining amount as paid. + +
+
+ +
+
+ +**idempotency_key:** `String` — A retry with the same key records the payment once. + +
+
+ +
+
+ +**reference:** `String` — A note that identifies the payment, such as a bank transfer reference. + +
+
+ +
+
+ +**settled_at:** `String` — When the payment arrived. Defaults to now, and cannot be in the future. + +
+
+ +
+
+ +**request_options:** `Schematic::Billing::RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.billing.download_native_invoice_pdf(invoice_id:) -> String +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```ruby +client.billing.download_native_invoice_pdf(invoice_id: "invoice_id") +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**invoice_id:** `String` — invoice_id + +
+
+ +
+
+ +**request_options:** `Schematic::Billing::RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.billing.void_native_invoice(invoice_id:) -> Schematic::Billing::Types::VoidNativeInvoiceResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```ruby +client.billing.void_native_invoice(invoice_id: "invoice_id") +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**invoice_id:** `String` — invoice_id + +
+
+ +
+
+ +**request_options:** `Schematic::Billing::RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.billing.count_native_invoices() -> Schematic::Billing::Types::CountNativeInvoicesResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```ruby +client.billing.count_native_invoices( + company_id: "company_id", + contract_id: "contract_id", + document_state: "credited", + limit: 1000000, + offset: 1000000 +) +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**company_id:** `String` + +
+
+ +
+
+ +**contract_id:** `String` + +
+
+ +
+
+ +**document_state:** `Schematic::Types::InvoiceDocumentState` + +
+
+ +
+
+ +**limit:** `Integer` — Page limit (default 100) + +
+
+ +
+
+ +**offset:** `Integer` — Page offset (default 0) + +
+
+ +
+
+ +**request_options:** `Schematic::Billing::RequestOptions` + +
+
+
+
+ +
@@ -7042,7 +7585,7 @@ client.credits.create_credit_spend_policy(billing_credit_id: "billing_credit_id"
-**company_id:** `String` — The company the cap applies to. Set exactly one of company_id and user_id. +**company_id:** `String` — The company the cap applies in. Alone, it caps the whole company. With user_id, it caps that user's spend in this company. Required with user_id when the user belongs to more than one company.
@@ -7066,7 +7609,7 @@ client.credits.create_credit_spend_policy(billing_credit_id: "billing_credit_id"
-**user_id:** `String` — The user the cap applies to. Set exactly one of company_id and user_id. +**user_id:** `String` — The user the cap applies to. The user must belong to company_id, and with no company_id, to exactly one company.
@@ -9298,7 +9841,7 @@ client.companies.list_companies(
-**without_feature_override_for:** `String` — Filter out companies that already have a company override for the specified feature ID +**without_feature_override_for:** `String` — Filter out companies that have an unexpired company override for the specified feature ID
@@ -9694,7 +10237,7 @@ client.companies.count_companies(
-**without_feature_override_for:** `String` — Filter out companies that already have a company override for the specified feature ID +**without_feature_override_for:** `String` — Filter out companies that have an unexpired company override for the specified feature ID
@@ -15657,7 +16200,9 @@ client.plans.update_company_plans( client.plans.list_custom_plan_billings( company_id: "company_id", plan_id: "plan_id", + plan_version_id: "plan_version_id", plan_billing_source: "amendment", + plan_billing_sources: ["amendment"], status: "active", statuses: ["active"], limit: 1000000, @@ -15693,7 +16238,23 @@ client.plans.list_custom_plan_billings(
-**plan_billing_source:** `Schematic::Types::PlanBillingSource` — Filter by the flow that created the billing record: custom_plan for a first publish, amendment for a republish, manage_plan for a standard plan assigned by invoice. Defaults to custom_plan. +**plan_version_id:** `String` — Filter by the plan version the billing record was created for + +
+
+ +
+
+ +**plan_billing_source:** `Schematic::Types::PlanBillingSource` — Filter by the flow that created the billing record: custom_plan for a first publish, amendment for a republish, manage_plan for a standard plan assigned by invoice. Defaults to custom_plan unless plan_billing_sources is set. + +
+
+ +
+
+ +**plan_billing_sources:** `Schematic::Types::PlanBillingSource` — Filter by multiple billing sources. Takes precedence over plan_billing_source.
@@ -17195,47 +17756,7 @@ client.plans.publish_plan_version(
-**activation_strategy:** `Schematic::Types::CustomPlanActivationStrategy` — When the company gets the plan. On a custom-plan republish, on_payment is only accepted when the amendment is invoiced today (migration_strategy immediate, proration_behavior always_invoice, collection_method send_invoice): the company stays on its current version until that invoice is paid. - -
-
- -
-
- -**address:** `Schematic::Types::CustomerBillingAddress` - -
-
- -
-
- -**billing_cycle_anchor:** `String` — The date the subscription's billing period renews on. Only honored on a first publish that starts a subscription. - -
-
- -
-
- -**billing_start_date:** `String` — The date the contract term starts. A past date backdates the subscription so the first invoice covers the term from this date to the renewal date. Requires billing_cycle_anchor. Only honored on a first publish that starts a subscription. - -
-
- -
-
- -**collection_method:** `Schematic::Types::BillingCollectionMethod` — How the invoice a custom-plan republish raises today is collected. send_invoice (the default) issues it for the company to pay; charge_automatically charges the default payment method straight away. Only accepted on a custom-plan republish with migration_strategy immediate and proration_behavior always_invoice. - -
-
- -
-
- -**coupon_external_id:** `String` — A Stripe coupon to apply. On a custom-plan republish it discounts the amendment invoice and is only used when that invoice is raised today; it must exist in Stripe. It is attached to the subscription, so a repeating or forever coupon also discounts the renewals that follow. +**request:** `Schematic::Types::PublishPlanVersionRequestBody`
@@ -17243,87 +17764,51 @@ client.plans.publish_plan_version(
-**custom_field_values:** `Internal::Types::Array[Schematic::Types::CheckoutFieldValue]` - -
-
- -
-
- -**customer_email:** `String` +**request_options:** `Schematic::Plans::RequestOptions`
- -
-
- -**days_until_due:** `Integer` — Payment terms in days. On a custom-plan republish they apply to the amendment invoice only, leave the subscription's renewal terms unchanged, and are only used when that invoice is raised today and sent rather than charged. Defaults to the subscription's terms. -
-
-
-**excluded_company_ids:** `Internal::Types::Array[String]` -
+ +
client.plans.preview_publish_plan_version(plan_version_id:, request) -> Schematic::Plans::Types::PreviewPublishPlanVersionResponse
-**migration_strategy:** `Schematic::Types::PlanVersionMigrationStrategy` - -
-
+#### 🔌 Usage
-**phone:** `String` - -
-
-
-**prorate_first_period:** `Internal::Types::Boolean` — When true, the partial period between the subscription starting and its renewal date is billed pro rata straight away. When false that period is free and no invoice is raised until the renewal date. Only applies alongside billing_cycle_anchor. Defaults to true. - +```ruby +client.plans.preview_publish_plan_version( + plan_version_id: "plan_version_id", + excluded_company_ids: ["excluded_company_ids"], + migration_strategy: "end_of_billing_period" +) +```
- -
-
- -**proration_behavior:** `Schematic::Types::MigrationProrationBehavior` — How Stripe handles the price difference when companies are migrated. With migration_strategy immediate, omitted means create_prorations. With end_of_billing_period only none is accepted and means the same as omitting it: the change lands on the renewal boundary, so there is nothing to prorate. With scheduled any value is accepted and omitted means none. Not accepted with leave. -
-
-
- -**require_no_migration:** `Internal::Types::Boolean` — Refuse the publish if any company would be migrated onto the new version - -
-
+#### ⚙️ Parameters
-**scheduled_at:** `String` — When every company moves, for migration_strategy scheduled. Must be in the future; the migration runs within about a minute of this time. Not accepted with other strategies. - -
-
-
-**send_invoice:** `Internal::Types::Boolean` — Whether Stripe emails the invoice when it is finalized. Defaults to true. +**plan_version_id:** `String` — plan_version_id
@@ -17331,7 +17816,7 @@ client.plans.publish_plan_version(
-**tax_id:** `Schematic::Types::TaxIdInput` +**request:** `Schematic::Types::PublishPlanVersionRequestBody`
@@ -18973,7 +19458,7 @@ client.features.list_features(
-**without_company_override_for:** `String` — Filter out features that already have a company override for the specified company ID +**without_company_override_for:** `String` — Filter out features that have an unexpired company override for the specified company ID
@@ -19642,7 +20127,7 @@ client.features.count_features(
-**without_company_override_for:** `String` — Filter out features that already have a company override for the specified company ID +**without_company_override_for:** `String` — Filter out features that have an unexpired company override for the specified company ID
@@ -19786,7 +20271,6 @@ client.features.list_flags( ```ruby client.features.create_flag( - default_value: true, description: "description", flag_type: "boolean", key: "key", @@ -19889,7 +20373,6 @@ client.features.get_flag(flag_id: "flag_id") ```ruby client.features.update_flag( flag_id: "flag_id", - default_value: true, description: "description", flag_type: "boolean", key: "key", @@ -20160,7 +20643,7 @@ client.features.check_and_reserve_flag(key: "key")
-**expires_at:** `String` — When the hold lapses if no track event settles it; defaults to one minute from now and may be at most one hour out. The unspent hold is refunded on expiry +**expires_at:** `String` — When the hold lapses if no track or inference event settles it; defaults to one minute from now and may be at most one hour out. The unspent hold is refunded on expiry
@@ -20176,7 +20659,7 @@ client.features.check_and_reserve_flag(key: "key")
-**preflight:** `Schematic::Types::PreflightRequestBody` — Hypothetical usage to evaluate the flag against. When credit_cost names the entitlement's credit, that cost is what gets held; otherwise the hold is the entitlement's consumption rate times quantity, or, when quantity is omitted, times the usage stated here +**preflight:** `Schematic::Types::PreflightRequestBody` — Hypothetical usage to evaluate the flag against. When credit_cost names the entitlement's credit, that cost is what gets held; otherwise, when event_quantities names the entitlement's event subtype, the hold is that event priced at the entitlement's consumption rate and quantity rates, and quantity is ignored; otherwise the hold is the entitlement's consumption rate times quantity, or, when quantity is omitted, times the usage stated here
@@ -20184,7 +20667,7 @@ client.features.check_and_reserve_flag(key: "key")
-**quantity:** `Float` — Units of the feature the operation will consume. Sets the hold size together with the entitlement's consumption rate, and is echoed back on the reservation for the settling track event. When it is omitted the units come from preflight.event_usage.quantity, if that event subtype is the entitlement's, else from preflight.usage, else 1 +**quantity:** `Float` — Units of the feature the operation will consume. Sets the hold size together with the entitlement's consumption rate, and is echoed back on the reservation for the settling track event. When it is omitted the units come from preflight.event_usage.quantity, if that event subtype is the entitlement's, else from preflight.usage, else 1. Ignored when preflight.event_quantities names the entitlement's event subtype, whose quantity is used instead
diff --git a/test/unit/internal/iterators/test_cursor_item_iterator.rb b/test/unit/internal/iterators/test_cursor_item_iterator.rb index 06c2c33..0e21888 100644 --- a/test/unit/internal/iterators/test_cursor_item_iterator.rb +++ b/test/unit/internal/iterators/test_cursor_item_iterator.rb @@ -337,4 +337,27 @@ def test_http_response_is_from_the_most_recent_request assert_equal "response 60", iterator.http_response end + + def test_reads_nested_cursor_and_item_fields + nested_page = Struct.new(:payload, :pagination, keyword_init: true) + payload = Struct.new(:cards, keyword_init: true) + pagination = Struct.new(:next_cursor, keyword_init: true) + cursors = [] + iterator = Schematic::Internal::CursorItemIterator.new( + initial_cursor: nil, + cursor_field: %i[pagination next_cursor], + item_field: %i[payload cards] + ) do |cursor| + cursors << cursor + start = cursor || 0 + next_cursor = start + 10 + nested_page.new( + payload: payload.new(cards: NUMBERS[start...next_cursor]), + pagination: pagination.new(next_cursor: next_cursor < NUMBERS.length ? next_cursor : nil) + ) + end + + assert_equal NUMBERS, iterator.to_a + assert_equal [nil, 10, 20, 30, 40, 50, 60], cursors + end end diff --git a/test/unit/internal/types/test_model.rb b/test/unit/internal/types/test_model.rb index f69b7d5..95388ed 100644 --- a/test/unit/internal/types/test_model.rb +++ b/test/unit/internal/types/test_model.rb @@ -102,6 +102,29 @@ class ExampleWithNumericKeyMaps < Schematic::Internal::Types::Model assert_equal "Christopher Nolan", example.director end + it "drops extra keys that match a declared field case-insensitively" do + example = ExampleModel.load({ name: "Inception", NAME: "Other", YearOfRelease: 1999, Year: 1998 }.to_json) + + assert_equal "Inception", example.name + assert_equal({ "name" => "Inception" }, example.to_h) + refute_respond_to example, :NAME + end + + it "drops case-insensitive collisions even when the declared field is absent" do + example = ExampleModel.new({ "NAME" => "Other", "yearofrelease" => 1999 }) + + assert_nil example.name + refute example.to_h.key?("NAME") + refute example.to_h.key?("yearofrelease") + end + + it "keeps non-colliding extra keys" do + example = ExampleModel.load({ name: "Inception", brand_new_field: "kept" }.to_json) + + assert_equal "kept", example.brand_new_field + assert_equal({ "name" => "Inception", "brand_new_field" => "kept" }, example.to_h) + end + it "sets the defaults where applicable" do example_using_defaults = ExampleWithDefaults.new