class Incentivale::Client
Attributes
token[RW]
Public Class Methods
host()
click to toggle source
# 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
new(token)
click to toggle source
# File lib/incentivale/client.rb, line 5 def initialize(token) @token = token end
Public Instance Methods
current_token()
click to toggle source
# File lib/incentivale/client.rb, line 28 def current_token @token.expired? ? new_token : token end
get(path, params = {})
click to toggle source
# File lib/incentivale/client.rb, line 20 def get(path, params = {}) request.get path, params.merge(campaign_token) end
post(path, resource = {})
click to toggle source
# File lib/incentivale/client.rb, line 24 def post(path, resource = {}) request.post path, resource.merge(campaign_token) end
Private Instance Methods
campaign_token()
click to toggle source
# File lib/incentivale/client.rb, line 38 def campaign_token @campaign_token ||= { token: Incentivale.configuration.campaign } end
new_token()
click to toggle source
# File lib/incentivale/client.rb, line 42 def new_token self.token = token.refresh end
request()
click to toggle source
# File lib/incentivale/client.rb, line 34 def request Request.new(self) end