wynst / email_direct Goto Github PK
View Code? Open in Web Editor NEWRuby wrapper for Email Direct SOAP service
Home Page: http://dev.emaildirect.com/v1/
License: MIT License
Ruby wrapper for Email Direct SOAP service
Home Page: http://dev.emaildirect.com/v1/
License: MIT License
When using Email_AddWithFields, the lists, publications and custom fields aren't being set.
require 'rubygems'
require 'email_direct'
username = 'username'
password = 'password'
@soap = EmailDirect::SOAP.new(username, password)
#uncomment this line for full debug info
#@soap.debug = true
result = @soap.Source_GetAll()
source_id = result.data["Element"].first["ElementID"]
# create some publication
@soap.Publication_Add("ElementName" => "Publication1", "Description" => "publication 1 info")
@soap.Publication_Add("ElementName" => "Publication2", "Description" => "publication 2 info")
result = @soap.Publication_GetAll()
publication_id1 = result.data["Element"][0]["ElementID"]
publication_id2 = result.data["Element"][1]["ElementID"]
# create some list
result = @soap.List_Add("ElementName" => "List1", "Description" => "List 1 info")
result = @soap.List_Add("ElementName" => "List2", "Description" => "List 2 info")
result = @soap.List_GetAll()
list_id1 = result.data["Element"][0]["ElementID"]
list_id2 = result.data["Element"][1]["ElementID"]
result = @soap.Email_AddWithFields(
"Email" => "[email protected]",
"SourceID" => source_id,
"Publications" => [
{"int" => publication_id1},
{"int" => publication_id2}
],
"Lists" => [
{"int" => list_id1},
{"int" => list_id2}
],
"AutoResponderID" => 0,
"Force" => "false",
"CustomFields" => [
{
"FieldName" => "FirstName",
"Value" => "Jason"
}, {
"FieldName" => "LastName",
"Value" => "Red"
}
])
puts result.message
# Success
result = @soap.Email_GetProperties("Email" => "[email protected]")
p result.data
# {"Status"=>"Active", "Lists"=>nil, "CreateDate"=>"2011-04-25T21:00:00", "EmailID"=>"2",
# "DateStamp"=>"2011-04-25T21:00:00", "IPAddress"=>nil, "Source"=>{"ElementID"=>"126",
# "Description"=>"a description.", "ElementName"=>"name581090"}, "Publications"=>nil,
# "Email"=>"[email protected]", "CustomFields"=>{"CustomField"=>[
# {"FieldName"=>"Email", "Value"=>"[email protected]"}, {"FieldName"=>"IPAddress", "Value"=>nil},
# {"FieldName"=>"DateStamp", "Value"=>"4/25/2011"}, {"FieldName"=>"FirstName", "Value"=>nil},
# {"FieldName"=>"LastName", "Value"=>nil}, {"FieldName"=>"Gender", "Value"=>nil},
# {"FieldName"=>"Address", "Value"=>nil}, {"FieldName"=>"City", "Value"=>nil},
# {"FieldName"=>"State", "Value"=>nil}, {"FieldName"=>"Zip", "Value"=>nil},
# {"FieldName"=>"Phone", "Value"=>nil}, {"FieldName"=>"Fax", "Value"=>nil},
# {"FieldName"=>"Age", "Value"=>nil}, {"FieldName"=>"SourceCode", "Value"=>nil},
# {"FieldName"=>"Domain", "Value"=>nil}, {"FieldName"=>"CampusList", "Value"=>nil},
# {"FieldName"=>"VendorCode", "Value"=>nil}, {"FieldName"=>"LeadStatus", "Value"=>nil}]}}
require 'rubygems'
require 'email_direct'
username = 'username'
password = 'password'
@soap = EmailDirect::SOAP.new(username, password)
list_name = 'List1021'
list_description = 'none.'
result = @soap.List_Add("ElementName" => list_name, "Description" => list_description)
p result.success?
# true
result = @soap.List_GetAll()
p result.data
# {"Element"=>{"ElementID"=>"<some number>", "Description"=>"none.", "ElementName"=>"List1010"}}
list_id = result.data['Element']['ElementID']
# delete the list
result = @soap.List_Delete('ListID' => list_id)
p result.success?
# true
# check
result = @soap.List_GetAll()
p result.data
# nil
# recreating the same list
result = @soap.List_Add("ElementName" => list_name, "Description" => list_description)
p result.success?
# false
p result.message
# "A List with this name already exists."
# there are no lists with this name!
# the web interface doesn't show this list either and if I try to create it on the web interface, it will work.
require 'rubygems'
require 'email_direct'
username = 'username'
password = 'password'
@soap = EmailDirect::SOAP.new(username, password)
result = @soap.List_Add("ElementName" => "List100", "Description" => "List 1 info")
result = @soap.List_GetAll()
p result.data
#{"Element"=>{"ElementID"=>"27", "Description"=>"List 1 info", "ElementName"=>"List100"}}
result = @soap.List_Add("ElementName" => "List200", "Description" => "List 2 info")
result = @soap.List_GetAll()
p result.data
#{"Element"=>[{"ElementID"=>"27", "Description"=>"List 1 info", "ElementName"=>"List100"}, {"ElementID"=>"28", "Description"=>"List 2 info", "ElementName"=>"List200"}]}
# the result.data['Element'] type is a hash if there is only 1 list and a list if there is more than 1 list (!)
# to be consistent, it should be always a list
# {"Element"=>[{"ElementID"=>"27", "Description"=>"List 1 info", "ElementName"=>"List100"}}]
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.