blob: 9d8f908db14259163c0c9a0aa4cf9cb912d64524 (
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 Organizations
class UpdateService < BaseService
def execute(organization)
return error_no_permissions unless allowed?
return error_updating(organization) unless organization.update(params)
ServiceResponse.success(payload: organization)
end
private
def error_no_permissions
error('You have insufficient permissions to update an organization for this group')
end
def error_updating(organization)
error(organization&.errors&.full_messages || 'Failed to update organization')
end
end
end
end
|