hummingbird-me/kitsu-server

View on GitHub
app/graphql/mutations/pro/unsubscribe.rb

Summary

Maintainability
A
0 mins
Test Coverage
F
50%
class Mutations::Pro::Unsubscribe < Mutations::Base
  field :expires_at, GraphQL::Types::ISO8601DateTime, null: true

  def ready?
    raise GraphQL::ExecutionError, 'Must be logged in' if user.blank?

    true
  end

  def resolve(reason: nil)
    Pro::Unsubscribe.call(
      user: context[:user],
      reason: reason
    )
  rescue ProSubscription::NoCancellationError
    raise GraphQL::ExecutionError, 'Cannot cancel that type of subscription here'
  end
end