Class: Basecampeverest::Calendar
- Inherits:
-
Object
- Object
- Basecampeverest::Calendar
- Defined in:
- lib/basecampeverest/resources/calendar.rb
Class Method Summary collapse
-
.all ⇒ Basecampeverest::Project
find all calendars via the Basecamp API.
-
.delete(calendar_id) ⇒ Basecampeverest::Project
delete a calendar via the Basecamp API.
-
.find(calendar_id) ⇒ Basecampeverest::Project
a specific calendar via the Basecamp API.
-
.new(options = {}) ⇒ Basecampeverest::Project
create a calendar via the Basecamp API.
-
.update(calendar_id) ⇒ Basecampeverest::Project
update a calendar via the Basecamp API.
Class Method Details
.all ⇒ Basecampeverest::Project
find all calendars via the Basecamp API
6 7 8 9 10 11 12 |
# File 'lib/basecampeverest/resources/calendar.rb', line 6 def self.all url = "/calendars.json" response = Basecampeverest::Connect.get url # parse the response to remove HTTParty info response.parsed_response end |
.delete(calendar_id) ⇒ Basecampeverest::Project
delete a calendar via the Basecamp API
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/basecampeverest/resources/calendar.rb', line 66 def self.delete(calendar_id) url = "/calendars/#{calendar_id}.json" response = Basecampeverest::Connect.delete url # This checks the response code for validity and error checking if response.code == 204 = "#### successfully deleted" elsif response.code == 403 = "You do not have permission to delete this ####" else = "Invalid project ID or authentication. The #### was not deleted." end # return the message end |
.find(calendar_id) ⇒ Basecampeverest::Project
a specific calendar via the Basecamp API
18 19 20 21 22 23 24 |
# File 'lib/basecampeverest/resources/calendar.rb', line 18 def self.find(calendar_id) url = "/calendars/#{calendar_id}.json" response = Basecampeverest::Connect.get url # parse the response to remove HTTParty info response.parsed_response end |
.new(options = {}) ⇒ Basecampeverest::Project
create a calendar via the Basecamp API
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/basecampeverest/resources/calendar.rb', line 31 def self.new(={}) post_params = { :body => .to_json, :headers => Basecampeverest::Connect.headers.merge({'Content-Type' => 'application/json'}) } # make the http basecamp call url = "/calendars.json" response = Basecampeverest::Connect.post url, post_params # parse the response to remove HTTParty info response.parsed_response end |
.update(calendar_id) ⇒ Basecampeverest::Project
update a calendar via the Basecamp API
48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/basecampeverest/resources/calendar.rb', line 48 def self.update(calendar_id) post_params = { :body => .to_json, :headers => Basecampeverest::Connect.merge({'Content-Type' => 'application/json'}) } # make the http basecamp call url = "/calendars/#{calendar_id}.json" response = Basecampeverest::Connect.put url, post_params # parse the response to remove HTTParty info response.parsed_response end |