Class: ModernTreasury::InvoiceController
- Inherits:
-
BaseController
- Object
- BaseController
- ModernTreasury::InvoiceController
- Defined in:
- lib/modern_treasury/controllers/invoice_controller.rb
Overview
InvoiceController
Constant Summary
Constants inherited from BaseController
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
-
#create_invoice(idempotency_key: nil, body: nil) ⇒ Invoice
TODO: type endpoint description here something unique, preferably something like an UUID.
-
#get_invoice(id) ⇒ Invoice
TODO: type endpoint description here.
-
#list_invoices(per_page: nil, after_cursor: nil) ⇒ Array[Invoice]
TODO: type endpoint description here here here.
-
#update_invoice(id, body: nil) ⇒ Invoice
TODO: type endpoint description here description here.
Methods inherited from BaseController
#initialize, #new_parameter, #new_request_builder, #new_response_handler, user_agent
Constructor Details
This class inherits a constructor from ModernTreasury::BaseController
Instance Method Details
#create_invoice(idempotency_key: nil, body: nil) ⇒ Invoice
TODO: type endpoint description here something unique, preferably something like an UUID. description here
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/modern_treasury/controllers/invoice_controller.rb', line 38 def create_invoice(idempotency_key: nil, body: nil) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/api/invoices', Server::DEFAULT) .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(Invoice.method(:from_hash))) .execute end |
#get_invoice(id) ⇒ Invoice
TODO: type endpoint description here
59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/modern_treasury/controllers/invoice_controller.rb', line 59 def get_invoice(id) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/api/invoices/{id}', Server::DEFAULT) .template_param(new_parameter(id, key: 'id') .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(Invoice.method(:from_hash))) .execute end |
#list_invoices(per_page: nil, after_cursor: nil) ⇒ Array[Invoice]
TODO: type endpoint description here here here
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/modern_treasury/controllers/invoice_controller.rb', line 15 def list_invoices(per_page: nil, after_cursor: nil) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/api/invoices', Server::DEFAULT) .query_param(new_parameter(per_page, key: 'per_page')) .query_param(new_parameter(after_cursor, key: 'after_cursor')) .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(Invoice.method(:from_hash)) .is_response_array(true)) .execute end |
#update_invoice(id, body: nil) ⇒ Invoice
TODO: type endpoint description here description here
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/modern_treasury/controllers/invoice_controller.rb', line 79 def update_invoice(id, body: nil) @api_call .request(new_request_builder(HttpMethodEnum::PATCH, '/api/invoices/{id}', Server::DEFAULT) .template_param(new_parameter(id, key: 'id') .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(Invoice.method(:from_hash))) .execute end |