79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
# File 'lib/ups/UpsInfo.rb', line 79
def getTransitTime(options)
@url = options[:mode] == "production" ? PRODUCTION_URL : TEST_URL + '/TimeInTransit'
pickup_date = calculate_pickup_date
options[:pickup_date] = pickup_date.strftime('%Y%m%d')
xml = @access_xml + generate_xml(build_transit_attributes(options))
delivery_dates = {}
attempts = 0
begin
Timeout.timeout(@timeout) do
response = send_request(@url, xml)
delivery_dates = response_to_map(response)
end
rescue Timeout::Error => error
if(attempts < @retry_count)
attempts += 1
retry
else
raise error
end
end
delivery_dates
end
|