26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/linkshare_api/coupon_web_service.rb', line 26
def query(params)
raise ArgumentError, "Hash expected, got #{params.class} instead" unless params.is_a?(Hash)
params.merge!(token: token)
begin
response = self.class.get(
api_base_url,
query: params,
timeout: api_timeout
)
rescue Timeout::Error
raise ConnectionError.new("Timeout error (#{timeout}s)")
end
if response.code != 200
raise Error.new(response.message, response.code)
end
error = response["fault"]
raise InvalidRequestError.new(error["errorstring"], error["errorcode"].to_i) if error
Response.new(response, :coupon_web_service)
end
|