diff --git a/lib/responsys/api/campaign.rb b/lib/responsys/api/campaign.rb index 2d21551..23d3c73 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 +