Class: Pipekit::Person

Inherits:
Object
  • Object
show all
Includes:
Repository
Defined in:
lib/pipekit/person.rb

Instance Method Summary collapse

Methods included from Repository

#all, #create, #find_by, #initialize, #update, #where

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Pipekit::Repository

Instance Method Details

#create_or_update(fields) ⇒ Object



18
19
20
21
22
# File 'lib/pipekit/person.rb', line 18

def create_or_update(fields)
  update_by_email(fields[:email], fields)
rescue ResourceNotFoundError
  create(fields)
end

#find_deals(id) ⇒ Object



24
25
26
# File 'lib/pipekit/person.rb', line 24

def find_deals(id)
  request.get("#{id}/deals")
end

#get_by_email(email) ⇒ Object



5
6
7
# File 'lib/pipekit/person.rb', line 5

def get_by_email(email)
  request.get("find", term: email, search_by_email: 1)
end

#get_by_name(name) ⇒ Object



9
10
11
# File 'lib/pipekit/person.rb', line 9

def get_by_name(name)
  request.get("find", term: name)
end

#update_by_email(email, fields) ⇒ Object



13
14
15
16
# File 'lib/pipekit/person.rb', line 13

def update_by_email(email, fields)
  person = find_by(email: email)
  update(person["id"], fields)
end