import { ApiResponse , RequestOptions } from '../core' ; import { CancelSubscriptionResponse , cancelSubscriptionResponseSchema , } from '../models/cancelSubscriptionResponse' ; import { CreateSubscriptionRequest , createSubscriptionRequestSchema , } from '../models/createSubscriptionRequest' ; import { CreateSubscriptionResponse , createSubscriptionResponseSchema , } from '../models/createSubscriptionResponse' ; import { DeleteSubscriptionActionResponse , deleteSubscriptionActionResponseSchema , } from '../models/deleteSubscriptionActionResponse' ; import { ListSubscriptionEventsResponse , listSubscriptionEventsResponseSchema , } from '../models/listSubscriptionEventsResponse' ; import { PauseSubscriptionRequest , pauseSubscriptionRequestSchema , } from '../models/pauseSubscriptionRequest' ; import { PauseSubscriptionResponse , pauseSubscriptionResponseSchema , } from '../models/pauseSubscriptionResponse' ; import { ResumeSubscriptionRequest , resumeSubscriptionRequestSchema , } from '../models/resumeSubscriptionRequest' ; import { ResumeSubscriptionResponse , resumeSubscriptionResponseSchema , } from '../models/resumeSubscriptionResponse' ; import { RetrieveSubscriptionResponse , retrieveSubscriptionResponseSchema , } from '../models/retrieveSubscriptionResponse' ; import { SearchSubscriptionsRequest , searchSubscriptionsRequestSchema , } from '../models/searchSubscriptionsRequest' ; import { SearchSubscriptionsResponse , searchSubscriptionsResponseSchema , } from '../models/searchSubscriptionsResponse' ; import { SwapPlanRequest , swapPlanRequestSchema , } from '../models/swapPlanRequest' ; import { SwapPlanResponse , swapPlanResponseSchema , } from '../models/swapPlanResponse' ; import { UpdateSubscriptionRequest , updateSubscriptionRequestSchema , } from '../models/updateSubscriptionRequest' ; import { UpdateSubscriptionResponse , updateSubscriptionResponseSchema , } from '../models/updateSubscriptionResponse' ; import { number , optional , string } from '../schema' ; import { BaseApi } from './baseApi' ; export class SubscriptionsApi extends BaseApi { param body return async createSubscription ( body , requestOptions ? ) { const req = this . createRequest ( 'POST' , '/v2/subscriptions' ) ; const mapped = req . prepareArgs ( { body : [ body , createSubscriptionRequestSchema ] , } ) ; req . header ( 'Content-Type' , 'application/json' ) ; req . json ( mapped . body ) ; return req . callAsJson ( createSubscriptionResponseSchema , requestOptions ) ; } param body return async searchSubscriptions ( body , requestOptions ? ) { const req = this . createRequest ( 'POST' , '/v2/subscriptions/search' ) ; const mapped = req . prepareArgs ( { body : [ body , searchSubscriptionsRequestSchema ] , } ) ; req . header ( 'Content-Type' , 'application/json' ) ; req . json ( mapped . body ) ; return req . callAsJson ( searchSubscriptionsResponseSchema , requestOptions ) ; } param subscriptionId param include return async retrieveSubscription ( subscriptionId , include ? , requestOptions ? ) { const req = this . createRequest ( 'GET' ) ; const mapped = req . prepareArgs ( { subscriptionId : [ subscriptionId , string ( ) ] , include : [ include , optional ( string ( ) ) ] , } ) ; req . query ( 'include' , mapped . include ) ; req . appendTemplatePath `/v2/subscriptions/${ mapped . subscriptionId }` ; return req . callAsJson ( retrieveSubscriptionResponseSchema , requestOptions ) ; } param subscriptionId param body return async updateSubscription ( subscriptionId , body , requestOptions ? ) { const req = this . createRequest ( 'PUT' ) ; const mapped = req . prepareArgs ( { subscriptionId : [ subscriptionId , string ( ) ] , body : [ body , updateSubscriptionRequestSchema ] , } ) ; req . header ( 'Content-Type' , 'application/json' ) ; req . json ( mapped . body ) ; req . appendTemplatePath `/v2/subscriptions/${ mapped . subscriptionId }` ; return req . callAsJson ( updateSubscriptionResponseSchema , requestOptions ) ; } param subscriptionId param actionId return async deleteSubscriptionAction ( subscriptionId , actionId , requestOptions ? ) { const req = this . createRequest ( 'DELETE' ) ; const mapped = req . prepareArgs ( { subscriptionId : [ subscriptionId , string ( ) ] , actionId : [ actionId , string ( ) ] , } ) ; req . appendTemplatePath `/v2/subscriptions/${ mapped . subscriptionId }/actions/${ mapped . actionId }` ; return req . callAsJson ( deleteSubscriptionActionResponseSchema , requestOptions ) ; } param subscriptionId return async cancelSubscription ( subscriptionId , requestOptions ? ) { const req = this . createRequest ( 'POST' ) ; const mapped = req . prepareArgs ( { subscriptionId : [ subscriptionId , string ( ) ] , } ) ; req . appendTemplatePath `/v2/subscriptions/${ mapped . subscriptionId }/cancel` ; return req . callAsJson ( cancelSubscriptionResponseSchema , requestOptions ) ; } param subscriptionId param cursor param limit return async listSubscriptionEvents ( subscriptionId , cursor ? , limit ? , requestOptions ? ) { const req = this . createRequest ( 'GET' ) ; const mapped = req . prepareArgs ( { subscriptionId : [ subscriptionId , string ( ) ] , cursor : [ cursor , optional ( string ( ) ) ] , limit : [ limit , optional ( number ( ) ) ] , } ) ; req . query ( 'cursor' , mapped . cursor ) ; req . query ( 'limit' , mapped . limit ) ; req . appendTemplatePath `/v2/subscriptions/${ mapped . subscriptionId }/events` ; return req . callAsJson ( listSubscriptionEventsResponseSchema , requestOptions ) ; } param subscriptionId param body return async pauseSubscription ( subscriptionId , body , requestOptions ? ) { const req = this . createRequest ( 'POST' ) ; const mapped = req . prepareArgs ( { subscriptionId : [ subscriptionId , string ( ) ] , body : [ body , pauseSubscriptionRequestSchema ] , } ) ; req . header ( 'Content-Type' , 'application/json' ) ; req . json ( mapped . body ) ; req . appendTemplatePath `/v2/subscriptions/${ mapped . subscriptionId }/pause` ; return req . callAsJson ( pauseSubscriptionResponseSchema , requestOptions ) ; } param subscriptionId param body return async resumeSubscription ( subscriptionId , body , requestOptions ? ) { const req = this . createRequest ( 'POST' ) ; const mapped = req . prepareArgs ( { subscriptionId : [ subscriptionId , string ( ) ] , body : [ body , resumeSubscriptionRequestSchema ] , } ) ; req . header ( 'Content-Type' , 'application/json' ) ; req . json ( mapped . body ) ; req . appendTemplatePath `/v2/subscriptions/${ mapped . subscriptionId }/resume` ; return req . callAsJson ( resumeSubscriptionResponseSchema , requestOptions ) ; } param subscriptionId param body return async swapPlan ( subscriptionId , body , requestOptions ? ) { const req = this . createRequest ( 'POST' ) ; const mapped = req . prepareArgs ( { subscriptionId : [ subscriptionId , string ( ) ] , body : [ body , swapPlanRequestSchema ] , } ) ; req . header ( 'Content-Type' , 'application/json' ) ; req . json ( mapped . body ) ; req . appendTemplatePath `/v2/subscriptions/${ mapped . subscriptionId }/swap-plan` ; return req . callAsJson ( swapPlanResponseSchema , requestOptions ) ; } }