Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add Status Page Updates API #19

Merged
merged 1 commit into from
Feb 9, 2021

Conversation

owenvoke
Copy link
Collaborator

@owenvoke owenvoke commented Feb 9, 2021

I noticed there was an API for this, but it's not in the PHP SDK. I was just thinking it might be useful for the Oh Dear CLI tool to be able to post updates. 馃し馃徎

For the createStatusPageUpdate() method, I wasn't sure whether to separate it into multiple parameters, or just an array. 馃

Feel free to use the following for the markdown docs if you'd like:


Copy-able Markdown documentation

Manage your status page updates with the PHP SDK

Make sure you've read the getting started guide first. Once that's done, you should have our package & authentication ready to go.

Retrieve all status page updates

The simplest example is one where we list all the updates for a status page.

$ohDear->statusPage(1)->updates();

// Alternatively you could do this
$statusPages = $ohDear->statusPageUpdates(1);

This will return an array of OhDear\PhpSdk\Resources\StatusPageUpdate instances.

The individual attributes will be explained in the next section.

Add a status page update through the SDK

A new status page update can be created with createStatusPageUpdate().

$statusPageUpdate = $ohDear->createStatusPageUpdate([
    'status_page_id' => 1,
    'title' => 'Our site is down',
    'text' => 'We are working on it!',
    'pinned' => true, 
    'severity' => 'high', // One of: info, warning, high, resolved, scheduled
    'time' => '2021-02-09 12:25', // A UTC date field for this update in the Y-m-d H:i format
]);

This will return an instance of OhDear\PhpSdk\Resources\StatusPageUpdate

You can get a few properties of a Status Page Update.

$statusPageUpdate->id;
$statusPageUpdate->title;
$statusPageUpdate->text;
$statusPageUpdate->pinned;
$statusPageUpdate->severity;
$statusPageUpdate->time;
$statusPageUpdate->statusPageUrl;

Deleting a status page update

A site can easily be deleted. This assumes the $statusPageUpdate is an instance of OhDear\PhpSdk\Resources\StatusPageUpdate, which you can get with the statusPageUpdates() method.

$statusPageUpdate->delete();

// Alternatively you could do this
$ohDear->deleteStatusPageUpdate(1);

For more extensive understanding of the return values, please have a look at our status page updates API documentation.

@freekmurze freekmurze merged commit ac01df2 into ohdearapp:master Feb 9, 2021
@freekmurze
Copy link
Contributor

Thank you very much!

@owenvoke owenvoke deleted the feature/status-page-updates branch February 9, 2021 16:04
@freekmurze
Copy link
Contributor

I've added that markdown to our docs! Big thank you for that!

@owenvoke
Copy link
Collaborator Author

owenvoke commented Feb 9, 2021

No problem, loving the service. 馃憣馃徎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants