Skip to content

Instantly share code, notes, and snippets.

@sethyanow
Last active July 29, 2016 21:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sethyanow/8cdd5a90136840dd1d8f to your computer and use it in GitHub Desktop.
Save sethyanow/8cdd5a90136840dd1d8f to your computer and use it in GitHub Desktop.
BaseCRM lead sorting hat
class BaseAdapter
attr_accessor :session
def initialize
@session = BaseCrm::Session.new('your_key')
end
def leads
@session.leads.all
end
# Return with {num} leads
def fetch_leads (num)
@session.leads.all.sample(num)
end
# Assign a sample of leads to a user (owner id)
def assign_sample(user, num)
leads = fetch_leads(num)
leads.each do |lead|
lead.owner_id = user
lead.save
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment