lib/promoter/contact.rb in promoter-0.1.4 vs lib/promoter/contact.rb in promoter-0.1.5

- old
+ new

@@ -13,20 +13,32 @@ @last_name = attrs["last_name"] @created_date = Time.parse(attrs["created_date"]) if attrs["created_date"] @attributes = attrs["attributes"] end + def destroy + Contact.destroy(self.email) + end + def self.all(page=1) response = Request.get("#{API_URL}/?page=#{page}") response['results'].map {|attrs| new(attrs)} end def self.find(id) response = Request.get("#{API_URL}/#{id}") new(response) end + def self.destroy(email) + attributes = { + email: email + } + response = Request.post("#{API_URL}/remove/", attributes) + new(response) + end + # Contact Params # Parameter Optional? Description # email no The email of the contact to add to the organization. # first_name yes The first name of the contact to add to the organization. # last_name yes The last name of the contact to add to the organization. @@ -44,9 +56,14 @@ # be added correctly. Otherwise, the contact will # be associated to a default generated contact list # for your given organization. def self.create(attributes) response = Request.post(API_URL + "/", attributes) + new(response) + end + + def self.survey(attributes) + response = Request.post(API_URL + "/survey/", attributes) new(response) end end end \ No newline at end of file