Class FetcherServiceInternal

The base service that handles all HTTP requests.

Hierarchy

Constructors

Properties

authProxyUrl?: URL

The URL to the proxy server to use for authentication.

cred?: AuthCredential

The credential to use for authenticating against Twitter API.

errorHandler: IErrorHandler

The service used to handle HTTP and API errors

httpsAgent: Agent

The HTTPS Agent to use for requests to Twitter API.

isAuthenticated: boolean

Whether the instance is authenticated or not.

logger: LogService

The log service instance to use to logging.

timeout: number

The max wait time for a response.

Methods

  • Checks the authorization status based on the requested resource.

    Parameters

    • resourceType: EResourceType

      The type of resource to fetch.

    Returns void

    Throws

    An error if not authorized to access the requested resource.

  • Deserializes the extracted data into a cursored list.

    Type Parameters

    Parameters

    • extractedData: (ITweet | IUser)[] = []

      The list of extracted data.

    • next: string = ''

      The cursor to the next batch of data.

    Returns CursoredData<OutType>

    The cursored data object.

  • Extracts the required data based on the type of resource passed as argument.

    Parameters

    • data: {}

      The data from which extraction is to be done.

      • type: EResourceType

        The type of data to extract.

      Returns {
          next: string;
          required: (ITweet | IUser)[];
      }

      The extracted data.

      • next: string

        The cursor string to the next batch of data.

      • required: (ITweet | IUser)[]

        The required extracted data.

    • Fetches the requested resource from Twitter and returns it after processing.

      Type Parameters

      • OutType extends User | Tweet

        The type of deserialized data returned.

      Parameters

      • resourceType: EResourceType

        The type of resource to fetch.

      • args: FetchArgs

        Resource specific arguments.

      Returns Promise<CursoredData<OutType>>

      The processed data requested from Twitter.

    • Returns an AuthCredential generated using the given API key.

      Parameters

      • apiKey: string

        The API key to use for authenticating.

      Returns AuthCredential

      The generated AuthCredential.

    • Returns an AuthCredential generated using the given guest key.

      Parameters

      • guestKey: string

        The guest key to use for authenticating as guest.

      Returns AuthCredential

      The generated AuthCredential.

    • Gets the HttpsAgent based on whether a proxy is used or not.

      Parameters

      • Optional proxyUrl: URL

        Optional URL with proxy configuration to use for requests to Twitter API.

      Returns Agent

      The HttpsAgent to use.

    • Posts the requested resource to Twitter and returns the response.

      Parameters

      • resourceType: EResourceType

        The type of resource to post.

      • args: PostArgs

        Resource specific arguments.

      Returns Promise<boolean>

      Whether posting was successful or not.

    • Makes an HTTP request according to the given parameters.

      Type Parameters

      • ResType

        The type of the returned response data.

      Parameters

      • config: AxiosRequestConfig<any>

        The request configuration.

      Returns Promise<AxiosResponse<ResType, any>>

      The response received.

    • Uploads the given media file to Twitter

      Parameters

      • media: string

        The path to the media file to upload.

      Returns Promise<string>

      The id of the uploaded media.

    Generated using TypeDoc