Sha256: 7291052108e0154537f223d5fb11cc2ac93d9aa0408f527ed401ff58d92c76b1

Contents?: true

Size: 968 Bytes

Versions: 8

Compression:

Stored size: 968 Bytes

Contents

module AppleID
  class EventToken::Event < OpenIDConnect::ConnectObject
    attr_required :type, :sub, :event_time
    attr_optional :email, :is_private_email

    module Type
      EMAIL_ENABLED   = 'email-enabled'
      EMAIL_DISABLED  = 'email-disabled'
      CONSENT_REVOKED = 'consent-revoked'
      ACCOUNT_DELETED = 'account-delete'
    end

    def email_enabled?
      type == Type::EMAIL_ENABLED
    end

    def email_disabled?
      type == Type::EMAIL_DISABLED
    end

    def consent_revoked?
      type == Type::CONSENT_REVOKED
    end

    def account_deleted?
      type == Type::ACCOUNT_DELETED
    end
    alias_method :account_delete?, :account_deleted?

    def is_private_email?
      if is_private_email.is_a? String
        is_private_email == 'true'
      else
        !!is_private_email
      end
    end

    class << self
      def decode(json_string)
        new JSON.parse(json_string).with_indifferent_access
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
apple_id-forestv8_compatibility-1.5.3 lib/apple_id/event_token/event.rb
apple_id-1.6.4 lib/apple_id/event_token/event.rb
apple_id-1.6.3 lib/apple_id/event_token/event.rb
apple_id-1.6.2 lib/apple_id/event_token/event.rb
apple_id-1.6.1 lib/apple_id/event_token/event.rb
apple_id-1.6.0 lib/apple_id/event_token/event.rb
apple_id-1.5.2 lib/apple_id/event_token/event.rb
apple_id-1.5.1 lib/apple_id/event_token/event.rb