24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/mbsy/resources/base.rb', line 24
def call(method, params = {})
response = JSON.parse(self.get(api_url(method), :query => params).body)['response']
case response['code']
when '200'
when '400'
raise BadRequestError.new(response['errors']['error'])
when '401'
raise UnauthorizedError.new(response['errors']['error'])
when '404'
raise RecordNotFound.new(response['errors']['error'])
when '500'
raise ServerError.new(response['errors']['error'])
else
raise BadResponse.new(response: response)
end
response['data']
end
|