Class: Schematic::Billing::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/schematic/billing/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ void



9
10
11
# File 'lib/schematic/billing/client.rb', line 9

def initialize(client:)
  @client = client
end

Instance Method Details

#count_billing_products(request_options: {}, **params) ⇒ Schematic::Billing::Types::CountBillingProductsResponse

Examples:

client.billing.count_billing_products(
  ids: ["ids"],
  is_active: true,
  name: "name",
  price_usage_type: "licensed",
  provider_type: "metronome",
  q: "q",
  recurring_charges_only: true,
  with_one_time_charges: true,
  with_prices_only: true,
  with_zero_price: true,
  without_linked_to_plan: true,
  limit: 1000000,
  offset: 1000000
)

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :ids (String, nil)
  • :is_active (Boolean, nil)
  • :name (String, nil)
  • :price_usage_type (Schematic::Types::BillingPriceUsageType, nil)
  • :provider_type (Schematic::Types::BillingProviderType, nil)
  • :q (String, nil)
  • :recurring_charges_only (Boolean, nil)
  • :with_one_time_charges (Boolean, nil)
  • :with_prices_only (Boolean, nil)
  • :with_zero_price (Boolean, nil)
  • :without_linked_to_plan (Boolean, nil)
  • :limit (Integer, nil)
  • :offset (Integer, nil)

Returns:



1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
# File 'lib/schematic/billing/client.rb', line 1129

def count_billing_products(request_options: {}, **params)
  params = Schematic::Internal::Types::Utils.normalize_keys(params)
  query_params = {}
  query_params["ids"] = params[:ids] if params.key?(:ids)
  query_params["is_active"] = params[:is_active] if params.key?(:is_active)
  query_params["name"] = params[:name] if params.key?(:name)
  query_params["price_usage_type"] = params[:price_usage_type] if params.key?(:price_usage_type)
  query_params["provider_type"] = params[:provider_type] if params.key?(:provider_type)
  query_params["q"] = params[:q] if params.key?(:q)
  query_params["recurring_charges_only"] = params[:recurring_charges_only] if params.key?(:recurring_charges_only)
  query_params["with_one_time_charges"] = params[:with_one_time_charges] if params.key?(:with_one_time_charges)
  query_params["with_prices_only"] = params[:with_prices_only] if params.key?(:with_prices_only)
  query_params["with_zero_price"] = params[:with_zero_price] if params.key?(:with_zero_price)
  query_params["without_linked_to_plan"] = params[:without_linked_to_plan] if params.key?(:without_linked_to_plan)
  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: "billing/products/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)
    Schematic::Billing::Types::CountBillingProductsResponse.load(response.body)
  else
    error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#count_customers(request_options: {}, **params) ⇒ Schematic::Billing::Types::CountCustomersResponse

Examples:

client.billing.count_customers(
  company_ids: ["company_ids"],
  name: "name",
  provider_type: "metronome",
  q: "q",
  limit: 1000000,
  offset: 1000000
)

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

Returns:



300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
# File 'lib/schematic/billing/client.rb', line 300

def count_customers(request_options: {}, **params)
  params = Schematic::Internal::Types::Utils.normalize_keys(params)
  query_params = {}
  query_params["company_ids"] = params[:company_ids] if params.key?(:company_ids)
  query_params["name"] = params[:name] if params.key?(:name)
  query_params["provider_type"] = params[:provider_type] if params.key?(:provider_type)
  query_params["q"] = params[:q] if params.key?(:q)
  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: "billing/customers/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)
    Schematic::Billing::Types::CountCustomersResponse.load(response.body)
  else
    error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#delete_billing_coupon(request_options: {}, **params) ⇒ Schematic::Billing::Types::DeleteBillingCouponResponse

Examples:

client.billing.delete_billing_coupon(billing_id: "billing_id")

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :billing_id (String)

Returns:



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/schematic/billing/client.rb', line 120

def delete_billing_coupon(request_options: {}, **params)
  params = Schematic::Internal::Types::Utils.normalize_keys(params)
  request = Schematic::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "DELETE",
    path: "billing/coupons/#{URI.encode_uri_component(params[:billing_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)
    Schematic::Billing::Types::DeleteBillingCouponResponse.load(response.body)
  else
    error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#delete_billing_customer(request_options: {}, **params) ⇒ Schematic::Billing::Types::DeleteBillingCustomerResponse

Examples:

