Class: Orb::Resources::Items

Inherits:
Object
  • Object
show all
Defined in:
lib/orb/resources/items.rb,
sig/orb/resources/items.rbs

Overview

The Item resource represents a sellable product or good. Items are associated with all line items, billable metrics, and prices and are used for defining external sync behavior for invoices and tax calculation purposes.

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Items

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 Items.

Parameters:



132
133
134
# File 'lib/orb/resources/items.rb', line 132

def initialize(client:)
  @client = client
end

Instance Method Details

#archive(item_id, request_options: {}) ⇒ Orb::Models::Item

Archive item

Parameters:

Returns:

See Also:



101
102
103
104
105
106
107
108
# File 'lib/orb/resources/items.rb', line 101

def archive(item_id, params = {})
  @client.request(
    method: :post,
    path: ["items/%1$s/archive", item_id],
    model: Orb::Item,
    options: params[:request_options]
  )
end

#create(name:, metadata: nil, request_options: {}) ⇒ Orb::Models::Item

Some parameter documentations has been truncated, see Models::ItemCreateParams for more details.

This endpoint is used to create an Item.

Parameters:

  • name (String)

    The name of the item.

  • metadata (Hash{Symbol=>String, nil}, nil)

    User-specified key/value pairs for the resource. Individual keys can be removed

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

Returns:

See Also:



25
26
27
28
# File 'lib/orb/resources/items.rb', line 25

def create(params)
  parsed, options = Orb::ItemCreateParams.dump_request(params)
  @client.request(method: :post, path: "items", body: parsed, model: Orb::Item, options: options)
end

#fetch(item_id, request_options: {}) ⇒ Orb::Models::Item

This endpoint returns an item identified by its item_id.

Parameters:

Returns:

See Also:



120
121
122
123
124
125
126
127
# File 'lib/orb/resources/items.rb', line 120

def fetch(item_id, params = {})
  @client.request(
    method: :get,
    path: ["items/%1$s", item_id],
    model: Orb::Item,
    options: params[:request_options]
  )
end

#list(cursor: nil, limit: nil, request_options: {}) ⇒ Orb::Internal::Page<Orb::Models::Item>

Some parameter documentations has been truncated, see Models::ItemListParams for more details.

This endpoint returns a list of all Items, ordered in descending order by creation time.

Parameters:

  • cursor (String, nil)

    Cursor for pagination. This can be populated by the next_cursor value returned

  • limit (Integer)

    The number of items to fetch. Defaults to 20.

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

Returns:

See Also:



78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/orb/resources/items.rb', line 78

def list(params = {})
  parsed, options = Orb::ItemListParams.dump_request(params)
  query = Orb::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "items",
    query: query,
    page: Orb::Internal::Page,
    model: Orb::Item,
    options: options
  )
end

#update(item_id, external_connections: nil, metadata: nil, name: nil, request_options: {}) ⇒ Orb::Models::Item

Some parameter documentations has been truncated, see Models::ItemUpdateParams for more details.

This endpoint can be used to update properties on the Item.

Parameters:

Returns:

See Also:



50
51
52
53
54
55
56
57
58
59
# File 'lib/orb/resources/items.rb', line 50

def update(item_id, params = {})
  parsed, options = Orb::ItemUpdateParams.dump_request(params)
  @client.request(
    method: :put,
    path: ["items/%1$s", item_id],
    body: parsed,
    model: Orb::Item,
    options: options
  )
end