// File generated from our OpenAPI spec by Stainless.

import * as Core from "../../../core";
import { APIResource } from "../../../resource";
import * as ImageResizingAPI from "./image-resizing";

export class ImageResizing extends APIResource {
  /**
   * Image Resizing provides on-demand resizing, conversion and optimisation for
   * images served through Cloudflare's network. Refer to the
   * [Image Resizing documentation](https://developers.cloudflare.com/images/) for
   * more information.
   */
  edit(params: ImageResizingEditParams, options?: Core.RequestOptions): Core.APIPromise<ZonesImageResizing> {
    const { zone_id, ...body } = params;
    return (
      this._client.patch(`/zones/${zone_id}/settings/image_resizing`, {
        body,
        ...options,
      }) as Core.APIPromise<{ result: ZonesImageResizing }>
    )._thenUnwrap((obj) => obj.result);
  }

  /**
   * Image Resizing provides on-demand resizing, conversion and optimisation for
   * images served through Cloudflare's network. Refer to the
   * [Image Resizing documentation](https://developers.cloudflare.com/images/) for
   * more information.
   */
  get(params: ImageResizingGetParams, options?: Core.RequestOptions): Core.APIPromise<ZonesImageResizing> {
    const { zone_id } = params;
    return (
      this._client.get(`/zones/${zone_id}/settings/image_resizing`, options) as Core.APIPromise<{
        result: ZonesImageResizing;
      }>
    )._thenUnwrap((obj) => obj.result);
  }
}

/**
 * Image Resizing provides on-demand resizing, conversion and optimisation for
 * images served through Cloudflare's network. Refer to the
 * [Image Resizing documentation](https://developers.cloudflare.com/images/) for
 * more information.
 */
export interface ZonesImageResizing {
  /**
   * ID of the zone setting.
   */
  id: 'image_resizing';

  /**
   * Current value of the zone setting.
   */
  value: 'on' | 'off' | 'open';

  /**
   * Whether or not this setting can be modified for this zone (based on your
   * Cloudflare plan level).
   */
  editable?: true | false;

  /**
   * last time this setting was modified.
   */
  modified_on?: string | null;
}

export interface ImageResizingEditParams {
  /**
   * Path param: Identifier
   */
  zone_id: string;

  /**
   * Body param: Image Resizing provides on-demand resizing, conversion and
   * optimisation for images served through Cloudflare's network. Refer to the
   * [Image Resizing documentation](https://developers.cloudflare.com/images/) for
   * more information.
   */
  value: ZonesImageResizing;
}

export interface ImageResizingGetParams {
  /**
   * Identifier
   */
  zone_id: string;
}

export namespace ImageResizing {
  export import ZonesImageResizing = ImageResizingAPI.ZonesImageResizing;
  export import ImageResizingEditParams = ImageResizingAPI.ImageResizingEditParams;
  export import ImageResizingGetParams = ImageResizingAPI.ImageResizingGetParams;
}
