Class: Shark::Contact

Inherits:
Base
  • Object
show all
Extended by:
Shark::ContactService::Resource
Includes:
NormalizedEmail
Defined in:
lib/shark/contact.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

add_datetime_accessors

Class Method Details

.find_by_email(email) ⇒ Object



16
17
18
19
20
# File 'lib/shark/contact.rb', line 16

def self.find_by_email(email)
  normalized_email = normalize_email(email)
  options = { filter: { equals: { email: normalized_email } } }
  where(options).first
end

.find_by_permissions(permissions_filter) ⇒ Object

Examples:

contacts = Shark::ContactService::Contact.find_by_permissions([
  { resource: 'paragraph::contract', privilege: 'admin' },
  { resource: 'datenraum', privilege: 'admin'}
])

Parameters:

  • permissions_filter (Array)

    the filter of resources and privileges.



30
31
32
# File 'lib/shark/contact.rb', line 30

def self.find_by_permissions(permissions_filter)
  includes('permission').where(permissions: permissions_filter)
end

Instance Method Details

#accountObject



34
35
36
37
38
# File 'lib/shark/contact.rb', line 34

def 
  return nil if .blank?

  Shark::Account.find().first
end

#consentsObject



40
41
42
# File 'lib/shark/contact.rb', line 40

def consents
  Shark::Consent.where(contact_id: id)
end

#create_contract(params) ⇒ Object



44
45
46
# File 'lib/shark/contact.rb', line 44

def create_contract(params)
  Shark::Contract.create(params.merge(contact_id: id))
end