client.billing.delete_billing_customer(billing_id: "billing_id")

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :billing_id (String)

Returns:



155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# File 'lib/schematic/billing/client.rb', line 155

def delete_billing_customer(request_options: {}, **params)
  params = Schematic::Internal::Types::Utils.normalize_keys(params)
  request = Schematic::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "DELETE",
    path: "billing/customer/#{URI.encode_uri_component(params[:billing_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)
    Schematic::Billing::Types::DeleteBillingCustomerResponse.load(response.body)
  else
    error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#delete_billing_invoice(request_options: {}, **params) ⇒ Schematic::Billing::Types::DeleteBillingInvoiceResponse

Examples:

client.billing.delete_billing_invoice(billing_id: "billing_id")

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :billing_id (String)

Returns:



440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
# File 'lib/schematic/billing/client.rb', line 440

def delete_billing_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: "DELETE",
    path: "billing/invoices/#{URI.encode_uri_component(params[:billing_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)
    Schematic::Billing::Types::DeleteBillingInvoiceResponse.load(response.body)
  else
    error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#delete_billing_product(request_options: {}, **params) ⇒ Schematic::Billing::Types::DeleteBillingProductResponse

Examples:

client.billing.delete_billing_product(billing_id: "billing_id")

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :billing_id (String)

Returns:



826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
# File 'lib/schematic/billing/client.rb', line 826

def delete_billing_product(request_options: {}, **params)
  params = Schematic::Internal::Types::Utils.normalize_keys(params)
  request = Schematic::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "DELETE",
    path: "billing/product/#{URI.encode_uri_component(params[:billing_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)
    Schematic::Billing::Types::DeleteBillingProductResponse.load(response.body)
  else
    error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#delete_payment_method_by_external_id(request_options: {}, **params) ⇒ Schematic::Billing::Types::DeletePaymentMethodByExternalIdResponse

Examples:

client.billing.delete_payment_method_by_external_id(billing_id: "billing_id")

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :billing_id (String)

Returns:



651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
# File 'lib/schematic/billing/client.rb', line 651

def delete_payment_method_by_external_id(request_options: {}, **params)
  params = Schematic::Internal::Types::Utils.normalize_keys(params)
  request = Schematic::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "DELETE",
    path: "billing/payment-methods/#{URI.encode_uri_component(params[:billing_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)
    Schematic::Billing::Types::DeletePaymentMethodByExternalIdResponse.load(response.body)
  else
    error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#delete_product_price(request_options: {}, **params) ⇒ Schematic::Billing::Types::DeleteProductPriceResponse

Examples:

client.billing.delete_product_price(billing_id: "billing_id")

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :billing_id (String)

Returns:



953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
# File 'lib/schematic/billing/client.rb', line 953

def delete_product_price(request_options: {}, **params)
  params = Schematic::Internal::Types::Utils.normalize_keys(params)
  request = Schematic::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "DELETE",
    path: "billing/product/prices/#{URI.encode_uri_component(params[:billing_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)
    Schematic::Billing::Types::DeleteProductPriceResponse.load(response.body)
  else
    error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#list_billing_prices(request_options: {}, **params) ⇒ Schematic::Billing::Types::ListBillingPricesResponse

Examples:

client.billing.list_billing_prices(
  currency: "currency",
  for_initial_plan: true,
  for_trial_expiry_plan: true,
  ids: ["ids"],
  interval: "interval",
  interval_count: 1000000,
  is_active: true,
  plan_version_id: "plan_version_id",
  price: 1000000,
  product_id: "product_id",
  product_ids: ["product_ids"],
  provider_type: "metronome",
  q: "q",
  tiers_mode: "graduated",
  usage_type: "licensed",
  with_meter: true,
  limit: 1000000,
  offset: 1000000
)

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :currency (String, nil)
  • :for_initial_plan (Boolean, nil)
  • :for_trial_expiry_plan (Boolean, nil)
  • :ids (String, nil)
  • :interval (String, nil)
  • :interval_count (Integer, nil)
  • :is_active (Boolean, nil)
  • :plan_version_id (String, nil)
  • :price (Integer, nil)
  • :product_id (String, nil)
  • :product_ids (String, nil)
  • :provider_type (Schematic::Types::BillingProviderType, nil)
  • :q (String, nil)
  • :tiers_mode (Schematic::Types::BillingTiersMode, nil)
  • :usage_type (Schematic::Types::BillingPriceUsageType, nil)
  • :with_meter (Boolean, nil)
  • :limit (Integer, nil)
  • :offset (Integer, nil)

