/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 * @generated-id: 026c94904537
 */

import { betaObservabilityCampaignsCreate } from "../funcs/betaObservabilityCampaignsCreate.js";
import { betaObservabilityCampaignsDelete } from "../funcs/betaObservabilityCampaignsDelete.js";
import { betaObservabilityCampaignsFetch } from "../funcs/betaObservabilityCampaignsFetch.js";
import { betaObservabilityCampaignsFetchStatus } from "../funcs/betaObservabilityCampaignsFetchStatus.js";
import { betaObservabilityCampaignsList } from "../funcs/betaObservabilityCampaignsList.js";
import { betaObservabilityCampaignsListEvents } from "../funcs/betaObservabilityCampaignsListEvents.js";
import { ClientSDK, RequestOptions } from "../lib/sdks.js";
import * as components from "../models/components/index.js";
import * as operations from "../models/operations/index.js";
import { unwrapAsync } from "../types/fp.js";

export class Campaigns extends ClientSDK {
  /**
   * Create and start a new campaign
   */
  async create(
    request: components.CreateCampaignRequest,
    options?: RequestOptions,
  ): Promise<components.Campaign> {
    return unwrapAsync(betaObservabilityCampaignsCreate(
      this,
      request,
      options,
    ));
  }

  /**
   * Get all campaigns
   */
  async list(
    request?:
      | operations.GetCampaignsV1ObservabilityCampaignsGetRequest
      | undefined,
    options?: RequestOptions,
  ): Promise<components.ListCampaignsResponse> {
    return unwrapAsync(betaObservabilityCampaignsList(
      this,
      request,
      options,
    ));
  }

  /**
   * Get campaign by id
   */
  async fetch(
    request:
      operations.GetCampaignByIdV1ObservabilityCampaignsCampaignIdGetRequest,
    options?: RequestOptions,
  ): Promise<components.Campaign> {
    return unwrapAsync(betaObservabilityCampaignsFetch(
      this,
      request,
      options,
    ));
  }

  /**
   * Delete a campaign
   */
  async delete(
    request:
      operations.DeleteCampaignV1ObservabilityCampaignsCampaignIdDeleteRequest,
    options?: RequestOptions,
  ): Promise<void> {
    return unwrapAsync(betaObservabilityCampaignsDelete(
      this,
      request,
      options,
    ));
  }

  /**
   * Get campaign status by campaign id
   */
  async fetchStatus(
    request:
      operations.GetCampaignStatusByIdV1ObservabilityCampaignsCampaignIdStatusGetRequest,
    options?: RequestOptions,
  ): Promise<components.FetchCampaignStatusResponse> {
    return unwrapAsync(betaObservabilityCampaignsFetchStatus(
      this,
      request,
      options,
    ));
  }

  /**
   * Get event ids that were selected by the given campaign
   */
  async listEvents(
    request:
      operations.GetCampaignSelectedEventsV1ObservabilityCampaignsCampaignIdSelectedEventsGetRequest,
    options?: RequestOptions,
  ): Promise<components.ListCampaignSelectedEventsResponse> {
    return unwrapAsync(betaObservabilityCampaignsListEvents(
      this,
      request,
      options,
    ));
  }
}
