#Script Pages

<back to all web services

QueryCustomers


// @DataContract
export class QueryBase
{
    // @DataMember(Order=1)
    public skip?: number;

    // @DataMember(Order=2)
    public take?: number;

    // @DataMember(Order=3)
    public orderBy: string;

    // @DataMember(Order=4)
    public orderByDesc: string;

    // @DataMember(Order=5)
    public include: string;

    // @DataMember(Order=6)
    public fields: string;

    // @DataMember(Order=7)
    public meta: { [index: string]: string; };

    public constructor(init?: Partial<QueryBase>) { (Object as any).assign(this, init); }
}

export class QueryDb<T> extends QueryBase
{

    public constructor(init?: Partial<QueryDb<T>>) { super(init); (Object as any).assign(this, init); }
}

export class Order
{
    public orderId: number;
    public customerId: string;
    public orderDate: string;
    public total: number;

    public constructor(init?: Partial<Order>) { (Object as any).assign(this, init); }
}

export class Customer
{
    public customerId: string;
    public companyName: string;
    public address: string;
    public city: string;
    public region: string;
    public postalCode: string;
    public country: string;
    public phone: string;
    public fax: string;
    public orders: Order[];

    public constructor(init?: Partial<Customer>) { (Object as any).assign(this, init); }
}

export class QueryCustomers extends QueryDb<Customer>
{
    public customerId: string;
    public companyNameContains: string;
    public countryIn: string[];

    public constructor(init?: Partial<QueryCustomers>) { super(init); (Object as any).assign(this, init); }
}

// @DataContract
export class QueryResponse<Customer>
{
    // @DataMember(Order=1)
    public offset: number;

    // @DataMember(Order=2)
    public total: number;

    // @DataMember(Order=3)
    public results: Customer[];

    // @DataMember(Order=4)
    public meta: { [index: string]: string; };

    // @DataMember(Order=5)
    public responseStatus: ResponseStatus;

    public constructor(init?: Partial<QueryResponse<Customer>>) { (Object as any).assign(this, init); }
}

TypeScript QueryCustomers DTOs

To override the Content-type in your clients, use the HTTP Accept Header, append the .csv suffix or ?format=csv

HTTP + CSV

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

POST /csv/reply/QueryCustomers HTTP/1.1 
Host: sharpscript.net 
Accept: text/csv
Content-Type: text/csv
Content-Length: length

{"customerId":"String","companyNameContains":"String","countryIn":["String"],"skip":0,"take":0,"orderBy":"String","orderByDesc":"String","include":"String","fields":"String","meta":{"String":"String"}}
HTTP/1.1 200 OK
Content-Type: text/csv
Content-Length: length

{"offset":0,"total":0,"results":[{"customerId":"String","companyName":"String","address":"String","city":"String","region":"String","postalCode":"String","country":"String","phone":"String","fax":"String","orders":[{"orderId":0,"customerId":"String","orderDate":"\/Date(-62135596800000-0000)\/","total":0}]}],"meta":{"String":"String"},"responseStatus":{"errorCode":"String","message":"String","stackTrace":"String","errors":[{"errorCode":"String","fieldName":"String","message":"String","meta":{"String":"String"}}],"meta":{"String":"String"}}}