exact-target-api 0.0.1 → 0.0.2
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/exact-target-api/client.rb +13 -9
- data/lib/exact-target-api/subscriber.rb +5 -1
- data/lib/exact-target-api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3b6bd3ed15cda28cfe2f05f7e89c35a03bbc472
|
4
|
+
data.tar.gz: 636380464fa77643163b5a54f422683e6bfa84c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b2a89d7eb6d1262eee81b4f018cf2bfc954f2fc9fd2ba61e337ad2421c08e1a5d4c6ce671528d402cd59f93a304fcdbfbe1758cf5460678ec6b2ca39b9541c0
|
7
|
+
data.tar.gz: bf9efa06eac1b73196e8d910623ad662029f5db016f300844cb00d3f5ae547f9ba164ff82e41f2d649a7193e55189a2b319e1df28f87136c176ce72f3d982e2e
|
@@ -27,7 +27,7 @@ module ET
|
|
27
27
|
@internalAuthToken = jwt['request']['user']['internalOauthToken']
|
28
28
|
@refreshKey = jwt['request']['user']['refreshToken']
|
29
29
|
|
30
|
-
self.
|
30
|
+
self.determine_stack
|
31
31
|
|
32
32
|
@authObj = {'oAuth' => {'oAuthToken' => @internalAuthToken}}
|
33
33
|
@authObj[:attributes!] = { 'oAuth' => { 'xmlns' => 'http://exacttarget.com' }}
|
@@ -41,7 +41,7 @@ module ET
|
|
41
41
|
open_timeout: 180,
|
42
42
|
read_timeout: 180)
|
43
43
|
end
|
44
|
-
|
44
|
+
refresh_token
|
45
45
|
rescue
|
46
46
|
raise
|
47
47
|
end
|
@@ -49,7 +49,7 @@ module ET
|
|
49
49
|
@ready = @auth.operations.length > 0 && @status >= 200 && @status <= 400
|
50
50
|
end
|
51
51
|
|
52
|
-
def
|
52
|
+
def refresh_token(force = nil)
|
53
53
|
#If we don't already have a token or the token expires within 5 min(300 seconds), get one
|
54
54
|
if force || @authToken.nil? || Time.now + 300 > @authTokenExpiration
|
55
55
|
begin
|
@@ -58,10 +58,12 @@ module ET
|
|
58
58
|
http.use_ssl = true
|
59
59
|
request = Net::HTTP::Post.new(uri.request_uri)
|
60
60
|
|
61
|
-
jsonPayload = {clientId: @clientId, clientSecret: @clientSecret
|
61
|
+
jsonPayload = {clientId: @clientId, clientSecret: @clientSecret, accessType: 'offline'}
|
62
62
|
# Pass in the refreshKey if we have it
|
63
|
-
|
64
|
-
|
63
|
+
if @refreshKey
|
64
|
+
jsonPayload[:refreshToken] = @refreshKey
|
65
|
+
jsonPayload[:scope] = "cas:#{@internalAuthToken}"
|
66
|
+
end
|
65
67
|
request.body = jsonPayload.to_json
|
66
68
|
request.add_field "Content-Type", "application/json"
|
67
69
|
tokenResponse = JSON.parse(http.request(request).body)
|
@@ -78,7 +80,7 @@ module ET
|
|
78
80
|
end
|
79
81
|
|
80
82
|
|
81
|
-
self.
|
83
|
+
self.determine_stack if @endpoint.nil?
|
82
84
|
|
83
85
|
@authObj = {'oAuth' => {'oAuthToken' => @internalAuthToken}}
|
84
86
|
@authObj[:attributes!] = {'oAuth' => {'xmlns' => 'http://exacttarget.com' }}
|
@@ -155,7 +157,7 @@ module ET
|
|
155
157
|
@wsdl = config[:defaultwsdl] || 'https://webservice.exacttarget.com/etframework.wsdl'
|
156
158
|
end
|
157
159
|
|
158
|
-
def
|
160
|
+
def determine_stack
|
159
161
|
begin
|
160
162
|
uri = URI.parse("https://www.exacttargetapis.com/platform/v1/endpoints/soap?access_token=" + @authToken)
|
161
163
|
http = Net::HTTP.new(uri.host, uri.port)
|
@@ -171,5 +173,7 @@ module ET
|
|
171
173
|
raise 'Unable to determine stack using /platform/v1/tokenContext: ' + e.message
|
172
174
|
end
|
173
175
|
end
|
176
|
+
|
177
|
+
alias_method :refreshToken, :refresh_token
|
174
178
|
end
|
175
|
-
end
|
179
|
+
end
|
@@ -24,7 +24,11 @@ module ET
|
|
24
24
|
end
|
25
25
|
|
26
26
|
props = {'EmailAddress' => email}
|
27
|
-
props['SubscriberKey'] =
|
27
|
+
props['SubscriberKey'] = if params['SubscriberKey']
|
28
|
+
params.delete('SubscriberKey')
|
29
|
+
else
|
30
|
+
email
|
31
|
+
end
|
28
32
|
|
29
33
|
props['Lists'] = [{'ID' => list_id.to_s}] if list_id
|
30
34
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: exact-target-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Shapiotko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-06-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: savon
|