Class: Incentivale::Client
- Inherits:
-
Object
- Object
- Incentivale::Client
- Defined in:
- lib/incentivale/client.rb
Instance Attribute Summary collapse
-
#token ⇒ Object
Returns the value of attribute token.
Class Method Summary collapse
Instance Method Summary collapse
- #current_token ⇒ Object
- #get(path, params = {}) ⇒ Object
-
#initialize(token) ⇒ Client
constructor
A new instance of Client.
- #post(path, resource = {}) ⇒ Object
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
#token ⇒ Object
Returns the value of attribute token.
3 4 5 |
# File 'lib/incentivale/client.rb', line 3 def token @token end |
Class Method Details
.host ⇒ Object
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_token ⇒ Object
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 |