Sha256: 60986ced360b219fa6c7b0ad3973c281e4642863e4e9ed12e6efec0d5bb263fc

Contents?: true

Size: 1.5 KB

Versions: 13

Compression:

Stored size: 1.5 KB

Contents

# frozen_string_literal: true

module WorkOS
  # The Invitation class provides a lightweight wrapper around a WorkOS Invitation
  # resource. This class is not meant to be instantiated in a user space,
  # and is instantiated internally but exposed.
  class Invitation
    include HashProvider

    attr_accessor :id, :email, :state, :accepted_at, :revoked_at, :accept_invitation_url,
                  :expires_at, :token, :organization_id, :inviter_user_id, :created_at, :updated_at

    # rubocop:disable Metrics/AbcSize
    def initialize(json)
      hash = JSON.parse(json, symbolize_names: true)

      @id = hash[:id]
      @email = hash[:email]
      @state = hash[:state]
      @token = hash[:token]
      @accept_invitation_url = hash[:accept_invitation_url]
      @organization_id = hash[:organization_id]
      @inviter_user_id = hash[:inviter_user_id]
      @accepted_at = hash[:accepted_at]
      @revoked_at = hash[:revoked_at]
      @expires_at = hash[:expires_at]
      @created_at = hash[:created_at]
      @updated_at = hash[:updated_at]
    end
    # rubocop:enable Metrics/AbcSize

    def to_json(*)
      {
        id: id,
        email: email,
        state: state,
        token: token,
        accept_invitation_url: accept_invitation_url,
        organization_id: organization_id,
        inviter_user_id: inviter_user_id,
        accepted_at: accepted_at,
        revoked_at: revoked_at,
        expires_at: expires_at,
        created_at: created_at,
        updated_at: updated_at,
      }
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
workos-5.9.0 lib/workos/invitation.rb
workos-5.8.0 lib/workos/invitation.rb
workos-5.7.0 lib/workos/invitation.rb
workos-5.6.0 lib/workos/invitation.rb
workos-5.5.1 lib/workos/invitation.rb
workos-5.5.0 lib/workos/invitation.rb
workos-5.4.0 lib/workos/invitation.rb
workos-5.3.0 lib/workos/invitation.rb
workos-5.2.1 lib/workos/invitation.rb
workos-5.2.0 lib/workos/invitation.rb
workos-5.1.0 lib/workos/invitation.rb
workos-5.0.0 lib/workos/invitation.rb
workos-4.8.0 lib/workos/invitation.rb