divineomega / cachet.php Goto Github PK
View Code? Open in Web Editor NEW๐ PHP client library for the Cachet API
License: GNU Lesser General Public License v3.0
๐ PHP client library for the Cachet API
License: GNU Lesser General Public License v3.0
The readme 'Quick Start' section should contain actual examples of all basic functions, instead of just referring to the examples PHP file.
Factories and object classes should be created for the following Cachet elements and existing code some be re-factored to use them.
CachetInstance
to hold details of the Cachet instance you are currently using.Component
Incident
Metric
MetricPoint
Subscriber
$subscriberDetails = ['email' => '[email protected]', 'verify' => 1 , 'components' => [5,7]];
$subscriber = $cachetInstance->createSubscriber($subscriberDetails);
echo $subscriber->id.' - '.$subscriber->email;
I run this code, but the new Subscriber isn't being subscribed to the supplied component but is Subscribed to all updates.
Need to test all of the library's functionality before and when Cachet 2 is released.
The following code should work as you'd expect.
$components = ComponentFactory::getAll($cachetInstance);
$component = $components[0];
$component->delete();
The factories for all Cachet elements should have a 'create' method that accepts an associative array as a parameter and then performs to appropriate POST request.
Appropriate 'createComponent' style methods should be added to the CachetInstance object that calls these new factory methods.
On dev branch, currently we retrieve components like this:
$components = ComponentFactory::getAll($cachetInstance);
We should allow this more intuitive syntax:
$components = $cachetInstance->getAllComponents();
Merge to master, tag the release and write release notes.
You're duplicating a lot of code for cURL.
CachetInstanceFactory::create should be static
As @splitice very rightly suggested, we should get some unit testing in cachet.php. I think we should aim some basic coverage to be in for the v0.3 release.
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
We should ensure the following files match the new syntax of v0.3.
README.md
examples.php
examples.php
should be fully tested with the new syntax.
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
This might be a regression, not certain.
When running the following two snippets, they return seem to both return the same (descending) results.
// Get components sorted by name ascending
$components = $cachetInstance->getAllComponents('name', 'asc');
// Display components sorted by name ascending
echo "\n";
echo '*** Components (sorted by name ascending) ***';
echo "\n";
foreach ($components as $component) {
echo $component->id.' - '.$component->name.' - '.$component->description.' - '.$component->status;
echo "\n";
}
// Get components sorted by name descending
$components = $cachetInstance->getAllComponents('name', 'desc');
// Display components sorted by name descending
echo "\n";
echo '*** Components (sorted by name descending) ***';
echo "\n";
foreach ($components as $component) {
echo $component->id.' - '.$component->name.' - '.$component->description.' - '.$component->status;
echo "\n";
}
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
Only use API tokens!
The next version (v0.2) should be released with a more open license.
We'll release v0.2 with the Lesser GPL3, instead of the regular GPL3.
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
use \DivineOmega\CachetPHP\Factories\CachetInstanceFactory;
$cachetInstance = CachetInstanceFactory::create($host, $token);
$incidents = $cachetInstance->getAllIncidents();
$incident = $incidents[0];
$incident->status = 1;
$incident->save();
Receiving the following error -
PHP Fatal error: Uncaught exception 'GuzzleHttp\Exception\ClientException' with message 'Client error: `PUT http://status1.test.in/api/v1/incidents/2?name=Downtime%20Incoming%20Calls&message=%23%20Issue%20Observed%0D%0A%0D%0A%23%20Issue%20Fixed%20at%2012%3A15PM&status=1&visible=1&component_id=9` resulted in a `400 Bad Request` response:
{"errors":[{"id":"390e83d4-a2db-440f-b93d-2f0b4bb754cd","status":400,"title":"Bad Request","detail":"The request cannot (truncated...)
' in /home/test/commonix/extlib/cachet-status-board-php-client/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:107
Stack trace:
#0 /home/test/commonix/extlib/cachet-status-board-php-client/vendor/guzzlehttp/guzzle/src/Middleware.php(65): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response))
#1 /home/test/commonix/extlib/cachet-status-board-php-client/vendor/guzzlehttp/promises/src/Promise.php(201): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\Response))
#2 /hom in /home/test/commonix/extlib/cachet-status-board-php-client/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php on line 107
What is the fix for this?
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
The following code should work as you'd expect.
$components = $cachetInstance->getAllComponents();
$component = $components[0];
$component->name = 'Jeff The Awesome Component';
$component->save();
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.