Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade to savon 2.1.0 #3

Open
wants to merge 59 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
5d412e1
List added
Saicheg Apr 26, 2012
cd2a854
fix result id bug
Saicheg Apr 26, 2012
a0d20ed
Email added
Saicheg Apr 27, 2012
f4f599c
Email added
Saicheg Apr 27, 2012
8c40b46
Merge branches 'additional-objects' and 'fix-result-id-field' into ad…
Saicheg Apr 28, 2012
b270f44
add some basic ApiObject fields and work with ApiObject properties a …
Saicheg Apr 28, 2012
f233448
change field types for APIObject
Saicheg Apr 30, 2012
8ed764e
pack of objects for EmailSendDefinition implementation
Saicheg Apr 30, 2012
6465920
SimpleOperatorEnum added
Saicheg May 2, 2012
bc7cc48
remove validations from objects, cause it fails retrieve and other ac…
Saicheg May 2, 2012
e3b7868
add new Schedule request to client
Saicheg May 2, 2012
3f44fdf
remove validation from EmailSendDefinition
Saicheg May 2, 2012
9fd17e2
add results to perfrom response and add objects for scheduling
Saicheg May 2, 2012
40be2f9
add some more objects for scheduling
Saicheg May 2, 2012
77bac46
bounce_event and send objects added
Saicheg May 2, 2012
50dbcec
Merge branches 'master' and 'additional-objects'
Saicheg May 2, 2012
3388047
move method for before_validation to block to prevent rails errors
Saicheg May 3, 2012
1e1d91b
add additional property to ESD
Saicheg May 4, 2012
2667175
add couple more fields for email_send_definition and send_definition_…
Saicheg May 7, 2012
8055f32
remove validation from subscriber(error)
Saicheg May 7, 2012
ccf09d4
handle id and object_id methods
Saicheg May 7, 2012
faf4e8b
add some fields and enum for delivery profile
Saicheg May 7, 2012
13109b2
add new enum to autoload folder
Saicheg May 8, 2012
8dfc87d
add some fields to data_extension
Saicheg May 8, 2012
79f3583
add couple more fields for data_extension and send_definition_list an…
Saicheg May 10, 2012
623ae33
Add property for SenderProfile to enable AutoForward feature
Saicheg May 15, 2012
c48de45
fix typo for DeliveryProfile
Saicheg May 15, 2012
6f93858
add SenderProfile to EmailSendDefinition
Saicheg May 16, 2012
477105a
remove handling UnknowError from execute_request call
Saicheg May 17, 2012
4212a72
add LogicalOperators enum
Saicheg May 17, 2012
ab8e7d7
Add couple fields to DataExtensionObject
Saicheg May 17, 2012
68d6f67
make object and id available for UpdateResult
klochner May 19, 2012
5448e3b
add SubscriberList object
Saicheg May 21, 2012
f8c0cc7
make object and id available for UpdateResult
klochner May 19, 2012
49cb13d
typo
Saicheg May 21, 2012
73d038a
Merge branches 'master' and 'new-feature'
Saicheg May 21, 2012
93dd7a5
Merge branch 'master' of github.com:Saicheg/exact_target_sdk
klochner May 21, 2012
2600b45
gitignore updated
Saicheg May 24, 2012
ff54ab1
add objects for SpamAssasin integration
Saicheg May 25, 2012
430f6b5
rework Email model
Saicheg Jun 11, 2012
2b59df2
use ExactTargetSDK.config instead config
Saicheg Jun 11, 2012
1948e20
fix couple more config options
Saicheg Jun 11, 2012
e96308f
add option for enabling logs
Saicheg Jun 11, 2012
1ec397a
downgrade savon version and remove enabling login option
Saicheg Jun 11, 2012
6a2de6b
remove default rails logger
Saicheg Jun 11, 2012
4ea10ec
roll back previous savon version
Saicheg Jun 11, 2012
b207521
revert back rails logger and setup dependencies
Saicheg Jun 11, 2012
0b32702
add click open and sent events objects
Saicheg Jun 13, 2012
a058725
add one more abstraction level to implement Options class
Saicheg Jun 20, 2012
8b82cb0
add all classes to implement options
Saicheg Jun 20, 2012
7c71b90
result_message added
Saicheg Jun 21, 2012
a92b20f
implement options feature for requests
Saicheg Jun 21, 2012
7576037
nested_children for subsctibers in content_validation
Saicheg Jun 21, 2012
80e079e
update rspec
Saicheg Jul 9, 2012
4e0acab
skip validation if object is existing object with some id given
Saicheg Jul 9, 2012
9a1b492
put some validations back and fix all the tests + add some color to r…
Saicheg Jul 9, 2012
73b44fd
update all gems
Saicheg Jul 9, 2012
e101854
Merge branches 'master' and 'fix-broken-savon'
Saicheg Jul 9, 2012
c725a6b
* update savon
gregory Feb 11, 2013
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -2,3 +2,6 @@
/gems_dev
/.rbx
.*.swp
.idea/
temp/
.rvmrc
3 changes: 1 addition & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -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

56 changes: 29 additions & 27 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,48 +1,50 @@
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)
builder (3.0.0)
nokogiri (>= 1.4.0)
builder (3.0.4)
diff-lcs (1.1.3)
guid (0.1.1)
gyoku (0.4.4)
gyoku (1.0.0)
builder (>= 2.1.2)
httpi (0.9.5)
httpi (2.0.2)
rack
i18n (0.6.0)
multi_json (1.0.4)
nokogiri (1.5.0)
nori (1.0.2)
rack (1.4.1)
multi_json (1.3.6)
nokogiri (1.5.6)
nori (2.0.3)
rack (1.5.2)
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)
savon (0.9.7)
akami (~> 1.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 (2.1.0)
akami (~> 1.2.0)
builder (>= 2.1.2)
gyoku (>= 0.4.0)
httpi (~> 0.9)
gyoku (~> 1.0.0)
httpi (~> 2.0.2)
nokogiri (>= 1.4.0)
nori (~> 1.0)
wasabi (~> 2.0)
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.0.0)
wasabi (3.0.0)
httpi (~> 2.0)
nokogiri (>= 1.4.0)

PLATFORMS
@@ -53,5 +55,5 @@ DEPENDENCIES
activesupport (~> 3.0)
guid (~> 0.1)
rspec (~> 2.8)
savon (~> 0.9)
savon (~> 2.1.0)
simple_gem
4 changes: 2 additions & 2 deletions exact_target_sdk.gemspec
Original file line number Diff line number Diff line change
@@ -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'
s.add_dependency 'savon', '~> 2.1.0'

end
46 changes: 46 additions & 0 deletions lib/exact_target_sdk.rb
Original file line number Diff line number Diff line change
@@ -4,27 +4,73 @@
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'
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'
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 :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'
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 :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 :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'
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'
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'
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'
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 :UpdateOptions, 'exact_target_sdk/update_options'
autoload :UpdateResponse, 'exact_target_sdk/update_response'
autoload :UpdateResult, 'exact_target_sdk/update_result'

157 changes: 4 additions & 153 deletions lib/exact_target_sdk/api_object.rb
Original file line number Diff line number Diff line change
@@ -1,163 +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.
def properties
@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

# 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
property 'ID'
property 'ObjectID'
property 'CustomerKey'

# By default, loops through all registered properties, and renders
# each that has been explicitly set.
#
# May be overridden.
def render_properties!(xml)
self.class.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
24 changes: 24 additions & 0 deletions lib/exact_target_sdk/async_response.rb
Original file line number Diff line number Diff line change
@@ -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
Loading