Returns:



722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
# File 'lib/schematic/billing/client.rb', line 722

def list_billing_prices(request_options: {}, **params)
  params = Schematic::Internal::Types::Utils.normalize_keys(params)
  query_params = {}
  query_params["currency"] = params[:currency] if params.key?(:currency)
  query_params["for_initial_plan"] = params[:for_initial_plan] if params.key?(:for_initial_plan)
  query_params["for_trial_expiry_plan"] = params[:for_trial_expiry_plan] if params.key?(:for_trial_expiry_plan)
  query_params["ids"] = params[:ids] if params.key?(:ids)
  query_params["interval"] = params[:interval] if params.key?(:interval)
  query_params["interval_count"] = params[:interval_count] if params.key?(:interval_count)
  query_params["is_active"] = params[:is_active] if params.key?(:is_active)
  query_params["plan_version_id"] = params[:plan_version_id] if params.key?(:plan_version_id)
  query_params["price"] = params[:price] if params.key?(:price)
  query_params["product_id"] = params[:product_id] if params.key?(:product_id)
  query_params["product_ids"] = params[:product_ids] if params.key?(:product_ids)
  query_params["provider_type"] = params[:provider_type] if params.key?(:provider_type)
  query_params["q"] = params[:q] if params.key?(:q)
  query_params["tiers_mode"] = params[:tiers_mode] if params.key?(:tiers_mode)
  query_params["usage_type"] = params[:usage_type] if params.key?(:usage_type)
  query_params["with_meter"] = params[:with_meter] if params.key?(:with_meter)
  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: "billing/price",
    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)
    Schematic::Billing::Types::ListBillingPricesResponse.load(response.body)
  else
    error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#list_billing_product_prices(request_options: {}, **params) ⇒ Schematic::Billing::Types::ListBillingProductPricesResponse

Examples:

client.billing.list_billing_product_prices(
  currency: "currency",
  for_initial_plan: true,
  for_trial_expiry_plan: true,
  ids: ["ids"],
  interval: "interval",
  interval_count: 1000000,
  is_active: true,
  plan_version_id: "plan_version_id",
  price: 1000000,
  product_id: "product_id",
  product_ids: ["product_ids"],
  provider_type: "metronome",
  q: "q",
  tiers_mode: "graduated",
  usage_type: "licensed",
  with_meter: true,
  limit: 1000000,
  offset: 1000000
)

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :currency (String, nil)
  • :for_initial_plan (Boolean, nil)
  • :for_trial_expiry_plan (Boolean, nil)
  • :ids (String, nil)
  • :interval (String, nil)
  • :interval_count (Integer, nil)
  • :is_active (Boolean, nil)
  • :plan_version_id (String, nil)
  • :price (Integer, nil)
  • :product_id (String, nil)
  • :product_ids (String, nil)
  • :provider_type (Schematic::Types::BillingProviderType, nil)
  • :q (String, nil)
  • :tiers_mode (Schematic::Types::BillingTiersMode, nil)
  • :usage_type (Schematic::Types::BillingPriceUsageType, nil)
  • :with_meter (Boolean, nil)
  • :limit (Integer, nil)
  • :offset (Integer, nil)

Returns:



897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
# File 'lib/schematic/billing/client.rb', line 897

def list_billing_product_prices(request_options: {}, **params)
  params = Schematic::Internal::Types::Utils.normalize_keys(params)
  query_params = {}
  query_params["currency"] = params[:currency] if params.key?(:currency)
  query_params["for_initial_plan"] = params[:for_initial_plan] if params.key?(:for_initial_plan)
  query_params["for_trial_expiry_plan"] = params[:for_trial_expiry_plan] if params.key?(:for_trial_expiry_plan)
  query_params["ids"] = params[:ids] if params.key?(:ids)
  query_params["interval"] = params[:interval] if params.key?(:interval)
  query_params["interval_count"] = params[:interval_count] if params.key?(:interval_count)
  query_params["is_active"] = params[:is_active] if params.key?(:is_active)
  query_params["plan_version_id"] = params[:plan_version_id] if params.key?(:plan_version_id)
  query_params["price"] = params[:price] if params.key?(:price)
  query_params["product_id"] = params[:product_id] if params.key?(:product_id)
  query_params["product_ids"] = params[:product_ids] if params.key?(:product_ids)
  query_params["provider_type"] = params[:provider_type] if params.key?(:provider_type)
  query_params["q"] = params[:q] if params.key?(:q)
  query_params["tiers_mode"] = params[:tiers_mode] if params.key?(:tiers_mode)
  query_params["usage_type"] = params[:usage_type] if params.key?(:usage_type)
  query_params["with_meter"] = params[:with_meter] if params.key?(:with_meter)
  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: "billing/product/prices",
    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)
    Schematic::Billing::Types::ListBillingProductPricesResponse.load(response.body)
  else
    error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#list_billing_products(request_options: {}, **params) ⇒ Schematic::Billing::Types::ListBillingProductsResponse

