From 5d412e165af768457dc0660614ea23a5e72f66c9 Mon Sep 17 00:00:00 2001 From: Valentine Zavadsky Date: Thu, 26 Apr 2012 16:36:08 +0300 Subject: [PATCH 01/57] List added --- lib/exact_target_sdk.rb | 1 + lib/exact_target_sdk/list.rb | 8 ++++++++ spec/list_spec.rb | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 lib/exact_target_sdk/list.rb create mode 100644 spec/list_spec.rb diff --git a/lib/exact_target_sdk.rb b/lib/exact_target_sdk.rb index 8443c8e..fefe527 100644 --- a/lib/exact_target_sdk.rb +++ b/lib/exact_target_sdk.rb @@ -18,6 +18,7 @@ module ExactTargetSDK autoload :DeleteResult, 'exact_target_sdk/delete_result' autoload :FilterPart, 'exact_target_sdk/filter_part' autoload :PerformResponse, 'exact_target_sdk/perform_response' + autoload :List, 'exact_target_sdk/list' autoload :Result, 'exact_target_sdk/result' autoload :RetrieveResponse, 'exact_target_sdk/retrieve_response' autoload :RetrieveResult, 'exact_target_sdk/retrieve_result' diff --git a/lib/exact_target_sdk/list.rb b/lib/exact_target_sdk/list.rb new file mode 100644 index 0000000..95bf88c --- /dev/null +++ b/lib/exact_target_sdk/list.rb @@ -0,0 +1,8 @@ +module ExactTargetSDK +class List < APIObject + + property 'ListName', :required => true + array_property 'Subscribers' + +end +end diff --git a/spec/list_spec.rb b/spec/list_spec.rb new file mode 100644 index 0000000..a3c5c01 --- /dev/null +++ b/spec/list_spec.rb @@ -0,0 +1,35 @@ +require 'spec_helper' +include ExactTargetSDK + +describe List do + context 'a bare List' do + + it { should_not be_valid } + + end + + context ' a validated List with ListName set' do + before(:each) do + @list = List.new 'ListName' => 'My Favourite List' + @list.valid? + end + + subject { @list } + + it {should be_valid} + + end + + context ' an invalid List without ListName' do + before(:each) do + @list = List.new + @list.valid? + end + + subject { @list } + + it {should_not be_valid} + + end + +end \ No newline at end of file From cd2a85498b321fb748091a6b796accf5553ea152 Mon Sep 17 00:00:00 2001 From: Valentine Zavadsky Date: Thu, 26 Apr 2012 17:56:09 +0300 Subject: [PATCH 02/57] fix result id bug --- lib/exact_target_sdk/result.rb | 4 ++++ spec/result_spec.rb | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/lib/exact_target_sdk/result.rb b/lib/exact_target_sdk/result.rb index fc611e1..d2f5bf6 100644 --- a/lib/exact_target_sdk/result.rb +++ b/lib/exact_target_sdk/result.rb @@ -3,6 +3,10 @@ module ExactTargetSDK class Result + # If @result contains :id key, while trying result.id it calls + # Object#id alias method for Object#object_id instead calling method_missing + undef id if self.respond_to? :id + def initialize(hash) @result = hash end diff --git a/spec/result_spec.rb b/spec/result_spec.rb index 3e020ec..0ed8126 100644 --- a/spec/result_spec.rb +++ b/spec/result_spec.rb @@ -22,4 +22,14 @@ end + context 'a result initialized with id field ' do + + subject { Result.new(:id => "42") } + + it 'should respond to id with "42"' do + subject.id.should == "42" + end + + end + end From a0d20edd7f9a260978fc445f113c551fe0cdd700 Mon Sep 17 00:00:00 2001 From: Valentine Zavadsky Date: Fri, 27 Apr 2012 12:03:07 +0300 Subject: [PATCH 03/57] Email added --- lib/exact_target_sdk.rb | 1 + lib/exact_target_sdk/email.rb | 10 ++++++++++ spec/email_spec.rb | 23 +++++++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 lib/exact_target_sdk/email.rb create mode 100644 spec/email_spec.rb diff --git a/lib/exact_target_sdk.rb b/lib/exact_target_sdk.rb index fefe527..612ea89 100644 --- a/lib/exact_target_sdk.rb +++ b/lib/exact_target_sdk.rb @@ -16,6 +16,7 @@ module ExactTargetSDK autoload :DataExtensionObject, 'exact_target_sdk/data_extension_object' autoload :DeleteResponse, 'exact_target_sdk/delete_response' autoload :DeleteResult, 'exact_target_sdk/delete_result' + autoload :Email, 'exact_target_sdk/email' autoload :FilterPart, 'exact_target_sdk/filter_part' autoload :PerformResponse, 'exact_target_sdk/perform_response' autoload :List, 'exact_target_sdk/list' diff --git a/lib/exact_target_sdk/email.rb b/lib/exact_target_sdk/email.rb new file mode 100644 index 0000000..5e02307 --- /dev/null +++ b/lib/exact_target_sdk/email.rb @@ -0,0 +1,10 @@ +module ExactTargetSDK +class Email < APIObject + + property 'Name', :required => true + property 'Subject', :required => true + property 'HTMLBody' + property 'TextBody' + +end +end diff --git a/spec/email_spec.rb b/spec/email_spec.rb new file mode 100644 index 0000000..7b23c47 --- /dev/null +++ b/spec/email_spec.rb @@ -0,0 +1,23 @@ +require 'spec_helper' +include ExactTargetSDK + +describe Email do + context 'a bare Email' do + + it { should_not be_valid } + + end + + context ' a validated Email with Name and Subject set' do + before(:each) do + @email = Email.new 'Name' => 'Welcome email', 'Subject' => 'Welcome to the Dark Side' + @email.valid? + end + + subject { @email } + + it {should be_valid} + + end + +end \ No newline at end of file From f4f599c1d8d07a9a690902124b9fd29871687486 Mon Sep 17 00:00:00 2001 From: Valentine Zavadsky Date: Fri, 27 Apr 2012 13:31:02 +0300 Subject: [PATCH 04/57] Email added --- lib/exact_target_sdk/interaction_definition.rb | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 lib/exact_target_sdk/interaction_definition.rb diff --git a/lib/exact_target_sdk/interaction_definition.rb b/lib/exact_target_sdk/interaction_definition.rb new file mode 100644 index 0000000..e69de29 From b270f444a8e9b79e5d2b38b47954af29d4357b83 Mon Sep 17 00:00:00 2001 From: Valentine Zavadsky Date: Sat, 28 Apr 2012 14:42:05 +0300 Subject: [PATCH 05/57] add some basic ApiObject fields and work with ApiObject properties a little --- lib/exact_target_sdk/api_object.rb | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/exact_target_sdk/api_object.rb b/lib/exact_target_sdk/api_object.rb index 4cfa462..cbaa1e2 100644 --- a/lib/exact_target_sdk/api_object.rb +++ b/lib/exact_target_sdk/api_object.rb @@ -78,11 +78,20 @@ def int_property(name, options = {}) validates name.to_sym, :numericality => { :allow_nil => true, :only_integer => true } end - # Returns an array of all registered properties. + # Returns an array of all registered properties of current class. def properties @properties || {} end + # Returns an array of all registered properties, including parent classes + def all_properties + properties = {} + self.ancestors.each do |klass| + properties.merge!(klass.properties) if klass.respond_to? :properties + end + properties + end + def type_name name.split('::').last end @@ -97,6 +106,10 @@ def register_property!(name, options = {}) end + int_property "ID" + int_property 'ObjectID' + property 'CustomerKey' + # By default, any properties may be passed and set. # # May be overridden. @@ -128,7 +141,7 @@ def render!(xml) # # May be overridden. def render_properties!(xml) - self.class.properties.each do |property, options| + self.class.all_properties.each do |property, options| next unless instance_variable_get("@_set_#{property}") property_value = self.send(property) render_property!(property, property_value, xml, options) From f23344808aa8b6f7cc2a2509c45e8d9c831eeb9d Mon Sep 17 00:00:00 2001 From: Valentine Zavadsky Date: Mon, 30 Apr 2012 14:10:46 +0300 Subject: [PATCH 06/57] change field types for APIObject --- lib/exact_target_sdk/api_object.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/exact_target_sdk/api_object.rb b/lib/exact_target_sdk/api_object.rb index cbaa1e2..ff91503 100644 --- a/lib/exact_target_sdk/api_object.rb +++ b/lib/exact_target_sdk/api_object.rb @@ -106,8 +106,8 @@ def register_property!(name, options = {}) end - int_property "ID" - int_property 'ObjectID' + property "ID" + property 'ObjectID' property 'CustomerKey' # By default, any properties may be passed and set. From 8ed764e4d29b858ad783bbe606d15213e210f663 Mon Sep 17 00:00:00 2001 From: Valentine Zavadsky Date: Mon, 30 Apr 2012 22:36:59 +0300 Subject: [PATCH 07/57] pack of objects for EmailSendDefinition implementation --- lib/exact_target_sdk.rb | 5 ++ lib/exact_target_sdk/delivery_profile.rb | 11 ++++ lib/exact_target_sdk/email_send_definition.rb | 44 ++++++++++++++ lib/exact_target_sdk/send_classification.rb | 9 +++ lib/exact_target_sdk/send_definition_list.rb | 12 ++++ lib/exact_target_sdk/sender_profile.rb | 21 +++++++ spec/delivery_profile_spec.rb | 57 +++++++++++++++++++ spec/email_send_definition_spec.rb | 45 +++++++++++++++ spec/send_classification_spec.rb | 25 ++++++++ spec/sender_profile.rb | 25 ++++++++ 10 files changed, 254 insertions(+) create mode 100644 lib/exact_target_sdk/delivery_profile.rb create mode 100644 lib/exact_target_sdk/email_send_definition.rb create mode 100644 lib/exact_target_sdk/send_classification.rb create mode 100644 lib/exact_target_sdk/send_definition_list.rb create mode 100644 lib/exact_target_sdk/sender_profile.rb create mode 100644 spec/delivery_profile_spec.rb create mode 100644 spec/email_send_definition_spec.rb create mode 100644 spec/send_classification_spec.rb create mode 100644 spec/sender_profile.rb diff --git a/lib/exact_target_sdk.rb b/lib/exact_target_sdk.rb index 612ea89..f743ab3 100644 --- a/lib/exact_target_sdk.rb +++ b/lib/exact_target_sdk.rb @@ -16,7 +16,9 @@ module ExactTargetSDK autoload :DataExtensionObject, 'exact_target_sdk/data_extension_object' autoload :DeleteResponse, 'exact_target_sdk/delete_response' autoload :DeleteResult, 'exact_target_sdk/delete_result' + autoload :DeliveryProfile, 'exact_target_sdk/delivery_profile' autoload :Email, 'exact_target_sdk/email' + autoload :EmailSendDefinition, 'exact_target_sdk/email_send_definition' autoload :FilterPart, 'exact_target_sdk/filter_part' autoload :PerformResponse, 'exact_target_sdk/perform_response' autoload :List, 'exact_target_sdk/list' @@ -24,6 +26,9 @@ module ExactTargetSDK autoload :RetrieveResponse, 'exact_target_sdk/retrieve_response' autoload :RetrieveResult, 'exact_target_sdk/retrieve_result' autoload :SimpleFilterPart, 'exact_target_sdk/simple_filter_part' + autoload :SendClassification, 'exact_target_sdk/send_classification' + autoload :SendDefinitionList, 'exact_target_sdk/send_definition_list' + autoload :SenderProfile, 'exact_target_sdk/sender_profile' autoload :Subscriber, 'exact_target_sdk/subscriber' autoload :TriggeredSend, 'exact_target_sdk/triggered_send' autoload :TriggeredSendDefinition, 'exact_target_sdk/triggered_send_definition' diff --git a/lib/exact_target_sdk/delivery_profile.rb b/lib/exact_target_sdk/delivery_profile.rb new file mode 100644 index 0000000..704dbe1 --- /dev/null +++ b/lib/exact_target_sdk/delivery_profile.rb @@ -0,0 +1,11 @@ +module ExactTargetSDK +class DeliveryProfile < APIObject + + property 'Name', :required => true + property 'SourceAddressType',:required => true + + validates 'SourceAddressType', :inclusion => { :allow_nil => false, + :in => %w( CustomPrivateIPAddress DefaultPrivateIPAddress ) } + +end +end diff --git a/lib/exact_target_sdk/email_send_definition.rb b/lib/exact_target_sdk/email_send_definition.rb new file mode 100644 index 0000000..414e4f9 --- /dev/null +++ b/lib/exact_target_sdk/email_send_definition.rb @@ -0,0 +1,44 @@ +module ExactTargetSDK +class EmailSendDefinition < APIObject + + property 'Name', :required => true + + # Indicates the send classification to use as part of a send definition. + property 'SendClassification', :required => true + + # Indicates the subscriber list to use as part of an email send definition. + property 'SendDefinitionList', :required => true + + # Default email address for object. Indicates if subscriber information can be used for email sends. + property 'Email', :required => true + + # Defines an email address to which to send a test message as part + # of an email send definition. Use the Test action when sending a + # test email to an email send definition. + property 'TestEmailAddr' + + # Defines account users with access to tracking information for that send definition. + property 'TrackingUsers' + + # Defines blind carbon copy email address to which to send a message as + # part of an email send definition. + property 'AutoBccEmail' + + # Indicates email addresses to receive blind carbon copy of a message. + property 'BccEmail' + + # CC + property 'CCEmail' + + # Defines scheduled data and time for a send related to an email send definition. + property 'DeliveryScheduledTime' + + # Subject for an email send + property 'EmailSubject' + + +end +end + + + diff --git a/lib/exact_target_sdk/send_classification.rb b/lib/exact_target_sdk/send_classification.rb new file mode 100644 index 0000000..7a34a73 --- /dev/null +++ b/lib/exact_target_sdk/send_classification.rb @@ -0,0 +1,9 @@ +module ExactTargetSDK +class SendClassification < APIObject + + property 'Name', :required => true + property 'SenderProfile', :required => true + property 'DeliveryProfile', :required => true + +end +end diff --git a/lib/exact_target_sdk/send_definition_list.rb b/lib/exact_target_sdk/send_definition_list.rb new file mode 100644 index 0000000..63dd5b6 --- /dev/null +++ b/lib/exact_target_sdk/send_definition_list.rb @@ -0,0 +1,12 @@ +module ExactTargetSDK +class SendDefinitionList < APIObject + + property 'DataSourceTypeID', :required => true + property 'List' + + validates 'DataSourceTypeID', :inclusion => { :allow_nil => false, + :in => %w( List CustomObject DomainExclusion SalesForceCampaign FilterDefinition OptOutList ) } + +end + +end diff --git a/lib/exact_target_sdk/sender_profile.rb b/lib/exact_target_sdk/sender_profile.rb new file mode 100644 index 0000000..5bed73b --- /dev/null +++ b/lib/exact_target_sdk/sender_profile.rb @@ -0,0 +1,21 @@ +module ExactTargetSDK +class SenderProfile < APIObject + + property 'Name', :required => true + + # Specifies the default email message From Name. Deprecated for email send definitions and triggered send definitions. + property 'FromName', :required => true + + # Indicates From address associated with a object. Deprecated for email send definitions and triggered send definitions. + property 'FromAddress', :required => true + + # Indicates the To name to use on automatically forwarded email messages. + property 'AutoForwardToName' + + # Indicates the email address to use with automatically forwarded email messages. + property 'AutoForwardToEmailAddress' + + + +end +end diff --git a/spec/delivery_profile_spec.rb b/spec/delivery_profile_spec.rb new file mode 100644 index 0000000..5e3469e --- /dev/null +++ b/spec/delivery_profile_spec.rb @@ -0,0 +1,57 @@ +require 'spec_helper' +include ExactTargetSDK + +describe DeliveryProfile do + context 'a bare DeliveryProfile' do + + it { should_not be_valid } + + end + + context ' a validated DeliveryProfile with Name and SourceAddressType' do + before(:each) do + @delivery_profile = DeliveryProfile.new 'Name' => 'Test Profile', 'SourceAddressType' => 'DefaultPrivateIPAddress' + @delivery_profile.valid? + end + + subject { @delivery_profile } + + it { should be_valid } + + end + + context ' an invalid DeliveryProfiles' do + before(:each) do + @delivery_profile = DeliveryProfile.new + end + + subject { @delivery_profile } + + + it "without Name and SourceAddressType " do + @delivery_profile.valid? + @delivery_profile.should_not be_valid + end + + context 'with Name' do + before(:each) do + @delivery_profile.Name = "Test profile" + end + + it "and without SourceAddressType " do + @delivery_profile.valid? + @delivery_profile.should_not be_valid + end + + it "and invalid SourceAddressType " do + @delivery_profile.valid? + @delivery_profile.SourceAddressType = 'IAmInvalidType' + @delivery_profile.should_not be_valid + end + + end + + + end + +end \ No newline at end of file diff --git a/spec/email_send_definition_spec.rb b/spec/email_send_definition_spec.rb new file mode 100644 index 0000000..8668686 --- /dev/null +++ b/spec/email_send_definition_spec.rb @@ -0,0 +1,45 @@ +require 'spec_helper' +include ExactTargetSDK + +describe EmailSendDefinition do + context 'a bare EmailSendDefinition' do + + it { should_not be_valid } + + end + + context 'a validated EmailSendDefinition' do + before(:each) do + + # Create List + list = ExactTargetSDK::List.new('ID' => "273", + 'ListName' => "Test list") + + # Create SendClassification + send_classification = ExactTargetSDK::SendClassification.new('ObjectID' => "1234b99-b592-e111-b32b-984be17c0e6c") + + # Create SendDefinitionList + send_definition_list = ExactTargetSDK::SendDefinitionList.new('DataSourceTypeID' => 'List', 'List' => list) + + + #Create Email + email = ExactTargetSDK::Email.new('ID' => '239', + 'Name' => 'test', + 'Subject' => 'TestSubject', + 'HTMLBody' => '

