fuelsdk 0.1.1 → 0.1.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.
data/ChangeLog.md CHANGED
@@ -1,13 +1,22 @@
1
1
  FuelSDK-Ruby
2
2
  ============
3
3
 
4
- 2013-09-11: Version 0.1.1
4
+ 2013-09-18: Version 0.1.2
5
+ ```
6
+ get properties for dataextension for retrieve and edit calls
7
+
8
+ clear soap client on refresh so the client gets re-established with header with new token
9
+
10
+ refresh tests
11
+ ```
12
+
13
+ 2013-09-11: Version 0.1.1
5
14
  ```
6
15
  Added ChangeLog
7
-
16
+
8
17
  soap_configure, soap_perform with supporting tests
9
-
18
+
10
19
  make soap_cud more rubular and easier to read and support
11
-
20
+
12
21
  fixed some issues when trying to make requests after being passed a jwt
13
22
  ```
data/README.md CHANGED
@@ -81,7 +81,7 @@ All methods on Fuel SDK objects return a generic object that follows the same st
81
81
  - code: HTTP Error Code (will always be 200 for SOAP requests)
82
82
  - message: Text values containing more details in the event of an error
83
83
  - results: Collection containing the details unique to the method called.
84
- - more? - Boolean value that indicates on Get requests if more data is available.
84
+ - more? - Boolean value that indicates on Get requests if more data is available.
85
85
 
86
86
 
87
87
  ## Samples ##
data/fuelsdk.gemspec CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency "guard"
25
25
  spec.add_development_dependency "guard-rspec"
26
26
 
27
- spec.add_dependency "savon", "~> 2.0"
27
+ spec.add_dependency "savon", "2.1.0"
28
28
  spec.add_dependency "json", "~> 1.7.0"
29
29
  spec.add_dependency "jwt", "~> 0.1.6"
30
30
  spec.add_dependency "activesupport", "~> 3.2.8"
@@ -90,15 +90,20 @@ module FuelSDK
90
90
  end
91
91
 
92
92
  def request_token_options data
93
- Hash.new.tap do |h|
94
- h['data'] = data
95
- h['content_type'] = 'application/json'
96
- h['params'] = {'legacy' => 1}
97
- end
93
+ {
94
+ 'data' => data,
95
+ 'content_type' => 'application/json',
96
+ 'params' => {'legacy' => 1}
97
+ }
98
+ end
99
+
100
+ def clear_clients
101
+ instance_variable_set '@soap_client', nil
98
102
  end
99
103
 
100
104
  def refresh force=false
101
105
  if (self.auth_token.nil? || force)
106
+ clear_clients
102
107
  options = request_token_options(request_token_data)
103
108
  response = post("https://auth.exacttargetapis.com/v1/requestToken", options)
104
109
  raise "Unable to refresh token: #{response['message']}" unless response.has_key?('accessToken')
data/lib/fuelsdk/soap.rb CHANGED
@@ -139,6 +139,15 @@ module FuelSDK
139
139
  rsp
140
140
  end
141
141
 
142
+ def get_dataextension_properties dataextension
143
+ soap_get('DataExtensionField',
144
+ 'Name',
145
+ 'Property' => "DataExtension.CustomerKey",
146
+ 'SimpleOperator' => 'equals',
147
+ 'Value' => dataextension
148
+ ).results.collect{|f| f[:name]}
149
+ end
150
+
142
151
  def cache_properties action, object_type, properties
143
152
  raise 'Properties should be in cache as a list' unless properties.kind_of? Array
144
153
  cache[action][object_type] = properties
@@ -1,3 +1,3 @@
1
1
  module FuelSDK
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
data/spec/client_spec.rb CHANGED
@@ -161,6 +161,49 @@ describe FuelSDK::Client do
161
161
 
162
162
  let(:client) { FuelSDK::Client.new }
163
163
 
164
+ it 'does nothing if auth_token exists' do
165
+ client.should_receive(:auth_token).and_return(true)
166
+ client.should_not_receive(:clear_clients)
167
+ client.refresh
168
+ end
169
+
170
+ describe 'requests and sets new tokens' do
171
+ subject {
172
+ client.should_receive(:request_token_data)
173
+ client.should_receive(:request_token_options).and_return('options')
174
+ client.should_receive(:post)
175
+ .with("https://auth.exacttargetapis.com/v1/requestToken", 'options')
176
+ .and_return 'accessToken' => :access,
177
+ 'legacyToken' => :legacy,
178
+ 'refreshToken' => :refresh
179
+ client
180
+ }
181
+ it 'calls #clear_clients' do
182
+ subject.instance_variable_set '@soap_client', 'SOAP'
183
+ expect(subject.instance_variable_get '@soap_client').to eq 'SOAP'
184
+ subject.refresh
185
+ expect(subject.instance_variable_get '@soap_client').to be_nil
186
+ end
187
+ it 'sets auth_token' do
188
+ subject.refresh
189
+ expect(subject.auth_token).to eq :access
190
+ end
191
+ it 'sets internal_token' do
192
+ subject.refresh
193
+ expect(subject.internal_token).to eq :legacy
194
+ end
195
+ it 'sets refresh_token' do
196
+ subject.refresh
197
+ expect(subject.refresh_token).to eq :refresh
198
+ end
199
+
200
+ it 'sets auth_token when forced and auth_token is present' do
201
+ subject.auth_token = true
202
+ subject.refresh(true)
203
+ expect(subject.auth_token).to eq :access
204
+ end
205
+ end
206
+
164
207
  context 'raises an exception' do
165
208
 
166
209
  it 'when client id and secret are missing' do
@@ -177,22 +220,6 @@ describe FuelSDK::Client do
177
220
  expect { client.refresh }.to raise_exception 'Require Client Id and Client Secret to refresh tokens'
178
221
  end
179
222
  end
180
-
181
- #context 'posts' do
182
- # let(:client) { FuelSDK::Client.new 'client' => { 'id' => 123, 'secret' => 'sssh'} }
183
- # it 'accessType=offline' do
184
- # client.stub(:post)
185
- # .with({'clientId' => 123, 'secret' => 'ssh', 'accessType' => 'offline'})
186
- # .and_return()
187
- #end
188
-
189
- #context 'updates' do
190
- # let(:client) { FuelSDK::Client.new 'client' => { 'id' => 123, 'secret' => 'sssh'} }
191
-
192
- # it 'access_token' do
193
- # #client.stub(:post).
194
- # end
195
- #end
196
223
  end
197
224
 
198
225
  describe 'includes HTTPRequest' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fuelsdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-09-12 00:00:00.000000000 Z
13
+ date: 2013-09-18 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -97,17 +97,17 @@ dependencies:
97
97
  requirement: !ruby/object:Gem::Requirement
98
98
  none: false
99
99
  requirements:
100
- - - ~>
100
+ - - '='
101
101
  - !ruby/object:Gem::Version
102
- version: '2.0'
102
+ version: 2.1.0
103
103
  type: :runtime
104
104
  prerelease: false
105
105
  version_requirements: !ruby/object:Gem::Requirement
106
106
  none: false
107
107
  requirements:
108
- - - ~>
108
+ - - '='
109
109
  - !ruby/object:Gem::Version
110
- version: '2.0'
110
+ version: 2.1.0
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: json
113
113
  requirement: !ruby/object:Gem::Requirement