import { BatchRequest, ParsedResponse } from './batch'; import { EntitySet } from './entityset'; import { ODataFilter } from './filter'; import { ODataQueryParam } from './params'; import { BatchRequestOptions, ODataQueryRequest, ODataReadIDRequest, ODataWriteRequest } from './types'; export type ODataVersion = 'v2' | 'v4'; export interface PlainODataResponseV4 { error?: { /** if error occured, node error will have value */ code: string; message: { lang: string, value: string /** server error message */ } & string } /** * context string */ '@odata.context'?: string; /** * total count */ '@odata.count'?: number; '@odata.id'?: string; '@odata.etag'?: string; '@odata.editLink'?: string; } export type BatchPlainODataResponse = PlainODataResponseV4 & { value?: Array } & E export type PlainODataSingleResponseV4 = E & PlainODataResponseV4 export type PlainODataMultiResponseV4 = PlainODataResponseV4 & { /** * values result list */ value?: Array; } export interface ODataV4 { /** * get Entity Set by entityset name * * @param entitySetName the name of entity set, you can get it from metadata * */ getEntitySet(entitySetName: string): EntitySet; /** * Set OData Client Http Basic credential * * @param credential */ setCredential(credential: Credential): void; /** * setODataEndPath * * e.g. https://tenant.c4c.saphybriscloud.cn/sap/c4c/odata/v1/c4codata/ */ setODataEndPath(odataEnd: string): void; /** * get odata version */ getVersion(): ODataVersion; /** * new odata http request */ newRequest(options: ODataQueryRequest): Promise>; newRequest(options: ODataWriteRequest): Promise>; newRequest(options: ODataReadIDRequest): Promise>; /** * create new filter * * @alias OData.newFilter */ newFilter(): ODataFilter /** * create new param * * @alias OData.newParam */ newParam(): ODataQueryParam /** * create batch request (will not perform) * * @param options */ newBatchRequest(options: BatchRequestOptions): Promise; /** * execute batch requests and get response * * @param requests batch request * */ execBatchRequests(requests: Array>): Promise>> }