Last active
August 29, 2015 13:55
-
-
Save benjohnson77/8695801 to your computer and use it in GitHub Desktop.
Quick script for mashing up pipedrive and contacturally
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :pipedrive do | |
desc "Look into match up pipedrive with contactually" | |
require 'httparty' | |
require 'json' | |
task :import => :environment do | |
require 'csv' | |
filename = Rails.root + "lib/tasks/meetingplanners.csv" | |
CSV.foreach(filename, :headers => true) do |row| | |
name_arr = row[3].split(' ') | |
first_name = name_arr.first | |
last_name = name_arr.last(name_arr.length-1).join(' ') | |
email = row[5] | |
company_name = row[1] | |
rep = row[2] | |
phone = row[4] | |
puts contactually_put_contact(first_name,last_name,email,company_name,13326771) | |
end | |
end | |
def pipedrive | |
url = "http://api.pipedrive.com/v1/deals?start=0&sort_mode=asc&api_token=RRRR" | |
response = HTTParty.get(url) | |
json = JSON.parse(response.body) | |
if json['success'] = true | |
return json['data'] | |
end | |
end | |
def contactually_get_contacts | |
url = "https://www.contactually.com/api/v1/contacts.json?api_key=rrrr" | |
response = HTTParty.get(url) | |
json = JSON.parse(response.body) | |
if json['count'] > 0 | |
return json['contacts'] | |
end | |
end | |
def contactually_put_contact(first_name,last_name,email,company,user_bucket_id) | |
contact = {:contact => {first_name: first_name,last_name: last_name,email: email,company: company,user_bucket_id: user_bucket_id}.to_hash } | |
contact = contact.to_json | |
puts contact | |
url = "https://www.contactually.com/api/v1/contacts.json?api_key=###" | |
post = HTTParty.post(url, contact, ) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment