Class: Harvest::API::Expenses
- Includes:
- Behavior::Crud
- Defined in:
- lib/harvest/api/expenses.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods included from Behavior::Crud
#all, #create, #delete, #find, #update
Methods inherited from Base
Constructor Details
This class inherits a constructor from Harvest::API::Base
Instance Method Details
#attach(expense, filename, receipt) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/harvest/api/expenses.rb', line 7 def attach(expense, filename, receipt) body = "" body << "--__X_ATTACH_BOUNDARY__\r\n" body << %Q{Content-Disposition: form-data; name="expense[receipt]"; filename="#{filename}"\r\n} body << "\r\n#{receipt.read}" body << "\r\n--__X_ATTACH_BOUNDARY__--\r\n\r\n" request( :post, credentials, "#{api_model.api_path}/#{expense.id}/receipt", :headers => { 'Content-Type' => 'multipart/form-data; charset=utf-8; boundary=__X_ATTACH_BOUNDARY__', 'Content-Length' => body.length.to_s, }, :body => body) end |