Class: Intis::Sdk::UrlHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/intis/sdk/url_helper.rb

Class Method Summary collapse

Class Method Details

.parse_data(response) ⇒ Object



5
6
7
8
9
10
# File 'lib/intis/sdk/url_helper.rb', line 5

def self.parse_data(response)
  response_body = JSON.parse(response.body, symbolize_names: true)
  validate_response! response_body
  
  response_body
end

.validate_response!(response_body) ⇒ Object



12
13
14
15
16
17
# File 'lib/intis/sdk/url_helper.rb', line 12

def self.validate_response!(response_body)
  if !response_body.kind_of?(Array) and response_body.has_key? :error
    response_error = response_body[:error]
    raise("Error. Error code: #{response_error}")
  end
end