text: /*
   * Sematext Cloud API
   * API Explorer provides access and documentation for Sematext REST API. The REST API requires the API Key to be sent as part of `Authorization` header. E.g.: `Authorization : apiKey e5f18450-205a-48eb-8589-7d49edaea813`.
   *
   * OpenAPI spec version: v3
   *
   * NOTE: This class is auto generated by the swagger code generator program.
   * https://github.com/swagger-api/swagger-codegen.git
   *
   * Swagger Codegen version: 3.0.30
   *
   * Do not edit the class manually.
   *
   */
  import { ApiClient } from '../ApiClient'
  import { GenericMapBasedApiResponse } from '../model/GenericMapBasedApiResponse'
  import { MailReportResponse } from '../model/MailReportResponse'
  import { ReportInfo } from '../model/ReportInfo'
  import { SubscriptionDashboardDto } from '../model/SubscriptionDashboardDto'
  import { SubscriptionDto } from '../model/SubscriptionDto'
  import { SubscriptionResponse } from '../model/SubscriptionResponse'
  import { SubscriptionsResponse } from '../model/SubscriptionsResponse'
  import { UpdateSubscriptionDto } from '../model/UpdateSubscriptionDto'
  
  /**
   * Subscriptions service.
   * @module api/SubscriptionsApi
   * @version 0.4.0
   */
  export class SubscriptionsApi {
    /**
      * Constructs a new SubscriptionsApi. 
      * @alias module:api/SubscriptionsApi
      * @class
      * @param {module:ApiClient} [apiClient] Optional API client implementation to use,
      * default to {@link module:ApiClient#instanc
      e} if unspecified.
      */
    constructor (apiClient) {
      this.apiClient = apiClient || ApiClient.instance
    }
  
    /**
     * Create App subscription
     * @param {module:model/SubscriptionDto} body subscription
     * @param {Number} appId appId
     * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/SubscriptionResponse} and HTTP response
     */
    createForAppUsingPOSTWithHttpInfo (body, appId) {
      let postBody = body
      // verify the required parameter 'body' is set
      if (body === undefined || body === null) {
        throw new Error(
          "Missing the required parameter 'body' when calling createForAppUsingPOST"
        )
      }
      // verify the required parameter 'appId' is set
      if (appId === undefined || appId === null) {
        throw new Error(
          "Missing the required parameter 'appId' when calling createForAppUsingPOST"
        )
      }
  
      let pathParams = {
        appId: appId
      }
      let queryParams = {}
      let headerParams = {}
      let formParams = {}
  
      let authNames = ['api_key']
      let contentTypes = ['application/json']
      let accepts = ['application/json']
      let returnType = SubscriptionResponse
  
      return this.apiClient.callApi(
        '/users-web/api/v3/apps/{appId}/subscription',
        'POST',
        pathParams,
        queryParams,
        headerParams,
        formParams,
        postBody,
        authNames,
        contentTypes,
        accepts,
        returnType
      )
    }
  
    /**
     * Create App subscription
     * @param {<&vendorExtensions.x-jsdoc-type>} body subscription
     * @param {<&vendorExtensions.x-jsdoc-type>} appId appId
     * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/SubscriptionResponse}
     */
    createForAppUsingPOST (body, appId) {
      return this.createForAppUsingPOSTWithHttpInfo(body, appId).then(function (
        response_and_data
      ) {
        return response_and_data.data
      })
    }
  
    /**
     * Create dashboard subscription
     * @param {module:model/SubscriptionDashboardDto} body subscription
     * @param {Number} dashId dashId
     * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/SubscriptionResponse} and HTTP response
     */
    createForDashUsingPOST1WithHttpInfo (body, dashId) {
      let postBody = body
      // verify the required parameter 'body' is set
      if (body === undefined || body === null) {
        throw new Error(
          "Missing the required parameter 'body' when calling createForDashUsingPOST1"
        )
      }
      // verify the required parameter 'dashId' is set
      if (dashId === undefined || dashId === null) {
        throw new Error(
          "Missing the required parameter 'dashId' when calling createForDashUsingPOST1"
        )
      }
  
      let pathParams = {
        dashId: dashId
      }
      let queryParams = {}
      let headerParams = {}
      let formParams = {}
  
      let authNames = ['api_key']
      let contentTypes = ['application/json']
      let accepts = ['application/json']
      let returnType = SubscriptionResponse
  
      return this.apiClient.callApi(
        '/users-web/api/v3/dashboards/{dashId}/subscription',
        'POST',
        pathParams,
        queryParams,
        headerParams,
        formParams,
        postBody,
        authNames,
        contentTypes,
        accepts,
        returnType
      )
    }
  
    /**
     * Create dashboard subscription
     * @param {<&vendorExtensions.x-jsdoc-type>} body subscription
     * @param {<&vendorExtensions.x-jsdoc-type>} dashId dashId
     * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/SubscriptionResponse}
     */
    createForDashUsingPOST1 (body, dashId) {
      return this.createForDashUsingPOST1WithHttpInfo(body, dashId).then(
        function (response_and_data) {
          return response_and_data.data
        }
      )
    }
  
    /**
     * Delete subscription
     * @param {Number} updateableSubscriptionId updateableSubscriptionId
     * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/GenericMapBasedApiResponse} and HTTP response
     */
    deleteUsingDELETE2WithHttpInfo (updateableSubscriptionId) {
      let postBody = null
      // verify the required parameter 'updateableSubscriptionId' is set
      if (
        updateableSubscriptionId === undefined ||
        updateableSubscriptionId === null
      ) {
        throw new Error(
          "Missing the required parameter 'updateableSubscriptionId' when calling deleteUsingDELETE2"
        )
      }
  
      let pathParams = {
        updateableSubscriptionId: updateableSubscriptionId
      }
      let queryParams = {}
      let headerParams = {}
      let formParams = {}
  
      let authNames = ['api_key']
      let contentTypes = []
      let accepts = ['application/json']
      let returnType = GenericMapBasedApiResponse
  
      return this.apiClient.callApi(
        '/users-web/api/v3/subscriptions/{updateableSubscriptionId}',
        'DELETE',
        pathParams,
        queryParams,
        headerParams,
        formParams,
        postBody,
        authNames,
        contentTypes,
        accepts,
        returnType
      )
    }
  
    /**
     * Delete subscription
     * @param {<&vendorExtensions.x-jsdoc-type>} updateableSubscriptionId updateableSubscriptionId
     * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/GenericMapBasedApiResponse}
     */
    deleteUsingDELETE2 (updateableSubscriptionId) {
      return this.deleteUsingDELETE2WithHttpInfo(updateableSubscriptionId).then(
        function (response_and_data) {
          return response_and_data.data
        }
      )
    }
  
    /**
     * Get subscriptions for an App
     * @param {Number} appId appId
     * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/SubscriptionsResponse} and HTTP response
     */
    listUsingGET3WithHttpInfo (appId) {
      let postBody = null
      // verify the required parameter 'appId' is set
      if (appId === undefined || appId === null) {
        throw new Error(
          "Missing the required parameter 'appId' when calling listUsingGET3"
        )
      }
  
      let pathParams = {
        appId: appId
      }
      let queryParams = {}
      let headerParams = {}
      let formParams = {}
  
      let authNames = ['api_key']
      let contentTypes = []
      let accepts = ['application/json']
      let returnType = SubscriptionsResponse
  
      return this.apiClient.callApi(
        '/users-web/api/v3/apps/{appId}/subscriptions',
        'GET',
        pathParams,
        queryParams,
        headerParams,
        formParams,
        postBody,
        authNames,
        contentTypes,
        accepts,
        returnType
      )
    }
  
    /**
     * Get subscriptions for an App
     * @param {<&vendorExtensions.x-jsdoc-type>} appId appId
     * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/SubscriptionsResponse}
     */
    listUsingGET3 (appId) {
      return this.listUsingGET3WithHttpInfo(appId).then(function (
        response_and_data
      ) {
        return response_and_data.data
      })
    }
  
    /**
     * Get current account&#x27;s subscriptions
     * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/SubscriptionsResponse} and HTTP response
     */
    listUsingGET5WithHttpInfo () {
      let postBody = null
  
      let pathParams = {}
      let queryParams = {}
      let headerParams = {}
      let formParams = {}
  
      let authNames = ['api_key']
      let contentTypes = []
      let accepts = ['application/json']
      let returnType = SubscriptionsResponse
  
      return this.apiClient.callApi(
        '/users-web/api/v3/subscriptions',
        'GET',
        pathParams,
        queryParams,
        headerParams,
        formParams,
        postBody,
        authNames,
        contentTypes,
        accepts,
        returnType
      )
    }
  
    /**
     * Get current account&#x27;s subscriptions
     * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/SubscriptionsResponse}
     */
    listUsingGET5 () {
      return this.listUsingGET5WithHttpInfo().then(function (response_and_data) {
        return response_and_data.data
      })
    }
  
    /**
     * Email an App report
     * @param {module:model/ReportInfo} body emailDto
     * @param {Number} appId appId
     * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/MailReportResponse} and HTTP response
     */
    sendAppReportUsingPOSTWithHttpInfo (body, appId) {
      let postBody = body
      // verify the required parameter 'body' is set
      if (body === undefined || body === null) {
        throw new Error(
          "Missing the required parameter 'body' when calling sendAppReportUsingPOST"
        )
      }
      // verify the required parameter 'appId' is set
      if (appId === undefined || appId === null) {
        throw new Error(
          "Missing the required parameter 'appId' when calling sendAppReportUsingPOST"
        )
      }
  
      let pathParams = {
        appId: appId
      }
      let queryParams = {}
      let headerParams = {}
      let formParams = {}
  
      let authNames = ['api_key']
      let contentTypes = ['application/json']
      let accepts = ['application/json']
      let returnType = MailReportResponse
  
      return this.apiClient.callApi(
        '/users-web/api/v3/apps/{appId}/report/send',
        'POST',
        pathParams,
        queryParams,
        headerParams,
        formParams,
        postBody,
        authNames,
        contentTypes,
        accepts,
        returnType
      )
    }
  
    /**
     * Email an App report
     * @param {<&vendorExtensions.x-jsdoc-type>} body emailDto
     * @param {<&vendorExtensions.x-jsdoc-type>} appId appId
     * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/MailReportResponse}
     */
    sendAppReportUsingPOST (body, appId) {
      return this.sendAppReportUsingPOSTWithHttpInfo(body, appId).then(function (
        response_and_data
      ) {
        return response_and_data.data
      })
    }
  
    /**
     * Email a dashboard report
     * @param {module:model/ReportInfo} body emailDto
     * @param {Number} dashId dashId
     * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/MailReportResponse} and HTTP response
     */
    sendDashReportUsingPOSTWithHttpInfo (body, dashId) {
      let postBody = body
      // verify the required parameter 'body' is set
      if (body === undefined || body === null) {
        throw new Error(
          "Missing the required parameter 'body' when calling sendDashReportUsingPOST"
        )
      }
      // verify the required parameter 'dashId' is set
      if (dashId === undefined || dashId === null) {
        throw new Error(
          "Missing the required parameter 'dashId' when calling sendDashReportUsingPOST"
        )
      }
  
      let pathParams = {
        dashId: dashId
      }
      let queryParams = {}
      let headerParams = {}
      let formParams = {}
  
      let authNames = ['api_key']
      let contentTypes = ['application/json']
      let accepts = ['application/json']
      let returnType = MailReportResponse
  
      return this.apiClient.callApi(
        '/users-web/api/v3/dashboards/{dashId}/report/send',
        'POST',
        pathParams,
        queryParams,
        headerParams,
        formParams,
        postBody,
        authNames,
        contentTypes,
        accepts,
        returnType
      )
    }
  
    /**
     * Email a dashboard report
     * @param {<&vendorExtensions.x-jsdoc-type>} body emailDto
     * @param {<&vendorExtensions.x-jsdoc-type>} dashId dashId
     * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/MailReportResponse}
     */
    sendDashReportUsingPOST (body, dashId) {
      return this.sendDashReportUsingPOSTWithHttpInfo(body, dashId).then(
        function (response_and_data) {
          return response_and_data.data
        }
      )
    }
  
    /**
     * Toggle subscription status
     * @param {module:model/UpdateSubscriptionDto} body dto
     * @param {Number} updateableSubscriptionId updateableSubscriptionId
     * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/SubscriptionResponse} and HTTP response
     */
    toggleEnabledUsingPUT1WithHttpInfo (body, updateableSubscriptionId) {
      let postBody = body
      // verify the required parameter 'body' is set
      if (body === undefined || body === null) {
        throw new Error(
          "Missing the required parameter 'body' when calling toggleEnabledUsingPUT1"
        )
      }
      // verify the required parameter 'updateableSubscriptionId' is set
      if (
        updateableSubscriptionId === undefined ||
        updateableSubscriptionId === null
      ) {
        throw new Error(
          "Missing the required parameter 'updateableSubscriptionId' when calling toggleEnabledUsingPUT1"
        )
      }
  
      let pathParams = {
        updateableSubscriptionId: updateableSubscriptionId
      }
      let queryParams = {}
      let headerParams = {}
      let formParams = {}
  
      let authNames = ['api_key']
      let contentTypes = ['application/json']
      let accepts = ['application/json']
      let returnType = SubscriptionResponse
  
      return this.apiClient.callApi(
        '/users-web/api/v3/subscriptions/{updateableSubscriptionId}',
        'PUT',
        pathParams,
        queryParams,
        headerParams,
        formParams,
        postBody,
        authNames,
        contentTypes,
        accepts,
        returnType
      )
    }
  
    /**
     * Toggle subscription status
     * @param {<&vendorExtensions.x-jsdoc-type>} body dto
     * @param {<&vendorExtensions.x-jsdoc-type>} updateableSubscriptionId updateableSubscriptionId
     * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/SubscriptionResponse}
     */
    toggleEnabledUsingPUT1 (body, updateableSubscriptionId) {
      return this.toggleEnabledUsingPUT1WithHttpInfo(
        body,
        updateableSubscriptionId
      ).then(function (response_and_data) {
        return response_and_data.data
      })
    }
  
    /**
     * Update App subscription
     * @param {module:model/SubscriptionDto} body subscription
     * @param {Number} appId appId
     * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/SubscriptionResponse} and HTTP response
     */
    updateForAppUsingPUTWithHttpInfo (body, appId) {
      let postBody = body
      // verify the required parameter 'body' is set
      if (body === undefined || body === null) {
        throw new Error(
          "Missing the required parameter 'body' when calling updateForAppUsingPUT"
        )
      }
      // verify the required parameter 'appId' is set
      if (appId === undefined || appId === null) {
        throw new Error(
          "Missing the required parameter 'appId' when calling updateForAppUsingPUT"
        )
      }
  
      let pathParams = {
        appId: appId
      }
      let queryParams = {}
      let headerParams = {}
      let formParams = {}
  
      let authNames = ['api_key']
      let contentTypes = ['application/json']
      let accepts = ['application/json']
      let returnType = SubscriptionResponse
  
      return this.apiClient.callApi(
        '/users-web/api/v3/apps/{appId}/subscription',
        'PUT',
        pathParams,
        queryParams,
        headerParams,
        formParams,
        postBody,
        authNames,
        contentTypes,
        accepts,
        returnType
      )
    }
  
    /**
     * Update App subscription
     * @param {<&vendorExtensions.x-jsdoc-type>} body subscription
     * @param {<&vendorExtensions.x-jsdoc-type>} appId appId
     * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/SubscriptionResponse}
     */
    updateForAppUsingPUT (body, appId) {
      return this.updateForAppUsingPUTWithHttpInfo(body, appId).then(function (
        response_and_data
      ) {
        return response_and_data.data
      })
    }
  
    /**
     * Update dashboard subscription
     * @param {module:model/SubscriptionDashboardDto} body subscription
     * @param {Number} dashId dashId
     * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link module:model/SubscriptionResponse} and HTTP response
     */
    updateForDashUsingPUT1WithHttpInfo (body, dashId) {
      let postBody = body
      // verify the required parameter 'body' is set
      if (body === undefined || body === null) {
        throw new Error(
          "Missing the required parameter 'body' when calling updateForDashUsingPUT1"
        )
      }
      // verify the required parameter 'dashId' is set
      if (dashId === undefined || dashId === null) {
        throw new Error(
          "Missing the required parameter 'dashId' when calling updateForDashUsingPUT1"
        )
      }
  
      let pathParams = {
        dashId: dashId
      }
      let queryParams = {}
      let headerParams = {}
      let formParams = {}
  
      let authNames = ['api_key']
      let contentTypes = ['application/json']
      let accepts = ['application/json']
      let returnType = SubscriptionResponse
  
      return this.apiClient.callApi(
        '/users-web/api/v3/dashboards/{dashId}/subscription',
        'PUT',
        pathParams,
        queryParams,
        headerParams,
        formParams,
        postBody,
        authNames,
        contentTypes,
        accepts,
        returnType
      )
    }
  
    /**
     * Update dashboard subscription
     * @param {<&vendorExtensions.x-jsdoc-type>} body subscription
     * @param {<&vendorExtensions.x-jsdoc-type>} dashId dashId
     * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with data of type {@link module:model/SubscriptionResponse}
     */
    updateForDashUsingPUT1 (body, dashId) {
      return this.updateForDashUsingPUT1WithHttpInfo(body, dashId).then(function (
        response_and_data
      ) {
        return response_and_data.data
      })
    }
  }
  