Class: ConstantContact::Contact
- Inherits:
-
Base
- Object
- ActiveResource::Base
- Base
- ConstantContact::Contact
- Includes:
- HasManyLists, Searchable
- Defined in:
- lib/constantcontact/contact.rb
Constant Summary
Constant Summary
Constants inherited from Base
Instance Method Summary (collapse)
-
- (Contact) initialize(attributes = {}, persisted = false)
constructor
A new instance of Contact.
-
- (Object) opt_in_source
attr_accessor :opt_in_source.
-
- (Object) opt_in_source=(val)
see developer.constantcontact.com/doc/manageContacts#create_contact for more info about the two values.
- - (Object) to_xml
Methods included from HasManyLists
Methods included from Searchable
Methods inherited from Base
api_key, api_key=, collection_path, connection, element_path, parse_id, #to_atom
Constructor Details
- (Contact) initialize(attributes = {}, persisted = false)
A new instance of Contact
8 9 10 11 12 |
# File 'lib/constantcontact/contact.rb', line 8 def initialize(attributes = {}, persisted = false) attributes = attributes[0] if attributes.kind_of? Array self.contact_lists = attributes.delete(:list_ids) if attributes.has_key? :list_ids super end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class ConstantContact::Base
Instance Method Details
- (Object) opt_in_source
attr_accessor :opt_in_source
15 16 17 |
# File 'lib/constantcontact/contact.rb', line 15 def opt_in_source @opt_in_source ||= "ACTION_BY_CUSTOMER" end |
- (Object) opt_in_source=(val)
see developer.constantcontact.com/doc/manageContacts#create_contact for more info about the two values.
20 21 22 |
# File 'lib/constantcontact/contact.rb', line 20 def opt_in_source=(val) @opt_in_source = val if ['ACTION_BY_CONTACT','ACTION_BY_CUSTOMER'].include?(val) end |
- (Object) to_xml
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/constantcontact/contact.rb', line 24 def to_xml xml = Builder::XmlMarkup.new xml.tag!("Contact", :xmlns => "http://ws.constantcontact.com/ns/1.0/") do self.attributes.reject {|k,v| k == 'ContactLists'}.each{|k, v| xml.tag!( k.to_s.camelize, v )} xml.tag!("OptInSource", self.opt_in_source) xml.tag!("ContactLists") do self.contact_lists.each do |list| xml.tag!("ContactList", :id=> list.url) end end end end |