import * as Models from "./models";


/**
 * API endpoints for Web Push.
 */
export class WebPush {
  private client: any;

  constructor(client: any) {
    this.client = client;
  }

  /**
   * Send push notification
   * 
   * Send push notification to all active subscriptions for the authenticated
   * user.
   */
  async webpushSendCreate(data: Models.SendPushRequestRequest): Promise<Models.SendPushResponse> {
    const response = await this.client.request('POST', "/cfg/webpush/send/", { body: data });
    return response;
  }

  /**
   * Subscribe to push notifications
   * 
   * Save push subscription from browser for the authenticated user.
   */
  async webpushSubscribeCreate(data: Models.SubscribeRequestRequest): Promise<Models.SubscribeResponse> {
    const response = await this.client.request('POST', "/cfg/webpush/subscribe/", { body: data });
    return response;
  }

  /**
   * Get VAPID public key
   * 
   * Get VAPID public key for client subscription.
   */
  async webpushVapidRetrieve(): Promise<Models.VapidPublicKeyResponse> {
    const response = await this.client.request('GET', "/cfg/webpush/vapid/");
    return response;
  }

}