Skip to content

Commit

Permalink
added retry functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
anazar committed Mar 19, 2015
1 parent 5a1681f commit 5d25348
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions lib/vindata/services/nada.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def get_client
end

def get_region_by_state(state)
tries ||= 2
client = get_client
data = client.call(:get_region_by_state_code,
message: { 'l_Request' => { 'Token' => get_token,
Expand All @@ -79,6 +80,9 @@ def get_region_by_state(state)
}
)
data.to_hash[:get_region_by_state_code_response][:get_region_by_state_code_result]
rescue Savon::SOAPFault => error
retry if (tries -= 1) > 0
raise error.message
end

def details_by_vin(vin)
Expand Down Expand Up @@ -110,6 +114,8 @@ def get_acv(data)
client = get_client

begin
tries ||= 2

data = client.call(:get_default_vehicle_and_value_by_vin,
message: { 'vehicleRequest' =>
{ 'Token' => token,
Expand All @@ -132,6 +138,7 @@ def get_acv(data)

rescue Savon::SOAPFault => error
return false if error.message.include? 'No vehicle found'
retry if (tries -= 1) > 0
raise error.message
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/vindata/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module VinData
VERSION = '0.0.4'
VERSION = '0.0.5'
end

0 comments on commit 5d25348

Please sign in to comment.