Class: MetronomeSDK::Resources::V1::Contracts::Products

Inherits:
Object
  • Object
show all
Defined in:
lib/metronome_sdk/resources/v1/contracts/products.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Products

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Products.

Parameters:



211
212
213
# File 'lib/metronome_sdk/resources/v1/contracts/products.rb', line 211

def initialize(client:)
  @client = client
end

Instance Method Details

#archive(product_id: , request_options: {}) ⇒ MetronomeSDK::Models::V1::Contracts::ProductArchiveResponse

Archive a product. Any current rate cards associated with this product will continue to function as normal. However, it will no longer be available as an option for newly created rates. Once you archive a product, you can still retrieve it in the UI and API, but you cannot unarchive it.

Parameters:

Returns:

See Also:



197
198
199
200
201
202
203
204
205
206
# File 'lib/metronome_sdk/resources/v1/contracts/products.rb', line 197

def archive(params)
  parsed, options = MetronomeSDK::V1::Contracts::ProductArchiveParams.dump_request(params)
  @client.request(
    method: :post,
    path: "v1/contract-pricing/products/archive",
    body: parsed,
    model: MetronomeSDK::Models::V1::Contracts::ProductArchiveResponse,
    options: options
  )
end

#create(name: , type: , billable_metric_id: nil, composite_product_ids: nil, composite_tags: nil, custom_fields: nil, exclude_free_usage: nil, is_refundable: nil, netsuite_internal_item_id: nil, netsuite_overage_item_id: nil, presentation_group_key: nil, pricing_group_key: nil, quantity_conversion: nil, quantity_rounding: nil, tags: nil, request_options: {}) ⇒ MetronomeSDK::Models::V1::Contracts::ProductCreateResponse

Some parameter documentations has been truncated, see Models::V1::Contracts::ProductCreateParams for more details.

Create a new product object. Products in Metronome represent your company’s individual product or service offerings. A Product can be thought of as the basic unit of a line item on the invoice. This is analogous to SKUs or items in an ERP system. Give the product a meaningful name as they will appear on customer invoices.

Parameters:

  • name (String)

    displayed on invoices

  • type (Symbol, MetronomeSDK::Models::V1::Contracts::ProductCreateParams::Type)
  • billable_metric_id (String)

    Required for USAGE products

  • composite_product_ids (Array<String>)

    Required for COMPOSITE products

  • composite_tags (Array<String>)

    Required for COMPOSITE products

  • custom_fields (Hash{Symbol=>String})

    Custom fields to be added eg. { “key1”: “value1”, “key2”: “value2” }

  • exclude_free_usage (Boolean)

    Beta feature only available for composite products. If true, products with $0 wi

  • is_refundable (Boolean)

    This field’s availability is dependent on your client’s configuration. Defaults

  • netsuite_internal_item_id (String)

    This field’s availability is dependent on your client’s configuration.

  • netsuite_overage_item_id (String)

    This field’s availability is dependent on your client’s configuration.

  • presentation_group_key (Array<String>)

    For USAGE products only. Groups usage line items on invoices. The superset of va

  • pricing_group_key (Array<String>)

    For USAGE products only. If set, pricing for this product will be determined for

  • quantity_conversion (MetronomeSDK::Models::V1::Contracts::QuantityConversion, nil)

    Optional. Only valid for USAGE products. If provided, the quantity will be conve

  • quantity_rounding (MetronomeSDK::Models::V1::Contracts::QuantityRounding, nil)

    Optional. Only valid for USAGE products. If provided, the quantity will be round

  • tags (Array<String>)
  • request_options (MetronomeSDK::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



54
55
56
57
58
59
60
61
62
63
# File 'lib/metronome_sdk/resources/v1/contracts/products.rb', line 54

def create(params)
  parsed, options = MetronomeSDK::V1::Contracts::ProductCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "v1/contract-pricing/products/create",
    body: parsed,
    model: MetronomeSDK::Models::V1::Contracts::ProductCreateResponse,
    options: options
  )
end

#list(limit: nil, next_page: nil, archive_filter: nil, request_options: {}) ⇒ MetronomeSDK::Internal::CursorPage<MetronomeSDK::Models::V1::Contracts::ProductListResponse>

Some parameter documentations has been truncated, see Models::V1::Contracts::ProductListParams for more details.

