krzysztof-gzocha/simple-data-visualization — pull request #4 by krzysztof-gzocha-xsolve (2014-06-01 16:41:02+00:00)
Title: Measurements in REST API

Now it is available to insert Measurements through REST API.

Most significant parameters are available in backend/config/params.php:
- restQueryRegExp: regular expression, which will let application to identify all needed variables to put single measurement into the application.
- separatorSign: regular expression, which will let application to split long string into measurements.

```
'restQueryRegExp' => '/(?P[\d]{4})-(?P[\d]{1,2})-(?P[\d]{1,2})-(?P[\d]{1,2})-(?P[\d]{1,2})-(?P[\d]{1,2}):(?P[\d\.]+)/i',
'separatorSign' => '/[,; ]{1}/',
```

Creating measurement through API will require some authentication.
You can authenticate by using 1 of 3 defined auth systems:
- HttpBasicAuth
- HttpBearerAuth
- QueryParamAuth (the simpler one)

Example usage:
```
http://localhost/backend/web/index.php/measurement/create/badanie-szybkosci/2015-04-03-15-13-12:14.50,2015-04-03-15-13-54:16.50
http://localhost/backend/web/index.php/measurement/create//,,...
= -----:
```

To authenticate with QueryParamAuth you just need to add ```?access_token=XXXX``` to the end of the URL, where XXXX is representing ```User::auth_key```.

When measurements value will be bigger/smaller then ```Subject::maxValue/minValue``` then the appropriate event will be triggerd by ```\Yii::$app->trigger()```.

You can update your DB schema by using ```./yii migrate```