exact_target_sdk 0.3.0 → 0.4.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 +5 -0
- data/README.rdoc +3 -3
- data/lib/exact_target_sdk.rb +6 -0
- data/lib/exact_target_sdk/api_object.rb +6 -2
- data/lib/exact_target_sdk/client.rb +39 -0
- data/lib/exact_target_sdk/complex_filter_part.rb +9 -0
- data/lib/exact_target_sdk/create_result.rb +1 -20
- data/lib/exact_target_sdk/filter_part.rb +6 -0
- data/lib/exact_target_sdk/result.rb +15 -0
- data/lib/exact_target_sdk/retrieve_response.rb +25 -0
- data/lib/exact_target_sdk/retrieve_result.rb +4 -0
- data/lib/exact_target_sdk/simple_filter_part.rb +9 -0
- data/lib/exact_target_sdk/update_result.rb +1 -20
- data/lib/exact_target_sdk/version.rb +1 -1
- metadata +9 -3
data/CHANGELOG.rdoc
CHANGED
data/README.rdoc
CHANGED
@@ -10,9 +10,9 @@ outlined in the guide linked above are used. This is done in an attempt to be
|
|
10
10
|
as transparent as possible, so that the API may be used by referring only to
|
11
11
|
the guide linked above.
|
12
12
|
|
13
|
-
Note this SDK is currently
|
14
|
-
|
15
|
-
|
13
|
+
Note this SDK is currently quite incomplete, supporting only a subset of the
|
14
|
+
possible objects and methods. The framework is in place, however, to very
|
15
|
+
easily implement new objects by simply declaring their properties.
|
16
16
|
|
17
17
|
== Synopsis:
|
18
18
|
|
data/lib/exact_target_sdk.rb
CHANGED
@@ -6,8 +6,14 @@ module ExactTargetSDK
|
|
6
6
|
autoload :APIObject, 'exact_target_sdk/api_object'
|
7
7
|
autoload :Attribute, 'exact_target_sdk/attribute'
|
8
8
|
autoload :Client, 'exact_target_sdk/client'
|
9
|
+
autoload :ComplexFilterPart, 'exact_target_sdk/complex_filter_part'
|
9
10
|
autoload :CreateResponse, 'exact_target_sdk/create_response'
|
10
11
|
autoload :CreateResult, 'exact_target_sdk/create_result'
|
12
|
+
autoload :FilterPart, 'exact_target_sdk/filter_part'
|
13
|
+
autoload :Result, 'exact_target_sdk/result'
|
14
|
+
autoload :RetrieveResponse, 'exact_target_sdk/retrieve_response'
|
15
|
+
autoload :RetrieveResult, 'exact_target_sdk/retrieve_result'
|
16
|
+
autoload :SimpleFilterPart, 'exact_target_sdk/simple_filter_part'
|
11
17
|
autoload :Subscriber, 'exact_target_sdk/subscriber'
|
12
18
|
autoload :TriggeredSend, 'exact_target_sdk/triggered_send'
|
13
19
|
autoload :TriggeredSendDefinition, 'exact_target_sdk/triggered_send_definition'
|
@@ -69,6 +69,10 @@ class APIObject
|
|
69
69
|
@properties || []
|
70
70
|
end
|
71
71
|
|
72
|
+
def type_name
|
73
|
+
name.split('::').last
|
74
|
+
end
|
75
|
+
|
72
76
|
private
|
73
77
|
|
74
78
|
# Stores the given property name to be used at render time.
|
@@ -93,7 +97,7 @@ class APIObject
|
|
93
97
|
#
|
94
98
|
# May be overridden.
|
95
99
|
def type_name
|
96
|
-
self.class.
|
100
|
+
self.class.type_name
|
97
101
|
end
|
98
102
|
|
99
103
|
# By default, runs validation and executes #render_properties!.
|
@@ -120,7 +124,7 @@ class APIObject
|
|
120
124
|
|
121
125
|
def render_property!(property_name, property_value, xml)
|
122
126
|
if property_value.is_a?(APIObject)
|
123
|
-
xml.__send__(property_name) do
|
127
|
+
xml.__send__(property_name, { "xsi:type" => property_value.type_name } ) do
|
124
128
|
property_value.render!(xml)
|
125
129
|
end
|
126
130
|
elsif property_value.is_a?(Array)
|
@@ -64,6 +64,45 @@ class Client
|
|
64
64
|
CreateResponse.new(response)
|
65
65
|
end
|
66
66
|
|
67
|
+
# Invokes the Retrieve method.
|
68
|
+
#
|
69
|
+
# Note that this implementation abstracts away the useless RetrieveRequest
|
70
|
+
# sub-wrapper, and introduces a RequestResponse wrapper to contain the
|
71
|
+
# output parameters.
|
72
|
+
#
|
73
|
+
# Does not currently support requests that have too many results for one
|
74
|
+
# batch.
|
75
|
+
#
|
76
|
+
# Possible exceptions are:
|
77
|
+
# HTTPError if an HTTP error (such as a timeout) occurs
|
78
|
+
# SOAPFault if a SOAP fault occurs
|
79
|
+
# Timeout if there is a timeout waiting for the response
|
80
|
+
# InvalidAPIObject if any of the provided objects don't pass validation
|
81
|
+
#
|
82
|
+
# Returns a RetrieveResponse object.
|
83
|
+
def Retrieve(object_type_name, filter, *properties)
|
84
|
+
object_type_name = object_type_name.type_name if object_type_name.respond_to?(:type_name)
|
85
|
+
response = execute_request 'Retrieve' do |xml|
|
86
|
+
xml.RetrieveRequestMsg do
|
87
|
+
xml.RetrieveRequest do
|
88
|
+
xml.Options
|
89
|
+
|
90
|
+
xml.ObjectType object_type_name
|
91
|
+
|
92
|
+
properties.each do |property|
|
93
|
+
xml.Properties(property)
|
94
|
+
end
|
95
|
+
|
96
|
+
xml.Filter "xsi:type" => filter.type_name do
|
97
|
+
filter.render!(xml)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
RetrieveResponse.new(response)
|
104
|
+
end
|
105
|
+
|
67
106
|
# Invokes the Update method.
|
68
107
|
#
|
69
108
|
# The provided arguments should each be sub-classes of APIObject, and each
|
@@ -1,23 +1,4 @@
|
|
1
|
-
require 'active_support/inflector'
|
2
|
-
|
3
1
|
module ExactTargetSDK
|
4
|
-
class CreateResult
|
5
|
-
|
6
|
-
PROPERTIES = [
|
7
|
-
'StatusCode',
|
8
|
-
'StatusMessage',
|
9
|
-
'ErrorCode'
|
10
|
-
]
|
11
|
-
|
12
|
-
PROPERTIES.each do |property|
|
13
|
-
attr_reader property
|
14
|
-
end
|
15
|
-
|
16
|
-
def initialize(hash)
|
17
|
-
PROPERTIES.each do |property|
|
18
|
-
instance_variable_set("@#{property}", hash[property.underscore.to_sym])
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
2
|
+
class CreateResult < Result
|
22
3
|
end
|
23
4
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module ExactTargetSDK
|
2
|
+
class RetrieveResponse
|
3
|
+
|
4
|
+
attr_reader :OverallStatus, :RequestID, :Results
|
5
|
+
|
6
|
+
def initialize(response)
|
7
|
+
response = response.to_hash[:retrieve_response_msg]
|
8
|
+
@OverallStatus = response[:overall_status]
|
9
|
+
@RequestID = response[:request_id]
|
10
|
+
@Results = []
|
11
|
+
|
12
|
+
results = if response[:results].is_a? Array
|
13
|
+
response[:results]
|
14
|
+
elsif response[:results].is_a? Hash
|
15
|
+
[ response[:results] ]
|
16
|
+
else
|
17
|
+
[]
|
18
|
+
end
|
19
|
+
results.each do |result|
|
20
|
+
@Results << RetrieveResult.new(result)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -1,23 +1,4 @@
|
|
1
|
-
require 'active_support/inflector'
|
2
|
-
|
3
1
|
module ExactTargetSDK
|
4
|
-
class UpdateResult
|
5
|
-
|
6
|
-
PROPERTIES = [
|
7
|
-
'StatusCode',
|
8
|
-
'StatusMessage',
|
9
|
-
'ErrorCode'
|
10
|
-
]
|
11
|
-
|
12
|
-
PROPERTIES.each do |property|
|
13
|
-
attr_reader property
|
14
|
-
end
|
15
|
-
|
16
|
-
def initialize(hash)
|
17
|
-
PROPERTIES.each do |property|
|
18
|
-
instance_variable_set("@#{property}", hash[property.underscore.to_sym])
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
2
|
+
class UpdateResult < Result
|
22
3
|
end
|
23
4
|
end
|
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: 15
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 4
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.4.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- David Dawson
|
@@ -91,10 +91,16 @@ files:
|
|
91
91
|
- lib/exact_target_sdk/api_object.rb
|
92
92
|
- lib/exact_target_sdk/attribute.rb
|
93
93
|
- lib/exact_target_sdk/client.rb
|
94
|
+
- lib/exact_target_sdk/complex_filter_part.rb
|
94
95
|
- lib/exact_target_sdk/config.rb
|
95
96
|
- lib/exact_target_sdk/create_response.rb
|
96
97
|
- lib/exact_target_sdk/create_result.rb
|
97
98
|
- lib/exact_target_sdk/errors.rb
|
99
|
+
- lib/exact_target_sdk/filter_part.rb
|
100
|
+
- lib/exact_target_sdk/result.rb
|
101
|
+
- lib/exact_target_sdk/retrieve_response.rb
|
102
|
+
- lib/exact_target_sdk/retrieve_result.rb
|
103
|
+
- lib/exact_target_sdk/simple_filter_part.rb
|
98
104
|
- lib/exact_target_sdk/subscriber.rb
|
99
105
|
- lib/exact_target_sdk/triggered_send.rb
|
100
106
|
- lib/exact_target_sdk/triggered_send_definition.rb
|