Examples:

client.billing.list_billing_products(
  ids: ["ids"],
  is_active: true,
  name: "name",
  price_usage_type: "licensed",
  provider_type: "metronome",
  q: "q",
  recurring_charges_only: true,
  with_one_time_charges: true,
  with_prices_only: true,
  with_zero_price: true,
  without_linked_to_plan: true,
  limit: 1000000,
  offset: 1000000
)

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :ids (String, nil)
  • :is_active (Boolean, nil)
  • :name (String, nil)
  • :price_usage_type (Schematic::Types::BillingPriceUsageType, nil)
  • :provider_type (Schematic::Types::BillingProviderType, nil)
  • :q (String, nil)
  • :recurring_charges_only (Boolean, nil)
  • :with_one_time_charges (Boolean, nil)
  • :with_prices_only (Boolean, nil)
  • :with_zero_price (Boolean, nil)
  • :without_linked_to_plan (Boolean, nil)
  • :limit (Integer, nil)
  • :offset (Integer, nil)

Returns:



1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
# File 'lib/schematic/billing/client.rb', line 1052

def list_billing_products(request_options: {}, **params)
  params = Schematic::Internal::Types::Utils.normalize_keys(params)
  query_params = {}
  query_params["ids"] = params[:ids] if params.key?(:ids)
  query_params["is_active"] = params[:is_active] if params.key?(:is_active)
  query_params["name"] = params[:name] if params.key?(:name)
  query_params["price_usage_type"] = params[:price_usage_type] if params.key?(:price_usage_type)
  query_params["provider_type"] = params[:provider_type] if params.key?(:provider_type)
  query_params["q"] = params[:q] if params.key?(:q)
  query_params["recurring_charges_only"] = params[:recurring_charges_only] if params.key?(:recurring_charges_only)
  query_params["with_one_time_charges"] = params[:with_one_time_charges] if params.key?(:with_one_time_charges)
  query_params["with_prices_only"] = params[:with_prices_only] if params.key?(:with_prices_only)
  query_params["with_zero_price"] = params[:with_zero_price] if params.key?(:with_zero_price)
  query_params["without_linked_to_plan"] = params[:without_linked_to_plan] if params.key?(:without_linked_to_plan)
  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: "billing/products",
    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)
    Schematic::Billing::Types::ListBillingProductsResponse.load(response.body)
  else
    error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#list_coupons(request_options: {}, **params) ⇒ Schematic::Billing::Types::ListCouponsResponse

Examples:

client.billing.list_coupons(
  is_active: true,
  q: "q",
  limit: 1000000,
  offset: 1000000
)

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :is_active (Boolean, nil)
  • :q (String, nil)
  • :limit (Integer, nil)
  • :offset (Integer, nil)

Returns:



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/schematic/billing/client.rb', line 34

def list_coupons(request_options: {}, **params)
  params = Schematic::Internal::Types::Utils.normalize_keys(params)
  query_params = {}
  query_params["is_active"] = params[:is_active] if params.key?(:is_active)
  query_params["q"] = params[:q] if params.key?(:q)
  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: "billing/coupons",
    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)
    Schematic::Billing::Types::ListCouponsResponse.load(response.body)
  else
    error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#list_customers_with_subscriptions(request_options: {}, **params) ⇒ Schematic::Billing::Types::ListCustomersWithSubscriptionsResponse

Examples:

client.billing.list_customers_with_subscriptions(
  company_ids: ["company_ids"],
  name: "name",
  provider_type: "metronome",
  q: "q",
  limit: 1000000,
  offset: 1000000
)

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

Returns:



244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
# File 'lib/schematic/billing/client.rb', line 244