Body

', + 'TextBody' => 'Body') + + @email_send_definition = ExactTargetSDK::EmailSendDefinition.new('Name' => 'test', + 'Email' => email, + 'SendClassification' => send_classification, + 'SendDefinitionList' => send_definition_list) + @email_send_definition.valid? + end + + subject { @email_send_definition } + + it { should be_valid } + + end + +end \ No newline at end of file diff --git a/spec/send_classification_spec.rb b/spec/send_classification_spec.rb new file mode 100644 index 0000000..f4d38a5 --- /dev/null +++ b/spec/send_classification_spec.rb @@ -0,0 +1,25 @@ +require 'spec_helper' +include ExactTargetSDK + +describe SendClassification do + context 'a bare SendClassification' do + + it { should_not be_valid } + + end + + context 'a validated SendClassification' do + before(:each) do + sp = ExactTargetSDK::SenderProfile.new 'ObjectID' => "some-object-id" + dp = ExactTargetSDK::DeliveryProfile.new 'ObjectID' => "some-object-id" + @send_classification = ExactTargetSDK::SendClassification.new('Name' => 'Test Classification', 'SenderProfile' => sp, 'DeliveryProfile' => dp ) + @send_classification.valid? + end + + subject { @send_classification } + + it { should be_valid } + + end + +end \ No newline at end of file diff --git a/spec/sender_profile.rb b/spec/sender_profile.rb new file mode 100644 index 0000000..8b10124 --- /dev/null +++ b/spec/sender_profile.rb @@ -0,0 +1,25 @@ +require 'spec_helper' +include ExactTargetSDK + +describe SenderProfile do + context 'a bare SenderProfile' do + + it { should_not be_valid } + + end + + context ' a validated SenderProfile ' do + before(:each) do + @sender_profile = SenderProfile.new 'Name' => 'Test Profile', + 'FromName' => 'Bob', + 'FromAddress' => 'bob@example.com' + @sender_profile.valid? + end + + subject { @sender_profile } + + it { should be_valid } + + end + +end \ No newline at end of file From 64659202863d34d825f1ab32687028f3f234ca60 Mon Sep 17 00:00:00 2001 From: Valentine Zavadsky Date: Wed, 2 May 2012 12:26:56 +0300 Subject: [PATCH 08/57] SimpleOperatorEnum added --- lib/exact_target_sdk.rb | 1 + lib/exact_target_sdk/simple_operator.rb | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 lib/exact_target_sdk/simple_operator.rb diff --git a/lib/exact_target_sdk.rb b/lib/exact_target_sdk.rb index f743ab3..57d8304 100644 --- a/lib/exact_target_sdk.rb +++ b/lib/exact_target_sdk.rb @@ -29,6 +29,7 @@ module ExactTargetSDK autoload :SendClassification, 'exact_target_sdk/send_classification' autoload :SendDefinitionList, 'exact_target_sdk/send_definition_list' autoload :SenderProfile, 'exact_target_sdk/sender_profile' + autoload :SimpleOperator, 'exact_target_sdk/simple_operator' autoload :Subscriber, 'exact_target_sdk/subscriber' autoload :TriggeredSend, 'exact_target_sdk/triggered_send' autoload :TriggeredSendDefinition, 'exact_target_sdk/triggered_send_definition' diff --git a/lib/exact_target_sdk/simple_operator.rb b/lib/exact_target_sdk/simple_operator.rb new file mode 100644 index 0000000..f6a725c --- /dev/null +++ b/lib/exact_target_sdk/simple_operator.rb @@ -0,0 +1,15 @@ +module ExactTargetSDK +module SimpleOperator + EQUALS = 'equals' + NOT_EQUALS = 'notEquals' + GREATER_THAN = 'greaterThan' + LESS = 'lessThan' + IS_NOT_NULL = 'isNotNull' + IS_NULL = 'isNull' + GREATER_THAN_EQUAL = 'greaterThanOrEqual' + LESS_THAN_EQUAL = 'lessThanOrEqual' + BETWEEN = 'between' + IN = 'IN' + LIKE = 'like' +end +end From bc7cc48f385d99778b0ea898d42d839355e0a9d8 Mon Sep 17 00:00:00 2001 From: Valentine Zavadsky Date: Wed, 2 May 2012 19:08:46 +0300 Subject: [PATCH 09/57] remove validations from objects, cause it fails retrieve and other actions --- lib/exact_target_sdk/delivery_profile.rb | 7 ++-- lib/exact_target_sdk/send_classification.rb | 7 ++-- lib/exact_target_sdk/sender_profile.rb | 6 ++-- spec/delivery_profile_spec.rb | 36 ++------------------- spec/send_classification_spec.rb | 4 ++- 5 files changed, 13 insertions(+), 47 deletions(-) diff --git a/lib/exact_target_sdk/delivery_profile.rb b/lib/exact_target_sdk/delivery_profile.rb index 704dbe1..63ac64e 100644 --- a/lib/exact_target_sdk/delivery_profile.rb +++ b/lib/exact_target_sdk/delivery_profile.rb @@ -1,11 +1,8 @@ module ExactTargetSDK class DeliveryProfile < APIObject - property 'Name', :required => true - property 'SourceAddressType',:required => true - - validates 'SourceAddressType', :inclusion => { :allow_nil => false, - :in => %w( CustomPrivateIPAddress DefaultPrivateIPAddress ) } + property 'Name' + property 'SourceAddressType' end end diff --git a/lib/exact_target_sdk/send_classification.rb b/lib/exact_target_sdk/send_classification.rb index 7a34a73..b4f68cc 100644 --- a/lib/exact_target_sdk/send_classification.rb +++ b/lib/exact_target_sdk/send_classification.rb @@ -1,9 +1,8 @@ module ExactTargetSDK class SendClassification < APIObject - property 'Name', :required => true - property 'SenderProfile', :required => true - property 'DeliveryProfile', :required => true - + property 'Name' + property 'SenderProfile' + property 'DeliveryProfile' end end diff --git a/lib/exact_target_sdk/sender_profile.rb b/lib/exact_target_sdk/sender_profile.rb index 5bed73b..1da0f49 100644 --- a/lib/exact_target_sdk/sender_profile.rb +++ b/lib/exact_target_sdk/sender_profile.rb @@ -1,13 +1,13 @@ module ExactTargetSDK class SenderProfile < APIObject - property 'Name', :required => true + property 'Name' # Specifies the default email message From Name. Deprecated for email send definitions and triggered send definitions. - property 'FromName', :required => true + property 'FromName' # Indicates From address associated with a object. Deprecated for email send definitions and triggered send definitions. - property 'FromAddress', :required => true + property 'FromAddress' # Indicates the To name to use on automatically forwarded email messages. property 'AutoForwardToName' diff --git a/spec/delivery_profile_spec.rb b/spec/delivery_profile_spec.rb index 5e3469e..bb46452 100644 --- a/spec/delivery_profile_spec.rb +++ b/spec/delivery_profile_spec.rb @@ -10,7 +10,8 @@ context ' a validated DeliveryProfile with Name and SourceAddressType' do before(:each) do - @delivery_profile = DeliveryProfile.new 'Name' => 'Test Profile', 'SourceAddressType' => 'DefaultPrivateIPAddress' + @delivery_profile = DeliveryProfile.new 'Name' => 'Test Profile', + 'SourceAddressType' => DeliveryProfileSourceAddressTypeEnum::DEFAULT_PRIVATE_IP_ADDRESS @delivery_profile.valid? end @@ -20,38 +21,5 @@ end - context ' an invalid DeliveryProfiles' do - before(:each) do - @delivery_profile = DeliveryProfile.new - end - - subject { @delivery_profile } - - - it "without Name and SourceAddressType " do - @delivery_profile.valid? - @delivery_profile.should_not be_valid - end - - context 'with Name' do - before(:each) do - @delivery_profile.Name = "Test profile" - end - - it "and without SourceAddressType " do - @delivery_profile.valid? - @delivery_profile.should_not be_valid - end - - it "and invalid SourceAddressType " do - @delivery_profile.valid? - @delivery_profile.SourceAddressType = 'IAmInvalidType' - @delivery_profile.should_not be_valid - end - - end - - - end end \ No newline at end of file diff --git a/spec/send_classification_spec.rb b/spec/send_classification_spec.rb index f4d38a5..79e8e5e 100644 --- a/spec/send_classification_spec.rb +++ b/spec/send_classification_spec.rb @@ -12,7 +12,9 @@ before(:each) do sp = ExactTargetSDK::SenderProfile.new 'ObjectID' => "some-object-id" dp = ExactTargetSDK::DeliveryProfile.new 'ObjectID' => "some-object-id" - @send_classification = ExactTargetSDK::SendClassification.new('Name' => 'Test Classification', 'SenderProfile' => sp, 'DeliveryProfile' => dp ) + @send_classification = ExactTargetSDK::SendClassification.new('Name' => 'Test Classification', + 'SenderProfile' => sp, + 'DeliveryProfile' => dp ) @send_classification.valid? end From e3b7868724bc37fe33dc5c01a8fc6f1e2b7672ff Mon Sep 17 00:00:00 2001 From: Valentine Zavadsky Date: Wed, 2 May 2012 19:12:26 +0300 Subject: [PATCH 10/57] add new Schedule request to client --- lib/exact_target_sdk/client.rb | 42 +++++++++++++++++++++++ lib/exact_target_sdk/schedule_response.rb | 26 ++++++++++++++ lib/exact_target_sdk/schedule_result.rb | 5 +++ 3 files changed, 73 insertions(+) create mode 100644 lib/exact_target_sdk/schedule_response.rb create mode 100644 lib/exact_target_sdk/schedule_result.rb diff --git a/lib/exact_target_sdk/client.rb b/lib/exact_target_sdk/client.rb index 07b7e88..87cbfc6 100644 --- a/lib/exact_target_sdk/client.rb +++ b/lib/exact_target_sdk/client.rb @@ -203,6 +203,48 @@ def Perform(action, *args) PerformResponse.new(response) end + + # Invokes the Schedule 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 ScheduleResponse object. + def Schedule(action, schedule, *args) + # TODO: implement and accept ScheduleOptions + + interactions = args + + response = execute_request 'Schedule' do |xml| + xml.ScheduleRequestMsg do + xml.Action action + + xml.Schedule do + schedule.render!(xml) + end + + xml.Interactions do + interactions.each do |interaction| + xml.Interaction "xsi:type" => interaction.type_name do + interaction.render!(xml) + end + end + end + + xml.Options # TODO: support ScheduleOptions + end + end + + ScheduleResponse.new(response) + end + + def logger config[:logger] end diff --git a/lib/exact_target_sdk/schedule_response.rb b/lib/exact_target_sdk/schedule_response.rb new file mode 100644 index 0000000..9f45743 --- /dev/null +++ b/lib/exact_target_sdk/schedule_response.rb @@ -0,0 +1,26 @@ +module ExactTargetSDK +class ScheduleResponse + + attr_reader :OverallStatus, :OverallStatusMessage, :RequestID, :Results + + def initialize(response) + response = response.to_hash[:schedule_response_msg] + @OverallStatus = response[:overall_status] + @OverallStatusMessage = response[:overall_status_message] + @RequestID = response[:request_id] + @Results = [] + + results = if response[:results].is_a? Array + response[:results] + elsif response[:results].is_a? Hash + [response[:results]] + else + [] + end + results.each do |result| + @Results << ScheduleResult.new(result) + end + end + +end +end diff --git a/lib/exact_target_sdk/schedule_result.rb b/lib/exact_target_sdk/schedule_result.rb new file mode 100644 index 0000000..bcfc87d --- /dev/null +++ b/lib/exact_target_sdk/schedule_result.rb @@ -0,0 +1,5 @@ +module ExactTargetSDK +class ScheduleResult < Result + +end +end From 3f44fdf68acba2babb1d9fea7401b93342ff4350 Mon Sep 17 00:00:00 2001 From: Valentine Zavadsky Date: Wed, 2 May 2012 19:15:35 +0300 Subject: [PATCH 11/57] remove validation from EmailSendDefinition --- lib/exact_target_sdk/email_send_definition.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/exact_target_sdk/email_send_definition.rb b/lib/exact_target_sdk/email_send_definition.rb index 414e4f9..143e1db 100644 --- a/lib/exact_target_sdk/email_send_definition.rb +++ b/lib/exact_target_sdk/email_send_definition.rb @@ -1,16 +1,16 @@ module ExactTargetSDK class EmailSendDefinition < APIObject - property 'Name', :required => true + property 'Name' # Indicates the send classification to use as part of a send definition. - property 'SendClassification', :required => true + property 'SendClassification' # Indicates the subscriber list to use as part of an email send definition. - property 'SendDefinitionList', :required => true + property 'SendDefinitionList' # Default email address for object. Indicates if subscriber information can be used for email sends. - property 'Email', :required => true + property 'Email' # Defines an email address to which to send a test message as part # of an email send definition. Use the Test action when sending a From 9fd17e2f8418b226debf1e20d28e637869ed43d3 Mon Sep 17 00:00:00 2001 From: Valentine Zavadsky Date: Wed, 2 May 2012 19:28:57 +0300 Subject: [PATCH 12/57] add results to perfrom response and add objects for scheduling --- lib/exact_target_sdk.rb | 10 ++++++++++ lib/exact_target_sdk/perform_response.rb | 14 ++++++++++++- lib/exact_target_sdk/perform_result.rb | 4 ++++ .../recurrence_range_type_enum.rb | 6 ++++++ lib/exact_target_sdk/recurrence_type_enum.rb | 11 ++++++++++ lib/exact_target_sdk/schedule_definition.rb | 20 +++++++++++++++++++ 6 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 lib/exact_target_sdk/perform_result.rb create mode 100644 lib/exact_target_sdk/recurrence_range_type_enum.rb create mode 100644 lib/exact_target_sdk/recurrence_type_enum.rb create mode 100644 lib/exact_target_sdk/schedule_definition.rb diff --git a/lib/exact_target_sdk.rb b/lib/exact_target_sdk.rb index 57d8304..553cb08 100644 --- a/lib/exact_target_sdk.rb +++ b/lib/exact_target_sdk.rb @@ -11,23 +11,33 @@ module ExactTargetSDK autoload :ContentArea, 'exact_target_sdk/content_area' autoload :CreateResponse, 'exact_target_sdk/create_response' autoload :CreateResult, 'exact_target_sdk/create_result' + autoload :DailyRecurrence, 'exact_target_sdk/daily_recurrence' + autoload :DailyRecurrencePatternTypeEnum, 'exact_target_sdk/daily_recurrence_pattern_type_enum' autoload :DataExtension, 'exact_target_sdk/data_extension' autoload :DataExtensionField, 'exact_target_sdk/data_extension_field' autoload :DataExtensionObject, 'exact_target_sdk/data_extension_object' autoload :DeleteResponse, 'exact_target_sdk/delete_response' autoload :DeleteResult, 'exact_target_sdk/delete_result' autoload :DeliveryProfile, 'exact_target_sdk/delivery_profile' + autoload :DeliveryProfileSourceAddressTypeEnum, 'exact_target_sdk/delivery_profile_source_address_type_enum' autoload :Email, 'exact_target_sdk/email' autoload :EmailSendDefinition, 'exact_target_sdk/email_send_definition' autoload :FilterPart, 'exact_target_sdk/filter_part' autoload :PerformResponse, 'exact_target_sdk/perform_response' + autoload :PerformResult, 'exact_target_sdk/perform_result' autoload :List, 'exact_target_sdk/list' + autoload :RecurrenceRangeTypeEnum, 'exact_target_sdk/recurrence_range_type_enum' + autoload :RecurrenceTypeEnum, 'exact_target_sdk/recurrence_type_enum' autoload :Result, 'exact_target_sdk/result' autoload :RetrieveResponse, 'exact_target_sdk/retrieve_response' autoload :RetrieveResult, 'exact_target_sdk/retrieve_result' autoload :SimpleFilterPart, 'exact_target_sdk/simple_filter_part' + autoload :ScheduleDefinition, 'exact_target_sdk/schedule_definition' + autoload :ScheduleResponse, 'exact_target_sdk/schedule_response' + autoload :ScheduleResult, 'exact_target_sdk/schedule_result' autoload :SendClassification, 'exact_target_sdk/send_classification' autoload :SendDefinitionList, 'exact_target_sdk/send_definition_list' + autoload :SendDefinitionListTypeEnum, 'exact_target_sdk/send_definition_list_enum' autoload :SenderProfile, 'exact_target_sdk/sender_profile' autoload :SimpleOperator, 'exact_target_sdk/simple_operator' autoload :Subscriber, 'exact_target_sdk/subscriber' diff --git a/lib/exact_target_sdk/perform_response.rb b/lib/exact_target_sdk/perform_response.rb index 460698e..d6e53db 100644 --- a/lib/exact_target_sdk/perform_response.rb +++ b/lib/exact_target_sdk/perform_response.rb @@ -1,13 +1,25 @@ module ExactTargetSDK class PerformResponse - attr_reader :OverallStatus, :OverallStatusMessage, :RequestID + attr_reader :OverallStatus, :OverallStatusMessage, :RequestID, :Results def initialize(response) response = response.to_hash[:perform_response_msg] @OverallStatus = response[:overall_status] @OverallStatusMessage = response[:overall_status_message] @RequestID = response[:request_id] + @Results = [] + + results = if response[:results].is_a? Array + response[:results] + elsif response[:results].is_a? Hash + [response[:results]] + else + [] + end + results.each do |result| + @Results << PerformResult.new(result) + end end end diff --git a/lib/exact_target_sdk/perform_result.rb b/lib/exact_target_sdk/perform_result.rb new file mode 100644 index 0000000..035dffe --- /dev/null +++ b/lib/exact_target_sdk/perform_result.rb @@ -0,0 +1,4 @@ +module ExactTargetSDK +class PerformResult < Result +end +end diff --git a/lib/exact_target_sdk/recurrence_range_type_enum.rb b/lib/exact_target_sdk/recurrence_range_type_enum.rb new file mode 100644 index 0000000..f1742db --- /dev/null +++ b/lib/exact_target_sdk/recurrence_range_type_enum.rb @@ -0,0 +1,6 @@ +module ExactTargetSDK +module RecurrenceRangeTypeEnum + END_AFTER = "EndAfter" + END_ON = "EndOn" +end +end diff --git a/lib/exact_target_sdk/recurrence_type_enum.rb b/lib/exact_target_sdk/recurrence_type_enum.rb new file mode 100644 index 0000000..c22069b --- /dev/null +++ b/lib/exact_target_sdk/recurrence_type_enum.rb @@ -0,0 +1,11 @@ +module ExactTargetSDK +module RecurrenceTypeEnum + DAILY = "Daily" + HOURLY = "Hourly" + MINUTELY = "Minutely" + MONTHLY = "Monthly" + SECONDLY = "Secondly" + WEEKLY = "Weekly" + YEARLY = "Yearly" +end +end diff --git a/lib/exact_target_sdk/schedule_definition.rb b/lib/exact_target_sdk/schedule_definition.rb new file mode 100644 index 0000000..9087688 --- /dev/null +++ b/lib/exact_target_sdk/schedule_definition.rb @@ -0,0 +1,20 @@ +module ExactTargetSDK +class ScheduleDefinition < APIObject + + # Specifies type of recurrence, such as daily or hourly. + property "RecurrenceType" + + # Defines how a recurrence type ends. + property "RecurrenceRangeType" + + # Specifies start time of schedule definition + property "StartDateTime" + + # Specifies number of times to run a schedule definition. + property "Occurrences" + + # Interval of recurrence type. + property "Recurrence" + +end +end From 40be2f9297ee480b9666b98a705b05d6f1d22019 Mon Sep 17 00:00:00 2001 From: Valentine Zavadsky Date: Wed, 2 May 2012 19:30:48 +0300 Subject: [PATCH 13/57] add some more objects for scheduling --- lib/exact_target_sdk/daily_recurrence.rb | 10 ++++++++++ .../daily_recurrence_pattern_type_enum.rb | 6 ++++++ .../delivery_profile_source_address_type_enum.rb | 6 ++++++ lib/exact_target_sdk/interaction_definition.rb | 0 lib/exact_target_sdk/send_definition_list.rb | 6 +----- .../send_definition_list_type_enum.rb | 12 ++++++++++++ 6 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 lib/exact_target_sdk/daily_recurrence.rb create mode 100644 lib/exact_target_sdk/daily_recurrence_pattern_type_enum.rb create mode 100644 lib/exact_target_sdk/delivery_profile_source_address_type_enum.rb delete mode 100644 lib/exact_target_sdk/interaction_definition.rb create mode 100644 lib/exact_target_sdk/send_definition_list_type_enum.rb diff --git a/lib/exact_target_sdk/daily_recurrence.rb b/lib/exact_target_sdk/daily_recurrence.rb new file mode 100644 index 0000000..6820e95 --- /dev/null +++ b/lib/exact_target_sdk/daily_recurrence.rb @@ -0,0 +1,10 @@ +module ExactTargetSDK +class DailyRecurrence < APIObject + + # Specifies the type of daily recurrence (either Interval or EveryWeekDay) + property "DailyRecurrencePatternType" + + # Specifies the number of days on which to execute a daily recurrence. + property "DayInterval" +end +end diff --git a/lib/exact_target_sdk/daily_recurrence_pattern_type_enum.rb b/lib/exact_target_sdk/daily_recurrence_pattern_type_enum.rb new file mode 100644 index 0000000..d864721 --- /dev/null +++ b/lib/exact_target_sdk/daily_recurrence_pattern_type_enum.rb @@ -0,0 +1,6 @@ +module ExactTargetSDK +module DailyRecurrencePatternTypeEnum + EVERY_WEEK_DAY = "EveryWeekDay" + INTERVAL = "Interval" +end +end diff --git a/lib/exact_target_sdk/delivery_profile_source_address_type_enum.rb b/lib/exact_target_sdk/delivery_profile_source_address_type_enum.rb new file mode 100644 index 0000000..0ffb913 --- /dev/null +++ b/lib/exact_target_sdk/delivery_profile_source_address_type_enum.rb @@ -0,0 +1,6 @@ +module ExactTargetSDK +module DeliveryProfileSourceAddressTypeEnum + CUSTOM_PRIVATE_IP_ADDRESS = "CustomPrivateIPAddress" + DEFAULT_PRIVATE_IP_ADDRESS = "DefaultPrivateIPAddress" +end +end diff --git a/lib/exact_target_sdk/interaction_definition.rb b/lib/exact_target_sdk/interaction_definition.rb deleted file mode 100644 index e69de29..0000000 diff --git a/lib/exact_target_sdk/send_definition_list.rb b/lib/exact_target_sdk/send_definition_list.rb index 63dd5b6..8b7c122 100644 --- a/lib/exact_target_sdk/send_definition_list.rb +++ b/lib/exact_target_sdk/send_definition_list.rb @@ -1,12 +1,8 @@ module ExactTargetSDK class SendDefinitionList < APIObject - property 'DataSourceTypeID', :required => true + property 'DataSourceTypeID' property 'List' - validates 'DataSourceTypeID', :inclusion => { :allow_nil => false, - :in => %w( List CustomObject DomainExclusion SalesForceCampaign FilterDefinition OptOutList ) } - end - end diff --git a/lib/exact_target_sdk/send_definition_list_type_enum.rb b/lib/exact_target_sdk/send_definition_list_type_enum.rb new file mode 100644 index 0000000..a0ffe7c --- /dev/null +++ b/lib/exact_target_sdk/send_definition_list_type_enum.rb @@ -0,0 +1,12 @@ +module ExactTargetSDK +module SendDefinitionListTypeEnum + + LIST = "List" + CUSTOM_OBJECT = "CustomObject" + DOMAIN_EXCLUSION = "DomainExclusion" + SALES_FORCE_CAMPAIGN = "SalesForceCampaign" + FILTER_DEFINITION = "FilterDefinition" + OPT_OUT_LIST = "OptOutList" + +end +end From 77bac461242bd060ee568ed3770a7920d9d90a53 Mon Sep 17 00:00:00 2001 From: Valentine Zavadsky Date: Wed, 2 May 2012 21:16:24 +0300 Subject: [PATCH 14/57] bounce_event and send objects added --- lib/exact_target_sdk.rb | 2 + lib/exact_target_sdk/bounce_event.rb | 25 ++++++++++ lib/exact_target_sdk/send.rb | 71 ++++++++++++++++++++++++++++ 3 files changed, 98 insertions(+) create mode 100644 lib/exact_target_sdk/bounce_event.rb create mode 100644 lib/exact_target_sdk/send.rb diff --git a/lib/exact_target_sdk.rb b/lib/exact_target_sdk.rb index 553cb08..c8a497a 100644 --- a/lib/exact_target_sdk.rb +++ b/lib/exact_target_sdk.rb @@ -6,6 +6,7 @@ module ExactTargetSDK autoload :APIObject, 'exact_target_sdk/api_object' autoload :APIProperty, 'exact_target_sdk/api_property' autoload :Attribute, 'exact_target_sdk/attribute' + autoload :BounceEvent, 'exact_target_sdk/bounce_event' autoload :Client, 'exact_target_sdk/client' autoload :ComplexFilterPart, 'exact_target_sdk/complex_filter_part' autoload :ContentArea, 'exact_target_sdk/content_area' @@ -32,6 +33,7 @@ module ExactTargetSDK autoload :RetrieveResponse, 'exact_target_sdk/retrieve_response' autoload :RetrieveResult, 'exact_target_sdk/retrieve_result' autoload :SimpleFilterPart, 'exact_target_sdk/simple_filter_part' + autoload :Send, 'exact_target_sdk/send' autoload :ScheduleDefinition, 'exact_target_sdk/schedule_definition' autoload :ScheduleResponse, 'exact_target_sdk/schedule_response' autoload :ScheduleResult, 'exact_target_sdk/schedule_result' diff --git a/lib/exact_target_sdk/bounce_event.rb b/lib/exact_target_sdk/bounce_event.rb new file mode 100644 index 0000000..eb2fe41 --- /dev/null +++ b/lib/exact_target_sdk/bounce_event.rb @@ -0,0 +1,25 @@ +module ExactTargetSDK +class BounceEvent < APIObject + + # Date when a tracking event occurred. + property "EventDate" + + # Contains identifier for a specific send. + property "SendID" + + # Contains SMTP code related to a bounced email. + property "SMTPCode" + + # Contains SMTP reason associated with a bounced email. + property "SMTPReason" + + # Identification of a specific subscriber. + property "SubscriberKey" + + # Identifies the triggered send definition associated with an event. + # This value also appears in tracking events to allow you to tie those events to a specific triggered send. + property "TriggeredSendDefinitionObjectID " + + +end +end diff --git a/lib/exact_target_sdk/send.rb b/lib/exact_target_sdk/send.rb new file mode 100644 index 0000000..2f60183 --- /dev/null +++ b/lib/exact_target_sdk/send.rb @@ -0,0 +1,71 @@ +module ExactTargetSDK +class Send < APIObject + + property 'Name' + + # Default email address for object. Indicates if subscriber information can be used for email sends. + property "Email" + + # Specifies the name of an email message associated with a send. + property "EmailName" + + # Indicates email send definition to which the send object is attached. + property "EmailSendDefinition" + + # Indicates From address associated with a object. + # Deprecated for email send definitions and triggered send definitions. + property "FromAddress" + + # Specifies the default email message From Name. + # Deprecated for email send definitions and triggered send definitions. + property "FromName" + + # Indicates number of hard bounces associated with a send. + property "HardBounces" + + # List associated with an object. + property "List" + + # Number of sent emails that did not bounce. + property "NumberDelivered" + + # Number of emails not sent as part of a send because an error occurred while trying to build the email. + property "NumberErrored" + + # Indicates the number recipients excluded from an email send because of a held, + # unsubscribed, master unsubscribed, or global unsubscribed status. + property "NumberExcluded" + + # Number of emails actually sent as part of an email send. + # This number reflects all of the sent messages and may include bounced messages. + property "NumberSent" + + # Specifies number of Other-type bounces in a send. + property "OtherBounces" + + # Indicates URL used to preview the message associated with a send. + property "PreviewURL" + + # Indicates date on which a send took place. + property "SentDate" + + # Indicates number of soft bounces associated with a specific send. + property "SoftBounces" + + # Defines status of object. Status of an address. + property "Status" + + # Contains subject area information for a message. + property "Subject" + + # Indicates number of unique clicks on message. + property "UniqueClicks" + + # Indicates number of unique opens resulting from a triggered send. + property "UniqueOpens" + + # Indicates the number of unsubscribe events associated with a send. + property 'Unsubscribes' + +end +end From 50dbcec6f4c6106427ae70d77a6625a0e9dce014 Mon Sep 17 00:00:00 2001 From: Valentine Zavadsky Date: Wed, 2 May 2012 21:17:13 +0300 Subject: [PATCH 15/57] Merge branches 'master' and 'additional-objects' From 3388047d7c443308332ee39b701c4bb0ada1382a Mon Sep 17 00:00:00 2001 From: Valentine Zavadsky Date: Thu, 3 May 2012 18:17:50 +0300 Subject: [PATCH 16/57] move method for before_validation to block to prevent rails errors --- lib/exact_target_sdk/subscriber.rb | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/exact_target_sdk/subscriber.rb b/lib/exact_target_sdk/subscriber.rb index 0fcf592..f374639 100644 --- a/lib/exact_target_sdk/subscriber.rb +++ b/lib/exact_target_sdk/subscriber.rb @@ -18,17 +18,13 @@ class Subscriber < APIObject property 'EmailTypePreference' array_property 'Attributes' - before_validation :sync_subscriber_key_and_email_address - - validates 'EmailTypePreference', :inclusion => { :allow_nil => true, :in => %w( HTML Text ) } - - private - - def sync_subscriber_key_and_email_address + before_validation do self.SubscriberKey = self.EmailAddress if self.SubscriberKey.nil? self.EmailAddress = self.SubscriberKey if self.EmailAddress.nil? end + validates 'EmailTypePreference', :inclusion => { :allow_nil => true, :in => %w( HTML Text ) } + end end From 1e1d91b13b077fdebd08287cf51b4ea47fe800db Mon Sep 17 00:00:00 2001 From: Valentine Zavadsky Date: Fri, 4 May 2012 17:56:12 +0300 Subject: [PATCH 17/57] add additional property to ESD --- lib/exact_target_sdk/email_send_definition.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/exact_target_sdk/email_send_definition.rb b/lib/exact_target_sdk/email_send_definition.rb index 143e1db..c69a588 100644 --- a/lib/exact_target_sdk/email_send_definition.rb +++ b/lib/exact_target_sdk/email_send_definition.rb @@ -36,6 +36,10 @@ class EmailSendDefinition < APIObject # Subject for an email send property 'EmailSubject' + # Defines an email address to which to send a test message as part of an email send definition. + # Use the Test action when sending a test email to an email send definition. + property "TestEmailAddr" + end end From 2667175490e3313346f3bf4b4dd1b1a5a825b393 Mon Sep 17 00:00:00 2001 From: Valentine Zavadsky Date: Mon, 7 May 2012 21:47:54 +0300 Subject: [PATCH 18/57] add couple more fields for email_send_definition and send_definition_list --- lib/exact_target_sdk/email_send_definition.rb | 2 +- lib/exact_target_sdk/send_definition_list.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/exact_target_sdk/email_send_definition.rb b/lib/exact_target_sdk/email_send_definition.rb index c69a588..7a0ea18 100644 --- a/lib/exact_target_sdk/email_send_definition.rb +++ b/lib/exact_target_sdk/email_send_definition.rb @@ -7,7 +7,7 @@ class EmailSendDefinition < APIObject property 'SendClassification' # Indicates the subscriber list to use as part of an email send definition. - property 'SendDefinitionList' + array_property 'SendDefinitionList' # Default email address for object. Indicates if subscriber information can be used for email sends. property 'Email' diff --git a/lib/exact_target_sdk/send_definition_list.rb b/lib/exact_target_sdk/send_definition_list.rb index 8b7c122..cd8c353 100644 --- a/lib/exact_target_sdk/send_definition_list.rb +++ b/lib/exact_target_sdk/send_definition_list.rb @@ -4,5 +4,13 @@ class SendDefinitionList < APIObject property 'DataSourceTypeID' property 'List' + property 'Name' + + # Indicates the specified send is a test send. A value of true indicates a test send. + property 'IsTestObject' + + # Represents the ID of the sendable data extension used as part of a send. + property 'CustomObjectID' + end end From 8055f324f47127d8cc7d190d0d5f5c7c271643a5 Mon Sep 17 00:00:00 2001 From: Valentine Zavadsky Date: Mon, 7 May 2012 21:48:15 +0300 Subject: [PATCH 19/57] remove validation from subscriber(error) --- lib/exact_target_sdk/subscriber.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/exact_target_sdk/subscriber.rb b/lib/exact_target_sdk/subscriber.rb index f374639..bae788a 100644 --- a/lib/exact_target_sdk/subscriber.rb +++ b/lib/exact_target_sdk/subscriber.rb @@ -23,8 +23,6 @@ class Subscriber < APIObject self.EmailAddress = self.SubscriberKey if self.EmailAddress.nil? end - validates 'EmailTypePreference', :inclusion => { :allow_nil => true, :in => %w( HTML Text ) } - end end From ccf09d4eec0644325a9d60b59b0204ca6da9ed64 Mon Sep 17 00:00:00 2001 From: Valentine Zavadsky Date: Mon, 7 May 2012 21:48:38 +0300 Subject: [PATCH 20/57] handle id and object_id methods --- lib/exact_target_sdk/result.rb | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/lib/exact_target_sdk/result.rb b/lib/exact_target_sdk/result.rb index d2f5bf6..ffcb8b8 100644 --- a/lib/exact_target_sdk/result.rb +++ b/lib/exact_target_sdk/result.rb @@ -1,19 +1,23 @@ require 'active_support/inflector' module ExactTargetSDK -class Result + class Result - # If @result contains :id key, while trying result.id it calls - # Object#id alias method for Object#object_id instead calling method_missing - undef id if self.respond_to? :id + def id + @result[:id] || self.id + end - def initialize(hash) - @result = hash - end + def object_id + @result[:object_id] || self.object_id + end - def method_missing(symbol, *args) - @result[symbol.to_s.underscore.to_sym] - end + def initialize(hash) + @result = hash + end -end + def method_missing(symbol, *args) + @result[symbol.to_s.underscore.to_sym] + end + + end end From faf4e8b94d42061661918d87a975de6e191d2621 Mon Sep 17 00:00:00 2001 From: Valentine Zavadsky Date: Mon, 7 May 2012 22:12:02 +0300 Subject: [PATCH 21/57] add some fields and enum for delivery profile --- lib/exact_target_sdk/delivery_profile.rb | 6 ++++++ lib/exact_target_sdk/salutation_source_enum.rb | 7 +++++++ 2 files changed, 13 insertions(+) create mode 100644 lib/exact_target_sdk/salutation_source_enum.rb diff --git a/lib/exact_target_sdk/delivery_profile.rb b/lib/exact_target_sdk/delivery_profile.rb index 63ac64e..1a27fd0 100644 --- a/lib/exact_target_sdk/delivery_profile.rb +++ b/lib/exact_target_sdk/delivery_profile.rb @@ -4,5 +4,11 @@ class DeliveryProfile < APIObject property 'Name' property 'SourceAddressType' + # Defines source of a footer salutation to use as part of a delivery profile or send definition (Default, Content Library, or None) + property 'FooterSalutationSource' + + # Defines source of header salutation for a delivery profile or send definition. + property 'HeaderSalutationSource ' + end end diff --git a/lib/exact_target_sdk/salutation_source_enum.rb b/lib/exact_target_sdk/salutation_source_enum.rb new file mode 100644 index 0000000..7ec4374 --- /dev/null +++ b/lib/exact_target_sdk/salutation_source_enum.rb @@ -0,0 +1,7 @@ +module ExactTargetSDK +module SalutationSourceEnum + CONTENT_LIBRARY = "ContentLibrary" + DEFAULT = "Default" + NONE = "None" +end +end From 13109b24a8a341d8f35e03c05525efc75b3e6100 Mon Sep 17 00:00:00 2001 From: Valentine Zavadsky Date: Tue, 8 May 2012 09:21:39 +0300 Subject: [PATCH 22/57] add new enum to autoload folder --- lib/exact_target_sdk.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/exact_target_sdk.rb b/lib/exact_target_sdk.rb index c8a497a..e0143a0 100644 --- a/lib/exact_target_sdk.rb +++ b/lib/exact_target_sdk.rb @@ -32,6 +32,7 @@ module ExactTargetSDK autoload :Result, 'exact_target_sdk/result' autoload :RetrieveResponse, 'exact_target_sdk/retrieve_response' autoload :RetrieveResult, 'exact_target_sdk/retrieve_result' + autoload :SalutationSourceEnum, 'exact_target_sdk/salutation_source_enum' autoload :SimpleFilterPart, 'exact_target_sdk/simple_filter_part' autoload :Send, 'exact_target_sdk/send' autoload :ScheduleDefinition, 'exact_target_sdk/schedule_definition' From 8dfc87ddf1e97fb9b909c2b3d395c32b09575ae4 Mon Sep 17 00:00:00 2001 From: Valentine Zavadsky Date: Tue, 8 May 2012 09:24:30 +0300 Subject: [PATCH 23/57] add some fields to data_extension --- lib/exact_target_sdk/data_extension.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/exact_target_sdk/data_extension.rb b/lib/exact_target_sdk/data_extension.rb index 087b43e..54411b7 100644 --- a/lib/exact_target_sdk/data_extension.rb +++ b/lib/exact_target_sdk/data_extension.rb @@ -5,5 +5,11 @@ class DataExtension < APIObject array_property 'Fields', :nest_children => true property 'Name' + # Indicates whether you can use a data extension as part of an audience for a message send. + property 'IsSendable' + + # Indicates whether a sendable data extension can be used within tests sends for a message. + property 'IsTestable' + end end From 79f3583fddee64f3c728eaa3af050e304ebaf101 Mon Sep 17 00:00:00 2001 From: Valentine Zavadsky Date: Thu, 10 May 2012 10:59:12 +0300 Subject: [PATCH 24/57] add couple more fields for data_extension and send_definition_list and add new data_extenstion_field_type enum --- lib/exact_target_sdk.rb | 1 + lib/exact_target_sdk/data_extension.rb | 10 ++++++++++ lib/exact_target_sdk/data_extension_field_type.rb | 14 ++++++++++++++ lib/exact_target_sdk/send_definition_list.rb | 3 +++ 4 files changed, 28 insertions(+) create mode 100644 lib/exact_target_sdk/data_extension_field_type.rb diff --git a/lib/exact_target_sdk.rb b/lib/exact_target_sdk.rb index e0143a0..6b13895 100644 --- a/lib/exact_target_sdk.rb +++ b/lib/exact_target_sdk.rb @@ -16,6 +16,7 @@ module ExactTargetSDK autoload :DailyRecurrencePatternTypeEnum, 'exact_target_sdk/daily_recurrence_pattern_type_enum' autoload :DataExtension, 'exact_target_sdk/data_extension' autoload :DataExtensionField, 'exact_target_sdk/data_extension_field' + autoload :DataExtensionFieldType, 'exact_target_sdk/data_extension_field_type' autoload :DataExtensionObject, 'exact_target_sdk/data_extension_object' autoload :DeleteResponse, 'exact_target_sdk/delete_response' autoload :DeleteResult, 'exact_target_sdk/delete_result' diff --git a/lib/exact_target_sdk/data_extension.rb b/lib/exact_target_sdk/data_extension.rb index 54411b7..52be515 100644 --- a/lib/exact_target_sdk/data_extension.rb +++ b/lib/exact_target_sdk/data_extension.rb @@ -11,5 +11,15 @@ class DataExtension < APIObject # Indicates whether a sendable data extension can be used within tests sends for a message. property 'IsTestable' + # Indicates the field within a sendable data extension to use as an address as part of a send. + # Possible values include SubscriberID, CustomerKey, or EmailAddress. + # The application uses this field to establish a data relationship between a value specified by the + # SendableSubscriberField property and a value within a sendable data extension. + property 'SendableDataExtensionField' + + # Indicates field to use as sending address. The application uses this field to establish a data relationship + # between a subscriber field and a value specified by the SendableDataExtentionField property. + property 'SendableSubscriberField' + end end diff --git a/lib/exact_target_sdk/data_extension_field_type.rb b/lib/exact_target_sdk/data_extension_field_type.rb new file mode 100644 index 0000000..5efb3db --- /dev/null +++ b/lib/exact_target_sdk/data_extension_field_type.rb @@ -0,0 +1,14 @@ +module ExactTargetSDK +module DataExtensionFieldType + + TEXT = "Text" + NUMBER = "Number" + DATA = "Data" + BOOLEAN = "Boolean" + EMAIL_ADDRESS = "EmailAddress" + PHONE = "Phone" + DECIMAL = "Decimal" + LOCALE = "Locale" + +end +end diff --git a/lib/exact_target_sdk/send_definition_list.rb b/lib/exact_target_sdk/send_definition_list.rb index cd8c353..f0ba04e 100644 --- a/lib/exact_target_sdk/send_definition_list.rb +++ b/lib/exact_target_sdk/send_definition_list.rb @@ -12,5 +12,8 @@ class SendDefinitionList < APIObject # Represents the ID of the sendable data extension used as part of a send. property 'CustomObjectID' + # Defines type of send definition list. + property 'SendDefinitionListType' + end end From 623ae33f3996a8d4c1e814a6b32abbd4f9243eb2 Mon Sep 17 00:00:00 2001 From: Valentine Zavadsky Date: Tue, 15 May 2012 11:59:39 +0300 Subject: [PATCH 25/57] Add property for SenderProfile to enable AutoForward feature --- lib/exact_target_sdk/sender_profile.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/exact_target_sdk/sender_profile.rb b/lib/exact_target_sdk/sender_profile.rb index 1da0f49..58fec19 100644 --- a/lib/exact_target_sdk/sender_profile.rb +++ b/lib/exact_target_sdk/sender_profile.rb @@ -15,7 +15,8 @@ class SenderProfile < APIObject # Indicates the email address to use with automatically forwarded email messages. property 'AutoForwardToEmailAddress' - + # Indicates whether a sender profile uses the default RMM rules for that account. + property 'UseDefaultRMMRules' end end From c48de4570e8cfbd0c0e19f837c5ad1b8e4bd558f Mon Sep 17 00:00:00 2001 From: Valentine Zavadsky Date: Tue, 15 May 2012 12:07:38 +0300 Subject: [PATCH 26/57] fix typo for DeliveryProfile --- lib/exact_target_sdk/delivery_profile.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/exact_target_sdk/delivery_profile.rb b/lib/exact_target_sdk/delivery_profile.rb index 1a27fd0..0c36055 100644 --- a/lib/exact_target_sdk/delivery_profile.rb +++ b/lib/exact_target_sdk/delivery_profile.rb @@ -8,7 +8,7 @@ class DeliveryProfile < APIObject property 'FooterSalutationSource' # Defines source of header salutation for a delivery profile or send definition. - property 'HeaderSalutationSource ' + property 'HeaderSalutationSource' end end From 6f938587cd113b649dc95d7f3c5738208d893c5c Mon Sep 17 00:00:00 2001 From: Valentine Zavadsky Date: Wed, 16 May 2012 17:24:28 +0300 Subject: [PATCH 27/57] add SenderProfile to EmailSendDefinition --- lib/exact_target_sdk/email_send_definition.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/exact_target_sdk/email_send_definition.rb b/lib/exact_target_sdk/email_send_definition.rb index 7a0ea18..5672e20 100644 --- a/lib/exact_target_sdk/email_send_definition.rb +++ b/lib/exact_target_sdk/email_send_definition.rb @@ -40,6 +40,9 @@ class EmailSendDefinition < APIObject # Use the Test action when sending a test email to an email send definition. property "TestEmailAddr" + #Identifies the sender profile included in the send classificiation. + property 'SenderProfile' + end end From 477105a3db351737b9bd50be2c948c8018b6ae9e Mon Sep 17 00:00:00 2001 From: Valentine Zavadsky Date: Thu, 17 May 2012 15:36:48 +0300 Subject: [PATCH 28/57] remove handling UnknowError from execute_request call --- lib/exact_target_sdk/client.rb | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/exact_target_sdk/client.rb b/lib/exact_target_sdk/client.rb index 87cbfc6..2691c31 100644 --- a/lib/exact_target_sdk/client.rb +++ b/lib/exact_target_sdk/client.rb @@ -271,7 +271,6 @@ def initialize_client! # # Returns the raw savon response. def execute_request(method) - begin response = client.request(method) do soap.xml do |xml| xml.s :Envelope, @@ -313,13 +312,10 @@ def execute_request(method) end response - rescue ::Timeout::Error => e - timeout = ::ExactTargetSDK::TimeoutError.new("#{e.message}; open_timeout: #{config[:open_timeout]}; read_timeout: #{config[:read_timeout]}") - timeout.set_backtrace(e.backtrace) - raise timeout - rescue Exception => e - raise ::ExactTargetSDK::UnknownError, e - end + rescue ::Timeout::Error => e + timeout = ::ExactTargetSDK::TimeoutError.new("#{e.message}; open_timeout: #{config[:open_timeout]}; read_timeout: #{config[:read_timeout]}") + timeout.set_backtrace(e.backtrace) + raise timeout end end From 4212a72199b09dd388a956f41b215ad18148de1b Mon Sep 17 00:00:00 2001 From: Valentine Zavadsky Date: Thu, 17 May 2012 15:38:43 +0300 Subject: [PATCH 29/57] add LogicalOperators enum --- lib/exact_target_sdk.rb | 1 + lib/exact_target_sdk/logical_operators.rb | 6 ++++++ 2 files changed, 7 insertions(+) create mode 100644 lib/exact_target_sdk/logical_operators.rb diff --git a/lib/exact_target_sdk.rb b/lib/exact_target_sdk.rb index 6b13895..914f295 100644 --- a/lib/exact_target_sdk.rb +++ b/lib/exact_target_sdk.rb @@ -28,6 +28,7 @@ module ExactTargetSDK autoload :PerformResponse, 'exact_target_sdk/perform_response' autoload :PerformResult, 'exact_target_sdk/perform_result' autoload :List, 'exact_target_sdk/list' + autoload :LogicalOperators, 'exact_target_sdk/logical_operators' autoload :RecurrenceRangeTypeEnum, 'exact_target_sdk/recurrence_range_type_enum' autoload :RecurrenceTypeEnum, 'exact_target_sdk/recurrence_type_enum' autoload :Result, 'exact_target_sdk/result' diff --git a/lib/exact_target_sdk/logical_operators.rb b/lib/exact_target_sdk/logical_operators.rb new file mode 100644 index 0000000..759d810 --- /dev/null +++ b/lib/exact_target_sdk/logical_operators.rb @@ -0,0 +1,6 @@ +module ExactTargetSDK +module LogicalOperators + AND = "AND" + OR = "OR" +end +end From ab8e7d73c9a687f99f8c5e027820c61eca1202d7 Mon Sep 17 00:00:00 2001 From: Valentine Zavadsky Date: Thu, 17 May 2012 22:54:40 +0300 Subject: [PATCH 30/57] Add couple fields to DataExtensionObject --- lib/exact_target_sdk/data_extension_object.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/exact_target_sdk/data_extension_object.rb b/lib/exact_target_sdk/data_extension_object.rb index ce22d2b..ffd3d43 100644 --- a/lib/exact_target_sdk/data_extension_object.rb +++ b/lib/exact_target_sdk/data_extension_object.rb @@ -2,7 +2,9 @@ module ExactTargetSDK class DataExtensionObject < APIObject property 'CustomerKey' + property 'SubscriberKey' array_property 'Properties', :nest_children => true + array_property 'Keys', :nest_children => true end end From 68d6f679c3c275c9fb46d7a5fa48f86ea7fab47a Mon Sep 17 00:00:00 2001 From: klochner Date: Fri, 18 May 2012 17:15:26 -0700 Subject: [PATCH 31/57] make object and id available for UpdateResult - object returns the object that was updated - id returns the id of the object (if available) --- lib/exact_target_sdk/update_result.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/exact_target_sdk/update_result.rb b/lib/exact_target_sdk/update_result.rb index 7ce2d23..75dbaf0 100644 --- a/lib/exact_target_sdk/update_result.rb +++ b/lib/exact_target_sdk/update_result.rb @@ -1,4 +1,11 @@ module ExactTargetSDK -class UpdateResult < Result -end + class UpdateResult < Result + def object + @result[:object] + end + + def id + object && object[:id] + end + end end From 5448e3b2b09ebf68d2e8baf51de4c274c75a23b7 Mon Sep 17 00:00:00 2001 From: Valentine Zavadsky Date: Mon, 21 May 2012 16:19:31 +0300 Subject: [PATCH 32/57] add SubscriberList object --- lib/exact_target_sdk.rb | 1 + lib/exact_target_sdk/subscriber.rb | 1 + lib/exact_target_sdk/subscriber_list.rb | 17 +++++++++++++++++ 3 files changed, 19 insertions(+) create mode 100644 lib/exact_target_sdk/subscriber_list.rb diff --git a/lib/exact_target_sdk.rb b/lib/exact_target_sdk.rb index 914f295..d821d26 100644 --- a/lib/exact_target_sdk.rb +++ b/lib/exact_target_sdk.rb @@ -46,6 +46,7 @@ module ExactTargetSDK autoload :SenderProfile, 'exact_target_sdk/sender_profile' autoload :SimpleOperator, 'exact_target_sdk/simple_operator' autoload :Subscriber, 'exact_target_sdk/subscriber' + autoload :SubscriberList, 'exact_target_sdk/subscriber_list' autoload :TriggeredSend, 'exact_target_sdk/triggered_send' autoload :TriggeredSendDefinition, 'exact_target_sdk/triggered_send_definition' autoload :UpdateResponse, 'exact_target_sdk/update_response' diff --git a/lib/exact_target_sdk/subscriber.rb b/lib/exact_target_sdk/subscriber.rb index bae788a..093d9ba 100644 --- a/lib/exact_target_sdk/subscriber.rb +++ b/lib/exact_target_sdk/subscriber.rb @@ -17,6 +17,7 @@ class Subscriber < APIObject property 'EmailAddress', :required => true property 'EmailTypePreference' array_property 'Attributes' + array_property 'Lists' before_validation do self.SubscriberKey = self.EmailAddress if self.SubscriberKey.nil? diff --git a/lib/exact_target_sdk/subscriber_list.rb b/lib/exact_target_sdk/subscriber_list.rb new file mode 100644 index 0000000..dbb3055 --- /dev/null +++ b/lib/exact_target_sdk/subscriber_list.rb @@ -0,0 +1,17 @@ +module ExactTargetSDK +class SubscriberList < APIObject + + # Defines the action to take for the specified object. + propery 'Action' + + # List associated with an object. + property 'List' + + # Defines status of object. Status of an address. + property 'Status' + + # Defines status of object. Status of an address. + property 'Subscriber' + +end +end From f8c0cc7159f431a8fde0e86319f57f93dcc7b728 Mon Sep 17 00:00:00 2001 From: klochner Date: Fri, 18 May 2012 17:15:26 -0700 Subject: [PATCH 33/57] make object and id available for UpdateResult - object returns the object that was updated - id returns the id of the object (if available) --- lib/exact_target_sdk/update_result.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/exact_target_sdk/update_result.rb b/lib/exact_target_sdk/update_result.rb index 7ce2d23..75dbaf0 100644 --- a/lib/exact_target_sdk/update_result.rb +++ b/lib/exact_target_sdk/update_result.rb @@ -1,4 +1,11 @@ module ExactTargetSDK -class UpdateResult < Result -end + class UpdateResult < Result + def object + @result[:object] + end + + def id + object && object[:id] + end + end end From 49cb13de3247249d2f9577f02eebb484a91f688d Mon Sep 17 00:00:00 2001 From: Valentine Zavadsky Date: Mon, 21 May 2012 17:03:25 +0300 Subject: [PATCH 34/57] typo --- lib/exact_target_sdk/subscriber_list.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/exact_target_sdk/subscriber_list.rb b/lib/exact_target_sdk/subscriber_list.rb index dbb3055..22f39f4 100644 --- a/lib/exact_target_sdk/subscriber_list.rb +++ b/lib/exact_target_sdk/subscriber_list.rb @@ -2,7 +2,7 @@ module ExactTargetSDK class SubscriberList < APIObject # Defines the action to take for the specified object. - propery 'Action' + property 'Action' # List associated with an object. property 'List' From 73d038a526e0370713e5a51c631fb50769cf858b Mon Sep 17 00:00:00 2001 From: Valentine Zavadsky Date: Mon, 21 May 2012 17:41:24 +0300 Subject: [PATCH 35/57] Merge branches 'master' and 'new-feature' From 2600b45c1ec3a14f73948062eaf0229281a6cb0a Mon Sep 17 00:00:00 2001 From: Valentine Zavadsky Date: Thu, 24 May 2012 15:36:52 +0300 Subject: [PATCH 36/57] gitignore updated --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index da32bd1..a4d3cd7 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,6 @@ /gems_dev /.rbx .*.swp +.idea/ +temp/ +.rvmrc From ff54ab1d5afccd8510becf03f84ca936eab34647 Mon Sep 17 00:00:00 2001 From: Valentine Zavadsky Date: Fri, 25 May 2012 12:42:04 +0300 Subject: [PATCH 37/57] add objects for SpamAssasin integration --- lib/exact_target_sdk.rb | 3 +++ lib/exact_target_sdk/content_validation.rb | 14 ++++++++++++++ lib/exact_target_sdk/spam_assassin_validation.rb | 5 +++++ lib/exact_target_sdk/validation_action.rb | 11 +++++++++++ 4 files changed, 33 insertions(+) create mode 100644 lib/exact_target_sdk/content_validation.rb create mode 100644 lib/exact_target_sdk/spam_assassin_validation.rb create mode 100644 lib/exact_target_sdk/validation_action.rb diff --git a/lib/exact_target_sdk.rb b/lib/exact_target_sdk.rb index d821d26..a9259a1 100644 --- a/lib/exact_target_sdk.rb +++ b/lib/exact_target_sdk.rb @@ -10,6 +10,7 @@ module ExactTargetSDK autoload :Client, 'exact_target_sdk/client' autoload :ComplexFilterPart, 'exact_target_sdk/complex_filter_part' autoload :ContentArea, 'exact_target_sdk/content_area' + autoload :ContentValidation, 'exact_target_sdk/content_validation' autoload :CreateResponse, 'exact_target_sdk/create_response' autoload :CreateResult, 'exact_target_sdk/create_result' autoload :DailyRecurrence, 'exact_target_sdk/daily_recurrence' @@ -45,10 +46,12 @@ module ExactTargetSDK autoload :SendDefinitionListTypeEnum, 'exact_target_sdk/send_definition_list_enum' autoload :SenderProfile, 'exact_target_sdk/sender_profile' autoload :SimpleOperator, 'exact_target_sdk/simple_operator' + autoload :SpamAssassinValidation, 'exact_target_sdk/spam_assassin_validation' autoload :Subscriber, 'exact_target_sdk/subscriber' autoload :SubscriberList, 'exact_target_sdk/subscriber_list' autoload :TriggeredSend, 'exact_target_sdk/triggered_send' autoload :TriggeredSendDefinition, 'exact_target_sdk/triggered_send_definition' + autoload :ValidationAction, 'exact_target_sdk/validation_action' autoload :UpdateResponse, 'exact_target_sdk/update_response' autoload :UpdateResult, 'exact_target_sdk/update_result' diff --git a/lib/exact_target_sdk/content_validation.rb b/lib/exact_target_sdk/content_validation.rb new file mode 100644 index 0000000..88cbb1d --- /dev/null +++ b/lib/exact_target_sdk/content_validation.rb @@ -0,0 +1,14 @@ +module ExactTargetSDK +class ContentValidation < APIObject + + # Default email address for object. Indicates if subscriber information can be used for email sends. + property 'Email' + + # Specifies the validation action to run on content. Valid values include SpamAssassinValidation. + property 'ValidationAction' + + # Indicates subscribers associated with an object. + array_property 'Subscribers' + +end +end diff --git a/lib/exact_target_sdk/spam_assassin_validation.rb b/lib/exact_target_sdk/spam_assassin_validation.rb new file mode 100644 index 0000000..ffa1447 --- /dev/null +++ b/lib/exact_target_sdk/spam_assassin_validation.rb @@ -0,0 +1,5 @@ +module ExactTargetSDK +class SpamAssassinValidation < ValidationAction + +end +end diff --git a/lib/exact_target_sdk/validation_action.rb b/lib/exact_target_sdk/validation_action.rb new file mode 100644 index 0000000..b801d37 --- /dev/null +++ b/lib/exact_target_sdk/validation_action.rb @@ -0,0 +1,11 @@ +module ExactTargetSDK +class ValidationAction < APIObject + + # Options for validation object. Type: APIProperty[] + array_property 'ValidationOptions' + + # Specified type of validation + property 'ValidationType' + +end +end From 430f6b5c346ce4e69449a44e53c939d9f66cfdbe Mon Sep 17 00:00:00 2001 From: Valentine Zavadsky Date: Mon, 11 Jun 2012 18:34:49 +0300 Subject: [PATCH 38/57] rework Email model --- lib/exact_target_sdk/email.rb | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/exact_target_sdk/email.rb b/lib/exact_target_sdk/email.rb index 5e02307..315f528 100644 --- a/lib/exact_target_sdk/email.rb +++ b/lib/exact_target_sdk/email.rb @@ -1,10 +1,21 @@ +# http://docs.code.exacttarget.com/020_Web_Service_Guide/Objects/Email module ExactTargetSDK class Email < APIObject - property 'Name', :required => true - property 'Subject', :required => true + # Name of the object or property. + property 'Name' + + # Contains subject area information for a message. + property 'Subject' + + # Contains HTML body of an email message. property 'HTMLBody' + + # Contains raw text body of a message. property 'TextBody' + # Indicates if email message was created via pasted HTML. + property 'IsHTMLPaste' + end end From 2b59df248c0181f9273b4c9717d33c26f0af1b7e Mon Sep 17 00:00:00 2001 From: Valentine Zavadsky Date: Mon, 11 Jun 2012 19:57:44 +0300 Subject: [PATCH 39/57] use ExactTargetSDK.config instead config --- lib/exact_target_sdk/client.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/exact_target_sdk/client.rb b/lib/exact_target_sdk/client.rb index 2691c31..c214b02 100644 --- a/lib/exact_target_sdk/client.rb +++ b/lib/exact_target_sdk/client.rb @@ -255,11 +255,11 @@ def logger # Constructs and saves the savon client using provided config. def initialize_client! - self.client = ::Savon::Client.new do - wsdl.endpoint = config[:endpoint] - wsdl.namespace = config[:namespace] - http.open_timeout = config[:open_timeout] - http.read_timeout = config[:read_timeout] + self.client = ::Savon::Client.new do |wsdl, http| + wsdl.endpoint = ExactTargetSDK.config[:endpoint] + wsdl.namespace = ExactTargetSDK.config[:namespace] + http.open_timeout = ExactTargetSDK.config[:open_timeout] + http.read_timeout = ExactTargetSDK.config[:read_timeout] end end @@ -274,7 +274,7 @@ def execute_request(method) response = client.request(method) do soap.xml do |xml| xml.s :Envelope, - "xmlns" => config[:namespace], + "xmlns" => ExactTargetSDK.config[:namespace], "xmlns:xsd" => "http://www.w3.org/2001/XMLSchema", "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance", "xmlns:s" => "http://www.w3.org/2003/05/soap-envelope", @@ -287,11 +287,11 @@ def execute_request(method) xml.a :ReplyTo do xml.a :Address, "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous" end - xml.a :To, config[:endpoint], "s:mustUnderstand" => "1" + xml.a :To, ExactTargetSDK.config[:endpoint], "s:mustUnderstand" => "1" xml.o :Security, "s:mustUnderstand" => "1" do xml.o :UsernameToken, "o:Id" => "test" do - xml.o :Username, config[:username] - xml.o :Password, config[:password] + xml.o :Username, ExactTargetSDK.config[:username] + xml.o :Password, ExactTargetSDK.config[:password] end end end From 1948e203dd977851df2d3487c715ac14a9e0a0dd Mon Sep 17 00:00:00 2001 From: Valentine Zavadsky Date: Mon, 11 Jun 2012 20:23:15 +0300 Subject: [PATCH 40/57] fix couple more config options --- lib/exact_target_sdk/client.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/exact_target_sdk/client.rb b/lib/exact_target_sdk/client.rb index c214b02..e37157d 100644 --- a/lib/exact_target_sdk/client.rb +++ b/lib/exact_target_sdk/client.rb @@ -25,7 +25,7 @@ def initialize(options = {}) }.merge!(ExactTargetSDK.config).merge!(options) Savon.configure do |c| - c.logger = config[:logger] + c.logger = ExactTargetSDK.config[:logger] c.raise_errors = false end @@ -246,7 +246,7 @@ def Schedule(action, schedule, *args) def logger - config[:logger] + ExactTargetSDK.config[:logger] end private From e96308f1276f1318273bc30dfdd299d5fe4e477b Mon Sep 17 00:00:00 2001 From: Valentine Zavadsky Date: Mon, 11 Jun 2012 20:29:52 +0300 Subject: [PATCH 41/57] add option for enabling logs --- lib/exact_target_sdk/client.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/exact_target_sdk/client.rb b/lib/exact_target_sdk/client.rb index e37157d..fc9c540 100644 --- a/lib/exact_target_sdk/client.rb +++ b/lib/exact_target_sdk/client.rb @@ -26,6 +26,7 @@ def initialize(options = {}) Savon.configure do |c| c.logger = ExactTargetSDK.config[:logger] + c.log = ExactTargetSDK.config[:log_enabled] c.raise_errors = false end From 1ec397a1ba17bb0f934f3e4cbf7357b93e198473 Mon Sep 17 00:00:00 2001 From: Valentine Zavadsky Date: Mon, 11 Jun 2012 20:35:57 +0300 Subject: [PATCH 42/57] downgrade savon version and remove enabling login option --- Gemfile | 2 +- Gemfile.lock | 2 +- lib/exact_target_sdk/client.rb | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index aa02545..10bc8a3 100644 --- a/Gemfile +++ b/Gemfile @@ -3,7 +3,7 @@ source 'http://rubygems.org' gem 'activemodel', '~> 3.0' gem 'activesupport', '~> 3.0' gem 'guid', '~> 0.1' -gem 'savon', '~> 0.9' +gem 'savon', '<= 0.9.9' group :rake do gem 'simple_gem', :require => 'tasks/simple_gem' diff --git a/Gemfile.lock b/Gemfile.lock index ddf4a08..c403e32 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -53,5 +53,5 @@ DEPENDENCIES activesupport (~> 3.0) guid (~> 0.1) rspec (~> 2.8) - savon (~> 0.9) + savon (<= 0.9.9) simple_gem diff --git a/lib/exact_target_sdk/client.rb b/lib/exact_target_sdk/client.rb index fc9c540..e37157d 100644 --- a/lib/exact_target_sdk/client.rb +++ b/lib/exact_target_sdk/client.rb @@ -26,7 +26,6 @@ def initialize(options = {}) Savon.configure do |c| c.logger = ExactTargetSDK.config[:logger] - c.log = ExactTargetSDK.config[:log_enabled] c.raise_errors = false end From 6a2de6b854f9b83fb3eedda201ac9749c24fa3b2 Mon Sep 17 00:00:00 2001 From: Valentine Zavadsky Date: Mon, 11 Jun 2012 20:52:33 +0300 Subject: [PATCH 43/57] remove default rails logger --- lib/exact_target_sdk/config.rb | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/exact_target_sdk/config.rb b/lib/exact_target_sdk/config.rb index 286bc68..ec31323 100644 --- a/lib/exact_target_sdk/config.rb +++ b/lib/exact_target_sdk/config.rb @@ -49,13 +49,9 @@ def self.config(options = nil) private def self.default_logger - if defined?(::Rails) - ::Rails.logger - else - logger = ::Logger.new(STDERR) - logger.level = ::Logger::INFO - logger - end + logger = ::Logger.new(STDERR) + logger.level = ::Logger::INFO + logger end end From 4ea10ec55427dff89a3aaadc3c63494b0eab396c Mon Sep 17 00:00:00 2001 From: Valentine Zavadsky Date: Mon, 11 Jun 2012 20:53:17 +0300 Subject: [PATCH 44/57] roll back previous savon version --- Gemfile | 2 +- Gemfile.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 10bc8a3..aa02545 100644 --- a/Gemfile +++ b/Gemfile @@ -3,7 +3,7 @@ source 'http://rubygems.org' gem 'activemodel', '~> 3.0' gem 'activesupport', '~> 3.0' gem 'guid', '~> 0.1' -gem 'savon', '<= 0.9.9' +gem 'savon', '~> 0.9' group :rake do gem 'simple_gem', :require => 'tasks/simple_gem' diff --git a/Gemfile.lock b/Gemfile.lock index c403e32..ddf4a08 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -53,5 +53,5 @@ DEPENDENCIES activesupport (~> 3.0) guid (~> 0.1) rspec (~> 2.8) - savon (<= 0.9.9) + savon (~> 0.9) simple_gem From b2075215d4f11e8a40b133b327b15e698e399c77 Mon Sep 17 00:00:00 2001 From: Valentine Zavadsky Date: Mon, 11 Jun 2012 21:02:37 +0300 Subject: [PATCH 45/57] revert back rails logger and setup dependencies --- Gemfile | 2 +- Gemfile.lock | 2 +- exact_target_sdk.gemspec | 2 +- lib/exact_target_sdk/config.rb | 10 +++++++--- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Gemfile b/Gemfile index aa02545..10bc8a3 100644 --- a/Gemfile +++ b/Gemfile @@ -3,7 +3,7 @@ source 'http://rubygems.org' gem 'activemodel', '~> 3.0' gem 'activesupport', '~> 3.0' gem 'guid', '~> 0.1' -gem 'savon', '~> 0.9' +gem 'savon', '<= 0.9.9' group :rake do gem 'simple_gem', :require => 'tasks/simple_gem' diff --git a/Gemfile.lock b/Gemfile.lock index ddf4a08..c403e32 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -53,5 +53,5 @@ DEPENDENCIES activesupport (~> 3.0) guid (~> 0.1) rspec (~> 2.8) - savon (~> 0.9) + savon (<= 0.9.9) simple_gem diff --git a/exact_target_sdk.gemspec b/exact_target_sdk.gemspec index 0cb54c0..c0bba23 100644 --- a/exact_target_sdk.gemspec +++ b/exact_target_sdk.gemspec @@ -27,6 +27,6 @@ Gem::Specification.new do |s| s.add_dependency 'activemodel', '~> 3.0' s.add_dependency 'activesupport', '~> 3.0' s.add_dependency 'guid', '~> 0.1' - s.add_dependency 'savon', '~> 0.9' + s.add_dependency 'savon', '<= 0.9.9' end diff --git a/lib/exact_target_sdk/config.rb b/lib/exact_target_sdk/config.rb index ec31323..286bc68 100644 --- a/lib/exact_target_sdk/config.rb +++ b/lib/exact_target_sdk/config.rb @@ -49,9 +49,13 @@ def self.config(options = nil) private def self.default_logger - logger = ::Logger.new(STDERR) - logger.level = ::Logger::INFO - logger + if defined?(::Rails) + ::Rails.logger + else + logger = ::Logger.new(STDERR) + logger.level = ::Logger::INFO + logger + end end end From 0b327026fdaad32b3b1635d5894811518e2cbf41 Mon Sep 17 00:00:00 2001 From: Valentine Zavadsky Date: Wed, 13 Jun 2012 17:55:57 +0300 Subject: [PATCH 46/57] add click open and sent events objects --- lib/exact_target_sdk.rb | 3 +++ lib/exact_target_sdk/click_event.rb | 14 ++++++++++++++ lib/exact_target_sdk/open_event.rb | 14 ++++++++++++++ lib/exact_target_sdk/sent_event.rb | 14 ++++++++++++++ 4 files changed, 45 insertions(+) create mode 100644 lib/exact_target_sdk/click_event.rb create mode 100644 lib/exact_target_sdk/open_event.rb create mode 100644 lib/exact_target_sdk/sent_event.rb diff --git a/lib/exact_target_sdk.rb b/lib/exact_target_sdk.rb index a9259a1..8e8e61f 100644 --- a/lib/exact_target_sdk.rb +++ b/lib/exact_target_sdk.rb @@ -8,6 +8,7 @@ module ExactTargetSDK autoload :Attribute, 'exact_target_sdk/attribute' autoload :BounceEvent, 'exact_target_sdk/bounce_event' autoload :Client, 'exact_target_sdk/client' + autoload :ClickEvent, 'exact_target_sdk/click_event' autoload :ComplexFilterPart, 'exact_target_sdk/complex_filter_part' autoload :ContentArea, 'exact_target_sdk/content_area' autoload :ContentValidation, 'exact_target_sdk/content_validation' @@ -30,6 +31,7 @@ module ExactTargetSDK autoload :PerformResult, 'exact_target_sdk/perform_result' autoload :List, 'exact_target_sdk/list' autoload :LogicalOperators, 'exact_target_sdk/logical_operators' + autoload :OpenEvent, 'exact_target_sdk/open_event' autoload :RecurrenceRangeTypeEnum, 'exact_target_sdk/recurrence_range_type_enum' autoload :RecurrenceTypeEnum, 'exact_target_sdk/recurrence_type_enum' autoload :Result, 'exact_target_sdk/result' @@ -45,6 +47,7 @@ module ExactTargetSDK autoload :SendDefinitionList, 'exact_target_sdk/send_definition_list' autoload :SendDefinitionListTypeEnum, 'exact_target_sdk/send_definition_list_enum' autoload :SenderProfile, 'exact_target_sdk/sender_profile' + autoload :SentEvent, 'exact_target_sdk/sent_event' autoload :SimpleOperator, 'exact_target_sdk/simple_operator' autoload :SpamAssassinValidation, 'exact_target_sdk/spam_assassin_validation' autoload :Subscriber, 'exact_target_sdk/subscriber' diff --git a/lib/exact_target_sdk/click_event.rb b/lib/exact_target_sdk/click_event.rb new file mode 100644 index 0000000..75fde29 --- /dev/null +++ b/lib/exact_target_sdk/click_event.rb @@ -0,0 +1,14 @@ +module ExactTargetSDK +class ClickEvent < APIObject + + # Date when a tracking event occurred. + property 'EventDate' + + # Contains identifier for a specific send. + property 'SendID' + + # Identification of a specific subscriber. + property 'SubscriberKey' + +end +end diff --git a/lib/exact_target_sdk/open_event.rb b/lib/exact_target_sdk/open_event.rb new file mode 100644 index 0000000..9fd618f --- /dev/null +++ b/lib/exact_target_sdk/open_event.rb @@ -0,0 +1,14 @@ +module ExactTargetSDK +class OpenEvent < APIObject + + # Date when a tracking event occurred. + property 'EventDate' + + # Contains identifier for a specific send. + property 'SendID' + + # Identification of a specific subscriber. + property 'SubscriberKey' + +end +end diff --git a/lib/exact_target_sdk/sent_event.rb b/lib/exact_target_sdk/sent_event.rb new file mode 100644 index 0000000..66d0afa --- /dev/null +++ b/lib/exact_target_sdk/sent_event.rb @@ -0,0 +1,14 @@ +module ExactTargetSDK +class SentEvent < APIObject + + # Date when a tracking event occurred. + property 'EventDate' + + # Contains identifier for a specific send. + property 'SendID' + + # Identification of a specific subscriber. + property 'SubscriberKey' + +end +end From a05872505c602fb2ab1be3316d73feb2ab59c7a6 Mon Sep 17 00:00:00 2001 From: Valentine Zavadsky Date: Wed, 20 Jun 2012 19:36:18 +0300 Subject: [PATCH 47/57] add one more abstraction level to implement Options class --- lib/exact_target_sdk/api_object.rb | 170 +---------------------------- lib/exact_target_sdk/base.rb | 0 2 files changed, 4 insertions(+), 166 deletions(-) create mode 100644 lib/exact_target_sdk/base.rb diff --git a/lib/exact_target_sdk/api_object.rb b/lib/exact_target_sdk/api_object.rb index ff91503..997eeb0 100644 --- a/lib/exact_target_sdk/api_object.rb +++ b/lib/exact_target_sdk/api_object.rb @@ -1,176 +1,14 @@ -require 'active_model' -require 'active_support/inflector' - module ExactTargetSDK # Parent class of all ExactTarget API objects (listed here: # http://docs.code.exacttarget.com/020_Web_Service_Guide/Objects). Provides # class-level declarations, validation, and rendering that makes modeling # each object easy. -class APIObject - - include ::ActiveModel::Validations - include ::ActiveModel::Validations::Callbacks - - class << self - - # Declares a property of this object, optionally requiring it upon - # validation. - # - # Provides a getter and setter for this property, keeping track of - # whether or not it has been set and registering it for rendering. - def property(name, options = {}) - options = { - :required => false - }.merge(options) - - name = name.to_s - attr_reader name.to_sym - class_eval <<-__EOF__ - def #{name}=(value) - @_set_#{name} = true - @#{name} = value - end - __EOF__ - if options[:required] - validates name.to_sym, :presence => true - end - register_property!(name, options) - end - - # Declares a property as an array of values. - # - # Provides a getter and setter for this property. The getter will - # always return an array (not null), so the client may simply append - # to this property. - # - # Note that once the property has been either read or written to, it - # will be rendered. - def array_property(name, options = {}) - # TODO: type validation would be nice - name = name.to_s - - options = { - :nest_children => false, - :singular => name.singularize - }.merge(options) - - class_eval <<-__EOF__ - def #{name} - @_set_#{name} = true - @#{name} ||= [] - end - def #{name}=(value) - @_set_#{name} = true - @#{name} = value - end - __EOF__ - register_property!(name, options) - end - - # Same as #property, adding validation the the provided value is an - # integer. - def int_property(name, options = {}) - options = { - :required => false - }.merge(options) - property(name, options) - validates name.to_sym, :numericality => { :allow_nil => true, :only_integer => true } - end - - # Returns an array of all registered properties of current class. - def properties - @properties || {} - end - - # Returns an array of all registered properties, including parent classes - def all_properties - properties = {} - self.ancestors.each do |klass| - properties.merge!(klass.properties) if klass.respond_to? :properties - end - properties - end - - def type_name - name.split('::').last - end - - private - - # Stores the given property name to be used at render time. - def register_property!(name, options = {}) - @properties ||= {} - @properties[name] = options - end + class APIObject < Base - end - - property "ID" - property 'ObjectID' - property 'CustomerKey' - - # By default, any properties may be passed and set. - # - # May be overridden. - def initialize(properties = {}) - properties.each do |key, value| - self.send "#{key}=", value - end - end - - # By default, returns the name of the class. - # - # May be overridden. - def type_name - self.class.type_name - end - - # By default, runs validation and executes #render_properties!. - # - # If overridden, the child class should check wehter or not the - # object is valid, and then render the object. In general, - # the render_properties! method should be overridden instead. - def render!(xml) - raise(InvalidAPIObject, self) if invalid? - render_properties!(xml) - end - - # By default, loops through all registered properties, and renders - # each that has been explicitly set. - # - # May be overridden. - def render_properties!(xml) - self.class.all_properties.each do |property, options| - next unless instance_variable_get("@_set_#{property}") - property_value = self.send(property) - render_property!(property, property_value, xml, options) - end - end + property "ID" + property 'ObjectID' + property 'CustomerKey' - def render_property_array!(property_name, array, xml) - array.each do |current| - render_property!(property_name, current, xml) - end end - - def render_property!(property_name, property_value, xml, options = {}) - if property_value.is_a?(APIObject) - xml.__send__(property_name, { "xsi:type" => property_value.type_name } ) do - property_value.render!(xml) - end - elsif property_value.is_a?(Array) - if options[:nest_children] - xml.__send__(property_name) do - render_property_array!(options[:singular], property_value, xml) - end - else - render_property_array!(property_name, property_value, xml) - end - else - xml.__send__(property_name, property_value.to_s) - end - end - -end end diff --git a/lib/exact_target_sdk/base.rb b/lib/exact_target_sdk/base.rb new file mode 100644 index 0000000..e69de29 From 8b82cb0ed5d6b82cd4e67de8561f2b6ca546127f Mon Sep 17 00:00:00 2001 From: Valentine Zavadsky Date: Wed, 20 Jun 2012 20:37:04 +0300 Subject: [PATCH 48/57] add all classes to implement options --- lib/exact_target_sdk.rb | 9 ++ lib/exact_target_sdk/async_response.rb | 24 +++ lib/exact_target_sdk/async_response_type.rb | 17 ++ lib/exact_target_sdk/base.rb | 169 ++++++++++++++++++++ lib/exact_target_sdk/options.rb | 33 ++++ lib/exact_target_sdk/priority.rb | 13 ++ lib/exact_target_sdk/request_type.rb | 10 ++ lib/exact_target_sdk/respond_when.rb | 23 +++ lib/exact_target_sdk/save_action.rb | 23 +++ lib/exact_target_sdk/save_option.rb | 12 ++ 10 files changed, 333 insertions(+) create mode 100644 lib/exact_target_sdk/async_response.rb create mode 100644 lib/exact_target_sdk/async_response_type.rb create mode 100644 lib/exact_target_sdk/options.rb create mode 100644 lib/exact_target_sdk/priority.rb create mode 100644 lib/exact_target_sdk/request_type.rb create mode 100644 lib/exact_target_sdk/respond_when.rb create mode 100644 lib/exact_target_sdk/save_action.rb create mode 100644 lib/exact_target_sdk/save_option.rb diff --git a/lib/exact_target_sdk.rb b/lib/exact_target_sdk.rb index 8e8e61f..0fa374a 100644 --- a/lib/exact_target_sdk.rb +++ b/lib/exact_target_sdk.rb @@ -4,8 +4,11 @@ module ExactTargetSDK autoload :APIObject, 'exact_target_sdk/api_object' + autoload :AsyncResponse, 'exact_target_sdk/async_response' + autoload :AsyncResponseType, 'exact_target_sdk/async_response_type' autoload :APIProperty, 'exact_target_sdk/api_property' autoload :Attribute, 'exact_target_sdk/attribute' + autoload :Base, 'exact_target_sdk/base' autoload :BounceEvent, 'exact_target_sdk/bounce_event' autoload :Client, 'exact_target_sdk/client' autoload :ClickEvent, 'exact_target_sdk/click_event' @@ -32,12 +35,18 @@ module ExactTargetSDK autoload :List, 'exact_target_sdk/list' autoload :LogicalOperators, 'exact_target_sdk/logical_operators' autoload :OpenEvent, 'exact_target_sdk/open_event' + autoload :Options, 'exact_target_sdk/options' + autoload :Priority, 'exact_target_sdk/priority' autoload :RecurrenceRangeTypeEnum, 'exact_target_sdk/recurrence_range_type_enum' autoload :RecurrenceTypeEnum, 'exact_target_sdk/recurrence_type_enum' autoload :Result, 'exact_target_sdk/result' + autoload :RespondWhen, 'exact_target_sdk/respond_when' autoload :RetrieveResponse, 'exact_target_sdk/retrieve_response' autoload :RetrieveResult, 'exact_target_sdk/retrieve_result' + autoload :RequestType, 'exact_target_sdk/request_type' autoload :SalutationSourceEnum, 'exact_target_sdk/salutation_source_enum' + autoload :SaveAction, 'exact_target_sdk/save_action' + autoload :SaveOption, 'exact_target_sdk/save_option' autoload :SimpleFilterPart, 'exact_target_sdk/simple_filter_part' autoload :Send, 'exact_target_sdk/send' autoload :ScheduleDefinition, 'exact_target_sdk/schedule_definition' diff --git a/lib/exact_target_sdk/async_response.rb b/lib/exact_target_sdk/async_response.rb new file mode 100644 index 0000000..eed93bd --- /dev/null +++ b/lib/exact_target_sdk/async_response.rb @@ -0,0 +1,24 @@ +# http://docs.code.exacttarget.com/020_Web_Service_Guide/Objects/AsyncResponse +module ExactTargetSDK +class AsyncResponse < Base + + # Indicates whether the APIObject should be included in the response. + property 'IncludeObjects' + + # Determines whether the Result objects will be included in the response when an asynchronous API call completes processing. + property 'IncludeResults' + + # Reduce object to base APIObject information. Includes basic reference data associating object and request. + property 'OnlyIncludeBase' + + # Specifies event triggers the AsyncResponse object action. + property 'RespondWhen' + + # Email address or public URL to receive POST response to asynchronous request. + property 'ResponseAddress' + + # Specifies type of response associated with an asynchronous operation. + property 'ResponseType' + +end +end diff --git a/lib/exact_target_sdk/async_response_type.rb b/lib/exact_target_sdk/async_response_type.rb new file mode 100644 index 0000000..3a36904 --- /dev/null +++ b/lib/exact_target_sdk/async_response_type.rb @@ -0,0 +1,17 @@ +# http://docs.code.exacttarget.com/020_Web_Service_Guide/Objects/AsyncResponseType +module ExactTargetSDK +module AsyncResponseType + # Default email address for object. Indicates if subscriber information can be used for email sends. + EMAIL = "email" + + # Reserved for future use. + FTP = "FTP" + + # Indicates the response will be sent using the Post method of the HTTP protocol to the URL specified in the call when the asynchronous API call completes processing. + + HTTP_POST = "HTTPPost" + + #Default response type for AsyncResponseType. + NONE = "None" +end +end diff --git a/lib/exact_target_sdk/base.rb b/lib/exact_target_sdk/base.rb index e69de29..80ee72a 100644 --- a/lib/exact_target_sdk/base.rb +++ b/lib/exact_target_sdk/base.rb @@ -0,0 +1,169 @@ +require 'active_model' +require 'active_support/inflector' + +module ExactTargetSDK + + class Base + include ::ActiveModel::Validations + include ::ActiveModel::Validations::Callbacks + + class << self + + # Declares a property of this object, optionally requiring it upon + # validation. + # + # Provides a getter and setter for this property, keeping track of + # whether or not it has been set and registering it for rendering. + def property(name, options = {}) + options = { + :required => false + }.merge(options) + + name = name.to_s + attr_reader name.to_sym + class_eval <<-__EOF__ + def #{name}=(value) + @_set_#{name} = true + @#{name} = value + end + __EOF__ + if options[:required] + validates name.to_sym, :presence => true + end + register_property!(name, options) + end + + # Declares a property as an array of values. + # + # Provides a getter and setter for this property. The getter will + # always return an array (not null), so the client may simply append + # to this property. + # + # Note that once the property has been either read or written to, it + # will be rendered. + def array_property(name, options = {}) + # TODO: type validation would be nice + name = name.to_s + + options = { + :nest_children => false, + :singular => name.singularize + }.merge(options) + + class_eval <<-__EOF__ + def #{name} + @_set_#{name} = true + @#{name} ||= [] + end + def #{name}=(value) + @_set_#{name} = true + @#{name} = value + end + __EOF__ + register_property!(name, options) + end + + # Same as #property, adding validation the the provided value is an + # integer. + def int_property(name, options = {}) + options = { + :required => false + }.merge(options) + property(name, options) + validates name.to_sym, :numericality => {:allow_nil => true, :only_integer => true} + end + + # Returns an array of all registered properties of current class. + def properties + @properties || {} + end + + # Returns an array of all registered properties, including parent classes + def all_properties + properties = {} + self.ancestors.each do |klass| + properties.merge!(klass.properties) if klass.respond_to? :properties + end + properties + end + + def type_name + name.split('::').last + end + + private + + # Stores the given property name to be used at render time. + def register_property!(name, options = {}) + @properties ||= {} + @properties[name] = options + end + + end + + # By default, any properties may be passed and set. + # + # May be overridden. + def initialize(properties = {}) + properties.each do |key, value| + self.send "#{key}=", value + end + end + + # By default, returns the name of the class. + # + # May be overridden. + def type_name + self.class.type_name + end + + # By default, runs validation and executes #render_properties!. + # + # If overridden, the child class should check wehter or not the + # object is valid, and then render the object. In general, + # the render_properties! method should be overridden instead. + def render!(xml) + raise(InvalidAPIObject, self) if invalid? + render_properties!(xml) + end + + # By default, loops through all registered properties, and renders + # each that has been explicitly set. + # + # May be overridden. + def render_properties!(xml) + self.class.all_properties.each do |property, options| + next unless instance_variable_get("@_set_#{property}") + property_value = self.send(property) + render_property!(property, property_value, xml, options) + end + end + + def render_property_array!(property_name, array, xml) + array.each do |current| + render_property!(property_name, current, xml) + end + end + + def render_property!(property_name, property_value, xml, options = {}) + if property_value.is_a?(APIObject) + xml.__send__(property_name, {"xsi:type" => property_value.type_name}) do + property_value.render!(xml) + end + elsif property_value.is_a?(Array) + if options[:nest_children] + xml.__send__(property_name) do + render_property_array!(options[:singular], property_value, xml) + end + else + render_property_array!(property_name, property_value, xml) + end + else + xml.__send__(property_name, property_value.to_s) + end + end + + + end + +end \ No newline at end of file diff --git a/lib/exact_target_sdk/options.rb b/lib/exact_target_sdk/options.rb new file mode 100644 index 0000000..0ba626f --- /dev/null +++ b/lib/exact_target_sdk/options.rb @@ -0,0 +1,33 @@ +# http://docs.code.exacttarget.com/020_Web_Service_Guide/Objects/Options +module ExactTargetSDK +class Options < Base + + # Represents the number of calls that must be received before the conversation support in the asynchronous API will begin processing. + int_property "CallsInConversation" + + # Specifies the account ownership and context of an object. + property "Client" + + # Unique ID of initial async API call; All requests that should be processed as a single unit will have the same ConversationID. + property "ConversationID" + + # Defines the priority for a triggered send. Valid values include Low, Medium, and High. + property "Priority" + + # Defines request as synchronous or asynchronous API. + property "RequestType" + + # Keeps requests in asynchronous queue until time specified in the call. + property "ScheduledTime" + + # Specifies the processing sequence of a multi-step conversation. This optional property requires the use of ConversationID. + property "SequenceCode" + + # Allows upsert on selected objects. + array_property "SaveOptions" + + # Defines how responses are returned and under what conditions. Optional. + array_property "SendResponseTo" + +end +end diff --git a/lib/exact_target_sdk/priority.rb b/lib/exact_target_sdk/priority.rb new file mode 100644 index 0000000..a98bf22 --- /dev/null +++ b/lib/exact_target_sdk/priority.rb @@ -0,0 +1,13 @@ +# http://docs.code.exacttarget.com/020_Web_Service_Guide/Objects/Priority +module ExactTargetSDK +module Priority + # Specifies high priority for API process. + HIGH = "High" + + # Specifies medium priority on API processes. + MEDIUM = "Medium" + + # Specifies low priority for API process. + LOW = "Low" +end +end diff --git a/lib/exact_target_sdk/request_type.rb b/lib/exact_target_sdk/request_type.rb new file mode 100644 index 0000000..1e271b7 --- /dev/null +++ b/lib/exact_target_sdk/request_type.rb @@ -0,0 +1,10 @@ +# http://docs.code.exacttarget.com/020_Web_Service_Guide/Objects/RequestType +module ExactTargetSDK +module RequestType + # Specifies that the API request should be processed asynchronously. + ASYNCHRONOUS = "Asynchronous" + + # Specifies that the process should be processed synchronously. + SYNCHRONOUS = "Synchronous" +end +end diff --git a/lib/exact_target_sdk/respond_when.rb b/lib/exact_target_sdk/respond_when.rb new file mode 100644 index 0000000..80e6d1a --- /dev/null +++ b/lib/exact_target_sdk/respond_when.rb @@ -0,0 +1,23 @@ +# http://docs.code.exacttarget.com/020_Web_Service_Guide/Objects/RespondWhen +module ExactTargetSDK +module RespondWhen + # Always send the response. + ALWAYS = "Always" + + # Specifies that a response should never be set for an asynchronous process. + NEVER = "Never" + + # Specifies that a response should be sent when an asynchronous call is complete. + ON_CALL_COMPLETE = "OnCallComplete" + + # Specifies that a response should be sent when an asynchronous conversation is complete. + ON_CONVERSATION_COMPLETE = "OnConversationComplete" + + # Specifies that a response should be sent when an asynchronous conversation returns an error. + ON_CONVERSATION_ERROR = "OnConversationError" + + # Specifies that a response should be send when an asynchronous process returns an error. + ON_ERROR = "OnError" +end +end + diff --git a/lib/exact_target_sdk/save_action.rb b/lib/exact_target_sdk/save_action.rb new file mode 100644 index 0000000..fd32384 --- /dev/null +++ b/lib/exact_target_sdk/save_action.rb @@ -0,0 +1,23 @@ +# http://docs.code.exacttarget.com/020_Web_Service_Guide/Objects/SaveAction +module ExactTargetSDK +module SaveAction + # Indicates that data should only be added and not updated during a save action. + ADD_ONLY = "AddOnly" + + #Specifies default source of salutation when building an email (SalutationSourceEnum) Use the default action when saving an object. (SaveAction) + DEFAULT = "Default" + + #Indicates whether an object should be deleted. + DELETE = "Delete" + + #Indicates no save action should take place. + NOTHING = "Nothing" + + #Indicates an UpdateAdd type for a save action. If this property is specified, the save action will update existing information and add new information. + UPDATE_ADD = "UpdateAdd" + + #Indicates an UpdateOnly type for a save action. If this property is specified, the save action with update existing information only. + UPDATE_ONLY = "UpdateOnly" + +end +end diff --git a/lib/exact_target_sdk/save_option.rb b/lib/exact_target_sdk/save_option.rb new file mode 100644 index 0000000..c633b47 --- /dev/null +++ b/lib/exact_target_sdk/save_option.rb @@ -0,0 +1,12 @@ +# http://docs.code.exacttarget.com/020_Web_Service_Guide/Objects/SaveOption +module ExactTargetSDK +class SaveOption < Base + + # String object to which the SaveOption object applies. + property "PropertyName" + + # Behavior specified for SaveAction object. + property "SaveAction" + +end +end From 7c71b9035df8aae273aa0f193c19e7ca00bba383 Mon Sep 17 00:00:00 2001 From: Valentine Zavadsky Date: Thu, 21 Jun 2012 21:11:07 +0300 Subject: [PATCH 49/57] result_message added --- lib/exact_target_sdk.rb | 1 + lib/exact_target_sdk/result_message.rb | 63 ++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 lib/exact_target_sdk/result_message.rb diff --git a/lib/exact_target_sdk.rb b/lib/exact_target_sdk.rb index 0fa374a..7c93af4 100644 --- a/lib/exact_target_sdk.rb +++ b/lib/exact_target_sdk.rb @@ -40,6 +40,7 @@ module ExactTargetSDK autoload :RecurrenceRangeTypeEnum, 'exact_target_sdk/recurrence_range_type_enum' autoload :RecurrenceTypeEnum, 'exact_target_sdk/recurrence_type_enum' autoload :Result, 'exact_target_sdk/result' + autoload :ResultMessage, 'exact_target_sdk/result_message' autoload :RespondWhen, 'exact_target_sdk/respond_when' autoload :RetrieveResponse, 'exact_target_sdk/retrieve_response' autoload :RetrieveResult, 'exact_target_sdk/retrieve_result' diff --git a/lib/exact_target_sdk/result_message.rb b/lib/exact_target_sdk/result_message.rb new file mode 100644 index 0000000..620341a --- /dev/null +++ b/lib/exact_target_sdk/result_message.rb @@ -0,0 +1,63 @@ +# http://docs.code.exacttarget.com/020_Web_Service_Guide/Objects/ResultMessage +module ExactTargetSDK +class ResultMessage < APIObject + + # Number of calls within an async API conversation. + property 'CallsInConversation' + + # Specifies the account ownership and context of an object. + property 'Client' + + # Unique ID of initial async API call. + property 'ConversationID' + + # Identifies correlation of objects across several requests. + property 'CorrelationID' + + # Read-only date and time of the objects creation. + property 'CreatedDate' + + # Identifies the error of an API request. + property 'ErrorCode' + + # Last time object information was modified. + property 'ModifiedDate' + + # Reserved for future use. + property 'ObjectState' + + # Represents overall status of conversation via async API. + property 'OverallStatusCode' + + # Describes account ownership of subscriber in an on-your-behalf account. + property 'Owner' + + # Unique identifier provided by partner for an object, accessible only via API. + property 'PartnerKey' + + # A collection of metadata supplied by client and stored by system - only accessible via API. + array_property 'PartnerProperties' + + # Unique ID of initial async API call. + property 'RequestID' + + # Defines request as synchronous or asynchronous API. + property 'RequestType' + + # Contains details of operation result in XML format. + property 'ResultDetailXML' + + # Defines result as coming from synchronous or asynchronous API. + property 'ResultType' + + # Specifies the processing sequence of a multi-step conversation. + property 'SequenceCode' + + # Status of async API request. + property 'StatusCode' + + # Describes the status of an API call. + property 'StatusMessage' + +end +end From a92b20fd418a251ca010fd0f1cca7998a07f64fd Mon Sep 17 00:00:00 2001 From: Valentine Zavadsky Date: Thu, 21 Jun 2012 22:38:07 +0300 Subject: [PATCH 50/57] implement options feature for requests --- lib/exact_target_sdk.rb | 6 ++ lib/exact_target_sdk/client.rb | 83 ++++++++++++++++++------ lib/exact_target_sdk/create_options.rb | 6 ++ lib/exact_target_sdk/delete_options.rb | 6 ++ lib/exact_target_sdk/perform_options.rb | 6 ++ lib/exact_target_sdk/retrieve_options.rb | 15 +++++ lib/exact_target_sdk/schedule_options.rb | 8 +++ lib/exact_target_sdk/update_options.rb | 7 ++ 8 files changed, 117 insertions(+), 20 deletions(-) create mode 100644 lib/exact_target_sdk/create_options.rb create mode 100644 lib/exact_target_sdk/delete_options.rb create mode 100644 lib/exact_target_sdk/perform_options.rb create mode 100644 lib/exact_target_sdk/retrieve_options.rb create mode 100644 lib/exact_target_sdk/schedule_options.rb create mode 100644 lib/exact_target_sdk/update_options.rb diff --git a/lib/exact_target_sdk.rb b/lib/exact_target_sdk.rb index 7c93af4..fbd5c48 100644 --- a/lib/exact_target_sdk.rb +++ b/lib/exact_target_sdk.rb @@ -15,6 +15,7 @@ module ExactTargetSDK autoload :ComplexFilterPart, 'exact_target_sdk/complex_filter_part' autoload :ContentArea, 'exact_target_sdk/content_area' autoload :ContentValidation, 'exact_target_sdk/content_validation' + autoload :CreateOptions, 'exact_target_sdk/create_options' autoload :CreateResponse, 'exact_target_sdk/create_response' autoload :CreateResult, 'exact_target_sdk/create_result' autoload :DailyRecurrence, 'exact_target_sdk/daily_recurrence' @@ -23,6 +24,7 @@ module ExactTargetSDK autoload :DataExtensionField, 'exact_target_sdk/data_extension_field' autoload :DataExtensionFieldType, 'exact_target_sdk/data_extension_field_type' autoload :DataExtensionObject, 'exact_target_sdk/data_extension_object' + autoload :DeleteOptions, 'exact_target_sdk/delete_options' autoload :DeleteResponse, 'exact_target_sdk/delete_response' autoload :DeleteResult, 'exact_target_sdk/delete_result' autoload :DeliveryProfile, 'exact_target_sdk/delivery_profile' @@ -37,12 +39,14 @@ module ExactTargetSDK autoload :OpenEvent, 'exact_target_sdk/open_event' autoload :Options, 'exact_target_sdk/options' autoload :Priority, 'exact_target_sdk/priority' + autoload :PerformOptions, 'exact_target_sdk/perform_options' autoload :RecurrenceRangeTypeEnum, 'exact_target_sdk/recurrence_range_type_enum' autoload :RecurrenceTypeEnum, 'exact_target_sdk/recurrence_type_enum' autoload :Result, 'exact_target_sdk/result' autoload :ResultMessage, 'exact_target_sdk/result_message' autoload :RespondWhen, 'exact_target_sdk/respond_when' autoload :RetrieveResponse, 'exact_target_sdk/retrieve_response' + autoload :RetrieveOptions, 'exact_target_sdk/retrieve_options' autoload :RetrieveResult, 'exact_target_sdk/retrieve_result' autoload :RequestType, 'exact_target_sdk/request_type' autoload :SalutationSourceEnum, 'exact_target_sdk/salutation_source_enum' @@ -51,6 +55,7 @@ module ExactTargetSDK autoload :SimpleFilterPart, 'exact_target_sdk/simple_filter_part' autoload :Send, 'exact_target_sdk/send' autoload :ScheduleDefinition, 'exact_target_sdk/schedule_definition' + autoload :ScheduleOptions, 'exact_target_sdk/schedule_options' autoload :ScheduleResponse, 'exact_target_sdk/schedule_response' autoload :ScheduleResult, 'exact_target_sdk/schedule_result' autoload :SendClassification, 'exact_target_sdk/send_classification' @@ -65,6 +70,7 @@ module ExactTargetSDK autoload :TriggeredSend, 'exact_target_sdk/triggered_send' autoload :TriggeredSendDefinition, 'exact_target_sdk/triggered_send_definition' autoload :ValidationAction, 'exact_target_sdk/validation_action' + autoload :UpdateOptions, 'exact_target_sdk/update_options' autoload :UpdateResponse, 'exact_target_sdk/update_response' autoload :UpdateResult, 'exact_target_sdk/update_result' diff --git a/lib/exact_target_sdk/client.rb b/lib/exact_target_sdk/client.rb index e37157d..7cbc253 100644 --- a/lib/exact_target_sdk/client.rb +++ b/lib/exact_target_sdk/client.rb @@ -47,17 +47,23 @@ def initialize(options = {}) def Create(*args) # TODO: implement and accept CreateOptions - api_objects = args + api_objects, options = filter_options(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 + + options.each do |option| + xml.Options do + option.render!(xml) + end + end + end end @@ -80,12 +86,14 @@ def Create(*args) # InvalidAPIObject if any of the provided objects don't pass validation # # Returns a RetrieveResponse object. - def Retrieve(object_type_name, filter, *properties) + def Retrieve(object_type_name, filter, *args) object_type_name = object_type_name.type_name if object_type_name.respond_to?(:type_name) + + properties, options = filter_options(args) + response = execute_request 'Retrieve' do |xml| xml.RetrieveRequestMsg do xml.RetrieveRequest do - xml.Options xml.ObjectType object_type_name @@ -96,6 +104,13 @@ def Retrieve(object_type_name, filter, *properties) xml.Filter "xsi:type" => filter.type_name do filter.render!(xml) end + + options.each do |option| + xml.Options do + option.render!(xml) + end + end + end end end @@ -116,19 +131,24 @@ def Retrieve(object_type_name, filter, *properties) # # Returns an UpdateResponse object. def Update(*args) - # TODO: implement and accept UpdateOptions - api_objects = args + api_objects, options = filter_options(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 + + options.each do |option| + xml.Options do + option.render!(xml) + end + end + end end @@ -148,19 +168,23 @@ def Update(*args) # # Returns a DeleteResponse object. def Delete(*args) - # TODO: implement and accept DeleteOptions - api_objects = args + api_objects, options = filter_options(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 + + options.each do |option| + xml.Options do + option.render!(xml) + end + end + end end @@ -180,9 +204,7 @@ def Delete(*args) # # Returns a PerformResponse object. def Perform(action, *args) - # TODO: implement and accept PerformOptions - - definitions = args + definitions, options = filter_options(args) response = execute_request 'Perform' do |xml| xml.PerformRequestMsg do @@ -194,9 +216,13 @@ def Perform(action, *args) definition.render!(xml) end end - end + end - xml.Options # TODO: support PerformOptions + options.each do |option| + xml.Options do + option.render!(xml) + end + end end end @@ -217,9 +243,8 @@ def Perform(action, *args) # # Returns a ScheduleResponse object. def Schedule(action, schedule, *args) - # TODO: implement and accept ScheduleOptions - interactions = args + interactions, options = filter_options(args) response = execute_request 'Schedule' do |xml| xml.ScheduleRequestMsg do @@ -237,7 +262,12 @@ def Schedule(action, schedule, *args) end end - xml.Options # TODO: support ScheduleOptions + options.each do |option| + xml.Options do + option.render!(xml) + end + end + end end @@ -252,7 +282,7 @@ def logger private attr_accessor :config, :client - + # Constructs and saves the savon client using provided config. def initialize_client! self.client = ::Savon::Client.new do |wsdl, http| @@ -318,6 +348,19 @@ def execute_request(method) raise timeout end + def filter_options(args) + options = find_options(args) + options.each{|opt| args.delete(opt)} + [args,options] + end + + + def find_options(args) + options = [] + args.each { |arg| options << arg if arg.is_a? Options } + options + end + end end diff --git a/lib/exact_target_sdk/create_options.rb b/lib/exact_target_sdk/create_options.rb new file mode 100644 index 0000000..528959b --- /dev/null +++ b/lib/exact_target_sdk/create_options.rb @@ -0,0 +1,6 @@ +# http://docs.code.exacttarget.com/020_Web_Service_Guide/Objects/CreateOptions +module ExactTargetSDK +class CreateOptions < Options + +end +end diff --git a/lib/exact_target_sdk/delete_options.rb b/lib/exact_target_sdk/delete_options.rb new file mode 100644 index 0000000..84abc05 --- /dev/null +++ b/lib/exact_target_sdk/delete_options.rb @@ -0,0 +1,6 @@ +# http://docs.code.exacttarget.com/020_Web_Service_Guide/Objects/DeleteOptions +module ExactTargetSDK +class DeleteOptions < Options + +end +end diff --git a/lib/exact_target_sdk/perform_options.rb b/lib/exact_target_sdk/perform_options.rb new file mode 100644 index 0000000..6daae3e --- /dev/null +++ b/lib/exact_target_sdk/perform_options.rb @@ -0,0 +1,6 @@ +# http://docs.code.exacttarget.com/020_Web_Service_Guide/Objects/PerformOptions +module ExactTargetSDK +class PerformOptions < Options + +end +end diff --git a/lib/exact_target_sdk/retrieve_options.rb b/lib/exact_target_sdk/retrieve_options.rb new file mode 100644 index 0000000..ec9d715 --- /dev/null +++ b/lib/exact_target_sdk/retrieve_options.rb @@ -0,0 +1,15 @@ +# http://docs.code.exacttarget.com/020_Web_Service_Guide/Objects/RetrieveOptions +module ExactTargetSDK +class RetrieveOptions < Options + + # Number of records to return in each batch as part of a Retrieve call. Reserved for future use. + property 'BatchSize' + + # Indicates whether the APIObject should be included in the response. + property 'IncludeObjects' + + # Reduce object to base APIObject information. Includes basic reference data associating object and request. + property 'OnlyIncludeBase' + +end +end diff --git a/lib/exact_target_sdk/schedule_options.rb b/lib/exact_target_sdk/schedule_options.rb new file mode 100644 index 0000000..8c31cb7 --- /dev/null +++ b/lib/exact_target_sdk/schedule_options.rb @@ -0,0 +1,8 @@ +# http://docs.code.exacttarget.com/020_Web_Service_Guide/Objects/ScheduleOptions +module ExactTargetSDK +class ScheduleOptions < Options + +end +end + + diff --git a/lib/exact_target_sdk/update_options.rb b/lib/exact_target_sdk/update_options.rb new file mode 100644 index 0000000..6856777 --- /dev/null +++ b/lib/exact_target_sdk/update_options.rb @@ -0,0 +1,7 @@ +# http://docs.code.exacttarget.com/020_Web_Service_Guide/Objects/UpdateOptions +module ExactTargetSDK +class UpdateOptions < Options + #Defines the action to take for the specified object. + property 'Action' +end +end From 75760379de12a4e7dab0d299433e1e34afa28d88 Mon Sep 17 00:00:00 2001 From: Valentine Zavadsky Date: Thu, 21 Jun 2012 22:38:52 +0300 Subject: [PATCH 51/57] nested_children for subsctibers in content_validation --- lib/exact_target_sdk/content_validation.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/exact_target_sdk/content_validation.rb b/lib/exact_target_sdk/content_validation.rb index 88cbb1d..5ec7e38 100644 --- a/lib/exact_target_sdk/content_validation.rb +++ b/lib/exact_target_sdk/content_validation.rb @@ -8,7 +8,7 @@ class ContentValidation < APIObject property 'ValidationAction' # Indicates subscribers associated with an object. - array_property 'Subscribers' + array_property 'Subscribers', :nest_children => true end end From 80e079e77208e94a270a5fb6f223484280935f88 Mon Sep 17 00:00:00 2001 From: Valentine Zavadsky Date: Mon, 9 Jul 2012 15:55:54 +0300 Subject: [PATCH 52/57] update rspec --- Gemfile.lock | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index c403e32..4a5bb9f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -22,14 +22,14 @@ GEM nori (1.0.2) rack (1.4.1) rake (0.9.2.2) - rspec (2.8.0) - rspec-core (~> 2.8.0) - rspec-expectations (~> 2.8.0) - rspec-mocks (~> 2.8.0) - rspec-core (2.8.0) - rspec-expectations (2.8.0) - diff-lcs (~> 1.1.2) - rspec-mocks (2.8.0) + rspec (2.11.0) + rspec-core (~> 2.11.0) + rspec-expectations (~> 2.11.0) + rspec-mocks (~> 2.11.0) + rspec-core (2.11.0) + rspec-expectations (2.11.1) + diff-lcs (~> 1.1.3) + rspec-mocks (2.11.0) savon (0.9.7) akami (~> 1.0) builder (>= 2.1.2) From 4e0acabb432ff6950549c491a5feb3ebbc92cb59 Mon Sep 17 00:00:00 2001 From: Valentine Zavadsky Date: Mon, 9 Jul 2012 15:57:09 +0300 Subject: [PATCH 53/57] skip validation if object is existing object with some id given --- lib/exact_target_sdk/api_object.rb | 2 +- lib/exact_target_sdk/base.rb | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/exact_target_sdk/api_object.rb b/lib/exact_target_sdk/api_object.rb index 997eeb0..ebff4c8 100644 --- a/lib/exact_target_sdk/api_object.rb +++ b/lib/exact_target_sdk/api_object.rb @@ -6,7 +6,7 @@ module ExactTargetSDK # each object easy. class APIObject < Base - property "ID" + property 'ID' property 'ObjectID' property 'CustomerKey' diff --git a/lib/exact_target_sdk/base.rb b/lib/exact_target_sdk/base.rb index 80ee72a..4d69537 100644 --- a/lib/exact_target_sdk/base.rb +++ b/lib/exact_target_sdk/base.rb @@ -4,6 +4,10 @@ module ExactTargetSDK class Base + # Properties that can be used as object id to perform update, delete, + # perform and schedule actions + ID_PROPERTIES = %w(ID ObjectID CustomerKey) + include ::ActiveModel::Validations include ::ActiveModel::Validations::Callbacks @@ -28,7 +32,7 @@ def #{name}=(value) end __EOF__ if options[:required] - validates name.to_sym, :presence => true + validates name.to_sym, :presence => true, :if => :new_record? end register_property!(name, options) end @@ -70,7 +74,7 @@ def int_property(name, options = {}) :required => false }.merge(options) property(name, options) - validates name.to_sym, :numericality => {:allow_nil => true, :only_integer => true} + validates name.to_sym, :numericality => {:allow_nil => true, :only_integer => true}, :if => :new_record? end # Returns an array of all registered properties of current class. @@ -163,6 +167,10 @@ def render_property!(property_name, property_value, xml, options = {}) end end + def new_record? + ID_PROPERTIES.each {|property| return false if instance_variable_get("@_set_#{property}")} + true + end end From 9a1b492d5f497472f6690a815d4e01d537aa50af Mon Sep 17 00:00:00 2001 From: Valentine Zavadsky Date: Mon, 9 Jul 2012 16:05:12 +0300 Subject: [PATCH 54/57] put some validations back and fix all the tests + add some color to rspec --- lib/exact_target_sdk/delivery_profile.rb | 3 ++- lib/exact_target_sdk/email.rb | 4 ++-- lib/exact_target_sdk/email_send_definition.rb | 2 +- lib/exact_target_sdk/send_classification.rb | 9 ++++--- spec/email_spec.rb | 24 +++++++++++++++++++ spec/spec_helper.rb | 9 +++++++ 6 files changed, 44 insertions(+), 7 deletions(-) diff --git a/lib/exact_target_sdk/delivery_profile.rb b/lib/exact_target_sdk/delivery_profile.rb index 0c36055..dce0f47 100644 --- a/lib/exact_target_sdk/delivery_profile.rb +++ b/lib/exact_target_sdk/delivery_profile.rb @@ -1,7 +1,8 @@ module ExactTargetSDK class DeliveryProfile < APIObject - property 'Name' + property 'Name', :required => true + property 'SourceAddressType' # Defines source of a footer salutation to use as part of a delivery profile or send definition (Default, Content Library, or None) diff --git a/lib/exact_target_sdk/email.rb b/lib/exact_target_sdk/email.rb index 315f528..7353333 100644 --- a/lib/exact_target_sdk/email.rb +++ b/lib/exact_target_sdk/email.rb @@ -3,10 +3,10 @@ module ExactTargetSDK class Email < APIObject # Name of the object or property. - property 'Name' + property 'Name', :required => true # Contains subject area information for a message. - property 'Subject' + property 'Subject', :required => true # Contains HTML body of an email message. property 'HTMLBody' diff --git a/lib/exact_target_sdk/email_send_definition.rb b/lib/exact_target_sdk/email_send_definition.rb index 5672e20..decccc4 100644 --- a/lib/exact_target_sdk/email_send_definition.rb +++ b/lib/exact_target_sdk/email_send_definition.rb @@ -1,7 +1,7 @@ module ExactTargetSDK class EmailSendDefinition < APIObject - property 'Name' + property 'Name', :required => true # Indicates the send classification to use as part of a send definition. property 'SendClassification' diff --git a/lib/exact_target_sdk/send_classification.rb b/lib/exact_target_sdk/send_classification.rb index b4f68cc..5b50dfb 100644 --- a/lib/exact_target_sdk/send_classification.rb +++ b/lib/exact_target_sdk/send_classification.rb @@ -1,8 +1,11 @@ module ExactTargetSDK class SendClassification < APIObject - property 'Name' - property 'SenderProfile' - property 'DeliveryProfile' + property 'Name', :required => true + + property 'SenderProfile', :required => true + + property 'DeliveryProfile', :required => true + end end diff --git a/spec/email_spec.rb b/spec/email_spec.rb index 7b23c47..6154880 100644 --- a/spec/email_spec.rb +++ b/spec/email_spec.rb @@ -20,4 +20,28 @@ end + context ' an invalid Email with Name and Subject set' do + before(:each) do + @email = Email.new 'Subject' => 'Welcome to the Dark Side' + @email.valid? + end + + subject { @email } + + it {should_not be_valid} + + end + + context 'a Email object with given ID' do + before(:each) do + @email = Email.new 'ID' => '587' + @email.valid? + end + + subject { @email } + + it {should be_valid} + + end + end \ No newline at end of file diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 6c77f7c..5790e55 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -6,3 +6,12 @@ # clear environment variables to have clean environment ENV['EXACT_TARGET_SDK_USERNAME'] = nil ENV['EXACT_TARGET_SDK_PASSWORD'] = nil + + +RSpec.configure do |config| + # Use color in STDOUT + config.color_enabled = true + + # Use color not only in STDOUT but also in pagers and files + config.tty = true +end \ No newline at end of file From 73b44fd0a224a3b6f67ad69581b2777544f707be Mon Sep 17 00:00:00 2001 From: Valentine Zavadsky Date: Mon, 9 Jul 2012 17:00:18 +0300 Subject: [PATCH 55/57] update all gems --- Gemfile | 2 +- Gemfile.lock | 34 ++++++++++++++++++---------------- exact_target_sdk.gemspec | 2 +- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/Gemfile b/Gemfile index 10bc8a3..aa02545 100644 --- a/Gemfile +++ b/Gemfile @@ -3,7 +3,7 @@ source 'http://rubygems.org' gem 'activemodel', '~> 3.0' gem 'activesupport', '~> 3.0' gem 'guid', '~> 0.1' -gem 'savon', '<= 0.9.9' +gem 'savon', '~> 0.9' group :rake do gem 'simple_gem', :require => 'tasks/simple_gem' diff --git a/Gemfile.lock b/Gemfile.lock index 4a5bb9f..4524f69 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,25 +1,26 @@ GEM remote: http://rubygems.org/ specs: - activemodel (3.2.1) - activesupport (= 3.2.1) + activemodel (3.2.6) + activesupport (= 3.2.6) builder (~> 3.0.0) - activesupport (3.2.1) + activesupport (3.2.6) i18n (~> 0.6) multi_json (~> 1.0) - akami (1.0.0) + akami (1.2.0) gyoku (>= 0.4.0) + nokogiri (>= 1.4.0) builder (3.0.0) diff-lcs (1.1.3) guid (0.1.1) - gyoku (0.4.4) + gyoku (0.4.6) builder (>= 2.1.2) - httpi (0.9.5) + httpi (1.1.1) rack i18n (0.6.0) - multi_json (1.0.4) - nokogiri (1.5.0) - nori (1.0.2) + multi_json (1.3.6) + nokogiri (1.5.5) + nori (1.1.2) rack (1.4.1) rake (0.9.2.2) rspec (2.11.0) @@ -30,19 +31,20 @@ GEM rspec-expectations (2.11.1) diff-lcs (~> 1.1.3) rspec-mocks (2.11.0) - savon (0.9.7) - akami (~> 1.0) + savon (0.9.14) + akami (~> 1.1) builder (>= 2.1.2) gyoku (>= 0.4.0) - httpi (~> 0.9) + httpi (~> 1.0) nokogiri (>= 1.4.0) - nori (~> 1.0) - wasabi (~> 2.0) + nori (~> 1.1) + wasabi (~> 2.2) simple_gem (0.0.2) activesupport (~> 3.0) rake (>= 0.8.7) rspec (~> 2.8) - wasabi (2.0.0) + wasabi (2.5.0) + httpi (~> 1.0) nokogiri (>= 1.4.0) PLATFORMS @@ -53,5 +55,5 @@ DEPENDENCIES activesupport (~> 3.0) guid (~> 0.1) rspec (~> 2.8) - savon (<= 0.9.9) + savon (~> 0.9) simple_gem diff --git a/exact_target_sdk.gemspec b/exact_target_sdk.gemspec index c0bba23..153f552 100644 --- a/exact_target_sdk.gemspec +++ b/exact_target_sdk.gemspec @@ -27,6 +27,6 @@ Gem::Specification.new do |s| s.add_dependency 'activemodel', '~> 3.0' s.add_dependency 'activesupport', '~> 3.0' s.add_dependency 'guid', '~> 0.1' - s.add_dependency 'savon', '<= 0.9.9' + s.add_dependency 'savon', '~> 0.9.9' end From e101854142b7e82e05b911d2bed851ec8db3c5ad Mon Sep 17 00:00:00 2001 From: Valentine Zavadsky Date: Mon, 9 Jul 2012 17:05:57 +0300 Subject: [PATCH 56/57] Merge branches 'master' and 'fix-broken-savon' From c725a6bd2b50496bcdf0597f397f81f08c9b0807 Mon Sep 17 00:00:00 2001 From: gregory horion Date: Mon, 11 Feb 2013 14:08:06 -0800 Subject: [PATCH 57/57] * update savon * patch exact_target --- Gemfile | 3 +-- Gemfile.lock | 30 +++++++++++++++--------------- exact_target_sdk.gemspec | 4 ++-- lib/exact_target_sdk/client.rb | 23 ++++++++++------------- 4 files changed, 28 insertions(+), 32 deletions(-) diff --git a/Gemfile b/Gemfile index aa02545..610eb4b 100644 --- a/Gemfile +++ b/Gemfile @@ -3,7 +3,7 @@ source 'http://rubygems.org' gem 'activemodel', '~> 3.0' gem 'activesupport', '~> 3.0' gem 'guid', '~> 0.1' -gem 'savon', '~> 0.9' +gem 'savon', '~> 2.1.0' group :rake do gem 'simple_gem', :require => 'tasks/simple_gem' @@ -12,4 +12,3 @@ end group :test do gem 'rspec', '~> 2.8' end - diff --git a/Gemfile.lock b/Gemfile.lock index 4524f69..754eb99 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -10,18 +10,18 @@ GEM akami (1.2.0) gyoku (>= 0.4.0) nokogiri (>= 1.4.0) - builder (3.0.0) + builder (3.0.4) diff-lcs (1.1.3) guid (0.1.1) - gyoku (0.4.6) + gyoku (1.0.0) builder (>= 2.1.2) - httpi (1.1.1) + httpi (2.0.2) rack i18n (0.6.0) multi_json (1.3.6) - nokogiri (1.5.5) - nori (1.1.2) - rack (1.4.1) + nokogiri (1.5.6) + nori (2.0.3) + rack (1.5.2) rake (0.9.2.2) rspec (2.11.0) rspec-core (~> 2.11.0) @@ -31,20 +31,20 @@ GEM rspec-expectations (2.11.1) diff-lcs (~> 1.1.3) rspec-mocks (2.11.0) - savon (0.9.14) - akami (~> 1.1) + savon (2.1.0) + akami (~> 1.2.0) builder (>= 2.1.2) - gyoku (>= 0.4.0) - httpi (~> 1.0) + gyoku (~> 1.0.0) + httpi (~> 2.0.2) nokogiri (>= 1.4.0) - nori (~> 1.1) - wasabi (~> 2.2) + nori (~> 2.0.3) + wasabi (~> 3.0.0) simple_gem (0.0.2) activesupport (~> 3.0) rake (>= 0.8.7) rspec (~> 2.8) - wasabi (2.5.0) - httpi (~> 1.0) + wasabi (3.0.0) + httpi (~> 2.0) nokogiri (>= 1.4.0) PLATFORMS @@ -55,5 +55,5 @@ DEPENDENCIES activesupport (~> 3.0) guid (~> 0.1) rspec (~> 2.8) - savon (~> 0.9) + savon (~> 2.1.0) simple_gem diff --git a/exact_target_sdk.gemspec b/exact_target_sdk.gemspec index 153f552..44bc6d1 100644 --- a/exact_target_sdk.gemspec +++ b/exact_target_sdk.gemspec @@ -14,7 +14,7 @@ Gem::Specification.new do |s| s.email = %q{daws23@gmail.com} s.homepage = %q{https://github.com/daws/exact_target_sdk} s.require_paths = [ 'lib' ] - + # documentation s.has_rdoc = true s.extra_rdoc_files = %w( README.rdoc CHANGELOG.rdoc LICENSE.txt ) @@ -27,6 +27,6 @@ Gem::Specification.new do |s| s.add_dependency 'activemodel', '~> 3.0' s.add_dependency 'activesupport', '~> 3.0' s.add_dependency 'guid', '~> 0.1' - s.add_dependency 'savon', '~> 0.9.9' + s.add_dependency 'savon', '~> 2.1.0' end diff --git a/lib/exact_target_sdk/client.rb b/lib/exact_target_sdk/client.rb index 7cbc253..80af881 100644 --- a/lib/exact_target_sdk/client.rb +++ b/lib/exact_target_sdk/client.rb @@ -11,6 +11,7 @@ module ExactTargetSDK # 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. + class Client # Constructs a client. @@ -21,13 +22,7 @@ class Client # Since ExactTarget's API is stateless, constructing a client object will not # make any remote calls. def initialize(options = {}) - self.config = { - }.merge!(ExactTargetSDK.config).merge!(options) - - Savon.configure do |c| - c.logger = ExactTargetSDK.config[:logger] - c.raise_errors = false - end + self.config = {}.merge!(ExactTargetSDK.config).merge!(options) initialize_client! end @@ -285,12 +280,14 @@ def logger # Constructs and saves the savon client using provided config. def initialize_client! - self.client = ::Savon::Client.new do |wsdl, http| - wsdl.endpoint = ExactTargetSDK.config[:endpoint] - wsdl.namespace = ExactTargetSDK.config[:namespace] - http.open_timeout = ExactTargetSDK.config[:open_timeout] - http.read_timeout = ExactTargetSDK.config[:read_timeout] - end + self.client = ::Savon::Client.new({ + wsdl: ExactTargetSDK.config[:endpoint], + namespace: ExactTargetSDK.config[:namespace], + logger: ExactTargetSDK.config[:logger], + raise_errors: false, + open_timeout: ExactTargetSDK.config[:open_timeout], + read_timeout: ExactTargetSDK.config[:read_timeout] + }) end # Builds the SOAP request for the given method, delegating body