Class: ViralLoops::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/viral_loops/client.rb

Direct Known Subclasses

Resources::Participants

Constant Summary collapse

API_VERSION =
'v3'

Instance Method Summary collapse

Constructor Details

#initialize(secret_token: ViralLoops.configuration.secret_token) ⇒ Client



11
12
13
14
15
16
17
18
# File 'lib/viral_loops/client.rb', line 11

def initialize(secret_token: ViralLoops.configuration.secret_token)
  @connection = Faraday.new(url: ViralLoops.configuration.api_base) do |faraday|
    faraday.headers['Content-Type'] = 'application/json'
    faraday.headers['apiToken'] = secret_token
    faraday.adapter Faraday.default_adapter
    faraday.response :logger if ViralLoops.configuration.debug
  end
end

Instance Method Details

#get(path, params = {}) ⇒ Object



20
21
22
# File 'lib/viral_loops/client.rb', line 20

def get(path, params = {})
  handle_response @connection.get(get_path(path), params)
end

#post(path, body = {}) ⇒ Object



24
25
26
# File 'lib/viral_loops/client.rb', line 24

def post(path, body = {})
  handle_response @connection.post(get_path(path), body.to_json)
end