<commit_before>target-process-php-client
=========================

PHP client for Target Process Management Software

## Instalation using composer:

```
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/toecto/targetprocess-php-client"
        }
    ],

    "require": {
        "toecto/targetprocess-php-client": "dev-master",
    },

```

## Using

Collections are implemented as dinamic methods. For example `$tp_client->Tasks()` or  `$tp_client->Users()` and etc.

Use [reference](https://md5.tpondemand.com/api/v1/index/meta) to get collection names

Create client

`$cl = new \ToEcto\TargetprocessPHPClient\Client('http://domain.com/api/v1/', 'user', 'password');`


Get list of objects, it is limited you will have to request more with additional parameters if list is long

```
$array = $cl->Users()->get();
$array = $cl->Users()->get('', array('take' => 25, 'skip' => 25));
```

Will make few requests for at gete full list
Be carefull with long lists!

`$array = $cl->Users()->getAll();`

Get one user

`$array = $cl->Users()->get(18); `

Add object

`$cl->Users()->add($array);`

Update object

`$cl->Users()->set($id, $array);`


Note: `add()` and `set()` return client object itself
Use `getResponce()` in order to get last responce object:

```
$cl->getResponse();
```


Handle errors for default transport

```
try {
    $tp_entity = $tp_client->Assignables()->get($entityID);
} catch (\GuzzleHttp\Exception\ClientException $e) {
    if ($e->getResponse()->getStatusCode() == 404) {
        error_log('Entity tp-'.$entityID.' does not exist');
        return;
    }
}
```<commit_msg>Fix typo<commit_after>target-process-php-client
=========================

PHP client for Target Process Management Software

## Instalation using composer:

```
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/toecto/targetprocess-php-client"
        }
    ],

    "require": {
        "toecto/targetprocess-php-client": "dev-master",
    },

```

## Using

Collections are implemented as dinamic methods. For example `$tp_client->Tasks()` or  `$tp_client->Users()` and etc.

Use [reference](https://md5.tpondemand.com/api/v1/index/meta) to get collection names

Create client

`$cl = new \ToEcto\TargetprocessPHPClient\Client('http://domain.com/api/v1/', 'user', 'password');`


Get list of objects, it is limited you will have to request more with additional parameters if list is long

```
$array = $cl->Users()->get();
$array = $cl->Users()->get('', array('take' => 25, 'skip' => 25));
```

Will make few requests for at gete full list
Be carefull with long lists!

`$array = $cl->Users()->getAll();`

Get one user

`$array = $cl->Users()->get(18); `

Add object

`$cl->Users()->add($array);`

Update object

`$cl->Users()->set($id, $array);`


Note: `add()` and `set()` return client object itself
Use `getResponse()` in order to get last responce object:

```
$cl->getResponse();
```


Handle errors for default transport

```
try {
    $tp_entity = $tp_client->Assignables()->get($entityID);
} catch (\GuzzleHttp\Exception\ClientException $e) {
    if ($e->getResponse()->getStatusCode() == 404) {
        error_log('Entity tp-'.$entityID.' does not exist');
        return;
    }
}
```
{'fraction_non_alphanumeric': 0.19629292008508054, 'fraction_numerical': 0.007292616226071103, 'mean_word_length': 3.6894586894586894, 'pattern_counts': {'":': 10, '<': 3, '<?xml version=': 0, '>': 45, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '997467', 'n_tokens_mistral': 1103, 'n_tokens_neox': 1047, 'n_words': 281}