Class: Harvest::API::Expenses
- Inherits:
-
Base
- Object
- Base
- Harvest::API::Expenses
- Includes:
- Behavior::Crud
- Defined in:
- lib/forecast/api/expenses.rb
Instance Method Summary collapse
- #all(date = ::Time.now, user = nil) ⇒ Object
-
#attach(expense, filename, receipt) ⇒ Object
This is currently broken, but will come back to it.
Instance Method Details
#all(date = ::Time.now, user = nil) ⇒ Object
8 9 10 11 12 |
# File 'lib/forecast/api/expenses.rb', line 8 def all(date = ::Time.now, user = nil) date = ::Time.parse(date) if String === date response = request(:get, credentials, "#{api_model.api_path}/#{date.yday}/#{date.year}", :query => of_user_query(user)) api_model.parse(response.parsed_response) end |
#attach(expense, filename, receipt) ⇒ Object
This is currently broken, but will come back to it
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/forecast/api/expenses.rb', line 15 def attach(expense, filename, receipt) body = "" body << "------------------------------b7edea381b46\r\n" body << %Q{Content-Disposition: form-data; name="expense[receipt]"; filename="#{filename}"\r\n} body << "Content-Type: image/png\r\n" body << "\r\n#{receipt.read}\r\n" body << "------------------------------b7edea381b46\r\n" request(:post, credentials, "#{api_model.api_path}/#{expense.to_i}/receipt", :headers => {'Content-Type' => 'multipart/form-data; boundary=------------------------------b7edea381b46'}, :body => body) end |