Created
March 2, 2011 01:04
-
-
Save jamesmartin/850261 to your computer and use it in GitHub Desktop.
Adding custom fields with multiple values to a subscriber
This file contains hidden or 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
| require 'rubygems' | |
| require 'json' | |
| custom_fields = [ | |
| { :Key => 'memstatus', :Value => "{account_status}"}, | |
| { :Key => 'memtype', :Value => "{user.member_type}"}, | |
| { :Key => 'memsincedate', :Value => "{member_since.to_date}"}, | |
| { :Key => 'memrenewaldate', :Value => "{user.account.renewal_date.to_date}"}, | |
| { :Key => 'usertype', :Value => "{user_type}"}, | |
| #{ :Key => 'neighborhood group', :Value => "#{neighborhood_groups.join('||')}", :DataType => 'Multi-Options'}, | |
| #{ :Key => 'social group', :Value => "social_groups.join('||')", :DataType => 'Multi-Options'} | |
| ] | |
| neighborhood_groups = %w[ a b c ] | |
| neighborhood_groups.each {|value| custom_fields << {:Key => 'neighborhood group', :Value => "#{value}"}} | |
| social_groups = %w[ 1 2 3 ] | |
| social_groups.each {|value| custom_fields << {:Key => 'social group', :Value => "#{value}"}} | |
| subscribers = [{ :EmailAddress => "{user.email}", :Name => "{user.last_name}, {user.first_name}", :CustomFields => custom_fields }] | |
| puts JSON.generate(subscribers) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Gives the following output: