new Schemas(endpoint, schemas, service)
- A Collection of Schema instances
Parameters:
Name | Type | Description |
---|---|---|
endpoint |
string | REST API endpoint base |
schemas |
Object | An object defining each schema associated to its name |
service |
apy.CompositeService | Apy Composite service instance |
Throws:
Example
var logs = { time: { type: 'datetime'}, text: { type: 'string'}, }; var members = { lastname: { type: 'string'}, firstname: { type: 'string'}, address: { type: 'dict', schema: { road: { type: 'string'}, street: { type: 'string'}, zipcode: { type: 'integer'}, city: { type: 'string'}, } } }; var activities = { start: { type: 'datetime'}, end: { type: 'datetime'}, description: { type: 'string'} }; var endpoint = 'http://my/api/2/'; var schemas = { logs: logs, members: members, activities: activities }; var service = apy.CompositeService(...); var apySchemas = new apy.components.Schemas(endpoint, schemas, { excludedEndpointByNames: ['logs'] }, service);
Methods
-
<static> Schemas#createResource(name, payload)
-
Create a Resource component based on, given Schema's name and optional payload
Parameters:
Name Type Description name
string Resource name based on given Schema names
payload
Object (optional) Resource payload object
Throws:
Returns:
Resource component based on given name & payload
-
<static> Schemas#get(schemaName)
-
Get an
apy.components.Schema
instance by its nameParameters:
Name Type Description schemaName
string Schema's name
Throws:
Returns:
-
<static> Schemas#load()
-
Load all given Schema objects
-
<static> Schemas#schema2data(schema, keyName)
-
Create recursively based on a Schema a matching payload
Parameters:
Name Type Description schema
Object Schema object
keyName
string key Schema's name
Returns:
A payload based on given schema
- Type
- Object
-
<static> Schemas#transformData(key, value)
-
Create recursively based on a Schema a matching payload
Parameters:
Name Type Description key
string Schema's name
value
Object Schema object
Returns:
Default value
- Type
- *