Last active
July 29, 2016 21:51
-
-
Save sethyanow/8cdd5a90136840dd1d8f to your computer and use it in GitHub Desktop.
BaseCRM lead sorting hat
This file contains 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
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