lib/promoter/contact.rb in promoter-0.1.5 vs lib/promoter/contact.rb in promoter-0.1.6
- old
+ new
@@ -17,11 +17,24 @@
def destroy
Contact.destroy(self.email)
end
- def self.all(page=1)
- response = Request.get("#{API_URL}/?page=#{page}")
+ # Parameter Optional? Description
+ # page yes Returns which page of results to return.
+ # Defaults to 1
+ # email yes Filter the results by email address.
+ def self.all(options={})
+ if !options.is_a?(Hash)
+ puts "-- DEPRECATION WARNING--"
+ puts "Passing in a number as a page is deprecated and will be removed from future versions of this gem.\nInstead pass in a hash of attributes.\n\n e.g. Promoter::Contact.all(page: 2)"
+ query_string = "page=#{options}"
+ else
+ # default to first page
+ options[:page] ||= 1
+ query_string = URI.encode_www_form(options)
+ end
+ response = Request.get("#{API_URL}/?#{query_string}")
response['results'].map {|attrs| new(attrs)}
end
def self.find(id)
response = Request.get("#{API_URL}/#{id}")
\ No newline at end of file