Class: Pipekit::Person
Constant Summary
collapse
- SINGULAR_CLASSNAME =
"person".freeze
- PLURALIZED_CLASSNAME =
"persons".freeze
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
26
27
28
29
30
|
# File 'lib/pipekit/person.rb', line 26
def create_or_update(fields)
update_by_email(fields[:email], fields)
rescue ResourceNotFoundError
create(fields)
end
|
#find_deals(id) ⇒ Object
32
33
34
|
# File 'lib/pipekit/person.rb', line 32
def find_deals(id)
request.get("#{id}/deals")
end
|
#find_exactly_by_email(email) ⇒ Object
15
16
17
18
19
|
# File 'lib/pipekit/person.rb', line 15
def find_exactly_by_email(email)
get_by_email(email).select do |item|
item["email"] == email
end.first
end
|
#get_by_email(email) ⇒ Object
7
8
9
|
# File 'lib/pipekit/person.rb', line 7
def get_by_email(email)
request.get("find", term: email, search_by_email: 1)
end
|
#get_by_name(name) ⇒ Object
11
12
13
|
# File 'lib/pipekit/person.rb', line 11
def get_by_name(name)
request.get("find", term: name)
end
|
#update_by_email(email, fields) ⇒ Object
21
22
23
24
|
# File 'lib/pipekit/person.rb', line 21
def update_by_email(email, fields)
person = find_exactly_by_email(email)
update(person["id"], fields)
end
|