Skip to content

Commit

Permalink
Merge pull request salesforce-marketingcloud#58 from clupprich/remove…
Browse files Browse the repository at this point in the history
…-retry

Remove evil retry
  • Loading branch information
amagar088 authored Dec 29, 2016
2 parents c68c15d + 3a05772 commit 99f2fb0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 27 deletions.
23 changes: 7 additions & 16 deletions lib/marketingcloudsdk/rest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,22 +100,13 @@ def rest_post url, properties={}
end

private
def rest_request action, url, options={}
retried = false
begin
#Try to refresh the token and if we do then we need to regenerate the header as well.
self.refresh
(options['params'] ||= {}).merge! 'access_token' => access_token
rsp = rest_client.send(action, url, options)
raise 'Unauthorized' if rsp.message == 'Unauthorized'
rescue
raise if retried
self.refresh! # ask for forgiveness not, permission
retried = true
retry
end
rsp
rescue
def rest_request action, url, options={}
#Try to refresh the token and if we do then we need to regenerate the header as well.
self.refresh
(options['params'] ||= {}).merge! 'access_token' => access_token
rsp = rest_client.send(action, url, options)
raise 'Unauthorized' if rsp.message == 'Unauthorized'

rsp
end
end
Expand Down
13 changes: 2 additions & 11 deletions lib/marketingcloudsdk/soap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -271,17 +271,8 @@ def soap_cud action, object_type, properties, upsert=nil

def soap_request action, message
response = action.eql?(:describe) ? DescribeResponse : SoapResponse
retried = false
begin
rsp = soap_client.call(action, :message => message)
rescue
raise if retried
retried = true
retry
end
response.new rsp, self
rescue
raise if rsp.nil?

rsp = soap_client.call(action, :message => message)
response.new rsp, self
end
end
Expand Down

0 comments on commit 99f2fb0

Please sign in to comment.