Class: ExactTargetSDK::Client
- Inherits:
-
Object
- Object
- ExactTargetSDK::Client
- Defined in:
- lib/exact_target_sdk/client.rb
Overview
Provides an object-oriented API to ExactTarget’s Web Service API (docs.code.exacttarget.com/020_Web_Service_Guide)
With few exceptions, ruby conventions for capitalization are ignored and those outlined in the guide linked above are used. This is done in an attempt to be as transparent as possible, so that the API may be used by referring only to the guide linked above.
Instance Method Summary collapse
-
#Create(*args) ⇒ Object
Invokes the Create method.
-
#Delete(*args) ⇒ Object
Invokes the Delete method.
-
#initialize(options = {}) ⇒ Client
constructor
Constructs a client.
- #logger ⇒ Object
-
#Perform(action, *args) ⇒ Object
Invokes the Perform method.
-
#Retrieve(object_type_name, filter, *properties) ⇒ Object
Invokes the Retrieve method.
-
#Update(*args) ⇒ Object
Invokes the Update method.
Constructor Details
#initialize(options = {}) ⇒ Client
Constructs a client.
Any of the options documented in ExactTargetSDK#config may be overridden using the options parameter.
Since ExactTarget’s API is stateless, constructing a client object will not make any remote calls.
23 24 25 26 27 28 |
# File 'lib/exact_target_sdk/client.rb', line 23 def initialize( = {}) self.config = { }.merge!(ExactTargetSDK.config).merge!() initialize_client! end |
Instance Method Details
#Create(*args) ⇒ Object
Invokes the Create method.
The provided arguments should each be sub-classes of APIObject, and each provided object will be created in order.
Possible exceptions are:
HTTPError if an HTTP error (such as a timeout) occurs
SOAPFault if a SOAP fault occurs
Timeout if there is a timeout waiting for the response
InvalidAPIObject if any of the provided objects don't pass validation
Returns a CreateResponse object.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/exact_target_sdk/client.rb', line 42 def Create(*args) # TODO: implement and accept CreateOptions api_objects = args response = execute_request 'Create' do |xml| xml.CreateRequest do xml.Options # TODO: support CreateOptions api_objects.each do |api_object| xml.Objects "xsi:type" => api_object.type_name do api_object.render!(xml) end end end end CreateResponse.new(response) end |
#Delete(*args) ⇒ Object
Invokes the Delete method.
The provided arguments should each be sub-classes of APIObject, and each provided object will be updated in order.
Possible exceptions are:
HTTPError if an HTTP error (such as a timeout) occurs
SOAPFault if a SOAP fault occurs
Timeout if there is a timeout waiting for the response
InvalidAPIObject if any of the provided objects don't pass validation
Returns a DeleteResponse object.
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/exact_target_sdk/client.rb', line 145 def Delete(*args) # TODO: implement and accept DeleteOptions api_objects = args response = execute_request 'Delete' do |xml| xml.DeleteRequest do xml.Options # TODO: support DeleteOptions api_objects.each do |api_object| xml.Objects "xsi:type" => api_object.type_name do api_object.render!(xml) end end end end DeleteResponse.new(response) end |
#logger ⇒ Object
201 202 203 |
# File 'lib/exact_target_sdk/client.rb', line 201 def logger config[:logger] end |
#Perform(action, *args) ⇒ Object
Invokes the Perform method.
The provided arguments should each be definitions that are sub-classes of APIObject.
Possible exceptions are:
HTTPError if an HTTP error (such as a timeout) occurs
SOAPFault if a SOAP fault occurs
Timeout if there is a timeout waiting for the response
InvalidAPIObject if any of the provided objects don't pass validation
Returns a PerformResponse object.
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
# File 'lib/exact_target_sdk/client.rb', line 177 def Perform(action, *args) # TODO: implement and accept PerformOptions definitions = args response = execute_request 'Perform' do |xml| xml.PerformRequestMsg do xml.Action action xml.Definitions do definitions.each do |definition| xml.Definition "xsi:type" => definition.type_name do definition.render!(xml) end end end xml.Options # TODO: support PerformOptions end end PerformResponse.new(response) end |
#Retrieve(object_type_name, filter, *properties) ⇒ Object
Invokes the Retrieve method.
Note that this implementation abstracts away the useless RetrieveRequest sub-wrapper, and introduces a RequestResponse wrapper to contain the output parameters.
Does not currently support requests that have too many results for one batch.
Possible exceptions are:
HTTPError if an HTTP error (such as a timeout) occurs
SOAPFault if a SOAP fault occurs
Timeout if there is a timeout waiting for the response
InvalidAPIObject if any of the provided objects don't pass validation
Returns a RetrieveResponse object.
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/exact_target_sdk/client.rb', line 78 def Retrieve(object_type_name, filter, *properties) object_type_name = object_type_name.type_name if object_type_name.respond_to?(:type_name) response = execute_request 'Retrieve' do |xml| xml.RetrieveRequestMsg do xml.RetrieveRequest do xml.Options xml.ObjectType object_type_name properties.each do |property| xml.Properties(property) end xml.Filter "xsi:type" => filter.type_name do filter.render!(xml) end end end end RetrieveResponse.new(response) end |
#Update(*args) ⇒ Object
Invokes the Update method.
The provided arguments should each be sub-classes of APIObject, and each provided object will be updated in order.
Possible exceptions are:
HTTPError if an HTTP error (such as a timeout) occurs
SOAPFault if a SOAP fault occurs
Timeout if there is a timeout waiting for the response
InvalidAPIObject if any of the provided objects don't pass validation
Returns an UpdateResponse object.
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/exact_target_sdk/client.rb', line 113 def Update(*args) # TODO: implement and accept UpdateOptions api_objects = args response = execute_request 'Update' do |xml| xml.UpdateRequest do xml.Options # TODO: support UpdateOptions api_objects.each do |api_object| xml.Objects "xsi:type" => api_object.type_name do api_object.render!(xml) end end end end UpdateResponse.new(response) end |