Sha256: 04c33750340c9078dafb0b68a725bff02eb00a6c9319d756da5fb315909d78a2

Contents?: true

Size: 984 Bytes

Versions: 2

Compression:

Stored size: 984 Bytes

Contents

# frozen_string_literal: true

require 'roko/report_event'
require 'time'

module Roko
  module Source
    module GoogleCalendar
      module EventAdapter
        class << self
          # @param event [Google::Apis::CalendarV3::Event]
          # @return [Roko::ReportEvent]
          def to_report_event(event)
            source = 'google calendar'
            event_type = 'MTG'
            # [Google::Apis::CalendarV3::EventDateTime]
            start = event.start
            return nil if start.nil?

            created_at = if start.date_time.nil?
                           Time.parse(start.date.to_s)
                         else
                           Time.parse(start.date_time.to_s)
                         end

            url = event.html_link
            summary = event.summary
            detail = event.description
            Roko::ReportEvent.new(source, event_type, created_at, url, summary, detail)
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
roko-0.2.1 lib/roko/source/google_calendar/event_adapter.rb
roko-0.2.0 lib/roko/source/google_calendar/event_adapter.rb