Class: OpenDaum::Calendar::Base
- Inherits:
-
Object
- Object
- OpenDaum::Calendar::Base
- Defined in:
- lib/opendaum/calendar.rb
Instance Method Summary collapse
- #categories ⇒ Object
-
#create_category(attrs = {}) ⇒ Object
:color, :description.
- #events(start_at = nil, end_at = nil, category_id = nil) ⇒ Object
-
#initialize(access_token) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(access_token) ⇒ Base
Returns a new instance of Base.
6 7 8 |
# File 'lib/opendaum/calendar.rb', line 6 def initialize access_token @access_token = access_token end |
Instance Method Details
#categories ⇒ Object
15 16 17 18 19 20 |
# File 'lib/opendaum/calendar.rb', line 15 def categories res = @access_token.get '/calendar/category/index.json' JSON.parse(res.body).collect do |json| Category.new @access_token, json end end |
#create_category(attrs = {}) ⇒ Object
:color, :description
11 12 13 |
# File 'lib/opendaum/calendar.rb', line 11 def create_category attrs = {} @access_token.post '/calendar/category/create.json', {} end |
#events(start_at = nil, end_at = nil, category_id = nil) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/opendaum/calendar.rb', line 22 def events start_at = nil, end_at = nil, category_id = nil params = { :start_at => '2012-03-01', :end_at => '2012-07-01' } params.merge!(:category_id => category_id) if category_id url = "/calendar/event/index.json?" + params.to_param r = @access_token.get url JSON.parse(r.body).collect do |json| Event.new @access_token, json end end |