Class: TorqueUserClient
@torque-labs/torque-ts-sdk • Docs
@torque-labs/torque-ts-sdk / TorqueUserClient
Class: TorqueUserClient
The TorqueUserClient class is used to authenticate a user with the Torque API. The user client allows publishers to fetch campaigns and offers that are savailable for the current user.
Example
Constructors
new TorqueUserClient()
Create a new instance of the TorqueUserClient class with the publisher's handle, if provided.
Parameters
Parameter | Type | Description |
---|---|---|
| The options for the TorqueUserClient. |
Returns
Throws
Throws an error if the user's wallet is not provided.
Defined in
Properties
Property | Type |
---|---|
|
|
|
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Methods
acceptCampaign()
Initiate a user journey to accept a campaign for the current user.
Parameters
Parameter | Type | Description |
---|---|---|
|
| The ID of the campaign to accept. |
|
| The handle of the publisher to accept the campaign for. |
Returns
Promise
<ApiUserJourney
>
A Promise that resolves to the journey data for the campaign.
Throws
Throws an error if the client is not initialized or if there is an error accepting the campaign.
Defined in
authTelegram()
Links user's telegram account to their Torque account.
Parameters
Parameter | Type |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Returns
Promise
<ApiTelegramAuth
>
The data associated with the shared link if the request is successful.
Throws
Throws an error there was an error getting the shared link data.
Defined in
confirmActionSignature()
Sends a signed message to the Torque API to confirm the user's signature for a requirement.
Parameters
Parameter | Type | Description |
---|---|---|
|
| The ID of the campaign/offer to confirm the signature for. |
|
| The index of the offer requirement within the campaign. |
|
| - |
Returns
Promise
<ActionPostResponse
>
A Solana action response that contains the next requirement.
Defined in
createCustomEvent()
Creates a new a custom event for the user's account which can be used for custom event requirements during a campaign.
Parameters
Parameter | Type | Description |
---|---|---|
|
| The configuration of the custom event. |
|
| - |
|
| - |
Returns
Promise
<{ id
: string
; }>
A Promise that resolves to the id of the new custom event.
Name | Type |
---|---|
|
|
Defined in
getAllUserShareLinks()
Fetches all of the user's share links that they have previously created.
Returns
Promise
<{ links
: { campaignId
: string
; url
: string
; }[]; }>
A Promise resolving to the URLs of the user's share links.
Name | Type |
---|---|
| { |
Throws
An error if the link fetch fails.
Defined in
getBountyStepAction()
Get the Solana action for a specific bounty/requirement step.
Parameters
Parameter | Type | Description |
---|---|---|
|
| The ID of the campaign to retrieve the journey for. |
|
| The index of the offer requirement to retrieve the transaction for. |
|
| Additional data to be sent with the request. |
Returns
Promise
<ActionPostResponse
>
The Solana Action response which contains the transaction.
Defined in
getCampaignJourney()
Retrieves the user's campaign journey for the specified campaign.
Parameters
Parameter | Type | Description |
---|---|---|
|
| The ID of the campaign to retrieve the journey for. |
Returns
Promise
<undefined
| ApiCampaignJourney
>
A Promise that resolves to the user's campaign journey.
Throws
Throws an error if the client is not initialized or if there is an error getting the journey.
Defined in
getCurrentUser()
Checks to see if the user is already logged into the Torque API.
Returns
Promise
<undefined
| ApiUser
>
A promise that resolves to the user if they are signed in, otherwise undefined.
Throws
Throws an error if checking the user's login status fails.
Defined in
getCustomEvents()
Fetches the user's custom events
Returns
Promise
<{ config
: Record
<string
, CustomEventFieldType
>; id
: string
; name
: string
; }[]>
A Promise that resolves to an array of custom events.
Throws
If the client is not initialized or there was an error fetching the custom events.
Defined in
getJourneys()
Retrieves the user's campaign journeys
Returns
Promise
<undefined
| ApiCampaignJourney
[]>
A Promise that resolves to the user's campaign journey.
Throws
Throws an error if the client is not initialized or if there is an error getting the journey.
Defined in
getMaxTransferableSpl()
Parameters
Parameter | Type |
---|---|
|
|
Returns
Promise
<number
>
Defined in
getOffers()
Retrieves a list of active campaigns from the Torque API that the user is eligible to participate in.
Parameters
Parameter | Type |
---|---|
|
|
Returns
Promise
<{ campaigns
: ApiCampaign
[]; }>
A Promise resolving to an array of ApiCampaign
objects representing the active campaigns.
Name | Type |
---|---|
|
Throws
An error if the fetch operation fails, or if the API returns a status other than "SUCCESS".
Defined in
getPublisherBalance()
Get the balance of the publisher PDA for the current user.
Returns
Promise
<number
>
The balance of the publisher PDA for the current user in lamports.
Defined in
getPublisherPda()
Get the publisher PDA for the current user.
Returns
undefined
| PublicKey
The publisher PDA for the current user.
Defined in
getSharedLinkData()
Retrieves the data for an offer link for a specific campaign and handle.
Parameters
Parameter | Type | Description |
---|---|---|
|
| The unique identifier for the campaign. |
|
| The specific handle associated with the shared link. |
Returns
Promise
<ApiShare
>
The data associated with the shared link if the request is successful.
Throws
Throws an error there was an error getting the shared link data.
Defined in
getUserHandle()
Retrieves the user's handle.
Returns
undefined
| string
The user's handle or undefined
if no handle is available.
Defined in
getUserPayout()
Retrieves user's payout history from conversions.
Returns
Promise
<ApiUserPayout
>
The data associated with the shared link if the request is successful.
Throws
Throws an error there was an error getting the shared link data.
Defined in
getUserShareLink()
Generates a URL for a user's shared link for a specific campaign.
Parameters
Parameter | Type | Description |
---|---|---|
|
| The unique identifier for the campaign. |
Returns
string
A promise that resolves to the URL string of the user's shared link for the campaign.
Throws
Throws an error if the user is not a publisher or does not have a handle.
Defined in
initializeUser()
Initializes the TorqueUserClient with the provided options.
Parameters
Parameter | Type | Description |
---|---|---|
| User signature object that is required to authenticate a user with Torque. |
Returns
Promise
<ApiUser
>
A Promise that resolves when the initialization is complete.
Throws
If user was not verified.
Defined in
isPublisher()
Checks to see if the user is a publisher.
Returns
boolean
True if the user is a publisher, false otherwise.
Throws
Throws an error if the user is not signed in.
Defined in
login()
Authenticate the user with the torque API with the provided user signature object.
Parameters
Parameter | Type | Description |
---|---|---|
| The verification object that is required to authenticate a user with Torque. |
Returns
Promise
<ApiUser
>
A Promise that resolves to an object containing the user information.
Throws
Throws an error if there is an error authenticating the user.
Defined in
logout()
Logout the user from the Torque API.
Returns
Promise
<{ cleared
: boolean
; }>
Name | Type |
---|---|
|
|
Throws
Throws an error if the client is not initialized or if there is an error logging out the user.
Defined in
refreshUser()
Rereshes the user's information from the Torque API.
Returns
Promise
<undefined
| ApiUser
>
A promise that resolves to the user if they are signed in, otherwise undefined.
Defined in
setUserPublisher()
Returns
void
Defined in
updateCustomEvent()
Updates an existing custom event for the user's account.
Parameters
Parameter | Type | Description |
---|---|---|
|
| The updated configuration of the custom event. |
|
| - |
|
| - |
|
| - |
Returns
Promise
<{ id
: string
; }>
A Promise that resolves to the id of the updated custom event.
Name | Type |
---|---|
|
|
Defined in
verifyCampaignAudience()
Verifies that the user is part of the audience for a specific campaign.
Parameters
Parameter | Type | Description |
---|---|---|
|
| The ID of the campaign to verify the audience for. |
Returns
Promise
<boolean
>
A Promise that resolves to true if the user is part of the audience for the campaign, false otherwise.
Defined in
Last updated