Class: ModernTreasury::InvoiceLineItemController

Inherits:
BaseController show all
Defined in:
lib/modern_treasury/controllers/invoice_line_item_controller.rb

Overview

InvoiceLineItemController

Constant Summary

Constants inherited from BaseController

BaseController::GLOBAL_ERRORS

Instance Attribute Summary

Attributes inherited from BaseController

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseController

#initialize, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters

Constructor Details

This class inherits a constructor from ModernTreasury::BaseController

Instance Method Details

#create_invoice_line_item(invoice_id, idempotency_key: nil, body: nil) ⇒ ApiResponse

TODO: type endpoint description here something unique, preferably something like an UUID. description here

Parameters:

  • invoice_id (String)

    Required parameter: invoice_id

  • idempotency_key (String) (defaults to: nil)

    Optional parameter: This key should be

  • body (InvoiceLineItemCreateRequest) (defaults to: nil)

    Optional parameter: TODO: type

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/modern_treasury/controllers/invoice_line_item_controller.rb', line 45

def create_invoice_line_item(invoice_id,
                             idempotency_key: nil,
                             body: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/api/invoices/{invoice_id}/invoice_line_items',
                                 Server::DEFAULT)
               .template_param(new_parameter(invoice_id, key: 'invoice_id')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .header_param(new_parameter(idempotency_key, key: 'Idempotency-Key'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('basic_auth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(InvoiceLineItem.method(:from_hash))
                .is_api_response(true))
    .execute
end

#delete_invoice_line_item(invoice_id, id) ⇒ ApiResponse

TODO: type endpoint description here

Parameters:

  • invoice_id (String)

    Required parameter: invoice_id

  • id (String)

    Required parameter: id

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/modern_treasury/controllers/invoice_line_item_controller.rb', line 128

def delete_invoice_line_item(invoice_id,
                             id)
  @api_call
    .request(new_request_builder(HttpMethodEnum::DELETE,
                                 '/api/invoices/{invoice_id}/invoice_line_items/{id}',
                                 Server::DEFAULT)
               .template_param(new_parameter(invoice_id, key: 'invoice_id')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(id, key: 'id')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('basic_auth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(InvoiceLineItem.method(:from_hash))
                .is_api_response(true))
    .execute
end

#get_invoice_line_item(invoice_id, id) ⇒ ApiResponse

TODO: type endpoint description here

Parameters:

  • invoice_id (String)

    Required parameter: invoice_id

  • id (String)

    Required parameter: id

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/modern_treasury/controllers/invoice_line_item_controller.rb', line 72

def get_invoice_line_item(invoice_id,
                          id)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/api/invoices/{invoice_id}/invoice_line_items/{id}',
                                 Server::DEFAULT)
               .template_param(new_parameter(invoice_id, key: 'invoice_id')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(id, key: 'id')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('basic_auth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(InvoiceLineItem.method(:from_hash))
                .is_api_response(true))
    .execute
end

#list_invoice_line_items(invoice_id, after_cursor: nil, per_page: nil) ⇒ ApiResponse

TODO: type endpoint description here here here

Parameters:

  • invoice_id (String)

    Required parameter: invoice_id

  • after_cursor (String) (defaults to: nil)

    Optional parameter: TODO: type description

  • per_page (Integer) (defaults to: nil)

    Optional parameter: TODO: type description

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/modern_treasury/controllers/invoice_line_item_controller.rb', line 16

def list_invoice_line_items(invoice_id,
                            after_cursor: nil,
                            per_page: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/api/invoices/{invoice_id}/invoice_line_items',
                                 Server::DEFAULT)
               .template_param(new_parameter(invoice_id, key: 'invoice_id')
                                .is_required(true)
                                .should_encode(true))
               .query_param(new_parameter(after_cursor, key: 'after_cursor'))
               .query_param(new_parameter(per_page, key: 'per_page'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('basic_auth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(InvoiceLineItem.method(:from_hash))
                .is_api_response(true)
                .is_response_array(true))
    .execute
end

#update_invoice_line_item(invoice_id, id, body: nil) ⇒ ApiResponse

TODO: type endpoint description here description here

Parameters:

  • invoice_id (String)

    Required parameter: invoice_id

  • id (String)

    Required parameter: id

  • body (InvoiceLineItemUpdateRequest) (defaults to: nil)

    Optional parameter: TODO: type

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/modern_treasury/controllers/invoice_line_item_controller.rb', line 99

def update_invoice_line_item(invoice_id,
                             id,
                             body: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::PATCH,
                                 '/api/invoices/{invoice_id}/invoice_line_items/{id}',
                                 Server::DEFAULT)
               .template_param(new_parameter(invoice_id, key: 'invoice_id')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(id, key: 'id')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('basic_auth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(InvoiceLineItem.method(:from_hash))
                .is_api_response(true))
    .execute
end