module Rexpense::Resources::Attachment

Public Instance Methods

attachments(resource_id) click to toggle source

Get resource attachments

API

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

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

# 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) click to toggle source

Destroy resource attachment

API

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

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

# 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) click to toggle source

Get resource attachment

API

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

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

# 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

Private Instance Methods

attachment_endpoint(resource_id) click to toggle source
# File lib/rexpense/resources/nested_endpoints/attachment.rb, line 44
def attachment_endpoint(resource_id)
  "#{endpoint_base}/#{resource_id}/attachments"
end