This repository has been archived by the owner on Aug 9, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
38 additions
and
43 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,35 @@ | ||
class CampaignMonitor | ||
module Helpers | ||
def self.included(base) | ||
base.class_eval do | ||
extend ClassMethods | ||
include InstanceMethods | ||
end | ||
|
||
def handle_response(response) | ||
return [] if response.empty? | ||
|
||
if response["Code"].to_i == 0 | ||
# success! | ||
yield(response) | ||
else | ||
# error! | ||
raise response["Code"] + " - " + response["Message"] | ||
end | ||
end | ||
|
||
def wsdl_driver_factory | ||
SOAP::WSDLDriverFactory.new("#{api_url}?WSDL") | ||
end | ||
|
||
def using_soap | ||
driver = wsdl_driver_factory.create_rpc_driver | ||
response = yield(driver) | ||
driver.reset_stream | ||
end | ||
|
||
def timestamp_format | ||
'%Y-%m-%d %H:%M:%S' | ||
end | ||
|
||
module ClassMethods | ||
end | ||
|
||
module InstanceMethods | ||
def formatted_timestamp(datetime, format=timestamp_format) | ||
datetime.strftime(format) | ||
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
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