Get a paginated list of all products in your organization with their complete configuration, version history, and metadata. By default excludes archived products unless explicitly requested via the ‘archive_filter` parameter.

Parameters:

Returns:

See Also:



169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/metronome_sdk/resources/v1/contracts/products.rb', line 169

def list(params = {})
  parsed, options = MetronomeSDK::V1::Contracts::ProductListParams.dump_request(params)
  query_params = [:limit, :next_page]
  @client.request(
    method: :post,
    path: "v1/contract-pricing/products/list",
    query: parsed.slice(*query_params),
    body: parsed.except(*query_params),
    page: MetronomeSDK::Internal::CursorPage,
    model: MetronomeSDK::Models::V1::Contracts::ProductListResponse,
    options: options
  )
end

#retrieve(id: , request_options: {}) ⇒ MetronomeSDK::Models::V1::Contracts::ProductRetrieveResponse

Retrieve a product by its ID, including all metadata and historical changes.

Parameters:

Returns:

See Also:



75
76
77
78
79
80
81
82
83
84
# File 'lib/metronome_sdk/resources/v1/contracts/products.rb', line 75

def retrieve(params)
  parsed, options = MetronomeSDK::V1::Contracts::ProductRetrieveParams.dump_request(params)
  @client.request(
    method: :post,
    path: "v1/contract-pricing/products/get",
    body: parsed,
    model: MetronomeSDK::Models::V1::Contracts::ProductRetrieveResponse,
    options: options
  )
end

#update(product_id: , starting_at: , billable_metric_id: nil, composite_product_ids: nil, composite_tags: nil, exclude_free_usage: nil, is_refundable: nil, name: nil, netsuite_internal_item_id: nil, netsuite_overage_item_id: nil, presentation_group_key: nil, pricing_group_key: nil, quantity_conversion: nil, quantity_rounding: nil, tags: nil, request_options: {}) ⇒ MetronomeSDK::Models::V1::Contracts::ProductUpdateResponse

Some parameter documentations has been truncated, see Models::V1::Contracts::ProductUpdateParams for more details.

Updates a product’s configuration while maintaining billing continuity for active customers. Use this endpoint to modify product names, metrics, pricing rules, and composite settings without disrupting ongoing billing cycles. Changes are scheduled using the starting_at timestamp, which must be on an hour boundary—set future dates to schedule updates ahead of time, or past dates for retroactive changes. Returns the updated product ID upon success.

### Usage guidance:

  • Product type cannot be changed after creation. For incorrect product types, create a new product and archive the original instead.

Parameters:

  • product_id (String)

    ID of the product to update

  • starting_at (Time)

    Timestamp representing when the update should go into effect. It must be on an h

  • billable_metric_id (String)

    Available for USAGE products only. If not provided, defaults to product’s curren

  • composite_product_ids (Array<String>)

    Available for COMPOSITE products only. If not provided, defaults to product’s cu

  • composite_tags (Array<String>)

    Available for COMPOSITE products only. If not provided, defaults to product’s cu

  • exclude_free_usage (Boolean)

    Beta feature only available for composite products. If true, products with $0 wi

  • is_refundable (Boolean)

    Defaults to product’s current refundability status. This field’s availability is

  • name (String)

    displayed on invoices. If not provided, defaults to product’s current name.

  • netsuite_internal_item_id (String)

    If not provided, defaults to product’s current netsuite_internal_item_id. This f

  • netsuite_overage_item_id (String)

    Available for USAGE and COMPOSITE products only. If not provided, defaults to pr

  • presentation_group_key (Array<String>)

    For USAGE products only. Groups usage line items on invoices. The superset of va

  • pricing_group_key (Array<String>)

    For USAGE products only. If set, pricing for this product will be determined for

  • quantity_conversion (MetronomeSDK::Models::V1::Contracts::QuantityConversion, nil)

    Optional. Only valid for USAGE products. If provided, the quantity will be conve

  • quantity_rounding (MetronomeSDK::Models::V1::Contracts::QuantityRounding, nil)

    Optional. Only valid for USAGE products. If provided, the quantity will be round

  • tags (Array<String>)

    If not provided, defaults to product’s current tags

  • request_options (MetronomeSDK::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



138
139
140
141
142
143
144
145
146
147
# File 'lib/metronome_sdk/resources/v1/contracts/products.rb', line 138

def update(params)
  parsed, options = MetronomeSDK::V1::Contracts::ProductUpdateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "v1/contract-pricing/products/update",
    body: parsed,
    model: MetronomeSDK::Models::V1::Contracts::ProductUpdateResponse,
    options: options
  )
end