diff --git a/LICENSE b/LICENSE index 166b383..47c5de2 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2020 Daniel Stieber +Copyright (c) 2022 Daniel Stieber Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/README.md b/README.md index 183f726..85dbcd3 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ CodaPHP ======================= [![Latest Stable](https://img.shields.io/github/release/danielstieber/codaphp.svg?style=flat-square)](https://github.com/danielstieber/codaphp/releases) -[![Coda API Version](https://img.shields.io/badge/Coda_API_version-1.1.0-orange.svg?style=flat-square)](https://coda.io/developers/apis/v1) +[![Coda API Version](https://img.shields.io/badge/Coda_API_version-1.2.6-orange.svg?style=flat-square)](https://coda.io/developers/apis/v1) ![Downloads](https://img.shields.io/packagist/dt/danielstieber/coda-php?style=flat-square) * [Quickstart](#Quickstart) @@ -66,6 +66,13 @@ if($coda->insertRows($docId, 'Products', ['Title' => 'Goatmilk', 'Status' => 'so echo 'Product updated'; } ``` +### Triggering automations +Since May 2022, Coda automations can be triggered via webhooks – and via CodaPHP. To trigger an automation, the automation must be set to "Webhook invoked". To run the automation you need the doc ID an the ID of the automation rule. You can find the rule ID when you click on the 3 dots (kebap menu) above the rule step settings. + +```PHP +// Trigger the automation +$result = $coda->runAutomation('', ''); +``` ## Overview This is a personal side project. If you have any suggestions, find bugs or want to contribute, don't hesitate to contact me. You can use the [offical Coda community](https://community.coda.io/) to asks questions and reach out as well. @@ -150,6 +157,10 @@ $coda->deletePermission('', ''); // Remove a permission f $coda->getACLMetadata(''); // Returns the ACL metadata of a doc ``` Learn more about permission settings with the API [here](https://coda.io/developers/apis/v1#tag/ACLs). +### Run automations / trigger webhooks +```PHP +$coda->runAutomation('', ''); +``` ### Account and other ```PHP @@ -184,6 +195,11 @@ Now you can add a "open hyperlink"-button in your doc that opens https://yourdom ![clear cache button](https://i.imgur.com/it4rkxV.png) ## Changelog +### 0.3.0 (May 24, 2022) +* Update to API version 1.2.6. +* New features: + - Trigger "Webhook invoked" automations + ### 0.2.0 (January 3, 2021) * Update to API version 1.1.0. * New features: diff --git a/src/CodaPHP/CodaPHP.php b/src/CodaPHP/CodaPHP.php index 4dc124e..b2d0367 100644 --- a/src/CodaPHP/CodaPHP.php +++ b/src/CodaPHP/CodaPHP.php @@ -504,6 +504,18 @@ public function deleteUser($doc, $email) return false; } } + /** + * Runs an automation of type "webhook invoked" in a doc + * + * @param string $doc Id of a doc + * @param string $automation Id of the automation rule + * @return mixed + */ + public function runAutomation($doc, $ruleId) + { + $res = $this->request('/docs/'.$doc.'/hooks/automation/'.$ruleId, [], 'POST'); + return $res; + } /** * Cleares the cache folder *