Home Manual Reference Source
protected class | source

SimpleResourceProxy

Indirect Subclass:

GeoResourceProxy

Proxy for accessing resource. This will make sure that they are properly wrapped before the promise resolves.

Constructor Summary

Public Constructor
public

constructor(api: Maps4News, Target: ResourceBase, altUrl: string, seedData: object)

Member Summary

Public Members
public get

Target to wrap results in

public get

Get api instance

public get

Proxy target url

Method Summary

Public Methods
public

List target resource

public
this method was deprecated.

List target resource

public

Get the resource lister

public

Build a new instance of the target

Public Constructors

public constructor(api: Maps4News, Target: ResourceBase, altUrl: string, seedData: object) source

Params:

NameTypeAttributeDescription
api Maps4News

Instance of the api

Target ResourceBase

Target to wrap

altUrl string
  • optional
  • default: null
  • nullable: true

Internal use, Optional alternative url for more complex routing

seedData object

Internal use, used for seeding ::new

Public Members

public get Target: ResourceBase: * source

Target to wrap results in

Return:

ResourceBase

Target constructor

public get api: Maps4News: * source

Get api instance

Return:

Maps4News

Api instance

public get baseUrl: string: * source

Proxy target url

Return:

string

url

Example:

api.layers.select(100).organisations.baseUrl === "https://maponline-api.dev/v1/layers/100/organisations"

Public Methods

public list(params: Number | Object | RequestParameters): Promise<PaginatedResourceListing> source

List target resource

Params:

NameTypeAttributeDescription
params Number | Object | RequestParameters
  • optional

Parameters or the page number to be requested

params.page Number
  • optional
  • default: 1

The page to be requested

params.perPage Number
  • optional
  • default: this.api.defaults.perPage

Amount of items per page. This is silently capped by the API

params.sort String | String[]
  • optional
  • default: ''

Amount of items per page. This is silently capped by the API

params.deleted String
  • optional
  • default: this.api.defaults.showDeleted

Show deleted resources, posible values: only, none, all

params.search Object<String, String|Array<String>>
  • optional
  • nullable: true

Search parameters

Return:

Promise<PaginatedResourceListing>

paginated resource

Throw:

ApiError

Example:

// Find layers with a name that starts with "test" and a scale_min between 1 and 10
// See Api documentation for search query syntax
const search = {
  name: '^:test',
  scale_min: ['>:1', '<:10'],
};

api.layers.list({perPage: 10, search});

public listAndWrap(params: Number | Object | RequestParameters): PaginatedResourceWrapper source

this method was deprecated.

List target resource

Params:

NameTypeAttributeDescription
params Number | Object | RequestParameters
  • optional

Parameters or the page to be requested

params.page Number
  • optional
  • default: 1

The page to be requested

params.perPage Number
  • optional
  • default: this.api.defaults.perPage

Amount of items per page. This is silently capped by the API

params.sort Array<String> | string
  • optional
  • default: ''

Comma separated list or array

params.deleted String
  • optional
  • default: this.api.defaults.showDeleted

Show deleted resources, posible values: only, none, all

params.shareCache Boolean
  • optional
  • default: this.api.defaults.shareCache

Share cache across instances

params.search Object<String, String|Array<String>>
  • optional
  • nullable: true

Search parameters

Return:

PaginatedResourceWrapper

Wrapped paginated resource

Example:

// Find layers with a name that starts with "test" and a scale_min between 1 and 10
// See Api documentation for search query syntax
const search = {
  name: '^:test',
  scale_min: ['>:1', '<:10'],
};

api.layers.listandWrap({perPage: 10, search});

public lister(parameters: object | RequestParameters, maxRows: number): ResourceLister source

Get the resource lister

Params:

NameTypeAttributeDescription
parameters object | RequestParameters

parameters

maxRows number

Maximum amount of rows

Return:

ResourceLister

Resource lister

public new(data: Object<String, *>): ResourceBase source

Build a new instance of the target

Params:

NameTypeAttributeDescription
data Object<String, *>

Data for the object to be populated with

Return:

ResourceBase

Resource with target data