All files / sn-client-js/src/ODataApi CustomAction.ts

100% Statements 16/16
100% Branches 8/8
100% Functions 1/1
100% Lines 16/16
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              1x       78x 78x 78x 78x   78x 78x 78x 78x 78x 78x 30x 35x     78x 39x 45x                                  
/**
 * @module ODataApi
 */ /** */
 
/**
 * Class that represents a custom OData Action
 */
export class CustomAction {
    name: string;
    id?: number;
    path?: string;
    params: string[] = [];
    requiredParams: string[] = [];
    isAction: boolean = false;
    noCache: boolean = false;
    constructor(options: ICustomActionOptions) {
        this.name = options.name;
        this.id = options.id;
        this.path = options.path;
        this.isAction = options.isAction || false;
        this.noCache = options.noCache || false;
        if (options.params) {
            for (let i = 0; i < options.params.length; i++) {
                this.params.push(options.params[i]);
            }
        }
        if (options.requiredParams) {
            for (let i = 0; i < options.requiredParams.length; i++) {
                this.params.push(options.requiredParams[i]);
            }
        }
    }
}
 
/**
 * Interface that represents an options to institiating a CustomAction or CustomContentAction
 */
export interface ICustomActionOptions {
    name: string;
    id?: number;
    path?: string;
    params?: string[];
    requiredParams?: string[];
    isAction?: boolean;
    noCache?: boolean;
}