Sha256: 49bb79c793357b1b0d4d21aa8b7e7febddbb80c1d897947dc91bb9bf904fa341

Contents?: true

Size: 608 Bytes

Versions: 23

Compression:

Stored size: 608 Bytes

Contents

# frozen_string_literal: true

module WorkOS
  # The UserAndToken class represents a User and a corresponding Token. This
  # class is not meant to be instantiated in user space, and is instantiated
  # internally but exposed.
  class UserAndToken
    include HashProvider

    attr_accessor :token, :user

    def initialize(user_and_token_json)
      json = JSON.parse(user_and_token_json, symbolize_names: true)

      @token = json[:token]
      @user = WorkOS::User.new(json[:user].to_json)
    end

    def to_json(*)
      {
        token: token,
        user: user.to_json,
      }
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
workos-5.13.0 lib/workos/user_and_token.rb
workos-5.12.0 lib/workos/user_and_token.rb
workos-5.11.1 lib/workos/user_and_token.rb
workos-5.11.0 lib/workos/user_and_token.rb
workos-5.10.0 lib/workos/user_and_token.rb
workos-5.9.0 lib/workos/user_and_token.rb
workos-5.8.0 lib/workos/user_and_token.rb
workos-5.7.0 lib/workos/user_and_token.rb
workos-5.6.0 lib/workos/user_and_token.rb
workos-5.5.1 lib/workos/user_and_token.rb
workos-5.5.0 lib/workos/user_and_token.rb
workos-5.4.0 lib/workos/user_and_token.rb
workos-5.3.0 lib/workos/user_and_token.rb
workos-5.2.1 lib/workos/user_and_token.rb
workos-5.2.0 lib/workos/user_and_token.rb
workos-5.1.0 lib/workos/user_and_token.rb
workos-5.0.0 lib/workos/user_and_token.rb
workos-4.8.0 lib/workos/user_and_token.rb
workos-4.5.0 lib/workos/user_and_token.rb
workos-4.4.0 lib/workos/user_and_token.rb