Documentation

Mistake on this page? Email us

DeviceRequestsApi

Hierarchy

  • ApiBase
    • DeviceRequestsApi

Index

Constructors

constructor

  • Parameters

    • Optional options: ConnectionOptions
    • Default value responseHandler: function =¬†null
        • (sdkError: SDKError, response: superagent.Response): any
        • Parameters

          • sdkError: SDKError
          • response: superagent.Response

          Returns any

    Returns DeviceRequestsApi

Methods

complete

  • complete(error: any, response: any, acceptHeader: string, callback?: function): void
  • Parameters

    • error: any
    • response: any
    • acceptHeader: string
    • Optional callback: function
        • Parameters

          Returns any

    Returns void

createAsyncRequest

  • createAsyncRequest(deviceId: string, asyncId: string, body: DeviceRequest, callback?: function, requestOptions?: object): superagent.SuperAgentRequest
  • Send an async request to device This API provides an interface to asynchronously call methods on a device. The `async-id` is provided by the client, enabling the client to track the end-to-end flow with an identifier that is relevant to the end application. For example, a web application's session ID along with the device ID and the resource path could be used as the `async-id`. This also avoids any race conditions with the notification channel. All responses are sent through the currently configured notification channel as an AsyncIDResponse. For `GET` methods, values may be fetched from an internal cache, instead of contacting the device. See also /v2/endpoints/{device-id}/{resourcePath}. ``` Example URI: POST /v2/device-requests/015f2fa34d310000000000010030036c?async-id=123e4567-e89b-12d3-a456-426655440000 Example payloads: { "method": "GET", "uri": "/5/0/1" } { "method": "PUT", "uri": "/5/0/1%20?k1=v1&k2=v2%22", "accept": "text/plain", "content-type": "text/plain", "payload-b64": "dmFsdWUxCg==" } Immediate response: 202 Accepted Example AsyncIDResponse, delivered via the notification channel: { "async-responses": [ { "id": "123e4567-e89b-12d3-a456-426655440000", "status": 200, "payload": "dmFsdWUxCg==", "ct": "text/plain", "max-age": 600 } ] } ```

    Parameters

    • deviceId: string

      The device ID generated by Device Management.

    • asyncId: string

      The client-generated ID for matching the correct response delivered via a notification.

    • body: DeviceRequest

      Device request to send.

    • Optional callback: function
        • (error: any, data?: any, response?: superagent.Response): any
        • Parameters

          • error: any
          • Optional data: any
          • Optional response: superagent.Response

          Returns any

    • Optional requestOptions: object
      • [key: string]: any

    Returns superagent.SuperAgentRequest

currentConfig

  • currentConfig(): object
  • Returns the current configuration of this API module

    Returns object

    • apiKey: any
    • host: any

request

  • request<T>(options: object, callback?: function): superagent.SuperAgentRequest
  • Type parameters

    • T

    Parameters

    • options: object
      • acceptTypes: Array<string>
      • Optional body?: any
      • contentTypes: Array<string>
      • Optional file?: boolean
      • formParams: __type
      • headers: object
        • [key: string]: string
      • method: string
      • query: __type
      • Optional requestOptions?: object
        • [key: string]: any
      • url: string
      • useFormData: boolean
    • Optional callback: function
        • Parameters

          Returns any

    Returns superagent.SuperAgentRequest