|
1 | 1 | # PHP Client for PowerLink CRM |
| 2 | + |
| 3 | +It's php wrapper for [PowerLink CRM Api](https://github.com/powerlink/Rest-API), that uses [Guzzle HTTP Framework](https://github.com/guzzle/guzzle). |
| 4 | + |
| 5 | +## Install |
| 6 | + |
| 7 | +```bash |
| 8 | +composer require stelzer/php-powerlink |
| 9 | +``` |
| 10 | + |
| 11 | +## Usage |
| 12 | + |
| 13 | +```php |
| 14 | +<?php |
| 15 | + |
| 16 | +require_once "vendor/autoload.php"; |
| 17 | + |
| 18 | +use \PowerLink\PowerLink as API; |
| 19 | + |
| 20 | +$payload = array('your payload'); |
| 21 | +$token_id = '<YOUR TOKEN ID>'; |
| 22 | +$client = new API($token_id); |
| 23 | + |
| 24 | +$client->create(); |
| 25 | +``` |
| 26 | + |
| 27 | +## Methods |
| 28 | + |
| 29 | +### Create |
| 30 | + |
| 31 | +**Params** |
| 32 | + |
| 33 | +- object_type — `string` |
| 34 | +- params — `array` |
| 35 | + |
| 36 | +```php |
| 37 | +$object_type = 'crmorder'; |
| 38 | +$params = array('your object'); |
| 39 | +$client->create($object_type, $params); |
| 40 | +``` |
| 41 | + |
| 42 | +### Update |
| 43 | + |
| 44 | +**Params** |
| 45 | + |
| 46 | +- object_type — `string` |
| 47 | +- object_id — `int` |
| 48 | +- params — `array` |
| 49 | + |
| 50 | +```php |
| 51 | +$object_type = 'crmorder'; |
| 52 | +$object_id = 1; |
| 53 | +$params = array('your object'); |
| 54 | +$client->update($object_type, $object_id, $params); |
| 55 | +``` |
| 56 | + |
| 57 | +### Delete |
| 58 | + |
| 59 | +**Params** |
| 60 | + |
| 61 | +- object_type — `string` |
| 62 | +- object_id — `int` |
| 63 | + |
| 64 | +```php |
| 65 | +$client->delete($object_type, $object_id); |
| 66 | +``` |
| 67 | + |
| 68 | +### Query |
| 69 | + |
| 70 | +```php |
| 71 | +use \PowerLink\PowerLink as API; |
| 72 | +use \PowerLink\Query; |
| 73 | + |
| 74 | +$token_id = '<YOUR TOKEN ID>'; |
| 75 | +$client = new API($token_id); |
| 76 | + |
| 77 | +$query = new Query(); |
| 78 | +$query->setQuery(array( |
| 79 | + array('name', '=', '10'), 'AND', array('second_field', '>=', 20) |
| 80 | +)); |
| 81 | + |
| 82 | +$query->setPageNumger(2); |
| 83 | +$query->setPageSize(20); |
| 84 | +$query->setFields(array('first_field', 'second_field')); |
| 85 | +$query->setOrderBy('third_field', 'asc'); |
| 86 | + |
| 87 | +$client->query($query); |
| 88 | +``` |
0 commit comments