Class: ChartMogul::LineItem

Inherits:
APIResource show all
Includes:
API::Actions::Destroy, API::Actions::Retrieve, API::Actions::Update, Concerns::ExternalIdOperations, Concerns::ToggleDisabled
Defined in:
lib/chartmogul/line_item.rb

Overview

Standalone LineItem resource for CRUD operations on existing line items. Note: For creating line items on invoices, use LineItems::Subscription or LineItems::OneTime.

Constant Summary

Constants inherited from APIResource

APIResource::BACKOFF_FACTOR, APIResource::INTERVAL, APIResource::INTERVAL_RANDOMNESS, APIResource::MAX_INTERVAL, APIResource::RETRY_EXCEPTIONS, APIResource::RETRY_STATUSES, APIResource::THREAD_CONNECTION_KEY

Class Method Summary collapse

Methods included from Concerns::ExternalIdOperations

included

Methods included from Concerns::ToggleDisabled

#toggle_disabled!

Methods included from API::Actions::Destroy

#destroy!, included

Methods included from API::Actions::Update

included, #update!

Methods included from API::Actions::Retrieve

included

Methods inherited from APIResource

build_connection, build_query_path, connection, custom_with_query_params!, #custom_with_query_params!, extract_query_params, #extract_query_params, handle_other_error, handle_request_error, handling_errors, immutable_keys, json_patch, json_post, json_put, #path_with_query_params, query_params, set_immutable_keys, set_resource_name, set_resource_path, set_resource_root_key, writeable_query_param

Class Method Details

.create!(invoice_uuid:, handle_as_user_edit: nil, **attributes) ⇒ Object

Create a line item for an invoice

Parameters:

  • handle_as_user_edit (Boolean) (defaults to: nil) —

    If true, the change is treated as a user edit



50
51
52
53
54
55
56
57
58
# File 'lib/chartmogul/line_item.rb', line 50

def self.create!(invoice_uuid:, handle_as_user_edit: nil, **attributes)
  path = build_query_path(
    "/v1/import/invoices/#{invoice_uuid}/line_items",
    handle_as_user_edit: handle_as_user_edit
  )
  resp = handling_errors { json_post(path, attributes) }
  json = ChartMogul::Utils::JSONParser.parse(resp.body, immutable_keys:)
  new_from_json(json)
end