Method: Zype::Client#execute

Defined in:
lib/zype/client.rb

#execute(method:, path:, params: {}) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/zype/client.rb', line 53

def execute(method:, path:, params: {})
  if Zype.configuration.api_key.to_s.empty?
    raise NoApiKey if Zype.configuration.app_key.to_s.empty?
  end

  resp = self.send(method, path: path, params: params)
  if resp.success?
    resp['response'].nil? ? resp.parsed_response : resp['response']
  else
    error!(code: resp.code, message: resp['message'])
  end
end