Sha256: f43e1520ed4de19f1b1298b00b8d6885c8809ccf41dd52ac92cd0db7561a919e

Contents?: true

Size: 923 Bytes

Versions: 1

Compression:

Stored size: 923 Bytes

Contents

require "date"

module Ribose
  class Calendar < Ribose::Base
    include Ribose::Actions::All
    include Ribose::Actions::Fetch
    include Ribose::Actions::Create
    include Ribose::Actions::Delete

    # Fetch calendar events
    #
    # @params calendar_ids [Array] List of calendar Ids
    # @params start [Date] The start date to fetch events
    # @params length [Integer] How many days to fetch
    # @return [Sawyer::Resource] The calendar events
    #
    def self.fetch(calendar_ids, start: Date.today, length: 7)
      query = {
        length: length,
        cal_ids: Ribose.encode_ids(calendar_ids),
        start: start.to_time.to_i / (60 * 60 * 24),
      }

      super(nil, query: query)
    end

    private

    def resource
      "calendar"
    end

    def resources_path
      "calendar/calendar"
    end

    def validate(name:, **attributes)
      attributes.merge(name: name)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ribose-0.3.0 lib/ribose/calendar.rb