UNPKG

@cloudinary/url-gen

Version:

You are invited to influence our new SDK [Click here to view github discussion](https://github.com/cloudinary/js-url-gen/discussions/602) =========================

37 lines (33 loc) 1.45 kB
'use strict'; var Action = require('./Action-0ed405c1.cjs'); var FormatQualifier = require('./FormatQualifier-ffbb8eb3.cjs'); var Qualifier = require('./Qualifier-6633a22f.cjs'); var internalConstants = require('./internalConstants-6e675c29.cjs'); /** * @description Qualifies the delivery of an asset. * @memberOf Actions.Delivery * @extends SDK.Action */ class DeliveryAction extends Action.Action { /** * @param {string} deliveryKey A generic Delivery Action Key (such as q, f, dn, etc.) * @param {string} deliveryType A Format Qualifiers for the action, such as Quality.auto() * @param {string} modelProperty internal model property of the action, for example quality uses `level` while dpr uses `density` * @see Visit {@link Actions.Delivery|Delivery} for an example */ constructor(deliveryKey, deliveryType, modelProperty) { super(); this._actionModel = {}; let deliveryTypeValue; if (deliveryType instanceof FormatQualifier.FormatQualifier) { deliveryTypeValue = deliveryType.getValue(); } else { deliveryTypeValue = deliveryType; } this._actionModel.actionType = internalConstants.DELIVERY_MODE_TO_ACTION_TYPE_MAP[deliveryKey]; this._actionModel[modelProperty] = deliveryTypeValue; this.addQualifier(new Qualifier.Qualifier(deliveryKey, deliveryType)); } } exports.DeliveryAction = DeliveryAction;