3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/connpass_to_calendar/command.rb', line 3
def self.put_on_event(params)
check_env
DB.prepare
result = Api::Connpass::Event.get(params)
events = result["events"]
events.each do |event|
event_id = event["event_id"]
summary = event["title"]
location = "#{event["address"]} #{event["place"]}"
description = "#{event["catch"]}
イベントURL:#{event["event_url"]}
定員:#{event["limit"]}"
start_date_time = event["started_at"]
end_date_time = event["ended_at"]
puts summary
puts location
puts description
puts start_date_time
puts end_date_time
unless Models::Event.find_by(id: event_id)
Models::Event.create(id: event_id, summary: summary, description: description, start_date_time: start_date_time, end_date_time: end_date_time)
application_name = Models::Env.find_by(keyword: "application_name").value
credentials_path = Models::Env.find_by(keyword: "credentials_path").value
token_path = Models::Env.find_by(keyword: "token_path").value
user_id = Models::Env.find_by(keyword: "user_id").value
calendar = Api::GoogleApis::Calendar.new(application_name, credentials_path, token_path, user_id)
calendar.create_event(summary, location, description, start_date_time, end_date_time)
end
end
end
|