import { ApiResponse , RequestOptions } from '../core' ; import { DeleteSnippetResponse , deleteSnippetResponseSchema , } from '../models/deleteSnippetResponse' ; import { RetrieveSnippetResponse , retrieveSnippetResponseSchema , } from '../models/retrieveSnippetResponse' ; import { UpsertSnippetRequest , upsertSnippetRequestSchema , } from '../models/upsertSnippetRequest' ; import { UpsertSnippetResponse , upsertSnippetResponseSchema , } from '../models/upsertSnippetResponse' ; import { string } from '../schema' ; import { BaseApi } from './baseApi' ; export class SnippetsApi extends BaseApi { param siteId return async deleteSnippet ( siteId , requestOptions ? ) { const req = this . createRequest ( 'DELETE' ) ; const mapped = req . prepareArgs ( { siteId : [ siteId , string ( ) ] } ) ; req . appendTemplatePath `/v2/sites/${ mapped . siteId }/snippet` ; return req . callAsJson ( deleteSnippetResponseSchema , requestOptions ) ; } param siteId return async retrieveSnippet ( siteId , requestOptions ? ) { const req = this . createRequest ( 'GET' ) ; const mapped = req . prepareArgs ( { siteId : [ siteId , string ( ) ] } ) ; req . appendTemplatePath `/v2/sites/${ mapped . siteId }/snippet` ; return req . callAsJson ( retrieveSnippetResponseSchema , requestOptions ) ; } param siteId param body return async upsertSnippet ( siteId , body , requestOptions ? ) { const req = this . createRequest ( 'POST' ) ; const mapped = req . prepareArgs ( { siteId : [ siteId , string ( ) ] , body : [ body , upsertSnippetRequestSchema ] , } ) ; req . header ( 'Content-Type' , 'application/json' ) ; req . json ( mapped . body ) ; req . appendTemplatePath `/v2/sites/${ mapped . siteId }/snippet` ; return req . callAsJson ( upsertSnippetResponseSchema , requestOptions ) ; } }