debian-mirror-gitlab/app/services/customer_relations/organizations/update_service.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

25 lines
649 B
Ruby
Raw Normal View History

2021-11-11 11:23:49 +05:30
# 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