Class: Incentivale::Client

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token) ⇒ Client

Returns a new instance of Client.



5
6
7
# File 'lib/incentivale/client.rb', line 5

def initialize(token)
  @token = token
end

Instance Attribute Details

#tokenObject

Returns the value of attribute token.



3
4
5
# File 'lib/incentivale/client.rb', line 3

def token
  @token
end

Class Method Details

.hostObject



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

def self.host
  case Incentivale.configuration.environment
  when :sandbox
    'https://api-prd-01-hom.incentivale.com.br'
  when :production
    'https://api-prd-01.incentivale.com.br'
  else
    raise StandardError, 'invalid environment provided'
  end
end

Instance Method Details

#current_tokenObject



28
29
30
# File 'lib/incentivale/client.rb', line 28

def current_token
  @token.expired? ? new_token : token
end

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



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

def get(path, params = {})
  request.get path, params.merge(campaign_token)
end

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



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

def post(path, resource = {})
  request.post path, resource.merge(campaign_token)
end