fuelsdk 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog.md +3 -1
- data/lib/fuelsdk.rb +3 -0
- data/lib/fuelsdk/objects.rb +79 -18
- data/lib/fuelsdk/soap.rb +13 -2
- data/lib/fuelsdk/version.rb +1 -1
- data/spec/objects_spec.rb +4 -4
- data/spec/soap/get_spec.rb +12 -0
- metadata +2 -2
data/ChangeLog.md
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
FuelSDK-Ruby
|
2
2
|
============
|
3
3
|
|
4
|
-
2013-
|
4
|
+
2013-10-17: Version 0.1.5
|
5
5
|
```
|
6
6
|
moved dataextension property munging into client so not required to instantiate those objects.
|
7
|
+
|
8
|
+
convert properties to array at last minute. fixes #14
|
7
9
|
```
|
8
10
|
|
9
11
|
2013-09-18: Version 0.1.3
|
data/lib/fuelsdk.rb
CHANGED
data/lib/fuelsdk/objects.rb
CHANGED
@@ -4,7 +4,7 @@ module FuelSDK
|
|
4
4
|
module Read
|
5
5
|
attr_accessor :filter
|
6
6
|
def get _id=nil
|
7
|
-
client.soap_get _id||id, properties, filter
|
7
|
+
client.soap_get _id||id, Array.wrap(properties), filter
|
8
8
|
end
|
9
9
|
|
10
10
|
def info
|
@@ -14,15 +14,15 @@ module FuelSDK
|
|
14
14
|
|
15
15
|
module CUD #create, update, delete
|
16
16
|
def post
|
17
|
-
client.soap_post id, properties
|
17
|
+
client.soap_post id, Array.wrap(properties)
|
18
18
|
end
|
19
19
|
|
20
20
|
def patch
|
21
|
-
client.soap_patch id, properties
|
21
|
+
client.soap_patch id, Array.wrap(properties)
|
22
22
|
end
|
23
23
|
|
24
24
|
def delete
|
25
|
-
client.soap_delete id, properties
|
25
|
+
client.soap_delete id, Array.wrap(properties)
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
@@ -30,21 +30,21 @@ module FuelSDK
|
|
30
30
|
module Rest
|
31
31
|
module Read
|
32
32
|
def get
|
33
|
-
client.rest_get id, properties
|
33
|
+
client.rest_get id, Array.wrap(properties)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
37
|
module CUD
|
38
38
|
def post
|
39
|
-
client.rest_post id, properties
|
39
|
+
client.rest_post id, Array.wrap(properties)
|
40
40
|
end
|
41
41
|
|
42
42
|
def patch
|
43
|
-
client.rest_patch id, properties
|
43
|
+
client.rest_patch id, Array.wrap(properties)
|
44
44
|
end
|
45
45
|
|
46
46
|
def delete
|
47
|
-
client.rest_delete id, properties
|
47
|
+
client.rest_delete id, Array.wrap(properties)
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
@@ -56,11 +56,6 @@ module FuelSDK
|
|
56
56
|
alias props= properties= # backward compatibility
|
57
57
|
alias authStub= client= # backward compatibility
|
58
58
|
|
59
|
-
def properties
|
60
|
-
@properties = [@properties].compact unless @properties.kind_of? Array
|
61
|
-
@properties
|
62
|
-
end
|
63
|
-
|
64
59
|
def id
|
65
60
|
self.class.id
|
66
61
|
end
|
@@ -167,10 +162,6 @@ module FuelSDK
|
|
167
162
|
'DataExtensionField'
|
168
163
|
end
|
169
164
|
def get
|
170
|
-
if filter and filter.kind_of? Hash and \
|
171
|
-
filter.include? 'Property' and filter['Property'] == 'CustomerKey'
|
172
|
-
filter['Property'] = 'DataExtension.CustomerKey'
|
173
|
-
end
|
174
165
|
super
|
175
166
|
end
|
176
167
|
end
|
@@ -264,7 +255,7 @@ module FuelSDK
|
|
264
255
|
raise 'Unable to handle muliple DataExtension definitions and a field definition'
|
265
256
|
end
|
266
257
|
|
267
|
-
d.each do |de|
|
258
|
+
Array.wrap(d).each do |de|
|
268
259
|
|
269
260
|
if (explicit_fields(de) and (de['columns'] || de['fields'] || has_fields)) or
|
270
261
|
(de['columns'] and (de['fields'] || has_fields)) or
|
@@ -345,4 +336,74 @@ module FuelSDK
|
|
345
336
|
end
|
346
337
|
end
|
347
338
|
end
|
339
|
+
|
340
|
+
class Post < Objects::Base
|
341
|
+
include Objects::Soap::CUD
|
342
|
+
attr_accessor :id
|
343
|
+
|
344
|
+
def initialize client, id, properties
|
345
|
+
self.properties = properties
|
346
|
+
self.client = client
|
347
|
+
self.id = id
|
348
|
+
end
|
349
|
+
|
350
|
+
def post
|
351
|
+
super
|
352
|
+
end
|
353
|
+
|
354
|
+
class << self
|
355
|
+
def new client, id, properties=nil
|
356
|
+
o = self.allocate
|
357
|
+
o.send :initialize, client, id, properties
|
358
|
+
return o.post
|
359
|
+
end
|
360
|
+
end
|
361
|
+
end
|
362
|
+
|
363
|
+
class Delete < Objects::Base
|
364
|
+
include Objects::Soap::CUD
|
365
|
+
attr_accessor :id
|
366
|
+
|
367
|
+
def initialize client, id, properties
|
368
|
+
self.properties = properties
|
369
|
+
self.client = client
|
370
|
+
self.id = id
|
371
|
+
end
|
372
|
+
|
373
|
+
def delete
|
374
|
+
super
|
375
|
+
end
|
376
|
+
|
377
|
+
class << self
|
378
|
+
def new client, id, properties=nil
|
379
|
+
o = self.allocate
|
380
|
+
o.send :initialize, client, id, properties
|
381
|
+
return o.delete
|
382
|
+
end
|
383
|
+
end
|
384
|
+
end
|
385
|
+
|
386
|
+
class Patch < Objects::Base
|
387
|
+
include Objects::Soap::CUD
|
388
|
+
attr_accessor :id
|
389
|
+
|
390
|
+
def initialize client, id, properties
|
391
|
+
self.properties = properties
|
392
|
+
self.client = client
|
393
|
+
self.id = id
|
394
|
+
end
|
395
|
+
|
396
|
+
def patch
|
397
|
+
super
|
398
|
+
end
|
399
|
+
|
400
|
+
class << self
|
401
|
+
def new client, id, properties=nil
|
402
|
+
o = self.allocate
|
403
|
+
o.send :initialize, client, id, properties
|
404
|
+
return o.patch
|
405
|
+
end
|
406
|
+
end
|
407
|
+
end
|
408
|
+
|
348
409
|
end
|
data/lib/fuelsdk/soap.rb
CHANGED
@@ -247,8 +247,19 @@ module FuelSDK
|
|
247
247
|
}
|
248
248
|
end
|
249
249
|
|
250
|
-
def
|
250
|
+
def normalize_customer_key filter, object_type
|
251
|
+
filter.tap do |f|
|
252
|
+
if is_a_dataextension? object_type
|
253
|
+
if filter['Property'] == 'CustomerKey'
|
254
|
+
f['Property'] = 'DataExtension.CustomerKey'
|
255
|
+
end
|
256
|
+
end
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
def normalize_filter filter, object_type=''
|
251
261
|
if filter and filter.kind_of? Hash
|
262
|
+
normalize_customer_key filter, object_type
|
252
263
|
if filter.has_key?('LogicalOperator')
|
253
264
|
add_complex_filter_part filter
|
254
265
|
else
|
@@ -338,7 +349,7 @@ module FuelSDK
|
|
338
349
|
end
|
339
350
|
|
340
351
|
def is_a_dataextension? object_type
|
341
|
-
object_type
|
352
|
+
object_type.start_with? 'DataExtension'
|
342
353
|
end
|
343
354
|
|
344
355
|
def format_object_cud_properties object_type, properties
|
data/lib/fuelsdk/version.rb
CHANGED
data/spec/objects_spec.rb
CHANGED
@@ -6,13 +6,13 @@ describe FuelSDK::Objects::Base do
|
|
6
6
|
subject{ object }
|
7
7
|
|
8
8
|
describe '#properties' do
|
9
|
-
it 'is
|
10
|
-
expect(object.properties).to
|
9
|
+
it 'is nil by default' do
|
10
|
+
expect(object.properties).to be_nil
|
11
11
|
end
|
12
12
|
|
13
|
-
it 'returns
|
13
|
+
it 'returns property' do
|
14
14
|
object.properties = {'name' => 'value'}
|
15
|
-
expect(object.properties).to eq(
|
15
|
+
expect(object.properties).to eq({'name' => 'value'})
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'returns array when assigned array' do
|
data/spec/soap/get_spec.rb
CHANGED
@@ -254,4 +254,16 @@ describe FuelSDK::Soap do
|
|
254
254
|
end
|
255
255
|
end
|
256
256
|
|
257
|
+
describe '#normalize_customer_key' do
|
258
|
+
it 'changes CustomerKey to DataExtension.CustomerKey' do
|
259
|
+
expect(client.normalize_customer_key({'Property' => 'CustomerKey'}, 'DataExtensionField'))
|
260
|
+
.to eq({'Property' => 'DataExtension.CustomerKey'})
|
261
|
+
end
|
262
|
+
|
263
|
+
it 'nothing changes if object is not a DataExtension' do
|
264
|
+
expect(client.normalize_customer_key({'Property' => 'CustomerKey'}, 'SomethingObject'))
|
265
|
+
.to eq({'Property' => 'CustomerKey'})
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
257
269
|
end
|
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.
|
4
|
+
version: 0.1.5
|
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-
|
13
|
+
date: 2013-10-17 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|