Sha256: e37cecd5203d9ad08576b1f8fee72ed2cd4c8c5b2413d82227e7d053f6f928d5

Contents?: true

Size: 918 Bytes

Versions: 1

Compression:

Stored size: 918 Bytes

Contents

require "google/apis/calendar_v3"

module MyBanner
  class CalendarClient < Google::Apis::CalendarV3::CalendarService

    # @param authorization [CalendarAuthorization]
    def initialize(authorization=nil)
      super()
      self.client_options.application_name = "MyBanner Calendar Client"
      self.client_options.application_version = VERSION
      authorization ||= CalendarAuthorization.new
      self.authorization = authorization.stored_credentials || authorization.user_provided_credentials
    end

    def calendars
      @calendars ||= list_calendar_lists.items.sort_by { |cal| cal.summary }
    end

    # @param calendar [Google::Apis::CalendarV3::Calendar]
    def upcoming_events(calendar)
      request_options = {max_results: 100, single_events: true, order_by: "startTime", time_min: Time.now.iso8601, show_deleted: false}
      list_events(calendar.id, request_options).items
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
my_banner-1.0.0 lib/my_banner/calendar_client.rb