Home Manual Reference Source Test Repository
public class | source

SearchBuilder

This is a abstract class. It is a base to make all kind of search request to OpenGate North API.

Test:

Constructor Summary

Public Constructor
public

Constructor

Member Summary

Public Members
public

[route]: *

Method Summary

Public Methods
public

Add ascending param into the sort search object

public

addSortBy(filterField: string, typeSort: string): SearchBuilder

Add ascending/descending param into the sort search object

public

Add descending param into the sort search object

public

Build a instance of Search

public

The search request will have this filter

public

findAllFields(input: *): Promise

Return a promise which it will contains an array with fields recommended with complete structure

public

findFieldPath(field: *): Promise

Return a promise which it will contains an string with the path of a field

public

findFields(input: *): Promise

Return a promise which it will contains an array with fields recommended with only identifier

public

limit(size: number, start: number): SearchBuilder

Set reponse pagination.

public

Remove sort param from the search object

public

The request will have a specific time out if it will be exceeded then the promise throw an exception

Public Constructors

public constructor(parent: InternalOpenGateAPI, routes: object) source

Constructor

Params:

NameTypeAttributeDescription
parent InternalOpenGateAPI
  • nullable: false

this is ogapi instance

routes object
  • nullable: false

this defined the routes. One of those routes must be called on Builder before call build method.

Public Members

public [route]: * source

Public Methods

public addSortAscendingBy(filterField: string): SearchBuilder source

Add ascending param into the sort search object

Params:

NameTypeAttributeDescription
filterField string
  • nullable: false

This field must be allowed into the specific resource

Return:

SearchBuilder

Example:

 ogapi.subscriptionsSearchBuilder().addSortAscendingBy('prov.customid') // Order by prov.customid Ascending  

Test:

public addSortBy(filterField: string, typeSort: string): SearchBuilder source

Add ascending/descending param into the sort search object

Params:

NameTypeAttributeDescription
filterField string
  • nullable: false

This field must be allowed into the specific resource

typeSort string
  • nullable: false

Return:

SearchBuilder

Example:

 ogapi.subscriptionsSearchBuilder().addSortBy('prov.customid','ASCENDING') // Order by prov.customid Ascending
 ogapi.devicesSearchBuilder().addSortBy('prov.customid','DESCENDING') // Order by prov.customid Descending 

Test:

public addSortDescendingBy(filterField: string): SearchBuilder source

Add descending param into the sort search object

Params:

NameTypeAttributeDescription
filterField string
  • nullable: false

This field must be allowed into the specific resource

Return:

SearchBuilder

Example:

 ogapi.devicesSearchBuilder().addSortDescendingBy('prov.customid') // Order by prov.customid Descending

Test:

public build(): Search source

Build a instance of Search

Return:

Search

Throw:

SearchBuilderError

Throw error on url build

Example:

 ogapi.devicesSearchBuilder().onProvisioned().build()

Test:

public findAllFields(input: *): Promise source

Return a promise which it will contains an array with fields recommended with complete structure

Params:

NameTypeAttributeDescription
input *

Return:

Promise

public findFieldPath(field: *): Promise source

Return a promise which it will contains an string with the path of a field

Params:

NameTypeAttributeDescription
field *

Return:

Promise

public findFields(input: *): Promise source

Return a promise which it will contains an array with fields recommended with only identifier

Params:

NameTypeAttributeDescription
input *

Return:

Promise

public limit(size: number, start: number): SearchBuilder source

Set reponse pagination.

Params:

NameTypeAttributeDescription
size number
  • nullable: false

Defined the number of elements on response

start number
  • optional
  • default: 0

Defined the offset on response

Return:

SearchBuilder

Example:

 ogapi.subscribersSearchBuilder().limit(10) // Without offset
 ogapi.subscribersSearchBuilder().limit(25,50) //With offset value 50

Test:

public removeSortBy(filterField: string): SearchBuilder source

Remove sort param from the search object

Params:

NameTypeAttributeDescription
filterField string

This field must be allowed into the specific resource

Return:

SearchBuilder

Example:

 ogapi.subscriptionsSearchBuilder().removeSortBy('prov.customid') // Remove order by prov.customid
 ogapi.subscriptionsSearchBuilder().removeSortBy() // Remove all order by parameters