blob: 473a80be26221a84d719c1f41d0ebf7676423b9e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# frozen_string_literal: true
module CustomerRelations
module Contacts
class UpdateService < BaseService
def execute(contact)
return error_no_permissions unless allowed?
return error_updating(contact) unless contact.update(params)
ServiceResponse.success(payload: contact)
end
private
def error_no_permissions
error('You have insufficient permissions to update a contact for this group')
end
def error_updating(contact)
error(contact&.errors&.full_messages || 'Failed to update contact')
end
end
end
end
|