Skip to the content.

@goodwaygroup/lib-tradedesk - v1.3.1 / TradeDesk

Class: TradeDesk

Table of contents

Constructors

Properties

Methods

Constructors

constructor

+ new TradeDesk(options?: TradeDeskOptions): TradeDesk

Parameters

Name Type
options TradeDeskOptions

Returns: TradeDesk

Defined in: src/tradedesk.ts:69

Properties

options

options: TradeDeskOptions

Options used to make requests

Defined in: src/tradedesk.ts:69


token

token: string= ‘’

The authentication token

Defined in: src/tradedesk.ts:59


tokenTime

tokenTime: number

The time when the token was last set. This works to refresh a token before trying request with an expired token

Defined in: src/tradedesk.ts:64

Methods

canLogin

Private canLogin(): boolean

Does this instance have enough data to attempt a login

Returns: boolean

Defined in: src/tradedesk.ts:195


delete

delete(uri: string, options?: RequestInit): Promise<Response>

Create a DELETE request

Parameters

Name Type
uri string
options RequestInit

Returns: Promise<Response>

Defined in: src/tradedesk.ts:338


get

get(uri: string, options?: RequestInit): Promise<Response>

Create a GET request

Parameters

Name Type
uri string
options RequestInit

Returns: Promise<Response>

Defined in: src/tradedesk.ts:287


login

login(): Promise<TradeDesk>

Login to TradeDesk API and grab an authentication token

Returns: Promise<TradeDesk>

Defined in: src/tradedesk.ts:119

login(username: string, password: string, tokenExpiration?: number): Promise<TradeDesk>

Login to TradeDesk API and grab an authentication token

Parameters

Name Type Description
username string The login of the user requesting the authentication token.
password string The login of the user requesting the authentication token.
tokenExpiration? number The number of minutes until the token expires. If this parameter is not set or set to zero, the token will not expire

Returns: Promise<TradeDesk>

Defined in: src/tradedesk.ts:128


makeUrl

Private makeUrl(uri: string): string

Make URL by combining the apiUrl and the given uri

Parameters

Name Type
uri string

Returns: string

Defined in: src/tradedesk.ts:188


post

post(uri: string, payload: Record<string, unknown>, options?: RequestInit): Promise<Response>

Create a POST request

Parameters

Name Type
uri string
payload Record<string, unknown>
options RequestInit

Returns: Promise<Response>

Defined in: src/tradedesk.ts:300


put

put(uri: string, payload: Record<string, unknown>, options?: RequestInit): Promise<Response>

Create a PUT request

Parameters

Name Type
uri string
payload Record<string, unknown>
options RequestInit

Returns: Promise<Response>

Defined in: src/tradedesk.ts:319


request

Private request(uri: string, options: RequestInit, attempts?: number, tryLogin?: boolean): Promise<Response>

Make a http request with node-fetch with builtin retries and automatic login

Parameters

Name Type Default value
uri string -
options RequestInit -
attempts number 0
tryLogin boolean true

Returns: Promise<Response>

Defined in: src/tradedesk.ts:202


setApiUrl

setApiUrl(environment: ApiUrlEnvironments): TradeDesk

Set the API url based on an enumerated list

Parameters

Name Type
environment ApiUrlEnvironments

Returns: TradeDesk

Defined in: src/tradedesk.ts:97

setApiUrl(url: string): TradeDesk

Set the API Url to an explicit url

Parameters

Name Type
url string

Returns: TradeDesk

Defined in: src/tradedesk.ts:102


setToken

setToken(token: string): TradeDesk

Parameters

Name Type
token string

Returns: TradeDesk

Defined in: src/tradedesk.ts:81