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

Adds support for MergeTriggerEmail API #18

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 12 additions & 0 deletions lib/responsys/api/campaign.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add ListMergeRule.new as the default value for 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
1 change: 1 addition & 0 deletions lib/responsys/api/object/all.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
18 changes: 18 additions & 0 deletions lib/responsys/api/object/trigger_data.rb
Original file line number Diff line number Diff line change
@@ -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) }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@florrain got on my case about this, so I figured I'd pay it forward :)
Can we format this line like so?

{
  optionalData: @optional_data.map(&:to_api)
}

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha - oh @florrain - how he cracks me up. I think the 1 line hash syntax is fine so I wouldn't worry about it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we decided to split the hash in multiple ones if it doesn't fit in a "relatively short" line. This one should be fine 👍

end
end
end
end
end