Module: GoAcoustic::Client::Contact
- Included in:
- GoAcoustic::Client
- Defined in:
- lib/client/contact.rb
Instance Method Summary collapse
-
#add_recipient(fields, list_id, contact_list_id = nil, created_from = 1, options = {}) ⇒ Mash
Adds one new contact to an existing database.
-
#get_recipient(fields, list_id, recipient_id = nil, options = {}) ⇒ Object
Retrieves a contact from a database.
Instance Method Details
#add_recipient(fields, list_id, contact_list_id = nil, created_from = 1, options = {}) ⇒ Mash
Adds one new contact to an existing database.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/client/contact.rb', line 14 def add_recipient(fields, list_id, contact_list_id=nil, created_from=1, ={}) builder = Builder::XmlMarkup.new xml = builder.Envelope { builder.Body { builder.AddRecipient { builder.LIST_ID list_id builder.CREATED_FROM created_from if contact_list_id builder.CONTACT_LISTS { contact_list_id.each do |id| builder.CONTACT_LIST_ID id end } end unless .empty? .each do |opt| builder.tag! opt[0], opt[1] end end fields.each do |field| builder.COLUMN { builder.NAME field[0].to_s builder.VALUE field[1] } end } } } post(xml) end |
#get_recipient(fields, list_id, recipient_id = nil, options = {}) ⇒ Object
Retrieves a contact from a database
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/client/contact.rb', line 47 def get_recipient(fields, list_id, recipient_id=nil, ={}) builder = Builder::XmlMarkup.new xml = builder.Envelope { builder.Body { builder.SelectRecipientData { builder.LIST_ID list_id if recipient_id builder.RECIPIENT_ID recipient_id builder.COLUMN { builder.NAME "Recipient ID" builder.VALUE recipient_id } end if fields[:email] builder.EMAIL fields[:email] end unless .empty? .each do |opt| builder.tag! opt[0], opt[1] end end unless fields.empty? fields.each do |field| builder.COLUMN { builder.NAME field[0].to_s builder.VALUE field[1] } end end } } } begin response = post(xml) response.Envelope.Body.RESULT rescue return false end end |