def list_customers_with_subscriptions(request_options: {}, **params)
  params = Schematic::Internal::Types::Utils.normalize_keys(params)
  query_params = {}
  query_params["company_ids"] = params[:company_ids] if params.key?(:company_ids)
  query_params["name"] = params[:name] if params.key?(:name)
  query_params["provider_type"] = params[:provider_type] if params.key?(:provider_type)
  query_params["q"] = params[:q] if params.key?(:q)
  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: "billing/customers",
    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)
    Schematic::Billing::Types::ListCustomersWithSubscriptionsResponse.load(response.body)
  else
    error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#list_invoices(request_options: {}, **params) ⇒ Schematic::Billing::Types::ListInvoicesResponse

Examples:

client.billing.list_invoices(
  company_id: "company_id",
  customer_external_id: "customer_external_id",
  subscription_external_id: "subscription_external_id",
  limit: 1000000,
  offset: 1000000
)

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :company_id (String, nil)
  • :customer_external_id (String)
  • :subscription_external_id (String)
  • :limit (Integer, nil)
  • :offset (Integer, nil)

Returns:



354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
# File 'lib/schematic/billing/client.rb', line 354

def list_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["customer_external_id"] = params[:customer_external_id] if params.key?(:customer_external_id)
  query_params["subscription_external_id"] = params[:subscription_external_id] if params.key?(:subscription_external_id)
  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: "billing/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)
    Schematic::Billing::Types::ListInvoicesResponse.load(response.body)
  else
    error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#list_meters(request_options: {}, **params) ⇒ Schematic::Billing::Types::ListMetersResponse

Examples:

client.billing.list_meters(
  display_name: "display_name",
  limit: 1000000,
  offset: 1000000
)

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :display_name (String, nil)
  • :limit (Integer, nil)
  • :offset (Integer, nil)

Returns:



481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
# File 'lib/schematic/billing/client.rb', line 481

def list_meters(request_options: {}, **params)
  params = Schematic::Internal::Types::Utils.normalize_keys(params)
  query_params = {}
  query_params["display_name"] = params[:display_name] if params.key?(:display_name)
  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: "billing/meter",
    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)
    Schematic::Billing::Types::ListMetersResponse.load(response.body)
  else
    error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#list_payment_methods(request_options: {}, **params) ⇒ Schematic::Billing::Types::ListPaymentMethodsResponse

Examples:

client.billing.list_payment_methods(
  company_id: "company_id",
  customer_external_id: "customer_external_id",
  limit: 1000000,
  offset: 1000000
)

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :company_id (String, nil)
  • :customer_external_id (String)
  • :limit (Integer, nil)
  • :offset (Integer, nil)

Returns:



570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
# File 'lib/schematic/billing/client.rb', line 570

def list_payment_methods(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["customer_external_id"] = params[:customer_external_id] if params.key?(:customer_external_id)
  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: "billing/payment-methods",
    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)
    Schematic::Billing::Types::ListPaymentMethodsResponse.load(response.body)
  else
    error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#upsert_billing_coupon(request_options: {}, **params) ⇒ Schematic::Billing::Types::UpsertBillingCouponResponse

Examples:

client.billing.upsert_billing_coupon(
  amount_off: 1000000,
  duration: "duration",
  duration_in_months: 1000000,
  external_id: "external_id",
  max_redemptions: 1000000,
  name: "name",
  percent_off: 1.1,
  times_redeemed: 1000000
)

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Returns:



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/schematic/billing/client.rb', line 84

