Class: LetsFreckle::Entry
- Inherits:
-
Hashie::Mash
- Object
- Hashie::Mash
- LetsFreckle::Entry
- Extended by:
- ClientResource
- Defined in:
- lib/letsfreckle/entry.rb
Class Method Summary collapse
- .all ⇒ Object
-
.create(options = {}) ⇒ Object
Creates a new entry.
-
.find(options = {}) ⇒ Object
Fetches all entries.
- .searchable_options_from(options = {}) ⇒ Object
Methods included from ClientResource
base_api_url, get, post, relative_path_for
Class Method Details
.all ⇒ Object
5 6 7 |
# File 'lib/letsfreckle/entry.rb', line 5 def self.all get('entries') end |
.create(options = {}) ⇒ Object
Creates a new entry. Supported options are:
:minutes => '4h' (required)
:project_id => 3221
:description => 'new task'
:date => '2011-08-01'
25 26 27 28 29 |
# File 'lib/letsfreckle/entry.rb', line 25 def self.create( = {}) raise ArgumentError, ':username config missing' unless LetsFreckle.config.username raise ArgumentError, ':minutes missing' unless .has_key?(:minutes) post('entries', .merge(:root => :entry, :user => LetsFreckle.config.username)) end |
.find(options = {}) ⇒ Object
Fetches all entries. Supported options are:
:people => ['ryan', 'frank']
:projects => ['project1', 'project2']
:tags => ['tag1', 'tag2']
:from => '2011-01-01'
:to => '2012-01-01'
:billable => true/false
16 17 18 |
# File 'lib/letsfreckle/entry.rb', line 16 def self.find( = {}) get('entries', ()) end |
.searchable_options_from(options = {}) ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/letsfreckle/entry.rb', line 31 def self.( = {}) .each_with_object({}) do |(key, value), result| case value when Array then result["search[#{key}]"] = value.join(',') else result["search[#{key}]"] = value.to_s end end end |