Class: FreeAgent::Company
- Inherits:
-
Object
- Object
- FreeAgent::Company
- Defined in:
- lib/free_agent.rb
Instance Method Summary collapse
- #contacts ⇒ Object
- #expenses(user_id, options = {}) ⇒ Object
-
#initialize(domain, username, password) ⇒ Company
constructor
A new instance of Company.
- #invoices ⇒ Object
- #projects ⇒ Object
-
#timeslips ⇒ Object
Note, this is only for PUT/POSTing to.
- #users ⇒ Object
Constructor Details
#initialize(domain, username, password) ⇒ Company
Returns a new instance of Company.
17 18 19 20 21 22 |
# File 'lib/free_agent.rb', line 17 def initialize(domain, username, password) @resource = RestClient::Resource.new( "https://#{domain}.freeagentcentral.com", :user => username, :password => password ) end |
Instance Method Details
#contacts ⇒ Object
28 29 30 |
# File 'lib/free_agent.rb', line 28 def contacts @contacts ||= Collection.new(@resource['/contacts'], :entity => :contact) end |
#expenses(user_id, options = {}) ⇒ Object
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/free_agent.rb', line 45 def expenses(user_id, ={}) .assert_valid_keys(:view, :from, :to) .reverse_merge!(:view => 'recent') if [:from] && [:to] [:view] = "#{[:from].strftime('%Y-%m-%d')}_#{[:to].strftime('%Y-%m-%d')}" end Collection.new(@resource["/users/#{user_id}/expenses?view=#{[:view]}"], :entity => :expense) end |
#invoices ⇒ Object
24 25 26 |
# File 'lib/free_agent.rb', line 24 def invoices @invoices ||= Collection.new(@resource['/invoices'], :entity => :invoice) end |
#projects ⇒ Object
32 33 34 |
# File 'lib/free_agent.rb', line 32 def projects @projects ||= Collection.new(@resource['/projects'], :entity => :project) end |
#timeslips ⇒ Object
Note, this is only for PUT/POSTing to
41 42 43 |
# File 'lib/free_agent.rb', line 41 def timeslips @timeslips ||= Collection.new(@resource['/timeslips'], :entity => :timeslip) end |
#users ⇒ Object
36 37 38 |
# File 'lib/free_agent.rb', line 36 def users @users ||= Collection.new(@resource['/company/users'], :entity => :user) end |