Module: Rexpense::Resources::Attachment

Included in:
Expense
Defined in:
lib/rexpense/resources/nested_endpoints/attachment.rb

Instance Method Summary collapse

Instance Method Details

#attachments(resource_id) ⇒ Object

Get resource attachments

API

Method: GET /api/v1/expenses/:id/attachments

Documentation: developers.rexpense.com/api/attachments#index



10
11
12
13
14
# File 'lib/rexpense/resources/nested_endpoints/attachment.rb', line 10

def attachments(resource_id)
  http.get(attachment_endpoint(resource_id)) do |response|
    Rexpense::Entities::AttachmentCollection.build response
  end
end

#destroy_attachment(resource_id, attachment_id) ⇒ Object

Destroy resource attachment

API

Method: DELETE /api/v1/expenses/:id/attachments/:id

Documentation: developers.rexpense.com/api/attachments#show



36
37
38
39
40
# File 'lib/rexpense/resources/nested_endpoints/attachment.rb', line 36

def destroy_attachment(resource_id, attachment_id)
  http.delete("#{attachment_endpoint(resource_id)}/#{attachment_id}") do |response|
    true
  end
end

#find_attachment(resource_id, attachment_id) ⇒ Object

Get resource attachment

API

Method: GET /api/v1/expenses/:id/attachments/:id

Documentation: developers.rexpense.com/api/attachments#show



23
24
25
26
27
# File 'lib/rexpense/resources/nested_endpoints/attachment.rb', line 23

def find_attachment(resource_id, attachment_id)
  http.get("#{attachment_endpoint(resource_id)}/#{attachment_id}") do |response|
    Rexpense::Entities::Attachment.new response.parsed_body
  end
end