Class: Raynet::Core

Inherits:
Object
  • Object
show all
Defined in:
lib/raynet/core.rb

Direct Known Subclasses

BusinessCases, Companies, Leads

Instance Method Summary collapse

Instance Method Details

#headersObject



17
18
19
# File 'lib/raynet/core.rb', line 17

def headers
  {'X-Instance-Name' => Raynet::Config.config[:instance_name], accept: :json, content_type: :json}
end

#request(params = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/raynet/core.rb', line 4

def request(params = {})
  req = RestClient::Request.new(
      method: params[:method],
      url: "https://app.raynet.cz/api/v2/#{params[:endpoint]}",
      user: Raynet::Config.config[:user],
      password: Raynet::Config.config[:api_key],
      headers: headers,
      payload: params[:data].to_json
  ).execute

  JSON.parse(req, symbolize_keys: true)
end