incentivale-sdk-ruby 0.1.3 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/incentivale/client.rb +11 -2
- data/lib/incentivale/configuration.rb +1 -0
- data/lib/incentivale/request.rb +1 -2
- data/lib/incentivale/token.rb +13 -6
- data/lib/incentivale/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df7544f9d5950fe3c3708e4b3e13768ed61acf49bcfb8020e5c4fd930051e29d
|
4
|
+
data.tar.gz: e4bfcd457a1b0b1de66e73947cad54e28c40efeede3e3a94ee06b55762934b1f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c0c50cd01db8d8d44e629d373ceea757a8ab5913185a61615043003a0eee8d5f518b00803fb9aaa745b3830b3d1c7e949b76edc35a8645d9c1042b6b53a66c49
|
7
|
+
data.tar.gz: bca2458d00c615776d7277eafd5f8abf0b108ca5eda1c4c30c08f9a40479cbdfee7688fead9b4112ef339f94d0b031259c79f899c7f244a11927ac1bc77c1059
|
data/lib/incentivale/client.rb
CHANGED
@@ -1,13 +1,22 @@
|
|
1
1
|
module Incentivale
|
2
2
|
class Client
|
3
|
-
HOST = 'https://central-incentivale.herokuapp.com' # FIXME 'https://central.incentivale.com.br'
|
4
|
-
|
5
3
|
attr_accessor :token
|
6
4
|
|
7
5
|
def initialize(token)
|
8
6
|
@token = token
|
9
7
|
end
|
10
8
|
|
9
|
+
def self.host
|
10
|
+
case Incentivale.configuration.environment
|
11
|
+
when :sandbox
|
12
|
+
'https://homologacentral.incentivale.com.br'
|
13
|
+
when :production
|
14
|
+
'https://central.incentivale.com.br'
|
15
|
+
else
|
16
|
+
raise StandardError, 'invalid environment provided'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
11
20
|
def get(path, params = {})
|
12
21
|
request.get path, params.merge(campaign_token)
|
13
22
|
end
|
data/lib/incentivale/request.rb
CHANGED
@@ -5,11 +5,10 @@ module Incentivale
|
|
5
5
|
attr_accessor :connection
|
6
6
|
|
7
7
|
def initialize(client)
|
8
|
-
@connection = Faraday.new(url: Client
|
8
|
+
@connection = Faraday.new(url: Client.host) do |builder|
|
9
9
|
builder.headers['Authorization'] = Auth.new(client).header
|
10
10
|
builder.headers['Content-Type'] = 'application/x-www-form-urlencoded'
|
11
11
|
builder.headers['Connection'] = 'Keep-Alive'
|
12
|
-
builder.request :url_encoded
|
13
12
|
builder.adapter Faraday.default_adapter
|
14
13
|
end
|
15
14
|
end
|
data/lib/incentivale/token.rb
CHANGED
@@ -30,15 +30,22 @@ module Incentivale
|
|
30
30
|
private
|
31
31
|
|
32
32
|
def token_host
|
33
|
-
Client
|
33
|
+
Client.host + '/oauth/token'
|
34
|
+
end
|
35
|
+
|
36
|
+
def token_grants
|
37
|
+
{ username: Incentivale.configuration.username,
|
38
|
+
password: Incentivale.configuration.password,
|
39
|
+
grant_type: :password }
|
34
40
|
end
|
35
41
|
|
36
42
|
def generate_new_token
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
43
|
+
connection = Faraday.new(url: token_host)
|
44
|
+
response = connection.post do |request|
|
45
|
+
request.headers['Content-Type'] = 'application/x-www-form-urlencoded'
|
46
|
+
request.body = URI.encode_www_form(token_grants)
|
47
|
+
end
|
48
|
+
Response.new(response)
|
42
49
|
end
|
43
50
|
end
|
44
51
|
end
|
data/lib/incentivale/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: incentivale-sdk-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leonardo Santos
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-07-
|
11
|
+
date: 2018-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|