Method: Invoiced::Estimate#attachments

Defined in:
lib/invoiced/estimate.rb

#attachments(params = {}) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/invoiced/estimate.rb', line 26

def attachments(params={})
    response = @client.request(:get, "#{self.endpoint()}/attachments", params)

    # ensure each attachment has an ID
    body = response[:body]
    body.each do |attachment|
        if !attachment.has_key?(:id)
            attachment[:id] = attachment[:file][:id]
        end
    end

    # build objects
    attachment = Attachment.new(@client)
    attachments = Util.build_objects(attachment, body)

    # store the metadata from the list operation
     = Invoiced::List.new(response[:headers][:link], response[:headers][:x_total_count])

    return attachments, 
end