Class: MagicAdmin::Resource::User
- Inherits:
-
Object
- Object
- MagicAdmin::Resource::User
- Defined in:
- lib/magic-admin/resource/user.rb
Overview
The user resource and its methods are accessible on the Magic instance by the User attribute. It provides methods to interact with the User.
Instance Attribute Summary collapse
-
#magic ⇒ Object
readonly
attribute reader for magic client object.
Instance Method Summary collapse
-
#get_metadata_by_issuer(issuer, wallet_type = MagicAdmin::Resource::WalletType::NONE) ⇒ Object
Description: Method Retrieves information about the user by the supplied issuer.
-
#get_metadata_by_public_address(public_address, wallet_type = MagicAdmin::Resource::WalletType::NONE) ⇒ Object
Description: Method Retrieves information about the user by the supplied public_address and wallet type.
-
#get_metadata_by_token(did_token, wallet_type = MagicAdmin::Resource::WalletType::NONE) ⇒ Object
Description: Method Retrieves information about the user by the supplied DID Token and wallet type.
-
#initialize(magic) ⇒ User
constructor
The constructor allows you to create user object when your application interacting with the Magic API.
-
#logout_by_issuer(issuer) ⇒ Object
Description: Method logs a user out of all Magic SDK sessions by the supplied issuer.
-
#logout_by_public_address(public_address) ⇒ Object
Description: Method logs a user out of all Magic SDK sessions by the supplied public_address.
-
#logout_by_token(did_token) ⇒ Object
Description: Method logs a user out of all Magic SDK sessions by the supplied DID Token.
Constructor Details
#initialize(magic) ⇒ User
The constructor allows you to create user object when your application interacting with the Magic API
Arguments:
magic: A Magic object.
Returns:
A user object that provides access to all the supported resources.
Examples:
User.new(<magic>)
26 27 28 |
# File 'lib/magic-admin/resource/user.rb', line 26 def initialize(magic) @magic = magic end |
Instance Attribute Details
#magic ⇒ Object (readonly)
attribute reader for magic client object
13 14 15 |
# File 'lib/magic-admin/resource/user.rb', line 13 def magic @magic end |
Instance Method Details
#get_metadata_by_issuer(issuer, wallet_type = MagicAdmin::Resource::WalletType::NONE) ⇒ Object
Description:
Method Retrieves information about the user by
the supplied issuer
Arguments:
issuer: Extracted iss component of DID Token generated by a Magic user
on the client-side.
wallet_type: The type of wallet to retrieve. To query specific wallet(s),
the value passed must be consistent with the enumerated values in
MagicAdmin::Resource::WalletType. ALL wallets will be returned if wallet_type=ANY
is passed. If the wallet_type is None or does not match any WalletType
enums, then no wallets are returned.
Returns:
Metadata information about the user
45 46 47 48 49 50 |
# File 'lib/magic-admin/resource/user.rb', line 45 def (issuer, wallet_type=MagicAdmin::Resource::WalletType::NONE) headers = MagicAdmin::Util.headers(magic.secret_key) = { params: { issuer: issuer , wallet_type: wallet_type }, headers: headers } magic.http_client .call(:get, "/v1/admin/auth/user/get", ) end |
#get_metadata_by_public_address(public_address, wallet_type = MagicAdmin::Resource::WalletType::NONE) ⇒ Object
Description:
Method Retrieves information about the user by
the supplied public_address and wallet type
Arguments:
public_address: Extracted The user's Ethereum public address component
of DID Token generated by a Magic user on the client-side.
wallet_type: The type of wallet to retrieve. To query specific wallet(s),
the value passed must be consistent with the enumerated values in
MagicAdmin::Resource::WalletType. ALL wallets will be returned if wallet_type=ANY
is passed. If the wallet_type is None or does not match any WalletType
enums, then no wallets are returned.
Returns:
Metadata information about the user
67 68 69 70 |
# File 'lib/magic-admin/resource/user.rb', line 67 def (public_address, wallet_type=MagicAdmin::Resource::WalletType::NONE) issuer = token.construct_issuer_with_public_address(public_address) (issuer, wallet_type) end |
#get_metadata_by_token(did_token, wallet_type = MagicAdmin::Resource::WalletType::NONE) ⇒ Object
Description:
Method Retrieves information about the user by
the supplied DID Token and wallet type
Arguments:
did_token: A DID Token generated by a Magic user on the client-side.
wallet_type: The type of wallet to retrieve. To query specific wallet(s),
the value passed must be consistent with the enumerated values in
MagicAdmin::Resource::WalletType. ALL wallets will be returned if wallet_type=ANY
is passed. If the wallet_type is None or does not match any WalletType
enums, then no wallets are returned.
Returns:
Metadata information about the user
86 87 88 89 |
# File 'lib/magic-admin/resource/user.rb', line 86 def (did_token, wallet_type=MagicAdmin::Resource::WalletType::NONE) issuer = token.get_issuer(did_token) (issuer, wallet_type) end |
#logout_by_issuer(issuer) ⇒ Object
101 102 103 104 105 106 |
# File 'lib/magic-admin/resource/user.rb', line 101 def logout_by_issuer(issuer) headers = MagicAdmin::Util.headers(magic.secret_key) = { params: { issuer: issuer }, headers: headers } magic.http_client .call(:post, "/v2/admin/auth/user/logout", ) end |
#logout_by_public_address(public_address) ⇒ Object
118 119 120 121 |
# File 'lib/magic-admin/resource/user.rb', line 118 def logout_by_public_address(public_address) issuer = token.construct_issuer_with_public_address(public_address) logout_by_issuer(issuer) end |
#logout_by_token(did_token) ⇒ Object
132 133 134 135 |
# File 'lib/magic-admin/resource/user.rb', line 132 def logout_by_token(did_token) issuer = token.get_issuer(did_token) logout_by_issuer(issuer) end |