Class: Decidim::Meetings::WithdrawMeetingType

Inherits:
Api::Types::BaseMutation
  • Object
show all
Defined in:
lib/decidim/api/mutations/withdraw_meeting_type.rb

Instance Method Summary collapse

Instance Method Details

#authorized?Boolean

Returns:

  • (Boolean)

Raises:

  • (Decidim::Api::Errors::MutationNotAuthorizedError)


23
24
25
26
27
# File 'lib/decidim/api/mutations/withdraw_meeting_type.rb', line 23

def authorized?
  raise Decidim::Api::Errors::MutationNotAuthorizedError, I18n.t("decidim.api.errors.unauthorized_mutation") unless super && allowed_to?(:withdraw, :meeting, object, context)

  true
end

#resolveObject



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/decidim/api/mutations/withdraw_meeting_type.rb', line 11

def resolve
  WithdrawMeeting.call(object, current_user) do
    on(:ok) do |meeting|
      return meeting
    end

    on(:invalid) do
      raise Decidim::Api::Errors::ValidationError, I18n.t("decidim.meetings.withdraw.error")
    end
  end
end