forked from daws/exact_target_sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implementing Filter, SimpleFilterPart, and ComplexFilterPart implementing new Result superclass that makes all properties available adding unit tests
- Loading branch information
David Dawson
committed
Feb 16, 2012
1 parent
7010234
commit 5ea5ef7
Showing
13 changed files
with
149 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module ExactTargetSDK | ||
class ComplexFilterPart < FilterPart | ||
|
||
property 'LeftOperand', true | ||
property 'LogicalOperator', true | ||
property 'RightOperand', true | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,4 @@ | ||
require 'active_support/inflector' | ||
|
||
module ExactTargetSDK | ||
class CreateResult | ||
|
||
PROPERTIES = [ | ||
'StatusCode', | ||
'StatusMessage', | ||
'ErrorCode' | ||
] | ||
|
||
PROPERTIES.each do |property| | ||
attr_reader property | ||
end | ||
|
||
def initialize(hash) | ||
PROPERTIES.each do |property| | ||
instance_variable_set("@#{property}", hash[property.underscore.to_sym]) | ||
end | ||
end | ||
|
||
class CreateResult < Result | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module ExactTargetSDK | ||
|
||
class FilterPart < APIObject | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
require 'active_support/inflector' | ||
|
||
module ExactTargetSDK | ||
class Result | ||
|
||
def initialize(hash) | ||
@result = hash | ||
end | ||
|
||
def method_missing(symbol, *args) | ||
@result[symbol.to_s.underscore.to_sym] | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module ExactTargetSDK | ||
class RetrieveResponse | ||
|
||
attr_reader :OverallStatus, :RequestID, :Results | ||
|
||
def initialize(response) | ||
response = response.to_hash[:retrieve_response_msg] | ||
@OverallStatus = response[:overall_status] | ||
@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 << RetrieveResult.new(result) | ||
end | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module ExactTargetSDK | ||
class RetrieveResult < Result | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module ExactTargetSDK | ||
class SimpleFilterPart < FilterPart | ||
|
||
property 'Property', true | ||
property 'SimpleOperator', true | ||
array_property 'Value' | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,4 @@ | ||
require 'active_support/inflector' | ||
|
||
module ExactTargetSDK | ||
class UpdateResult | ||
|
||
PROPERTIES = [ | ||
'StatusCode', | ||
'StatusMessage', | ||
'ErrorCode' | ||
] | ||
|
||
PROPERTIES.each do |property| | ||
attr_reader property | ||
end | ||
|
||
def initialize(hash) | ||
PROPERTIES.each do |property| | ||
instance_variable_set("@#{property}", hash[property.underscore.to_sym]) | ||
end | ||
end | ||
|
||
class UpdateResult < Result | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
require 'spec_helper' | ||
|
||
include ExactTargetSDK | ||
|
||
describe Result do | ||
|
||
context 'a result initialized with OverallStatus and RequestID' do | ||
|
||
subject { Result.new(:overall_status => "OK", :request_id => "abc") } | ||
|
||
it 'should respond to OverallStatus with "OK"' do | ||
subject.OverallStatus.should == "OK" | ||
end | ||
|
||
it 'should respond to RequestID with "abc"' do | ||
subject.RequestID.should == "abc" | ||
end | ||
|
||
it 'should respond to Junk with nil' do | ||
subject.Junk.should_not be | ||
end | ||
|
||
end | ||
|
||
end |