Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ODataApi<THttpProvider>

This class contains methods and classes for sending requests and getting responses from the Content Repository through OData REST API.

Following methods return Rxjs Observables which are made from the ajax requests' promises. Action methods like Delete or Rename on Content calls this methods, gets their responses as Observables and returns them so that you can subscribe them in your code.

Type parameters

Hierarchy

  • ODataApi

Index

Constructors

constructor

  • Parameters

    Returns ODataApi

Methods

CreateCustomAction

  • Creates a wrapper function for a callable custom OData action.

    This method creates an Observable, sends an ajax request to the server and convert the reponse to promise which will be the argument of the Observable.

    Type parameters

    • TReturnType

    Parameters

    • actionOptions: ICustomActionOptions

      A CustomAction configuration object.

    • Optional options: IODataParams<any>

      An object that holds the config of the ajax request like urlparameters or data.

    • Optional returns: undefined | object

      Th type that the action should return

    Returns Observable<TReturnType>

    Returns an Rxjs observable whitch will be resolved with TReturnType that you can subscribe of in your code.

Delete

  • Delete(id: number, permanent?: undefined | true | false): Observable<any>
  • Method to delete a Content from the Content Repository through OData REST API.

    Parameters

    • id: number

      Id of the Content that will be deleted.

    • Optional permanent: undefined | true | false

    Returns Observable<any>

    Returns an observable that you can subscribe of in your code.

Fetch

  • Method to fetch children of a Content from the Content Repository through OData REST API.

    This method creates an Observable, sends an ajax request to the server and convert the reponse to promise which will be the argument of the Observable.

    params

    options {ODataRequestOptions} Object with the params of the ajax request.

    Type parameters

    Parameters

    Returns Observable<ODataCollectionResponse<T & ISavedContent>>

    Returns an Rxjs observable that you can subscribe of in your code.

    myODataApi.Fetch(new ODataApi.ODataRequestOptions({
          path: 'Root/Sites/Default_site/todos'
          }), ContentTypes.Task)
      .subscribe(result=>{
         console.log('Tasks count:', result.d.__count);
         console.log('The Tasks are:', result.d.results);
      });
    

Get

  • Method to get a Content from the Content Repository through OData REST API.

    Type parameters

    Parameters

    Returns Observable<ODataResponse<T & ISavedContent>>

    Returns an Rxjs observable that you can subscribe of in your code.

    myODataApi.Get(new ODataApi.ODataRequestOptions({
         path: 'Root/Sites/Default_site/todos'
         }), ContentTypes.TaskList)
        .subscribe(result=>{
             console.log('My TaskList is:', result.d)
         });
    

Patch

  • Method to modify a single or multiple fields of a Content through OData REST API.

    Type parameters

    Parameters

    • id: number

      Id of the Content that will be modified.

    • fields: T

      Contains the modifiable fieldnames as keys and their values.

    Returns Observable<T & ISavedContent>

    Returns an Rxjs observable that you can subscribe of in your code.

    myODataApi.Patch(3, ContentTypes.Task, {
          Name: 'MyUpdatedTask'
     })
    .subscribe(result=>{
         console.log('My Updated Task is:', result);
    });
    

Post

  • Post<T>(path: string, contentBody: T): Observable<SavedContent<T>>
  • Method to post a created content into the sense NET Content Repoository.

    Type parameters

    Parameters

    • path: string

      The Path of the content

    • contentBody: T

    Returns Observable<SavedContent<T>>

    An observable whitch will be updated with the created content.

     const myTask = new ContentTypes.Task({
          Name: 'My New Task',
          DueDate: new Date(),
     }, myRepository)
    
     myODataApi.Post('Root/Sites/Default_site/todos', myTask, ContentTypes.Task)
     .subscribe(result=>{
         console.log('My New Task is:', result);
     });
    

Put

  • Put<T>(id: number, fields: T): Observable<SavedContent<T>>
  • Method to set multiple fields of a Content and clear the rest through OData REST API.

    This method creates an Observable, sends an ajax request to the server and convert the reponse to promise which will be the argument of the Observable.

    Type parameters

    Parameters

    • id: number

      Id of the Content that will be modified.

    • fields: T

      Contains the modifiable fieldnames as keys and their values.

    Returns Observable<SavedContent<T>>

    Returns an Rxjs observable that you can subscribe of in your code.

    myODataApi.Put(3, ContentTypes.Task, {
          Name: 'MyUpdatedTask'
     })
    .subscribe(result=>{
         console.log('My Updated Task is:', result);
    });
    

Generated using TypeDoc