Class: EInvoiceAPI::Resources::Documents::Attachments
- Inherits:
-
Object
- Object
- EInvoiceAPI::Resources::Documents::Attachments
- Defined in:
- lib/e_invoice_api/resources/documents/attachments.rb
Instance Method Summary collapse
-
#add(document_id, file: , request_options: {}) ⇒ EInvoiceAPI::Models::Documents::DocumentAttachment
Add a new attachment to an invoice or credit note.
-
#delete(attachment_id, document_id: , request_options: {}) ⇒ EInvoiceAPI::Models::Documents::AttachmentDeleteResponse
Delete an attachment from an invoice or credit note.
-
#initialize(client:) ⇒ Attachments
constructor
private
A new instance of Attachments.
-
#list(document_id, request_options: {}) ⇒ Array<EInvoiceAPI::Models::Documents::DocumentAttachment>
Get all attachments for an invoice or credit note.
-
#retrieve(attachment_id, document_id: , request_options: {}) ⇒ EInvoiceAPI::Models::Documents::DocumentAttachment
Get attachment details with for an invoice or credit note with link to download file (signed URL, valid for 1 hour).
Constructor Details
#initialize(client:) ⇒ Attachments
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 Attachments.
103 104 105 |
# File 'lib/e_invoice_api/resources/documents/attachments.rb', line 103 def initialize(client:) @client = client end |
Instance Method Details
#add(document_id, file: , request_options: {}) ⇒ EInvoiceAPI::Models::Documents::DocumentAttachment
Add a new attachment to an invoice or credit note
88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/e_invoice_api/resources/documents/attachments.rb', line 88 def add(document_id, params) parsed, = EInvoiceAPI::Documents::AttachmentAddParams.dump_request(params) @client.request( method: :post, path: ["api/documents/%1$s/attachments", document_id], headers: {"content-type" => "multipart/form-data"}, body: parsed, model: EInvoiceAPI::Documents::DocumentAttachment, options: ) end |
#delete(attachment_id, document_id: , request_options: {}) ⇒ EInvoiceAPI::Models::Documents::AttachmentDeleteResponse
Delete an attachment from an invoice or credit note
63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/e_invoice_api/resources/documents/attachments.rb', line 63 def delete(, params) parsed, = EInvoiceAPI::Documents::AttachmentDeleteParams.dump_request(params) document_id = parsed.delete(:document_id) do raise ArgumentError.new("missing required path argument #{_1}") end @client.request( method: :delete, path: ["api/documents/%1$s/attachments/%2$s", document_id, ], model: EInvoiceAPI::Models::Documents::AttachmentDeleteResponse, options: ) end |
#list(document_id, request_options: {}) ⇒ Array<EInvoiceAPI::Models::Documents::DocumentAttachment>
Get all attachments for an invoice or credit note
43 44 45 46 47 48 49 50 |
# File 'lib/e_invoice_api/resources/documents/attachments.rb', line 43 def list(document_id, params = {}) @client.request( method: :get, path: ["api/documents/%1$s/attachments", document_id], model: EInvoiceAPI::Internal::Type::ArrayOf[EInvoiceAPI::Documents::DocumentAttachment], options: params[:request_options] ) end |
#retrieve(attachment_id, document_id: , request_options: {}) ⇒ EInvoiceAPI::Models::Documents::DocumentAttachment
Get attachment details with for an invoice or credit note with link to download file (signed URL, valid for 1 hour)
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/e_invoice_api/resources/documents/attachments.rb', line 19 def retrieve(, params) parsed, = EInvoiceAPI::Documents::AttachmentRetrieveParams.dump_request(params) document_id = parsed.delete(:document_id) do raise ArgumentError.new("missing required path argument #{_1}") end @client.request( method: :get, path: ["api/documents/%1$s/attachments/%2$s", document_id, ], model: EInvoiceAPI::Documents::DocumentAttachment, options: ) end |