exact_target_sdk 0.7.0 → 0.8.0
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.rdoc +10 -0
- data/lib/exact_target_sdk.rb +5 -0
- data/lib/exact_target_sdk/api_object.rb +40 -17
- data/lib/exact_target_sdk/api_property.rb +8 -0
- data/lib/exact_target_sdk/attribute.rb +1 -1
- data/lib/exact_target_sdk/client.rb +36 -0
- data/lib/exact_target_sdk/complex_filter_part.rb +3 -3
- data/lib/exact_target_sdk/data_extension.rb +9 -0
- data/lib/exact_target_sdk/data_extension_field.rb +12 -0
- data/lib/exact_target_sdk/data_extension_object.rb +8 -0
- data/lib/exact_target_sdk/perform_response.rb +14 -0
- data/lib/exact_target_sdk/simple_filter_part.rb +2 -2
- data/lib/exact_target_sdk/subscriber.rb +2 -2
- data/lib/exact_target_sdk/triggered_send.rb +1 -1
- data/lib/exact_target_sdk/triggered_send_definition.rb +1 -1
- data/lib/exact_target_sdk/version.rb +1 -1
- metadata +8 -3
data/CHANGELOG.rdoc
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
= ExactTarget SDK
|
2
2
|
|
3
|
+
== Version 0.8.0
|
4
|
+
* Implemented APIProperty object
|
5
|
+
* Implemented DataExtension object
|
6
|
+
* Implemented DataExtensionField object
|
7
|
+
* Implemented DataExtensionObject object
|
8
|
+
* Implemented Perform method
|
9
|
+
* Implemented PerformResponse object
|
10
|
+
* Refactored property, array_property, and int_property to accept options
|
11
|
+
* Allowed array_properties to be specified as nested
|
12
|
+
|
3
13
|
== Version 0.7.0
|
4
14
|
* Implemented Client#Delete method
|
5
15
|
|
data/lib/exact_target_sdk.rb
CHANGED
@@ -4,15 +4,20 @@ require 'exact_target_sdk/errors'
|
|
4
4
|
module ExactTargetSDK
|
5
5
|
|
6
6
|
autoload :APIObject, 'exact_target_sdk/api_object'
|
7
|
+
autoload :APIProperty, 'exact_target_sdk/api_property'
|
7
8
|
autoload :Attribute, 'exact_target_sdk/attribute'
|
8
9
|
autoload :Client, 'exact_target_sdk/client'
|
9
10
|
autoload :ComplexFilterPart, 'exact_target_sdk/complex_filter_part'
|
10
11
|
autoload :ContentArea, 'exact_target_sdk/content_area'
|
11
12
|
autoload :CreateResponse, 'exact_target_sdk/create_response'
|
12
13
|
autoload :CreateResult, 'exact_target_sdk/create_result'
|
14
|
+
autoload :DataExtension, 'exact_target_sdk/data_extension'
|
15
|
+
autoload :DataExtensionField, 'exact_target_sdk/data_extension_field'
|
16
|
+
autoload :DataExtensionObject, 'exact_target_sdk/data_extension_object'
|
13
17
|
autoload :DeleteResponse, 'exact_target_sdk/delete_response'
|
14
18
|
autoload :DeleteResult, 'exact_target_sdk/delete_result'
|
15
19
|
autoload :FilterPart, 'exact_target_sdk/filter_part'
|
20
|
+
autoload :PerformResponse, 'exact_target_sdk/perform_response'
|
16
21
|
autoload :Result, 'exact_target_sdk/result'
|
17
22
|
autoload :RetrieveResponse, 'exact_target_sdk/retrieve_response'
|
18
23
|
autoload :RetrieveResult, 'exact_target_sdk/retrieve_result'
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'active_model'
|
2
|
+
require 'active_support/inflector'
|
2
3
|
|
3
4
|
module ExactTargetSDK
|
4
5
|
|
@@ -18,7 +19,11 @@ class APIObject
|
|
18
19
|
#
|
19
20
|
# Provides a getter and setter for this property, keeping track of
|
20
21
|
# whether or not it has been set and registering it for rendering.
|
21
|
-
def property(name,
|
22
|
+
def property(name, options = {})
|
23
|
+
options = {
|
24
|
+
:required => false
|
25
|
+
}.merge(options)
|
26
|
+
|
22
27
|
name = name.to_s
|
23
28
|
attr_reader name.to_sym
|
24
29
|
class_eval <<-__EOF__
|
@@ -27,10 +32,10 @@ class APIObject
|
|
27
32
|
@#{name} = value
|
28
33
|
end
|
29
34
|
__EOF__
|
30
|
-
if required
|
35
|
+
if options[:required]
|
31
36
|
validates name.to_sym, :presence => true
|
32
37
|
end
|
33
|
-
register_property!(name)
|
38
|
+
register_property!(name, options)
|
34
39
|
end
|
35
40
|
|
36
41
|
# Declares a property as an array of values.
|
@@ -41,9 +46,15 @@ class APIObject
|
|
41
46
|
#
|
42
47
|
# Note that once the property has been either read or written to, it
|
43
48
|
# will be rendered.
|
44
|
-
def array_property(name)
|
49
|
+
def array_property(name, options = {})
|
45
50
|
# TODO: type validation would be nice
|
46
51
|
name = name.to_s
|
52
|
+
|
53
|
+
options = {
|
54
|
+
:nest_children => false,
|
55
|
+
:singular => name.singularize
|
56
|
+
}.merge(options)
|
57
|
+
|
47
58
|
class_eval <<-__EOF__
|
48
59
|
def #{name}
|
49
60
|
@_set_#{name} = true
|
@@ -54,19 +65,22 @@ class APIObject
|
|
54
65
|
@#{name} = value
|
55
66
|
end
|
56
67
|
__EOF__
|
57
|
-
register_property!(name)
|
68
|
+
register_property!(name, options)
|
58
69
|
end
|
59
70
|
|
60
71
|
# Same as #property, adding validation the the provided value is an
|
61
72
|
# integer.
|
62
|
-
def int_property(name,
|
63
|
-
|
73
|
+
def int_property(name, options = {})
|
74
|
+
options = {
|
75
|
+
:required => false
|
76
|
+
}.merge(options)
|
77
|
+
property(name, options)
|
64
78
|
validates name.to_sym, :numericality => { :allow_nil => true, :only_integer => true }
|
65
79
|
end
|
66
80
|
|
67
81
|
# Returns an array of all registered properties.
|
68
82
|
def properties
|
69
|
-
@properties ||
|
83
|
+
@properties || {}
|
70
84
|
end
|
71
85
|
|
72
86
|
def type_name
|
@@ -76,10 +90,9 @@ class APIObject
|
|
76
90
|
private
|
77
91
|
|
78
92
|
# Stores the given property name to be used at render time.
|
79
|
-
def register_property!(name)
|
80
|
-
@properties ||=
|
81
|
-
@properties
|
82
|
-
@properties.uniq!
|
93
|
+
def register_property!(name, options = {})
|
94
|
+
@properties ||= {}
|
95
|
+
@properties[name] = options
|
83
96
|
end
|
84
97
|
|
85
98
|
end
|
@@ -115,21 +128,31 @@ class APIObject
|
|
115
128
|
#
|
116
129
|
# May be overridden.
|
117
130
|
def render_properties!(xml)
|
118
|
-
self.class.properties.each do |property|
|
131
|
+
self.class.properties.each do |property, options|
|
119
132
|
next unless instance_variable_get("@_set_#{property}")
|
120
133
|
property_value = self.send(property)
|
121
|
-
render_property!(property, property_value, xml)
|
134
|
+
render_property!(property, property_value, xml, options)
|
122
135
|
end
|
123
136
|
end
|
124
137
|
|
125
|
-
def
|
138
|
+
def render_property_array!(property_name, array, xml)
|
139
|
+
array.each do |current|
|
140
|
+
render_property!(property_name, current, xml)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
def render_property!(property_name, property_value, xml, options = {})
|
126
145
|
if property_value.is_a?(APIObject)
|
127
146
|
xml.__send__(property_name, { "xsi:type" => property_value.type_name } ) do
|
128
147
|
property_value.render!(xml)
|
129
148
|
end
|
130
149
|
elsif property_value.is_a?(Array)
|
131
|
-
|
132
|
-
|
150
|
+
if options[:nest_children]
|
151
|
+
xml.__send__(property_name) do
|
152
|
+
render_property_array!(options[:singular], property_value, xml)
|
153
|
+
end
|
154
|
+
else
|
155
|
+
render_property_array!(property_name, property_value, xml)
|
133
156
|
end
|
134
157
|
else
|
135
158
|
xml.__send__(property_name, property_value.to_s)
|
@@ -167,6 +167,42 @@ class Client
|
|
167
167
|
DeleteResponse.new(response)
|
168
168
|
end
|
169
169
|
|
170
|
+
# Invokes the Perform method.
|
171
|
+
#
|
172
|
+
# The provided arguments should each be definitions that are sub-classes
|
173
|
+
# of APIObject.
|
174
|
+
#
|
175
|
+
# Possible exceptions are:
|
176
|
+
# HTTPError if an HTTP error (such as a timeout) occurs
|
177
|
+
# SOAPFault if a SOAP fault occurs
|
178
|
+
# Timeout if there is a timeout waiting for the response
|
179
|
+
# InvalidAPIObject if any of the provided objects don't pass validation
|
180
|
+
#
|
181
|
+
# Returns a PerformResponse object.
|
182
|
+
def Perform(action, *args)
|
183
|
+
# TODO: implement and accept PerformOptions
|
184
|
+
|
185
|
+
definitions = args
|
186
|
+
|
187
|
+
response = execute_request 'Perform' do |xml|
|
188
|
+
xml.PerformRequestMsg do
|
189
|
+
xml.Action action
|
190
|
+
|
191
|
+
xml.Definitions do
|
192
|
+
definitions.each do |definition|
|
193
|
+
xml.Definition "xsi:type" => definition.type_name do
|
194
|
+
definition.render!(xml)
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
xml.Options # TODO: support PerformOptions
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
PerformResponse.new(response)
|
204
|
+
end
|
205
|
+
|
170
206
|
def logger
|
171
207
|
config[:logger]
|
172
208
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module ExactTargetSDK
|
2
2
|
class ComplexFilterPart < FilterPart
|
3
3
|
|
4
|
-
property 'LeftOperand', true
|
5
|
-
property 'LogicalOperator', true
|
6
|
-
property 'RightOperand', true
|
4
|
+
property 'LeftOperand', :required => true
|
5
|
+
property 'LogicalOperator', :required => true
|
6
|
+
property 'RightOperand', :required => true
|
7
7
|
|
8
8
|
end
|
9
9
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module ExactTargetSDK
|
2
|
+
class PerformResponse
|
3
|
+
|
4
|
+
attr_reader :OverallStatus, :OverallStatusMessage, :RequestID
|
5
|
+
|
6
|
+
def initialize(response)
|
7
|
+
response = response.to_hash[:perform_response_msg]
|
8
|
+
@OverallStatus = response[:overall_status]
|
9
|
+
@OverallStatusMessage = response[:overall_status_message]
|
10
|
+
@RequestID = response[:request_id]
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
@@ -13,8 +13,8 @@ module ExactTargetSDK
|
|
13
13
|
# new email address.
|
14
14
|
class Subscriber < APIObject
|
15
15
|
|
16
|
-
property 'SubscriberKey', true
|
17
|
-
property 'EmailAddress', true
|
16
|
+
property 'SubscriberKey', :required => true
|
17
|
+
property 'EmailAddress', :required => true
|
18
18
|
property 'EmailTypePreference'
|
19
19
|
array_property 'Attributes'
|
20
20
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: exact_target_sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 63
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 8
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.8.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- David Dawson
|
@@ -89,6 +89,7 @@ extra_rdoc_files:
|
|
89
89
|
- LICENSE.txt
|
90
90
|
files:
|
91
91
|
- lib/exact_target_sdk/api_object.rb
|
92
|
+
- lib/exact_target_sdk/api_property.rb
|
92
93
|
- lib/exact_target_sdk/attribute.rb
|
93
94
|
- lib/exact_target_sdk/client.rb
|
94
95
|
- lib/exact_target_sdk/complex_filter_part.rb
|
@@ -96,10 +97,14 @@ files:
|
|
96
97
|
- lib/exact_target_sdk/content_area.rb
|
97
98
|
- lib/exact_target_sdk/create_response.rb
|
98
99
|
- lib/exact_target_sdk/create_result.rb
|
100
|
+
- lib/exact_target_sdk/data_extension.rb
|
101
|
+
- lib/exact_target_sdk/data_extension_field.rb
|
102
|
+
- lib/exact_target_sdk/data_extension_object.rb
|
99
103
|
- lib/exact_target_sdk/delete_response.rb
|
100
104
|
- lib/exact_target_sdk/delete_result.rb
|
101
105
|
- lib/exact_target_sdk/errors.rb
|
102
106
|
- lib/exact_target_sdk/filter_part.rb
|
107
|
+
- lib/exact_target_sdk/perform_response.rb
|
103
108
|
- lib/exact_target_sdk/result.rb
|
104
109
|
- lib/exact_target_sdk/retrieve_response.rb
|
105
110
|
- lib/exact_target_sdk/retrieve_result.rb
|