TorqueOffersModule

@torque-labs/sdk


@torque-labs/sdk / TorqueOffersModule

Class: TorqueOffersModule

Defined in: sdk/src/modules/offers.ts:40

The TorqueOffersModule class is used to interact with the offers endpoints of the Torque API.

Param

The URL of the Torque API server

Param

The auth token for the API

Constructors

new TorqueOffersModule()

new TorqueOffersModule(
   url, 
   transactions, 
   token?): TorqueOffersModule

Defined in: sdk/src/modules/offers.ts:48

Parameters

Parameter
Type

url

string

token?

string

Returns

TorqueOffersModule

Properties

Property
Type

_publicKey

undefined | string

_token

undefined | string

baseUrl

string

Accessors

publicKey

Set Signature

set publicKey(value): void

Defined in: sdk/src/modules/offers.ts:67

Set private public key for the offers module

Parameters

Parameter
Type

value

undefined | string

Returns

void


token

Set Signature

set token(value): void

Defined in: sdk/src/modules/offers.ts:59

Set private token for the offers module

Parameters

Parameter
Type

value

undefined | string

Returns

void

Methods

addDistributor()

addDistributor(offerid, distributor): Promise<DistributorResponse>

Defined in: sdk/src/modules/offers.ts:223

Adds a reward distributor to an offer

Parameters

Parameter
Type
Description

offerId

string

The offerId of the offer to add the distributor to

distributor

The distributor input parameters

Returns

Promise<DistributorResponse>

The created distributor object


chooseAsymmetricRewardWinner()

chooseAsymmetricRewardWinner(distributorid): Promise<{
  publicKey: string;
  winner: string;
}>

Defined in: sdk/src/modules/offers.ts:358

Choose asymmetric reward winner

Parameters

Parameter
Type
Description

distributorId

string

The distributorId of the distributor to choose the winner for

Returns

Promise<{publicKey: string;winner: string; }>

The winner of the asymmetric reward


closeDistributor()

closeDistributor(offerid, distributorid): Promise<{
  signature: string;
}>

Defined in: sdk/src/modules/offers.ts:326

Closes the distributor for the given offer and distributor IDs

Parameters

Parameter
Type
Description

offerId

string

The ID of the offer to close the distributor for

distributorId

string

The ID of the distributor to close

Returns

Promise<{signature: string; }>

The signature of the transaction


createOffer()

createOffer(offer): Promise<OfferResponse>

Defined in: sdk/src/modules/offers.ts:119

Create an offer

Parameters

Parameter
Type
Description

offer

The offer input

Returns

Promise<OfferResponse>

The created offer object


createProject()

createProject(projectdata): Promise<ProjectResponse>

Defined in: sdk/src/modules/offers.ts:394

Create a project

Parameters

Parameter
Type
Description

projectData

The project data

Returns

Promise<ProjectResponse>

The created project object


deployDistributor()

deployDistributor(offerid, distributorid): Promise<{
  signature: string;
}>

Defined in: sdk/src/modules/offers.ts:286

Gets the Solana action for deploying a distributor

Parameters

Parameter
Type
Description

offerId

string

The offerId of the offer to add the distributor to

distributorId

string

The distributorId of the distributor to deploy

Returns

Promise<{signature: string; }>

The serialized transaction for the deploy distributor action


getAsymmetricRewardEntries()

getAsymmetricRewardEntries(distributorid): Promise<Record<string, number>>

Defined in: sdk/src/modules/offers.ts:343

Get the asymmetric reward entries for a distributor

Parameters

Parameter
Type
Description

distributorId

string

The distributorId of the distributor to get the entries for

Returns

Promise<Record<string, number>>

The asymmetric reward entries for the distributor


getLeaderboard()

getLeaderboard(projectid, offchainrewardid): Promise<LeaderboardResponse>

Defined in: sdk/src/modules/offers.ts:373

Fetch a leaderboard for the specific off-chain reward

Parameters

Parameter
Type
Description

projectId

string

-

offchainRewardId

string

The id of the off-chain reward to get the leaderboard for

Returns

Promise<LeaderboardResponse>


getOfferById()

getOfferById(id): Promise<OfferResponse>

Defined in: sdk/src/modules/offers.ts:83

Fetch a single offer

Parameters

Parameter
Type
Description

id

string

The offerId of the offer to get

Returns

Promise<OfferResponse>

a single offer


getOffers()

getOffers(
   status, 
   userId?, 
projectId?): Promise<OfferResponse[]>

Defined in: sdk/src/modules/offers.ts:99

Fetch the offers with optional filters for status and userId

Parameters

Parameter
Type
Description

status

(optional) The status of the offer. Defaults to ACTIVE.

userId?

string

(optional) The userId or public key of the offer creator

projectId?

string

-

Returns

Promise<OfferResponse[]>

a list of offers


getProject()

getProject(projectid, includeoffers?): Promise<ProjectResponse>

Defined in: sdk/src/modules/offers.ts:419

Get a project

Parameters

Parameter
Type
Description

projectId

string

The project ID

includeOffers?

boolean

(optional) Whether to include offers in the project response

Returns

Promise<ProjectResponse>

The project object


getProjects()

getProjects(includeoffers?): Promise<ProjectResponse[]>

Defined in: sdk/src/modules/offers.ts:442

Get projects

Parameters

Parameter
Type
Description

includeOffers?

boolean

(optional) Whether to include offers in the project response

Returns

Promise<ProjectResponse[]>

A list of project objects


getUserJourneys()

getUserJourneys(
   offerId, 
   userPubkey?, 
status?): Promise<OfferJourneyReturn[]>

Defined in: sdk/src/modules/offers.ts:201

Get user journeys on the offer

Parameters

Parameter
Type
Description

offerId

string

The offerId of the offer to get the user journeys for

userPubkey?

string

The public key of the user to get the user journeys for

status?

The status of the user journeys to get

Returns

Promise<OfferJourneyReturn[]>


startOffer()

startOffer(offerid, referrer?): Promise<void>

Defined in: sdk/src/modules/offers.ts:174

Accept/start an offer for a user

Parameters

Parameter
Type
Description

offerId

string

The offerId of the offer to accept for the user

referrer?

string

-

Returns

Promise<void>


updateDistributor()

updateDistributor(
   offerId, 
   distributorId, 
distributor): Promise<DistributorResponse>

Defined in: sdk/src/modules/offers.ts:253

Update a distributor

Parameters

Parameter
Type
Description

offerId

string

The ID of the offer that contains the distributor

distributorId

string

The ID of the distributor to update

distributor

The updated distributor data

Returns

Promise<DistributorResponse>

The updated distributor object


updateOffer()

updateOffer(offerid, offer): Promise<OfferResponse>

Defined in: sdk/src/modules/offers.ts:148

Update an offer

Parameters

Parameter
Type
Description

offerId

string

The ID of the offer to update

offer

The updated offer data

Returns

Promise<OfferResponse>

The updated offer object

Last updated