From 7102eae8e300bc1530d2f6936d78d7ba563985f8 Mon Sep 17 00:00:00 2001 From: Michal Kurgan Date: Thu, 13 Nov 2014 13:11:48 -0700 Subject: [PATCH 1/2] add basic support for MergeTriggerEmail --- lib/responsys/api/campaign.rb | 12 ++++++++++++ lib/responsys/api/object/all.rb | 1 + lib/responsys/api/object/trigger_data.rb | 18 ++++++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 lib/responsys/api/object/trigger_data.rb diff --git a/lib/responsys/api/campaign.rb b/lib/responsys/api/campaign.rb index 2d21551..fd8b2ae 100644 --- a/lib/responsys/api/campaign.rb +++ b/lib/responsys/api/campaign.rb @@ -21,6 +21,18 @@ def check_failures(outcome, recipients) puts "failed:\n" + recipients[:recipient].to_s unless outcome[:success] end end + + def merge_trigger_email(campaign, record_data, trigger_data, merge_rule) + raise ParameterException, Responsys::Helper.get_message(("api.campaign.incorrect_trigger_data_type") unless trigger_data.is_a? Array + message = { + recordData: record_data.to_api, + mergeRule: merge_rule.to_api, + campaign: campaign.to_api, + triggerData: trigger_data.map(&:to_api) + } + + api_method(:merge_trigger_email, message) + end end end end diff --git a/lib/responsys/api/object/all.rb b/lib/responsys/api/object/all.rb index 08d15fd..9287416 100644 --- a/lib/responsys/api/object/all.rb +++ b/lib/responsys/api/object/all.rb @@ -9,3 +9,4 @@ require "responsys/api/object/recipient_data" require "responsys/api/object/email_format" require "responsys/api/object/optional_data" +require "responsys/api/object/trigger_data" diff --git a/lib/responsys/api/object/trigger_data.rb b/lib/responsys/api/object/trigger_data.rb new file mode 100644 index 0000000..eaeb7d8 --- /dev/null +++ b/lib/responsys/api/object/trigger_data.rb @@ -0,0 +1,18 @@ +module Responsys + module Api + module Object + class TriggerData + attr_accessor :optional_data + + def initialize(optional_data = [Responsys::Api::Object::OptionalData.new]) + @optional_data = optional_data + end + + def to_api + { optionalData: @optional_data.map(&:to_api) } + end + end + end + end +end + From 73e2050642b27d4b5ea1ecd8fd17d0cc945a0034 Mon Sep 17 00:00:00 2001 From: Michal Kurgan Date: Thu, 13 Nov 2014 14:27:13 -0700 Subject: [PATCH 2/2] fix copy and paste syntax error --- lib/responsys/api/campaign.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/responsys/api/campaign.rb b/lib/responsys/api/campaign.rb index fd8b2ae..23d3c73 100644 --- a/lib/responsys/api/campaign.rb +++ b/lib/responsys/api/campaign.rb @@ -23,7 +23,7 @@ def check_failures(outcome, recipients) end def merge_trigger_email(campaign, record_data, trigger_data, merge_rule) - raise ParameterException, Responsys::Helper.get_message(("api.campaign.incorrect_trigger_data_type") unless trigger_data.is_a? Array + raise ParameterException, Responsys::Helper.get_message("api.campaign.incorrect_trigger_data_type") unless trigger_data.is_a? Array message = { recordData: record_data.to_api, mergeRule: merge_rule.to_api,