Class: ModernTreasury::Resources::Invoices::LineItems

Inherits:
Object
  • Object
show all
Defined in:
lib/modern_treasury/resources/invoices/line_items.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ LineItems

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

Parameters:



175
176
177
# File 'lib/modern_treasury/resources/invoices/line_items.rb', line 175

def initialize(client:)
  @client = client
end

Instance Method Details

#create(invoice_id, name: , unit_amount: , description: nil, direction: nil, metadata: nil, quantity: nil, unit_amount_decimal: nil, request_options: {}) ⇒ ModernTreasury::Models::Invoices::InvoiceLineItem

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

create invoice_line_item

Parameters:

  • invoice_id (String)

    invoice_id

  • name (String)

    The name of the line item, typically a product or SKU name.

  • unit_amount (Integer)

    The cost per unit of the product or service that this line item is for,

  • description (String)

    An optional free-form description of the line item.

  • direction (String)

    Either ‘debit` or `credit`. `debit` indicates that a client owes the business mo

  • metadata (Hash{Symbol=>String})

    Additional data represented as key-value pairs. Both the key and value must be s

  • quantity (Integer)

    The number of units of a product or service that this line item is for.

  • unit_amount_decimal (String)

    The cost per unit of the product or service that this line item is for,

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

Returns:

See Also:



35
36
37
38
39
40
41
42
43
44
# File 'lib/modern_treasury/resources/invoices/line_items.rb', line 35

def create(invoice_id, params)
  parsed, options = ModernTreasury::Invoices::LineItemCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["api/invoices/%1$s/invoice_line_items", invoice_id],
    body: parsed,
    model: ModernTreasury::Invoices::InvoiceLineItem,
    options: options
  )
end

#delete(id, invoice_id: , request_options: {}) ⇒ ModernTreasury::Models::Invoices::InvoiceLineItem

delete invoice_line_item

Parameters:

Returns:

See Also:



158
159
160
161
162
163
164
165
166
167
168
169
170
# File 'lib/modern_treasury/resources/invoices/line_items.rb', line 158

def delete(id, params)
  parsed, options = ModernTreasury::Invoices::LineItemDeleteParams.dump_request(params)
  invoice_id =
    parsed.delete(:invoice_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :delete,
    path: ["api/invoices/%1$s/invoice_line_items/%2$s", invoice_id, id],
    model: ModernTreasury::Invoices::InvoiceLineItem,
    options: options
  )
end

#list(invoice_id, after_cursor: nil, per_page: nil, request_options: {}) ⇒ ModernTreasury::Internal::Page<ModernTreasury::Models::Invoices::InvoiceLineItem>

list invoice_line_items

Parameters:

  • invoice_id (String)

    invoice_id

  • after_cursor (String, nil)
  • per_page (Integer)
  • request_options (ModernTreasury::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



133
134
135
136
137
138
139
140
141
142
143
# File 'lib/modern_treasury/resources/invoices/line_items.rb', line 133

def list(invoice_id, params = {})
  parsed, options = ModernTreasury::Invoices::LineItemListParams.dump_request(params)
  @client.request(
    method: :get,
    path: ["api/invoices/%1$s/invoice_line_items", invoice_id],
    query: parsed,
    page: ModernTreasury::Internal::Page,
    model: ModernTreasury::Invoices::InvoiceLineItem,
    options: options
  )
end

#retrieve(id, invoice_id: , request_options: {}) ⇒ ModernTreasury::Models::Invoices::InvoiceLineItem

get invoice_line_item

Parameters:

Returns:

See Also:



59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/modern_treasury/resources/invoices/line_items.rb', line 59

def retrieve(id, params)
  parsed, options = ModernTreasury::Invoices::LineItemRetrieveParams.dump_request(params)
  invoice_id =
    parsed.delete(:invoice_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :get,
    path: ["api/invoices/%1$s/invoice_line_items/%2$s", invoice_id, id],
    model: ModernTreasury::Invoices::InvoiceLineItem,
    options: options
  )
end

#update(id, invoice_id: , description: nil, direction: nil, metadata: nil, name: nil, quantity: nil, unit_amount: nil, unit_amount_decimal: nil, request_options: {}) ⇒ ModernTreasury::Models::Invoices::InvoiceLineItem

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

update invoice_line_item

Parameters:

  • id (String)

    Path param: id

  • invoice_id (String)

    Path param: invoice_id

  • description (String)

    Body param: An optional free-form description of the line item.

  • direction (String)

    Body param: Either ‘debit` or `credit`. `debit` indicates that a client owes the

  • metadata (Hash{Symbol=>String})

    Body param: Additional data represented as key-value pairs. Both the key and val

  • name (String)

    Body param: The name of the line item, typically a product or SKU name.

  • quantity (Integer)

    Body param: The number of units of a product or service that this line item is f

  • unit_amount (Integer)

    Body param: The cost per unit of the product or service that this line item is f

  • unit_amount_decimal (String)

    Body param: The cost per unit of the product or service that this line item is f

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

Returns:

See Also:



103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/modern_treasury/resources/invoices/line_items.rb', line 103

def update(id, params)
  parsed, options = ModernTreasury::Invoices::LineItemUpdateParams.dump_request(params)
  invoice_id =
    parsed.delete(:invoice_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :patch,
    path: ["api/invoices/%1$s/invoice_line_items/%2$s", invoice_id, id],
    body: parsed,
    model: ModernTreasury::Invoices::InvoiceLineItem,
    options: options
  )
end