Class: EInvoiceAPI::Resources::Documents::Attachments

Inherits:
Object
  • Object
show all
Defined in:
lib/e_invoice_api/resources/documents/attachments.rb

Instance Method Summary collapse

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.

Parameters:



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

Parameters:

Returns:

See Also:



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, options = 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: options
  )
end

#delete(attachment_id, document_id: , request_options: {}) ⇒ EInvoiceAPI::Models::Documents::AttachmentDeleteResponse

Delete an attachment from an invoice or credit note

Parameters:

Returns:

See Also:



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(attachment_id, params)
  parsed, options = 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, attachment_id],
    model: EInvoiceAPI::Models::Documents::AttachmentDeleteResponse,
    options: options
  )
end

#list(document_id, request_options: {}) ⇒ Array<EInvoiceAPI::Models::Documents::DocumentAttachment>

Get all attachments for an invoice or credit note

Parameters:

Returns:

See Also:



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)

Parameters:

Returns:

See Also:



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(attachment_id, params)
  parsed, options = 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, attachment_id],
    model: EInvoiceAPI::Documents::DocumentAttachment,
    options: options
  )
end