new Connection(settings)
This:
Parameters:
Name | Type | Argument | Description | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
settings |
Object |
<optional> |
Properties
|
- Source:
Example
// create a connection for the user 'perkikiki' with the token 'TTZycvBTiq'
var conn = new pryv.Connection({username: 'perkikiki', auth: 'TTZycvBTiq'});
Methods
-
accessInfo(callback) → {Connection}
-
Get access information related this connection. This is also the best way to test that the combination username/token is valid.
Parameters:
Name Type Description callback
Connection~accessInfoCallback - Source:
Returns:
this
- Type
- Connection
-
fetchStructure(callback) → {Connection}
-
In order to access some properties such as event.stream and get a {Stream} object, you need to fetch the structure at least once. For now, there is now way to be sure that the structure is up to date. Soon we will implement an optional parameter "keepItUpToDate", that will do that for you.
TODO implements "keepItUpToDate" logic.
Parameters:
Name Type Description callback
Streams~getCallback array of "root" Streams
- Source:
Returns:
this
- Type
- Connection
-
getLocalTime(serverTime) → {number}
-
Translate this timestamp (server dimension) to local system dimension This could have been named to "translate2LocalTime"
Parameters:
Name Type Description serverTime
number timestamp (server dimension)
- Source:
Returns:
timestamp (local dimension) same time space as (new Date()).getTime();
- Type
- number
-
getServerTime(localTime) → {number}
-
Translate this timestamp (local system dimension) to server dimension This could have been named to "translate2ServerTime"
Parameters:
Name Type Description localTime
number timestamp (local dimension) same time space as (new Date()).getTime();
- Source:
Returns:
timestamp (server dimension)
- Type
- number
-
monitor(filter) → {Monitor}
-
Start monitoring this Connection. Any change that occurs on the connection (add, delete, change) will trigger an event. Changes to the filter will also trigger events if they have an impact on the monitored data.
Parameters:
Name Type Description filter
Filter changes to this filter will be monitored.
- Source:
Returns:
- Type
- Monitor
-
privateProfile(callback) → {Connection}
-
Get the private profile related this connection.
Parameters:
Name Type Description callback
Connection~privateProfileCallback - Source:
Returns:
this
- Type
- Connection
-
request(method, path, callback, jsonData)
-
Do a direct request to Pryv's API. Even if exposed there must be an abstraction for every API call in this library.
Parameters:
Name Type Description method
string GET | POST | PUT | DELETE
path
string to resource, starting with '/' like '/events'
callback
Connection~requestCallback jsonData
Object data to POST or PUT
- Source:
Type Definitions
-
accessInfoCallback(error, result)
-
Called with the desired Streams as result.
Parameters:
Name Type Description error
Object eventual error
result
AccessInfo - Source:
-
requestCallback(error, result, resultInfo)
-
Called with the result of the request
Parameters:
Name Type Description error
Object eventual error
result
Object jSonEncoded result
resultInfo
Object Properties
Name Type Description code
Number HTTP result code
headers
Object HTTP result headers by key
- Source: