exact_target_sdk 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +3 -0
- data/README.rdoc +3 -3
- data/lib/exact_target_sdk.rb +2 -0
- data/lib/exact_target_sdk/client.rb +32 -0
- data/lib/exact_target_sdk/update_response.rb +25 -0
- data/lib/exact_target_sdk/update_result.rb +23 -0
- data/lib/exact_target_sdk/version.rb +1 -1
- metadata +5 -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 very incomplete, allowing you only to create
|
14
|
-
subscribers and trigger sends. The framework is in place, however, to
|
15
|
-
easily implement new objects by simply declaring their properties.
|
13
|
+
Note this SDK is currently very incomplete, allowing you only to create and
|
14
|
+
update subscribers and trigger sends. The framework is in place, however, to
|
15
|
+
very easily implement new objects by simply declaring their properties.
|
16
16
|
|
17
17
|
== Synopsis:
|
18
18
|
|
data/lib/exact_target_sdk.rb
CHANGED
@@ -11,5 +11,7 @@ module ExactTargetSDK
|
|
11
11
|
autoload :Subscriber, 'exact_target_sdk/subscriber'
|
12
12
|
autoload :TriggeredSend, 'exact_target_sdk/triggered_send'
|
13
13
|
autoload :TriggeredSendDefinition, 'exact_target_sdk/triggered_send_definition'
|
14
|
+
autoload :UpdateResponse, 'exact_target_sdk/update_response'
|
15
|
+
autoload :UpdateResult, 'exact_target_sdk/update_result'
|
14
16
|
|
15
17
|
end
|
@@ -64,6 +64,38 @@ class Client
|
|
64
64
|
CreateResponse.new(response)
|
65
65
|
end
|
66
66
|
|
67
|
+
# Invokes the Update method.
|
68
|
+
#
|
69
|
+
# The provided arguments should each be sub-classes of APIObject, and each
|
70
|
+
# provided object will be updated in order.
|
71
|
+
#
|
72
|
+
# Possible exceptions are:
|
73
|
+
# HTTPError if an HTTP error (such as a timeout) occurs
|
74
|
+
# SOAPFault if a SOAP fault occurs
|
75
|
+
# Timeout if there is a timeout waiting for the response
|
76
|
+
# InvalidAPIObject if any of the provided objects don't pass validation
|
77
|
+
#
|
78
|
+
# Returns an UpdateResponse object.
|
79
|
+
def Update(*args)
|
80
|
+
# TODO: implement and accept UpdateOptions
|
81
|
+
|
82
|
+
api_objects = args
|
83
|
+
|
84
|
+
response = execute_request 'Update' do |xml|
|
85
|
+
xml.UpdateRequest do
|
86
|
+
xml.Options # TODO: support UpdateOptions
|
87
|
+
|
88
|
+
api_objects.each do |api_object|
|
89
|
+
xml.Objects "xsi:type" => api_object.type_name do
|
90
|
+
api_object.render!(xml)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
UpdateResponse.new(response)
|
97
|
+
end
|
98
|
+
|
67
99
|
def logger
|
68
100
|
config[:logger]
|
69
101
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module ExactTargetSDK
|
2
|
+
class UpdateResponse
|
3
|
+
|
4
|
+
attr_reader :OverallStatus, :RequestID, :Results
|
5
|
+
|
6
|
+
def initialize(response)
|
7
|
+
response = response.to_hash[:update_response]
|
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 << UpdateResult.new(result)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'active_support/inflector'
|
2
|
+
|
3
|
+
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
|
+
|
22
|
+
end
|
23
|
+
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: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 3
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.3.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- David Dawson
|
@@ -98,6 +98,8 @@ files:
|
|
98
98
|
- lib/exact_target_sdk/subscriber.rb
|
99
99
|
- lib/exact_target_sdk/triggered_send.rb
|
100
100
|
- lib/exact_target_sdk/triggered_send_definition.rb
|
101
|
+
- lib/exact_target_sdk/update_response.rb
|
102
|
+
- lib/exact_target_sdk/update_result.rb
|
101
103
|
- lib/exact_target_sdk/version.rb
|
102
104
|
- lib/exact_target_sdk.rb
|
103
105
|
- README.rdoc
|