Options
All
  • Public
  • Public/Protected
  • All
Menu

Class UserClient

The ApiClient used for making API requests to Twitter on behalf of a user. If an access token and access token secret are configured, this client will automatically signed each request using the OAuth1.0a protocol.

Hierarchy

  • ApiClient
    • UserClient

Index

Constructors

constructor

Properties

Protected client

client: AxiosInstance

config

config: Config

Private oAuthClient

oAuthClient: OAuth

Methods

get

  • get<T>(url: string, config?: AxiosRequestConfig): Promise<T>
  • A generic GET request.

    Type parameters

    • T

    Parameters

    • url: string
    • config: AxiosRequestConfig = ...

    Returns Promise<T>

getAccessToken

  • getAccessToken(__namedParameters: {}): Promise<unknown>
  • Request an access token and access token secret. This is done after retrieing an OAuth token and verifier from Twitters authorization server

    Parameters

    • __namedParameters: {}
      • [k: string]: string

    Returns Promise<unknown>

getRequestToken

  • getRequestToken(callbackUrl: string): Promise<string>
  • Start the OAuth ceremony. This will return a request token which will be used to send a user to Twitters authorization server.

    Parameters

    • callbackUrl: string

    Returns Promise<string>

getStream

  • getStream(url: string, config?: AxiosRequestConfig): Promise<StreamEventEmitter>
  • Creates an event emitter stream from a GET request. This application/x-www-form-urlencoded content-type.

    Parameters

    • url: string
    • config: AxiosRequestConfig = ...

    Returns Promise<StreamEventEmitter>

post

  • post<T>(url: string, body: any, config?: AxiosRequestConfig): Promise<T>
  • A generic POST request

    Type parameters

    • T

    Parameters

    • url: string
    • body: any
    • config: AxiosRequestConfig = ...

    Returns Promise<T>

postForm

  • postForm<T>(url: string, body: any, config?: AxiosRequestConfig): Promise<T>
  • A POST request which stringifys the body. This submits application/x-www-form-urlencoded content-type

    Type parameters

    • T

    Parameters

    • url: string
    • body: any
    • config: AxiosRequestConfig = ...

    Returns Promise<T>

postStream

  • postStream(url: string, body: any, config?: AxiosRequestConfig): Promise<StreamEventEmitter>
  • Creates an event emitter stream from a POST request. This application/x-www-form-urlencoded content-type.

    Parameters

    • url: string
    • body: any
    • config: AxiosRequestConfig = ...

    Returns Promise<StreamEventEmitter>

put

  • put<T>(url: string, body: any, config?: AxiosRequestConfig): Promise<T>
  • A generic PUT request

    Type parameters

    • T

    Parameters

    • url: string
    • body: any
    • config: AxiosRequestConfig = ...

    Returns Promise<T>

putForm

  • putForm<T>(url: string, body: any, config?: AxiosRequestConfig): Promise<T>
  • A PUT request which stringifys the body. This submits application/x-www-form-urlencoded content-type

    Type parameters

    • T

    Parameters

    • url: string
    • body: any
    • config: AxiosRequestConfig = ...

    Returns Promise<T>

setAccessToken

  • setAccessToken(accessToken: string): void
  • Set a new accessToken on the configuration

    Parameters

    • accessToken: string

    Returns void

setAccessTokenSecret

  • setAccessTokenSecret(accessTokenSecret: string): void
  • Set a new accessTokenSecret on the configuration

    Parameters

    • accessTokenSecret: string

    Returns void

Generated using TypeDoc