cwd / datamolino-client
This package is abandoned and no longer maintained.
No replacement package was suggested.
1.2.3.5
2018-12-21 13:09 UTC
Requires
- php: >=7.1
- ext-json: *
- php-http/discovery: ^1.0
- php-http/guzzle6-adapter: ^1.1
- symfony/finder: ~3.4 || ~4.0
- symfony/http-foundation: ~3.4 || ~4.0
- symfony/serializer-pack: ~1.0
- webmozart/assert: ~1.3
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.13
- symfony/debug: *
Suggests
- symfony/symfony: For using bundle integration
README
see https://datamolino.docs.apiary.io/#introduction/how-to-start-using-datamolino-api
This Datamolino Client is currently compatible with version 1.2.3 of the Datamolino API
Dependencies:
- php >=7.1
- ext-json
Installation:
composer require cwd/datamolino-client
Usage:
Authentication
$datamolino = new DatamolinoClient(); // Get a Token via password authentication $token = $datamolino->getClient()->authenticatePassword($clientID, $clientSecret, $username, $password); // Store the token for later use // you can refresh your token any time by using $token = $datamolino->getClient()->refreshToken($clientID, $clientSecret, $token->getRefreshToken()); // If you have stored the token elsewhere just build the object: $token = (new Token())->setAccessToken($accessToken) ->setRefreshToken($refreshToken) ->setsetExpiresIn($expiresIn); // Set the token in the Client $datamolino->getClient()->setToken($token);
User Endpoint
// me $user = $datamolino->user()->me();
Agenda Endpoint
// get all agendas $agendas = $datamolino->agenda()->getAll(); // get agenda by id $agenda = $datamolino->agenda()->get(4050); // update $agenda->setName('My Agenda Name') ->getAddress()->setBuildingNo(2); $datamolino->agenda()->update($agenda); // create $agenda = new Agenda(); $agenda->setName('My Other Agenda') ->setAddress((new Address()) ->setStreet('Example') ->setBuildingNo(125) ->setCountry('at') ); $agenda = $datamolino->agenda()->create($agenda, $lacyLoad = true); // delete $datamolino->agenda()->delete(4063);
Document Endpoint
// Find documents $documents = $datamolino->document()->find(4050, [], new \DateTime('2018-10-10 21:59:21')); // Get document by id $document = $datamolino->document()->get(268145); // Upload multiple documents via finder $finder = (new Finder())->in('../testdata')->date('since 1 hour ago'); $documents = $datamolino->document()->createMultiple($finder, 4050, Document::DOCTYPE_PURCHASE, false, true); // Or path $documents = $datamolino->document()->createMultiple('../testdata', 4050, Document::DOCTYPE_PURCHASE, false, true); // or supply an array with SPLFileInfo Objects $files = [ new \SplFileInfo('path/to/file.pdf'), new \SplFileInfo('path/to/other/file.pdf'), ]; $documents = $datamolino->document()->createMultiple($files, 4050, Document::DOCTYPE_PURCHASE, false, true); // send repair request for a document $datamolino->document()->repair(268138, 'API test ignore'); // Delete document $datamolino->document()->delete(268145);
Symfony Integration
Configuration
Enable the bundle in bundles.php:
return [
// ...
Cwd\Datamolino\CwdDatamolino::class => ['all' => true],
]
Create config/packages/cwd_datamolino.yaml:
cwd_datamolino:
client_id: your_client_id
client_secret: you_client_secret
datamolino_host: beta.datamolino.com or app.datamolino.com
username: your_username
password: your_password
Authentication
$datamolino = $this->get(Cwd\Datamolino\DatamolinoClient::class); // Get a Token via password authentication $token = $datamolino->getClient()->authenticate();