UNPKG

@sap-cloud-sdk/odata-common

Version:

SAP Cloud SDK for JavaScript common functions of OData client generator and OpenAPI clint generator.

68 lines (67 loc) 3.71 kB
import { ODataCreateRequestConfig } from '../request'; import { MethodRequestBuilder } from './request-builder-base'; import type { HttpDestinationOrFetchOptions } from '@sap-cloud-sdk/connectivity'; import type { HttpResponse } from '@sap-cloud-sdk/http-client'; import type { EntitySerializer } from '../entity-serializer'; import type { ODataUri } from '../uri-conversion'; import type { EntityBase, EntityIdentifiable } from '../entity-base'; import type { EntityDeserializer } from '../entity-deserializer'; import type { ResponseDataAccessor } from '../response-data-accessor'; import type { Link } from '../selectable'; import type { DeSerializers } from '../de-serializers'; import type { EntityApi } from '../entity-api'; import type { BatchReference, WithBatchReference } from '../request'; /** * Abstract create request class holding the parts shared in OData v2 and v4. * @typeParam EntityT - Type of the entity to be created */ export declare abstract class CreateRequestBuilderBase<EntityT extends EntityBase, DeSerializersT extends DeSerializers> extends MethodRequestBuilder<ODataCreateRequestConfig<EntityT, DeSerializersT>> implements EntityIdentifiable<EntityT, DeSerializersT>, WithBatchReference { readonly _entityApi: EntityApi<EntityT, DeSerializersT>; readonly _entity: EntityT; readonly oDataUri: ODataUri<DeSerializersT>; readonly serializer: EntitySerializer; readonly deserializer: EntityDeserializer; readonly responseDataAccessor: ResponseDataAccessor; readonly _deSerializers: DeSerializersT; private _batchReference; /** * Creates an instance of CreateRequestBuilder. * @param _entityApi - Entity API for building and executing the request. * @param _entity - Entity to be created. * @param oDataUri - URI conversion functions. * @param serializer - Entity serializer. * @param deserializer - Entity deserializer. * @param responseDataAccessor - Object access functions for get requests. */ constructor(_entityApi: EntityApi<EntityT, DeSerializersT>, _entity: EntityT, oDataUri: ODataUri<DeSerializersT>, serializer: EntitySerializer, deserializer: EntityDeserializer, responseDataAccessor: ResponseDataAccessor); get entity(): EntityT; /** * Gets identifier for the batch request. * @returns Batch request identifier. */ getBatchReference(): BatchReference; /** * Sets user-defined identifier for the batch reference. * @param id - User-defined batch request identifier. */ setBatchId(id: string): void; /** * Specifies the parent of the entity to create. * @param parentEntity - Parent of the entity to create. * @param linkField - Static representation of the navigation property that navigates from the parent entity to the child entity. * @returns The entity itself, to facilitate method chaining. */ asChildOf<ParentEntityT extends EntityBase>(parentEntity: ParentEntityT, linkField: Link<ParentEntityT, DeSerializersT, EntityApi<EntityT, any>>): this; /** * Execute query. * @param destination - Destination or DestinationFetchOptions to execute the request against. * @returns A promise resolving to the created entity. */ execute(destination: HttpDestinationOrFetchOptions): Promise<EntityT>; /** * Execute request and return an {@link @sap-cloud-sdk/http-client!HttpResponse}. * @param destination - Destination or DestinationFetchOptions to execute the request against. * @returns A promise resolving to an {@link @sap-cloud-sdk/http-client!HttpResponse}. */ executeRaw(destination: HttpDestinationOrFetchOptions): Promise<HttpResponse>; }