diff options
Diffstat (limited to 'app/services/customer_relations/organizations/update_service.rb')
-rw-r--r-- | app/services/customer_relations/organizations/update_service.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/app/services/customer_relations/organizations/update_service.rb b/app/services/customer_relations/organizations/update_service.rb index 9d8f908db14..78fff9cf8f4 100644 --- a/app/services/customer_relations/organizations/update_service.rb +++ b/app/services/customer_relations/organizations/update_service.rb @@ -5,6 +5,8 @@ module CustomerRelations class UpdateService < BaseService def execute(organization) return error_no_permissions unless allowed? + + handle_active_param return error_updating(organization) unless organization.update(params) ServiceResponse.success(payload: organization) @@ -12,6 +14,13 @@ module CustomerRelations private + def handle_active_param + return if params[:active].nil? + + active = params.delete(:active) + params[:state] = active ? 'active' : 'inactive' + end + def error_no_permissions error('You have insufficient permissions to update an organization for this group') end |