import { ApiResponse , RequestOptions } from '../core' ; import { CreateDeviceCodeRequest , createDeviceCodeRequestSchema , } from '../models/createDeviceCodeRequest' ; import { CreateDeviceCodeResponse , createDeviceCodeResponseSchema , } from '../models/createDeviceCodeResponse' ; import { GetDeviceCodeResponse , getDeviceCodeResponseSchema , } from '../models/getDeviceCodeResponse' ; import { ListDeviceCodesResponse , listDeviceCodesResponseSchema , } from '../models/listDeviceCodesResponse' ; import { optional , string } from '../schema' ; import { BaseApi } from './baseApi' ; export class DevicesApi extends BaseApi { param cursor param locationId param productType param status return async listDeviceCodes ( cursor ? , locationId ? , productType ? , status ? , requestOptions ? ) { const req = this . createRequest ( 'GET' , '/v2/devices/codes' ) ; const mapped = req . prepareArgs ( { cursor : [ cursor , optional ( string ( ) ) ] , locationId : [ locationId , optional ( string ( ) ) ] , productType : [ productType , optional ( string ( ) ) ] , status : [ status , optional ( string ( ) ) ] , } ) ; req . query ( 'cursor' , mapped . cursor ) ; req . query ( 'location_id' , mapped . locationId ) ; req . query ( 'product_type' , mapped . productType ) ; req . query ( 'status' , mapped . status ) ; return req . callAsJson ( listDeviceCodesResponseSchema , requestOptions ) ; } param body return async createDeviceCode ( body , requestOptions ? ) { const req = this . createRequest ( 'POST' , '/v2/devices/codes' ) ; const mapped = req . prepareArgs ( { body : [ body , createDeviceCodeRequestSchema ] , } ) ; req . header ( 'Content-Type' , 'application/json' ) ; req . json ( mapped . body ) ; return req . callAsJson ( createDeviceCodeResponseSchema , requestOptions ) ; } param id return async getDeviceCode ( id , requestOptions ? ) { const req = this . createRequest ( 'GET' ) ; const mapped = req . prepareArgs ( { id : [ id , string ( ) ] } ) ; req . appendTemplatePath `/v2/devices/codes/${ mapped . id }` ; return req . callAsJson ( getDeviceCodeResponseSchema , requestOptions ) ; } }