{"action":"created","comment":{"url":"https://api.github.com/repos/framgia/framgia_crb_v2/pulls/comments/66204946","id":66204946,"diff_hunk":"@@ -1,10 +1,89 @@\n class SyncGoogleCalendarServices\n-  def initialize events\n-    @events = events\n+  def initialize token, user\n+    @token = token\n+    @user = user\n+  end\n+\n+  def push_event\n+    insert_event_to_calendar\n   end\n \n   private\n   def extract_event_title title\n     calendar_name, event_title = title.split(\": \")\n   end\n+\n+  def insert_event_to_calendar\n+    events = Event.event_google @user.id\n+    client = Google::APIClient.new\n+    client.authorization.access_token = @token\n+    service = client.discovered_api(\"calendar\", \"v3\")\n+    events.each do |event|\n+      if event.google_event_id.nil?\n+        attendees = event.attendees\n+        emails = [];\n+        attendees.each {|attendee| emails << {email: attendee.user_email}}\n+        recurrences = event.repeat_type.nil? ? \"\": recurrence_google_calendar(event)\n+        event_google = event_google_calendar event, client, service, recurrences, emails\n+        result = client.execute(api_method: service.events.insert,\n+          parameters: {\"calendarId\": \"primary\"},\n+          body: JSON.dump(event_google),\n+          headers: {\"Content-Type\": Settings.content_type})\n+        if result.status == Settings.result_status","path":"app/services/sync_google_calendar_services.rb","position":34,"original_position":34,"commit_id":"7f6aef8351b6737b1960e41d0196d6ef7e0e355e","original_commit_id":"7f6aef8351b6737b1960e41d0196d6ef7e0e355e","user":{"login":"dieunb","id":2122175,"avatar_url":"https://avatars.githubusercontent.com/u/2122175?v=3","gravatar_id":"","url":"https://api.github.com/users/dieunb","html_url":"https://github.com/dieunb","followers_url":"https://api.github.com/users/dieunb/followers","following_url":"https://api.github.com/users/dieunb/following{/other_user}","gists_url":"https://api.github.com/users/dieunb/gists{/gist_id}","starred_url":"https://api.github.com/users/dieunb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dieunb/subscriptions","organizations_url":"https://api.github.com/users/dieunb/orgs","repos_url":"https://api.github.com/users/dieunb/repos","events_url":"https://api.github.com/users/dieunb/events{/privacy}","received_events_url":"https://api.github.com/users/dieunb/received_events","type":"User","site_admin":false},"body":"status của nó là gì?\r\n`cancelled` hay là `confirmed` hay ...?","created_at":"2016-06-08T07:29:57Z","updated_at":"2016-06-08T07:29:57Z","html_url":"https://github.com/framgia/framgia_crb_v2/pull/126#discussion_r66204946","pull_request_url":"https://api.github.com/repos/framgia/framgia_crb_v2/pulls/126","_links":{"self":{"href":"https://api.github.com/repos/framgia/framgia_crb_v2/pulls/comments/66204946"},"html":{"href":"https://github.com/framgia/framgia_crb_v2/pull/126#discussion_r66204946"},"pull_request":{"href":"https://api.github.com/repos/framgia/framgia_crb_v2/pulls/126"}}},"pull_request":{"url":"https://api.github.com/repos/framgia/framgia_crb_v2/pulls/126","id":72803919,"html_url":"https://github.com/framgia/framgia_crb_v2/pull/126","diff_url":"https://github.com/framgia/framgia_crb_v2/pull/126.diff","patch_url":"https://github.com/framgia/framgia_crb_v2/pull/126.patch","issue_url":"https://api.github.com/repos/framgia/framgia_crb_v2/issues/126","number":126,"state":"open","locked":false,"title":"push-to-google-calendar","user":{"login":"duynq","id":9071758,"avatar_url":"https://avatars.githubusercontent.com/u/9071758?v=3","gravatar_id":"","url":"https://api.github.com/users/duynq","html_url":"https://github.com/duynq","followers_url":"https://api.github.com/users/duynq/followers","following_url":"https://api.github.com/users/duynq/following{/other_user}","gists_url":"https://api.github.com/users/duynq/gists{/gist_id}","starred_url":"https://api.github.com/users/duynq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duynq/subscriptions","organizations_url":"https://api.github.com/users/duynq/orgs","repos_url":"https://api.github.com/users/duynq/repos","events_url":"https://api.github.com/users/duynq/events{/privacy}","received_events_url":"https://api.github.com/users/duynq/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-06-07T01:37:37Z","updated_at":"2016-06-08T07:29:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"93310820b2222718bf264f07b25aab190bcc9250","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/framgia/framgia_crb_v2/pulls/126/commits","review_comments_url":"https://api.github.com/repos/framgia/framgia_crb_v2/pulls/126/comments","review_comment_url":"https://api.github.com/repos/framgia/framgia_crb_v2/pulls/comments{/number}","comments_url":"https://api.github.com/repos/framgia/framgia_crb_v2/issues/126/comments","statuses_url":"https://api.github.com/repos/framgia/framgia_crb_v2/statuses/7f6aef8351b6737b1960e41d0196d6ef7e0e355e","head":{"label":"duynq:push-to-google-calendar","ref":"push-to-google-calendar","sha":"7f6aef8351b6737b1960e41d0196d6ef7e0e355e","user":{"login":"duynq","id":9071758,"avatar_url":"https://avatars.githubusercontent.com/u/9071758?v=3","gravatar_id":"","url":"https://api.github.com/users/duynq","html_url":"https://github.com/duynq","followers_url":"https://api.github.com/users/duynq/followers","following_url":"https://api.github.com/users/duynq/following{/other_user}","gists_url":"https://api.github.com/users/duynq/gists{/gist_id}","starred_url":"https://api.github.com/users/duynq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duynq/subscriptions","organizations_url":"https://api.github.com/users/duynq/orgs","repos_url":"https://api.github.com/users/duynq/repos","events_url":"https://api.github.com/users/duynq/events{/privacy}","received_events_url":"https://api.github.com/users/duynq/received_events","type":"User","site_admin":false},"repo":{"id":55932627,"name":"framgia_crb_v2","full_name":"duynq/framgia_crb_v2","owner":{"login":"duynq","id":9071758,"avatar_url":"https://avatars.githubusercontent.com/u/9071758?v=3","gravatar_id":"","url":"https://api.github.com/users/duynq","html_url":"https://github.com/duynq","followers_url":"https://api.github.com/users/duynq/followers","following_url":"https://api.github.com/users/duynq/following{/other_user}","gists_url":"https://api.github.com/users/duynq/gists{/gist_id}","starred_url":"https://api.github.com/users/duynq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duynq/subscriptions","organizations_url":"https://api.github.com/users/duynq/orgs","repos_url":"https://api.github.com/users/duynq/repos","events_url":"https://api.github.com/users/duynq/events{/privacy}","received_events_url":"https://api.github.com/users/duynq/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/duynq/framgia_crb_v2","description":"Conference Room Booking System","fork":true,"url":"https://api.github.com/repos/duynq/framgia_crb_v2","forks_url":"https://api.github.com/repos/duynq/framgia_crb_v2/forks","keys_url":"https://api.github.com/repos/duynq/framgia_crb_v2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/duynq/framgia_crb_v2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/duynq/framgia_crb_v2/teams","hooks_url":"https://api.github.com/repos/duynq/framgia_crb_v2/hooks","issue_events_url":"https://api.github.com/repos/duynq/framgia_crb_v2/issues/events{/number}","events_url":"https://api.github.com/repos/duynq/framgia_crb_v2/events","assignees_url":"https://api.github.com/repos/duynq/framgia_crb_v2/assignees{/user}","branches_url":"https://api.github.com/repos/duynq/framgia_crb_v2/branches{/branch}","tags_url":"https://api.github.com/repos/duynq/framgia_crb_v2/tags","blobs_url":"https://api.github.com/repos/duynq/framgia_crb_v2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/duynq/framgia_crb_v2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/duynq/framgia_crb_v2/git/refs{/sha}","trees_url":"https://api.github.com/repos/duynq/framgia_crb_v2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/duynq/framgia_crb_v2/statuses/{sha}","languages_url":"https://api.github.com/repos/duynq/framgia_crb_v2/languages","stargazers_url":"https://api.github.com/repos/duynq/framgia_crb_v2/stargazers","contributors_url":"https://api.github.com/repos/duynq/framgia_crb_v2/contributors","subscribers_url":"https://api.github.com/repos/duynq/framgia_crb_v2/subscribers","subscription_url":"https://api.github.com/repos/duynq/framgia_crb_v2/subscription","commits_url":"https://api.github.com/repos/duynq/framgia_crb_v2/commits{/sha}","git_commits_url":"https://api.github.com/repos/duynq/framgia_crb_v2/git/commits{/sha}","comments_url":"https://api.github.com/repos/duynq/framgia_crb_v2/comments{/number}","issue_comment_url":"https://api.github.com/repos/duynq/framgia_crb_v2/issues/comments{/number}","contents_url":"https://api.github.com/repos/duynq/framgia_crb_v2/contents/{+path}","compare_url":"https://api.github.com/repos/duynq/framgia_crb_v2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/duynq/framgia_crb_v2/merges","archive_url":"https://api.github.com/repos/duynq/framgia_crb_v2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/duynq/framgia_crb_v2/downloads","issues_url":"https://api.github.com/repos/duynq/framgia_crb_v2/issues{/number}","pulls_url":"https://api.github.com/repos/duynq/framgia_crb_v2/pulls{/number}","milestones_url":"https://api.github.com/repos/duynq/framgia_crb_v2/milestones{/number}","notifications_url":"https://api.github.com/repos/duynq/framgia_crb_v2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/duynq/framgia_crb_v2/labels{/name}","releases_url":"https://api.github.com/repos/duynq/framgia_crb_v2/releases{/id}","deployments_url":"https://api.github.com/repos/duynq/framgia_crb_v2/deployments","created_at":"2016-04-11T01:32:32Z","updated_at":"2016-04-07T02:42:44Z","pushed_at":"2016-06-08T07:27:52Z","git_url":"git://github.com/duynq/framgia_crb_v2.git","ssh_url":"git@github.com:duynq/framgia_crb_v2.git","clone_url":"https://github.com/duynq/framgia_crb_v2.git","svn_url":"https://github.com/duynq/framgia_crb_v2","homepage":null,"size":639,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"framgia:develop","ref":"develop","sha":"5bb54a16e2dc1b8e154fdfc7af92069813a79b97","user":{"login":"framgia","id":2322183,"avatar_url":"https://avatars.githubusercontent.com/u/2322183?v=3","gravatar_id":"","url":"https://api.github.com/users/framgia","html_url":"https://github.com/framgia","followers_url":"https://api.github.com/users/framgia/followers","following_url":"https://api.github.com/users/framgia/following{/other_user}","gists_url":"https://api.github.com/users/framgia/gists{/gist_id}","starred_url":"https://api.github.com/users/framgia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/framgia/subscriptions","organizations_url":"https://api.github.com/users/framgia/orgs","repos_url":"https://api.github.com/users/framgia/repos","events_url":"https://api.github.com/users/framgia/events{/privacy}","received_events_url":"https://api.github.com/users/framgia/received_events","type":"Organization","site_admin":false},"repo":{"id":55657829,"name":"framgia_crb_v2","full_name":"framgia/framgia_crb_v2","owner":{"login":"framgia","id":2322183,"avatar_url":"https://avatars.githubusercontent.com/u/2322183?v=3","gravatar_id":"","url":"https://api.github.com/users/framgia","html_url":"https://github.com/framgia","followers_url":"https://api.github.com/users/framgia/followers","following_url":"https://api.github.com/users/framgia/following{/other_user}","gists_url":"https://api.github.com/users/framgia/gists{/gist_id}","starred_url":"https://api.github.com/users/framgia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/framgia/subscriptions","organizations_url":"https://api.github.com/users/framgia/orgs","repos_url":"https://api.github.com/users/framgia/repos","events_url":"https://api.github.com/users/framgia/events{/privacy}","received_events_url":"https://api.github.com/users/framgia/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/framgia/framgia_crb_v2","description":"Conference Room Booking System","fork":false,"url":"https://api.github.com/repos/framgia/framgia_crb_v2","forks_url":"https://api.github.com/repos/framgia/framgia_crb_v2/forks","keys_url":"https://api.github.com/repos/framgia/framgia_crb_v2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/framgia/framgia_crb_v2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/framgia/framgia_crb_v2/teams","hooks_url":"https://api.github.com/repos/framgia/framgia_crb_v2/hooks","issue_events_url":"https://api.github.com/repos/framgia/framgia_crb_v2/issues/events{/number}","events_url":"https://api.github.com/repos/framgia/framgia_crb_v2/events","assignees_url":"https://api.github.com/repos/framgia/framgia_crb_v2/assignees{/user}","branches_url":"https://api.github.com/repos/framgia/framgia_crb_v2/branches{/branch}","tags_url":"https://api.github.com/repos/framgia/framgia_crb_v2/tags","blobs_url":"https://api.github.com/repos/framgia/framgia_crb_v2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/framgia/framgia_crb_v2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/framgia/framgia_crb_v2/git/refs{/sha}","trees_url":"https://api.github.com/repos/framgia/framgia_crb_v2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/framgia/framgia_crb_v2/statuses/{sha}","languages_url":"https://api.github.com/repos/framgia/framgia_crb_v2/languages","stargazers_url":"https://api.github.com/repos/framgia/framgia_crb_v2/stargazers","contributors_url":"https://api.github.com/repos/framgia/framgia_crb_v2/contributors","subscribers_url":"https://api.github.com/repos/framgia/framgia_crb_v2/subscribers","subscription_url":"https://api.github.com/repos/framgia/framgia_crb_v2/subscription","commits_url":"https://api.github.com/repos/framgia/framgia_crb_v2/commits{/sha}","git_commits_url":"https://api.github.com/repos/framgia/framgia_crb_v2/git/commits{/sha}","comments_url":"https://api.github.com/repos/framgia/framgia_crb_v2/comments{/number}","issue_comment_url":"https://api.github.com/repos/framgia/framgia_crb_v2/issues/comments{/number}","contents_url":"https://api.github.com/repos/framgia/framgia_crb_v2/contents/{+path}","compare_url":"https://api.github.com/repos/framgia/framgia_crb_v2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/framgia/framgia_crb_v2/merges","archive_url":"https://api.github.com/repos/framgia/framgia_crb_v2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/framgia/framgia_crb_v2/downloads","issues_url":"https://api.github.com/repos/framgia/framgia_crb_v2/issues{/number}","pulls_url":"https://api.github.com/repos/framgia/framgia_crb_v2/pulls{/number}","milestones_url":"https://api.github.com/repos/framgia/framgia_crb_v2/milestones{/number}","notifications_url":"https://api.github.com/repos/framgia/framgia_crb_v2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/framgia/framgia_crb_v2/labels{/name}","releases_url":"https://api.github.com/repos/framgia/framgia_crb_v2/releases{/id}","deployments_url":"https://api.github.com/repos/framgia/framgia_crb_v2/deployments","created_at":"2016-04-07T02:42:19Z","updated_at":"2016-05-03T02:07:01Z","pushed_at":"2016-06-08T07:27:52Z","git_url":"git://github.com/framgia/framgia_crb_v2.git","ssh_url":"git@github.com:framgia/framgia_crb_v2.git","clone_url":"https://github.com/framgia/framgia_crb_v2.git","svn_url":"https://github.com/framgia/framgia_crb_v2","homepage":null,"size":693,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":15,"mirror_url":null,"open_issues_count":7,"forks":15,"open_issues":7,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/framgia/framgia_crb_v2/pulls/126"},"html":{"href":"https://github.com/framgia/framgia_crb_v2/pull/126"},"issue":{"href":"https://api.github.com/repos/framgia/framgia_crb_v2/issues/126"},"comments":{"href":"https://api.github.com/repos/framgia/framgia_crb_v2/issues/126/comments"},"review_comments":{"href":"https://api.github.com/repos/framgia/framgia_crb_v2/pulls/126/comments"},"review_comment":{"href":"https://api.github.com/repos/framgia/framgia_crb_v2/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/framgia/framgia_crb_v2/pulls/126/commits"},"statuses":{"href":"https://api.github.com/repos/framgia/framgia_crb_v2/statuses/7f6aef8351b6737b1960e41d0196d6ef7e0e355e"}}}}
{"actor":{"display_login":"dieunb"}}