def upsert_billing_coupon(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: "billing/coupons",
    body: Schematic::Billing::Types::CreateCouponRequestBody.new(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)
    Schematic::Billing::Types::UpsertBillingCouponResponse.load(response.body)
  else
    error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#upsert_billing_customer(request_options: {}, **params) ⇒ Schematic::Billing::Types::UpsertBillingCustomerResponse

Examples:

client.billing.upsert_billing_customer(
  email: "email",
  external_id: "external_id",
  meta: {
    key: "value"
  },
  name: "name"
)

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Returns:



196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
# File 'lib/schematic/billing/client.rb', line 196

def upsert_billing_customer(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: "billing/customer/upsert",
    body: Schematic::Billing::Types::CreateBillingCustomerRequestBody.new(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)
    Schematic::Billing::Types::UpsertBillingCustomerResponse.load(response.body)
  else
    error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#upsert_billing_meter(request_options: {}, **params) ⇒ Schematic::Billing::Types::UpsertBillingMeterResponse

Examples:

client.billing.upsert_billing_meter(
  display_name: "display_name",
  event_name: "event_name",
  event_payload_key: "event_payload_key",
  external_id: "external_id"
)

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Returns:



526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
# File 'lib/schematic/billing/client.rb', line 526

def upsert_billing_meter(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: "billing/meter/upsert",
    body: Schematic::Billing::Types::CreateMeterRequestBody.new(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)
    Schematic::Billing::Types::UpsertBillingMeterResponse.load(response.body)
  else
    error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#upsert_billing_price(request_options: {}, **params) ⇒ Schematic::Billing::Types::UpsertBillingPriceResponse

Examples:

client.billing.upsert_billing_price(
  billing_scheme: "per_unit",
  currency: "currency",
  external_account_id: "external_account_id",
  interval: "interval",
  is_active: true,
  price: 1000000,
  price_external_id: "price_external_id",
  price_tiers: [{
    price_external_id: "price_external_id"
  }],
  product_external_id: "product_external_id",
  usage_type: "licensed"
)

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Returns:



790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
# File 'lib/schematic/billing/client.rb', line 790

def upsert_billing_price(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: "billing/price/upsert",
    body: Schematic::Billing::Types::CreateBillingPriceRequestBody.new(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)
    Schematic::Billing::Types::UpsertBillingPriceResponse.load(response.body)
  else
    error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#upsert_billing_product(request_options: {}, **params) ⇒ Schematic::Billing::Types::UpsertBillingProductResponse

Examples:

client.billing.upsert_billing_product(
  external_id: "external_id",
  price: 1.1
)

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Returns:



990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
# File 'lib/schematic/billing/client.rb', line 990

def upsert_billing_product(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: "billing/product/upsert",
    body: Schematic::Billing::Types::CreateBillingProductRequestBody.new(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)
    Schematic::Billing::Types::UpsertBillingProductResponse.load(response.body)
  else
    error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#upsert_billing_subscription(request_options: {}, **params) ⇒ Schematic::Billing::Types::UpsertBillingSubscriptionResponse

Examples:

client.billing.upsert_billing_subscription(
  cancel_at_period_end: true,
  currency: "currency",
  customer_external_id: "customer_external_id",
  discounts: [{
    coupon_external_id: "coupon_external_id",
    external_id: "external_id",
    is_active: true,
    started_at: "2024-01-15T09:30:00Z"
  }],
  expired_at: "2024-01-15T09:30:00Z",
  product_external_ids: [{
    currency: "currency",
    interval: "interval",
    price: 1000000,
    price_external_id: "price_external_id",
    product_external_id: "product_external_id",
    quantity: 1000000,
    usage_type: "licensed"
  }],
  subscription_external_id: "subscription_external_id",
  total_price: 1000000
)

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Returns:



1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
# File 'lib/schematic/billing/client.rb', line 1201

def upsert_billing_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: "POST",
    path: "billing/subscription/upsert",
    body: Schematic::Billing::Types::CreateBillingSubscriptionRequestBody.new(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)
    Schematic::Billing::Types::UpsertBillingSubscriptionResponse.load(response.body)
  else
    error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#upsert_invoice(request_options: {}, **params) ⇒ Schematic::Billing::Types::UpsertInvoiceResponse

Examples:

client.billing.upsert_invoice(
  amount_due: 1000000,
  amount_paid: 1000000,
  amount_remaining: 1000000,
  collection_method: "collection_method",
  currency: "currency",
  customer_external_id: "customer_external_id",
  subtotal: 1000000
)

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Returns:



404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
# File 'lib/schematic/billing/client.rb', line 404

def upsert_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: "billing/invoices",
    body: Schematic::Billing::Types::CreateInvoiceRequestBody.new(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)
    Schematic::Billing::Types::UpsertInvoiceResponse.load(response.body)
  else
    error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#upsert_payment_method(request_options: {}, **params) ⇒ Schematic::Billing::Types::UpsertPaymentMethodResponse

Examples:

client.billing.upsert_payment_method(
  customer_external_id: "customer_external_id",
  external_id: "external_id",
  payment_method_type: "payment_method_type"
)

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Returns:



615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
# File 'lib/schematic/billing/client.rb', line 615

def upsert_payment_method(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: "billing/payment-methods",
    body: Schematic::Billing::Types::CreatePaymentMethodRequestBody.new(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)
    Schematic::Billing::Types::UpsertPaymentMethodResponse.load(response.body)
  else
    error_class = Schematic::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end