All files / codegen/models Discount.ts

72.9% Statements 113/155
100% Branches 0/0
0% Functions 0/3
72.9% Lines 113/155

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 1571x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x     1x 1x                                       1x 1x                                              
/* tslint:disable */
/* eslint-disable */
/**
 * Octane API
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * The version of the OpenAPI document: 1.0.0
 * 
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */
 
import { exists, mapValues } from '../runtime';
import {
    AddOn,
    AddOnFromJSON,
    AddOnFromJSONTyped,
    AddOnToJSON,
} from './AddOn';
import {
    MeteredComponent,
    MeteredComponentFromJSON,
    MeteredComponentFromJSONTyped,
    MeteredComponentToJSON,
} from './MeteredComponent';
 
/**
 * 
 * @export
 * @interface Discount
 */
export interface Discount {
    /**
     * 
     * @type {any}
     * @memberof Discount
     */
    readonly discountType?: any | null;
    /**
     * 
     * @type {number}
     * @memberof Discount
     */
    amount?: number | null;
    /**
     * The date when the discount is applied from.
     * @type {Date}
     * @memberof Discount
     */
    startDate?: Date | null;
    /**
     * The date when the discount ends.
     * @type {Date}
     * @memberof Discount
     */
    endDate?: Date | null;
    /**
     * Offset in number of billing cycles for when this discount will apply. For example, if set to 1, the discount will apply from the start of the next billing cycle.
     * @type {number}
     * @memberof Discount
     */
    billingCycleStartOffset?: number;
    /**
     * Duration of this discount in number of billing cycles.
     * @type {number}
     * @memberof Discount
     */
    billingCycleDuration?: number | null;
    /**
     * The id of coupon associated with this discount, none if discount does not originate from coupon
     * @type {number}
     * @memberof Discount
     */
    couponId?: number | null;
    /**
     * External facing unique identifier of a price plan
     * @type {string}
     * @memberof Discount
     */
    externalUuid?: string;
    /**
     * The scope that this discount covers. One of 'INVOICE_TOTAL', 'ADD_ON', 'METERED_COMPONENT'.
     * @type {string}
     * @memberof Discount
     */
    scope: string;
    /**
     * Add-on this discount covers if scope is ADD_ON.
     * @type {AddOn}
     * @memberof Discount
     */
    addOn?: AddOn | null;
    /**
     * Metered Component this discount covers if scope is METERED_COMPONENT.
     * @type {MeteredComponent}
     * @memberof Discount
     */
    meteredComponent?: MeteredComponent | null;
    /**
     * Dictionary of labels (key: value) to which the discount applies if scope is METERED_COMPONENT.
     * @type {{ [key: string]: string; }}
     * @memberof Discount
     */
    labels?: { [key: string]: string; };
}
 
export function DiscountFromJSON(json: any): Discount {
    return DiscountFromJSONTyped(json, false);
}
 
export function DiscountFromJSONTyped(json: any, ignoreDiscriminator: boolean): Discount {
    if ((json === undefined) || (json === null)) {
        return json;
    }
    return {
        
        'discountType': !exists(json, 'discount_type') ? undefined : json['discount_type'],
        'amount': !exists(json, 'amount') ? undefined : json['amount'],
        'startDate': !exists(json, 'start_date') ? undefined : (json['start_date'] === null ? null : new Date(json['start_date'])),
        'endDate': !exists(json, 'end_date') ? undefined : (json['end_date'] === null ? null : new Date(json['end_date'])),
        'billingCycleStartOffset': !exists(json, 'billing_cycle_start_offset') ? undefined : json['billing_cycle_start_offset'],
        'billingCycleDuration': !exists(json, 'billing_cycle_duration') ? undefined : json['billing_cycle_duration'],
        'couponId': !exists(json, 'coupon_id') ? undefined : json['coupon_id'],
        'externalUuid': !exists(json, 'external_uuid') ? undefined : json['external_uuid'],
        'scope': json['scope'],
        'addOn': !exists(json, 'add_on') ? undefined : AddOnFromJSON(json['add_on']),
        'meteredComponent': !exists(json, 'metered_component') ? undefined : MeteredComponentFromJSON(json['metered_component']),
        'labels': !exists(json, 'labels') ? undefined : json['labels'],
    };
}
 
export function DiscountToJSON(value?: Discount | null): any {
    if (value === undefined) {
        return undefined;
    }
    if (value === null) {
        return null;
    }
    return {
        
        'amount': value.amount,
        'start_date': value.startDate === undefined ? undefined : (value.startDate === null ? null : value.startDate.toISOString()),
        'end_date': value.endDate === undefined ? undefined : (value.endDate === null ? null : value.endDate.toISOString()),
        'billing_cycle_start_offset': value.billingCycleStartOffset,
        'billing_cycle_duration': value.billingCycleDuration,
        'coupon_id': value.couponId,
        'external_uuid': value.externalUuid,
        'scope': value.scope,
        'add_on': AddOnToJSON(value.addOn),
        'metered_component': MeteredComponentToJSON(value.meteredComponent),
        'labels': value.labels,
    };
}