{"action":"created","comment":{"url":"https://api.github.com/repos/VAGAScom/exact_target_rest/pulls/comments/67696826","id":67696826,"diff_hunk":"@@ -21,31 +21,30 @@ def initialize(client_id, client_secret)\n     #\n     # @yield [access_token] Block to be executed\n     # @yieldparam access_token [String] Access token used to authorize a request\n+    # @yieldparam expires_in [String] Time to token's expire\n     def with_authorization\n       authorize! unless authorized?\n-      tries = 1\n-      begin\n-        yield @access_token\n-      rescue NotAuthorizedError\n-        authorize!\n-        tries -= 1\n-        retry if tries >= 0\n-      end\n-\n+      yield @access_token\n     end\n \n-    # Execute authorization and keeps an access token\n+    # Execute authorization, keeps an access token and returns the result\n     def authorize!\n+      tries ||= 1\n+\n       resp = endpoint.post do |p|\n         p.body = {clientId: @client_id,\n                   clientSecret: @client_secret}\n       end\n       if resp.success?\n         @access_token = resp.body['accessToken']\n         @expires_in = Time.now + resp.body['expiresIn']\n+        { access_token: @access_token, expires_in: @expires_in }\n       else\n-        fail resp.body.inspect\n+        fail NotAuthorizedError\n       end\n+    rescue NotAuthorizedError","path":"lib/exact_target_rest/authorization.rb","position":36,"original_position":36,"commit_id":"115e8311e1894acdaf4f19af5d3ecd8becd09de1","original_commit_id":"115e8311e1894acdaf4f19af5d3ecd8becd09de1","user":{"login":"rfocosi","id":6683063,"avatar_url":"https://avatars.githubusercontent.com/u/6683063?v=3","gravatar_id":"","url":"https://api.github.com/users/rfocosi","html_url":"https://github.com/rfocosi","followers_url":"https://api.github.com/users/rfocosi/followers","following_url":"https://api.github.com/users/rfocosi/following{/other_user}","gists_url":"https://api.github.com/users/rfocosi/gists{/gist_id}","starred_url":"https://api.github.com/users/rfocosi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rfocosi/subscriptions","organizations_url":"https://api.github.com/users/rfocosi/orgs","repos_url":"https://api.github.com/users/rfocosi/repos","events_url":"https://api.github.com/users/rfocosi/events{/privacy}","received_events_url":"https://api.github.com/users/rfocosi/received_events","type":"User","site_admin":false},"body":"Maybe this retry should not be here. It should be implemented by the caller. What you think about removing this retry?","created_at":"2016-06-20T14:17:16Z","updated_at":"2016-06-20T14:17:17Z","html_url":"https://github.com/VAGAScom/exact_target_rest/pull/2#discussion_r67696826","pull_request_url":"https://api.github.com/repos/VAGAScom/exact_target_rest/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/VAGAScom/exact_target_rest/pulls/comments/67696826"},"html":{"href":"https://github.com/VAGAScom/exact_target_rest/pull/2#discussion_r67696826"},"pull_request":{"href":"https://api.github.com/repos/VAGAScom/exact_target_rest/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/VAGAScom/exact_target_rest/pulls/2","id":74317495,"html_url":"https://github.com/VAGAScom/exact_target_rest/pull/2","diff_url":"https://github.com/VAGAScom/exact_target_rest/pull/2.diff","patch_url":"https://github.com/VAGAScom/exact_target_rest/pull/2.patch","issue_url":"https://api.github.com/repos/VAGAScom/exact_target_rest/issues/2","number":2,"state":"open","locked":false,"title":"Feature/extra attributes","user":{"login":"rfocosi","id":6683063,"avatar_url":"https://avatars.githubusercontent.com/u/6683063?v=3","gravatar_id":"","url":"https://api.github.com/users/rfocosi","html_url":"https://github.com/rfocosi","followers_url":"https://api.github.com/users/rfocosi/followers","following_url":"https://api.github.com/users/rfocosi/following{/other_user}","gists_url":"https://api.github.com/users/rfocosi/gists{/gist_id}","starred_url":"https://api.github.com/users/rfocosi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rfocosi/subscriptions","organizations_url":"https://api.github.com/users/rfocosi/orgs","repos_url":"https://api.github.com/users/rfocosi/repos","events_url":"https://api.github.com/users/rfocosi/events{/privacy}","received_events_url":"https://api.github.com/users/rfocosi/received_events","type":"User","site_admin":false},"body":"Added extra functionalities to TriggeredSend. It helps sending attributes with spaces and sending the API calls asynchronously.\r\n\r\nAs wrote on README:\r\n\r\n- If you have DataExtension's keys with spaces or any unusual pattern\r\n\r\n```ruby\r\nexternal_key = 'My TriggeredSend External Key'\r\nts = ExactTargetRest::TriggeredSend.new(auth, external_key)\r\nts.with_options(email_address: 'uga@kabuga.com', subscriber_attributes: { 'An Attribute' => 'XXX', 'Another_Attribute' => 'YYY' }).deliver\r\n```\r\n\r\n- if you have to call the api asynchronously\r\n\r\n```ruby\r\ndef deliver\r\n  external_key = 'My TriggeredSend External Key'\r\n  triggered_send = ExactTargetRest::TriggeredSend.new(auth, external_key)\r\n  triggered_send.with_options(email_address: 'uga@kabuga.com')\r\n\r\n  Worker.perform_async(triggered_send.to_yaml)\r\nend\r\n\r\nclass Worker\r\n  include Sidekiq::Worker\r\n\r\n  sidekiq_options queue: :exact_target_mailer\r\n\r\n  def perform(triggered_send)\r\n    YAML::load(triggered_send).deliver\r\n  end\r\nend\r\n\r\n```","created_at":"2016-06-17T23:15:53Z","updated_at":"2016-06-20T14:17:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8399842bff812832e0850c4204e73c3efcd78230","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/VAGAScom/exact_target_rest/pulls/2/commits","review_comments_url":"https://api.github.com/repos/VAGAScom/exact_target_rest/pulls/2/comments","review_comment_url":"https://api.github.com/repos/VAGAScom/exact_target_rest/pulls/comments{/number}","comments_url":"https://api.github.com/repos/VAGAScom/exact_target_rest/issues/2/comments","statuses_url":"https://api.github.com/repos/VAGAScom/exact_target_rest/statuses/115e8311e1894acdaf4f19af5d3ecd8becd09de1","head":{"label":"rfocosi:feature/extra-attributes","ref":"feature/extra-attributes","sha":"115e8311e1894acdaf4f19af5d3ecd8becd09de1","user":{"login":"rfocosi","id":6683063,"avatar_url":"https://avatars.githubusercontent.com/u/6683063?v=3","gravatar_id":"","url":"https://api.github.com/users/rfocosi","html_url":"https://github.com/rfocosi","followers_url":"https://api.github.com/users/rfocosi/followers","following_url":"https://api.github.com/users/rfocosi/following{/other_user}","gists_url":"https://api.github.com/users/rfocosi/gists{/gist_id}","starred_url":"https://api.github.com/users/rfocosi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rfocosi/subscriptions","organizations_url":"https://api.github.com/users/rfocosi/orgs","repos_url":"https://api.github.com/users/rfocosi/repos","events_url":"https://api.github.com/users/rfocosi/events{/privacy}","received_events_url":"https://api.github.com/users/rfocosi/received_events","type":"User","site_admin":false},"repo":{"id":61130415,"name":"exact_target_rest","full_name":"rfocosi/exact_target_rest","owner":{"login":"rfocosi","id":6683063,"avatar_url":"https://avatars.githubusercontent.com/u/6683063?v=3","gravatar_id":"","url":"https://api.github.com/users/rfocosi","html_url":"https://github.com/rfocosi","followers_url":"https://api.github.com/users/rfocosi/followers","following_url":"https://api.github.com/users/rfocosi/following{/other_user}","gists_url":"https://api.github.com/users/rfocosi/gists{/gist_id}","starred_url":"https://api.github.com/users/rfocosi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rfocosi/subscriptions","organizations_url":"https://api.github.com/users/rfocosi/orgs","repos_url":"https://api.github.com/users/rfocosi/repos","events_url":"https://api.github.com/users/rfocosi/events{/privacy}","received_events_url":"https://api.github.com/users/rfocosi/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rfocosi/exact_target_rest","description":"Simple wrapper around ExactTarget REST API","fork":true,"url":"https://api.github.com/repos/rfocosi/exact_target_rest","forks_url":"https://api.github.com/repos/rfocosi/exact_target_rest/forks","keys_url":"https://api.github.com/repos/rfocosi/exact_target_rest/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rfocosi/exact_target_rest/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rfocosi/exact_target_rest/teams","hooks_url":"https://api.github.com/repos/rfocosi/exact_target_rest/hooks","issue_events_url":"https://api.github.com/repos/rfocosi/exact_target_rest/issues/events{/number}","events_url":"https://api.github.com/repos/rfocosi/exact_target_rest/events","assignees_url":"https://api.github.com/repos/rfocosi/exact_target_rest/assignees{/user}","branches_url":"https://api.github.com/repos/rfocosi/exact_target_rest/branches{/branch}","tags_url":"https://api.github.com/repos/rfocosi/exact_target_rest/tags","blobs_url":"https://api.github.com/repos/rfocosi/exact_target_rest/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rfocosi/exact_target_rest/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rfocosi/exact_target_rest/git/refs{/sha}","trees_url":"https://api.github.com/repos/rfocosi/exact_target_rest/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rfocosi/exact_target_rest/statuses/{sha}","languages_url":"https://api.github.com/repos/rfocosi/exact_target_rest/languages","stargazers_url":"https://api.github.com/repos/rfocosi/exact_target_rest/stargazers","contributors_url":"https://api.github.com/repos/rfocosi/exact_target_rest/contributors","subscribers_url":"https://api.github.com/repos/rfocosi/exact_target_rest/subscribers","subscription_url":"https://api.github.com/repos/rfocosi/exact_target_rest/subscription","commits_url":"https://api.github.com/repos/rfocosi/exact_target_rest/commits{/sha}","git_commits_url":"https://api.github.com/repos/rfocosi/exact_target_rest/git/commits{/sha}","comments_url":"https://api.github.com/repos/rfocosi/exact_target_rest/comments{/number}","issue_comment_url":"https://api.github.com/repos/rfocosi/exact_target_rest/issues/comments{/number}","contents_url":"https://api.github.com/repos/rfocosi/exact_target_rest/contents/{+path}","compare_url":"https://api.github.com/repos/rfocosi/exact_target_rest/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rfocosi/exact_target_rest/merges","archive_url":"https://api.github.com/repos/rfocosi/exact_target_rest/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rfocosi/exact_target_rest/downloads","issues_url":"https://api.github.com/repos/rfocosi/exact_target_rest/issues{/number}","pulls_url":"https://api.github.com/repos/rfocosi/exact_target_rest/pulls{/number}","milestones_url":"https://api.github.com/repos/rfocosi/exact_target_rest/milestones{/number}","notifications_url":"https://api.github.com/repos/rfocosi/exact_target_rest/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rfocosi/exact_target_rest/labels{/name}","releases_url":"https://api.github.com/repos/rfocosi/exact_target_rest/releases{/id}","deployments_url":"https://api.github.com/repos/rfocosi/exact_target_rest/deployments","created_at":"2016-06-14T14:38:49Z","updated_at":"2016-06-14T14:38:50Z","pushed_at":"2016-06-17T23:11:05Z","git_url":"git://github.com/rfocosi/exact_target_rest.git","ssh_url":"git@github.com:rfocosi/exact_target_rest.git","clone_url":"https://github.com/rfocosi/exact_target_rest.git","svn_url":"https://github.com/rfocosi/exact_target_rest","homepage":null,"size":27,"stargazers_count":0,"watchers_count":0,"language":"Ruby","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":"VAGAScom:master","ref":"master","sha":"e761c460b3cf0f42179cdbae4aa1262c78bab275","user":{"login":"VAGAScom","id":9011045,"avatar_url":"https://avatars.githubusercontent.com/u/9011045?v=3","gravatar_id":"","url":"https://api.github.com/users/VAGAScom","html_url":"https://github.com/VAGAScom","followers_url":"https://api.github.com/users/VAGAScom/followers","following_url":"https://api.github.com/users/VAGAScom/following{/other_user}","gists_url":"https://api.github.com/users/VAGAScom/gists{/gist_id}","starred_url":"https://api.github.com/users/VAGAScom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VAGAScom/subscriptions","organizations_url":"https://api.github.com/users/VAGAScom/orgs","repos_url":"https://api.github.com/users/VAGAScom/repos","events_url":"https://api.github.com/users/VAGAScom/events{/privacy}","received_events_url":"https://api.github.com/users/VAGAScom/received_events","type":"Organization","site_admin":false},"repo":{"id":33327768,"name":"exact_target_rest","full_name":"VAGAScom/exact_target_rest","owner":{"login":"VAGAScom","id":9011045,"avatar_url":"https://avatars.githubusercontent.com/u/9011045?v=3","gravatar_id":"","url":"https://api.github.com/users/VAGAScom","html_url":"https://github.com/VAGAScom","followers_url":"https://api.github.com/users/VAGAScom/followers","following_url":"https://api.github.com/users/VAGAScom/following{/other_user}","gists_url":"https://api.github.com/users/VAGAScom/gists{/gist_id}","starred_url":"https://api.github.com/users/VAGAScom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VAGAScom/subscriptions","organizations_url":"https://api.github.com/users/VAGAScom/orgs","repos_url":"https://api.github.com/users/VAGAScom/repos","events_url":"https://api.github.com/users/VAGAScom/events{/privacy}","received_events_url":"https://api.github.com/users/VAGAScom/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/VAGAScom/exact_target_rest","description":"Simple wrapper around ExactTarget REST API","fork":false,"url":"https://api.github.com/repos/VAGAScom/exact_target_rest","forks_url":"https://api.github.com/repos/VAGAScom/exact_target_rest/forks","keys_url":"https://api.github.com/repos/VAGAScom/exact_target_rest/keys{/key_id}","collaborators_url":"https://api.github.com/repos/VAGAScom/exact_target_rest/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/VAGAScom/exact_target_rest/teams","hooks_url":"https://api.github.com/repos/VAGAScom/exact_target_rest/hooks","issue_events_url":"https://api.github.com/repos/VAGAScom/exact_target_rest/issues/events{/number}","events_url":"https://api.github.com/repos/VAGAScom/exact_target_rest/events","assignees_url":"https://api.github.com/repos/VAGAScom/exact_target_rest/assignees{/user}","branches_url":"https://api.github.com/repos/VAGAScom/exact_target_rest/branches{/branch}","tags_url":"https://api.github.com/repos/VAGAScom/exact_target_rest/tags","blobs_url":"https://api.github.com/repos/VAGAScom/exact_target_rest/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/VAGAScom/exact_target_rest/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/VAGAScom/exact_target_rest/git/refs{/sha}","trees_url":"https://api.github.com/repos/VAGAScom/exact_target_rest/git/trees{/sha}","statuses_url":"https://api.github.com/repos/VAGAScom/exact_target_rest/statuses/{sha}","languages_url":"https://api.github.com/repos/VAGAScom/exact_target_rest/languages","stargazers_url":"https://api.github.com/repos/VAGAScom/exact_target_rest/stargazers","contributors_url":"https://api.github.com/repos/VAGAScom/exact_target_rest/contributors","subscribers_url":"https://api.github.com/repos/VAGAScom/exact_target_rest/subscribers","subscription_url":"https://api.github.com/repos/VAGAScom/exact_target_rest/subscription","commits_url":"https://api.github.com/repos/VAGAScom/exact_target_rest/commits{/sha}","git_commits_url":"https://api.github.com/repos/VAGAScom/exact_target_rest/git/commits{/sha}","comments_url":"https://api.github.com/repos/VAGAScom/exact_target_rest/comments{/number}","issue_comment_url":"https://api.github.com/repos/VAGAScom/exact_target_rest/issues/comments{/number}","contents_url":"https://api.github.com/repos/VAGAScom/exact_target_rest/contents/{+path}","compare_url":"https://api.github.com/repos/VAGAScom/exact_target_rest/compare/{base}...{head}","merges_url":"https://api.github.com/repos/VAGAScom/exact_target_rest/merges","archive_url":"https://api.github.com/repos/VAGAScom/exact_target_rest/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/VAGAScom/exact_target_rest/downloads","issues_url":"https://api.github.com/repos/VAGAScom/exact_target_rest/issues{/number}","pulls_url":"https://api.github.com/repos/VAGAScom/exact_target_rest/pulls{/number}","milestones_url":"https://api.github.com/repos/VAGAScom/exact_target_rest/milestones{/number}","notifications_url":"https://api.github.com/repos/VAGAScom/exact_target_rest/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/VAGAScom/exact_target_rest/labels{/name}","releases_url":"https://api.github.com/repos/VAGAScom/exact_target_rest/releases{/id}","deployments_url":"https://api.github.com/repos/VAGAScom/exact_target_rest/deployments","created_at":"2015-04-02T19:30:05Z","updated_at":"2016-06-14T16:38:49Z","pushed_at":"2016-06-17T23:15:54Z","git_url":"git://github.com/VAGAScom/exact_target_rest.git","ssh_url":"git@github.com:VAGAScom/exact_target_rest.git","clone_url":"https://github.com/VAGAScom/exact_target_rest.git","svn_url":"https://github.com/VAGAScom/exact_target_rest","homepage":null,"size":10,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/VAGAScom/exact_target_rest/pulls/2"},"html":{"href":"https://github.com/VAGAScom/exact_target_rest/pull/2"},"issue":{"href":"https://api.github.com/repos/VAGAScom/exact_target_rest/issues/2"},"comments":{"href":"https://api.github.com/repos/VAGAScom/exact_target_rest/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/VAGAScom/exact_target_rest/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/VAGAScom/exact_target_rest/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/VAGAScom/exact_target_rest/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/VAGAScom/exact_target_rest/statuses/115e8311e1894acdaf4f19af5d3ecd8becd09de1"}}}}
{"actor":{"display_login":"rfocosi"}}