Sha256: d59d4ac4e2192ecb7558f1490ec7a6f0adf4da676423cf24a9dbf51954982e92
Contents?: true
Size: 1.81 KB
Versions: 3
Compression:
Stored size: 1.81 KB
Contents
module ExpressPigeon # Contacts # # Contacts end point allows you to create, read, update and delete contacts # on your lists. A contact consists of required email and various standard # and custom fields. class Contacts include HTTParty base_uri('https://api.expresspigeon.com/contacts') debug_output(nil) def initialize(auth_key) self.class.headers('X-auth-key' => auth_key) end # Read a single contact by email # # GET https://api.expresspigeon.com/contacts def find(email_address) self.class.get('/', query: { email: email_address }) end # Create or update contacts # # POST https://api.expresspigeon.com/contacts def create(list_id, contacts) fail "Contacts must be an Array received #{contacts.class.name}." unless contacts.is_a?(Array) options = { 'list_id' => list_id, 'contacts' => contacts } self.class.post( '/', body: options.to_json, headers: { 'Content-Type' => 'application/json' } ) end alias_method :update, :create # Delete a single contact # # DELETE https://api.expresspigeon.com/contacts def delete(_email_address) end # Move contacts between lists # # POST https://api.expresspigeon.com/contacts/move def move(source_list_id, target_list_id, email_addresses) fail "Email address must be an Array received #{email_addresses.class.name}." unless email_addresses.is_a?(Array) options = {} options['source_list'] = source_list_id options['target_list'] = target_list_id options['contacts'] = email_addresses self.class.post( '/move', body: options.to_json, headers: { 'Content-Type' => 'application/json' } ) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
express_pigeon-2.0.2 | lib/express_pigeon/contacts.rb |
express_pigeon-2.0.1 | lib/express_pigeon/contacts.rb |
express_pigeon-2.0.0 | lib/express_pigeon/contacts.rb |