Interface RequestBuilderInternal

RequestBuilderImpl

Description

Interface for the RequestBuilderImpl

See

RequestBuilderImpl - Default implementation

Hierarchy

  • RequestBuilder

Implemented by

Methods - Advanced/Development functions

Methods - OData functions

Methods - OData functions extensions

Methods - Resolve functions

Methods - Special functions

Methods - Advanced/Development functions

Methods - OData functions

  • Count the amount of results

    Parameters

    • count: boolean

      Whether to count the amount of results

    Returns RequestBuilder

    The RequestBuilderImpl

    Example

    new ODataRequest('Fractie')
    .count(true)

    Example

    new ODataRequest('Fractie')
    .count(false)
  • Expand the request to include information from other entities

    Parameters

    • attribute: string

      The attribute to expand

    • Optional func: string

      The function to apply to the attribute

    Returns RequestBuilder

    The RequestBuilderImpl

    Example

    new ODataRequest('Fractie')
    .expand('FractieZetel')
    .expand('Stemming', '$select=Soort')

    Example

    new ODataRequest('Fractie')
    .expand('FractieZetel')
    // Multiple functions can be applied to the same expansion
    // Using a semicolon (;) to separate them
    .expand('Stemming', "$top=1 ; $select=Soort")
  • Filter the results

    Parameters

    • expression: string

      The expression to format the results with

    Returns RequestBuilder

    The RequestBuilderImpl

    Example

    new ODataRequest('Fractie')
    .filter("Afkorting eq 'VVD'")

    Example

    new ODataRequest('Fractie')
    .filter("AantalZetels gt 10")
    .filter("AantalZetels lt 20")
  • The amount of metadata to return with the results

    Parameters

    • format: "none" | "minimal" | "full"

      The format to use

    Returns RequestBuilder

    The RequestBuilderImpl

    Example

    new ODataRequest('Fractie')
    .format('none')

    Example

    new ODataRequest('Fractie')
    .format('minimal')

    Example

    new ODataRequest('Fractie')
    .format('full')
  • Order the results by a specific attribute

    Parameters

    • field: string

      The attribute to order by

    • Optional direction: "asc" | "desc"

      The direction to order by (asc or desc)

    Returns RequestBuilder

    The RequestBuilderImpl

    Example

    new ODataRequest('Fractie')
    .orderby('NaamNL') // Direction defaults to asc

    Example

    new ODataRequest('Fractie')
    .orderby('NaamNL', 'asc')

    Example

    new ODataRequest('Fractie')
    .orderby('NaamNL', 'desc')
  • Select a specific attribute to return Will only show the attribute(s) selected for the entity

    Parameters

    • attribute: string

      The attribute to select

    Returns RequestBuilder

    The RequestBuilderImpl

    Example

    new ODataRequest('Fractie')
    // You can select multiple attributes
    .select('NaamNL')
    .select('NaamEN')

    Example

    new ODataRequest('Fractie')
    .select('NaamNL')
  • Limit the amount of results returned

    Parameters

    • top: number

      The amount of results to return (1..250)

    Returns RequestBuilder

    The RequestBuilderImpl

    Example

    new ODataRequest('Fractie')
    .top(1)

    Example

    new ODataRequest('Fractie')
    .top(250)

    Throws

    Error if $Top is already defined

    Throws

    Error if $Top is less than or equal to 0

    Throws

    Error if $Top is greater than 250

Methods - OData functions extensions

  • Use a custom query. Will overwrite all previously declared functions. And will directly use the given query. Functions declared after this function will also be ignored.

    Parameters

    • query: string

      The custom query to use

    Returns RequestBuilder

    The RequestBuilderImpl

    Throws

    Error if the query does not start with a '$'

    Remarks

    • Will ignore all previously declared functions
    • Will ignore all functions declared after this function

    Example

    new ODataRequest('Fractie')
    .custom('$select=Afkorting')
    // https://gegevensmagazijn.tweedekamer.nl/OData/v4/2.0/Fractie?$select=Afkorting

    Example

    new ODataRequest('Fractie')
    .custom('$select=Afkorting&$top=1')
    // https://gegevensmagazijn.tweedekamer.nl/OData/v4/2.0/Fractie?$select=Afkorting&$top=1
  • Select multiple attributes to return Will only show the attribute(s) selected for the entity

    Parameters

    • attributes: string[]

      The attributes to select

    Returns any

    The RequestBuilderImpl

    Example

    new ODataRequest('Fractie')
    .selectMultiple(['NaamNL', 'NaamEN'])
    // You can also use the select function multiple times
    .selectMultiple(['DatumActief', 'DatumInactief'])

    Example

    new ODataRequest('Fractie')
    .selectMultiple(['NaamNL', 'NaamEN'])
    // You can also use the selectMultiple function in combination with the select function
    .select('DatumActief')
  • Select a list of attributes to return Will overwrite any previous select functions

    Parameters

    • attributes: string[]

      The attributes to select

    Returns RequestBuilder

    The RequestBuilderImpl

    Example

    new ODataRequest('Fractie')
    .setSelect(['NaamNL', 'NaamEN'])

Methods - Resolve functions

  • Given the current state of the RequestBuilderImpl, build the request url according to functions provided

    Returns string

    The build request url

    Example

    const construction = new ODataRequest('Fractie')
    .expand('FractieZetel')
    .top(1)

    // Log the request url (build)
    console.log(construction.build());
  • Given the current state of the RequestBuilderImpl, build the request url according to functions provided and then utilize cross-fetch to make the request

    Returns Promise<any>

    The response from the request

    See

    cross-fetch - Fetch API implementation

    Remarks

    Function flow: request -> build -> fetch

    Example

    new ODataRequest('Fractie')
    .expand('FractieZetel')
    .expand('Stemming', '$select=Soort')
    .top(1)
    .request()
    // Log the data
    .then(data => console.log(data))
    .catch(err => console.warn(err))

    Example

    const construction = new ODataRequest('Fractie')
    .expand('FractieZetel')
    .expand('Stemming', '$select=Soort')
    .top(1)

    construction.request().then((data) => {
    // Log the data
    console.log(data);
    }).catch((error) => {
    console.warn(error);
    });

Methods - Special functions

  • Experimental

    Unique function to gather information on a specific entity instead of the entire collection

    Parameters

    • id: string

      The unique id of the entity

    Returns RequestBuilder

    The RequestBuilderImpl

    Throws

    If invalid query options are provided

    Remarks

    [!] Does not work with all other functions Query options $filter, $orderby, $count, $skip, and $top can be applied only on collections.

    Example

    new ODataRequest('Fractie')
    .findById('65129918-f256-4975-9da4-488da34d6695')

Generated using TypeDoc