/*
 * Selling Partner API for Notifications
 * The Selling Partner API for Notifications lets you subscribe to notifications that are relevant to a selling partner's business. Using this API you can create a destination to receive notifications, subscribe to notifications, delete notification subscriptions, and more.  For more information, see the [Notifications Use Case Guide](doc:notifications-api-v1-use-case-guide).
 *
 * OpenAPI spec version: v1
 *
 * NOTE: This class is auto generated by the swagger code generator program.
 * https://github.com/swagger-api/swagger-codegen.git
 *
 * Swagger Codegen version: 2.4.9
 *
 * Do not edit the class manually.
 *
 */

import { ApiClient } from "../ApiClient.js";
import { ProcessingDirective } from "./ProcessingDirective.js";

/**
 * The Subscription model module.
 * @module notifications/js-client.notifications.model/Subscription
 * @version v1
 */
export class Subscription {
  /**
   * Constructs a new <code>Subscription</code>.
   * Represents a subscription to receive notifications.
   * @alias module:notifications/js-client.notifications.model/Subscription
   * @class
   * @param subscriptionId {String} The subscription identifier generated when the subscription is created.
   * @param payloadVersion {String} The version of the payload object to be used in the notification.
   * @param destinationId {String} The identifier for the destination where notifications will be delivered.
   */
  constructor(subscriptionId, payloadVersion, destinationId) {
    this.subscriptionId = subscriptionId;
    this.payloadVersion = payloadVersion;
    this.destinationId = destinationId;
  }

  /**
   * Constructs a <code>Subscription</code> from a plain JavaScript object, optionally creating a new instance.
   * Copies all relevant properties from <code>data</code> to <code>obj</code> if supplied or a new instance if not.
   * @param {Object} data The plain JavaScript object bearing properties of interest.
   * @param {module:notifications/js-client.notifications.model/Subscription} obj Optional instance to populate.
   * @return {module:notifications/js-client.notifications.model/Subscription} The populated <code>Subscription</code> instance.
   */
  static constructFromObject(data, obj) {
    if (data) {
      obj = obj || new Subscription();
      if (data.hasOwnProperty("subscriptionId"))
        obj.subscriptionId = ApiClient.convertToType(
          data["subscriptionId"],
          "String",
        );
      if (data.hasOwnProperty("payloadVersion"))
        obj.payloadVersion = ApiClient.convertToType(
          data["payloadVersion"],
          "String",
        );
      if (data.hasOwnProperty("destinationId"))
        obj.destinationId = ApiClient.convertToType(
          data["destinationId"],
          "String",
        );
      if (data.hasOwnProperty("processingDirective"))
        obj.processingDirective = ProcessingDirective.constructFromObject(
          data["processingDirective"],
        );
    }
    return obj;
  }
}

/**
 * The subscription identifier generated when the subscription is created.
 * @member {String} subscriptionId
 */
Subscription.prototype.subscriptionId = undefined;

/**
 * The version of the payload object to be used in the notification.
 * @member {String} payloadVersion
 */
Subscription.prototype.payloadVersion = undefined;

/**
 * The identifier for the destination where notifications will be delivered.
 * @member {String} destinationId
 */
Subscription.prototype.destinationId = undefined;

/**
 * @member {module:notifications/js-client.notifications.model/ProcessingDirective} processingDirective
 */
Subscription.prototype.processingDirective = undefined;
