All files / src/ODataApi CustomAction.ts

100% Statements 14/14
100% Branches 8/8
100% Functions 1/1
100% Lines 14/14
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                  1x       102x 102x 102x 102x   102x 102x 102x 102x 102x 102x 34x   102x 59x                                  
/**
 * @module ODataApi
 */ /** */
 
 // tslint:disable:naming-convention
 
/**
 * Class that represents a custom OData Action
 */
export class CustomAction {
    public name: string;
    public id?: number;
    public path?: string;
    public params: string[] = [];
    public requiredParams: string[] = [];
    public isAction: boolean = false;
    public 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) {
            this.params = this.params.concat(options.params);
        }
        if (options.requiredParams) {
            this.params = this.params.concat(options.requiredParams);
        }
    }
}
 
/**
 * 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;
}