Sha256: 9a3460406f62a29d84e001e87785b3130d41987bb4dfb0127af015a3cdb4652f
Contents?: true
Size: 1.28 KB
Versions: 1
Compression:
Stored size: 1.28 KB
Contents
require 'ostruct' class GoogleR::Calendar attr_accessor :google_id, :etag, :summary, :description, :time_zone def self.url "https://www.googleapis.com" end def self.api_headers { 'GData-Version' => '3.0', 'Content-Type' => 'application/json', } end def self.path "/calendar/v3/users/me/calendarList" end def path if new? "/calendar/v3/calendars" else "/calendar/v3/calendars/#{google_id}" end end def self.from_json(json, *attrs) if json["kind"] == "calendar#calendar" || json["kind"] == "calendar#calendarListEntry" calendar = self.new calendar.google_id = json["id"] calendar.etag = json["etag"] calendar.summary = json["summary"] calendar.description = json["description"] calendar.time_zone = json["timeZone"] calendar else raise "Not implemented:\n#{json.inspect}" end end def to_google(yajl_opts = {}) hash = { "kind" => "calendar#calendar", } hash["etag"] = etag if etag hash["id"] = google_id if google_id hash["summary"] = summary if summary hash["description"] = description if description hash["timeZone"] = time_zone if time_zone Yajl::Encoder.encode(hash, yajl_opts) end def new? self.google_id.nil? end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
google_r-0.2.0 | lib/google_r/calendar.rb |