Skip to content

Commit

Permalink
updated to 0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
danielstieber committed May 24, 2022
1 parent d8b8a9d commit 66cf89d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -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:

Expand Down
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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('<YOUR DOC ID>', '<THE RULE ID>');
```

## 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.
Expand Down Expand Up @@ -150,6 +157,10 @@ $coda->deletePermission('<DOC ID>', '<PERMISSION ID>'); // Remove a permission f
$coda->getACLMetadata('<DOC ID>'); // 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('<YOUR DOC ID>', '<THE RULE ID>');
```

### Account and other
```PHP
Expand Down Expand Up @@ -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:
Expand Down
12 changes: 12 additions & 0 deletions src/CodaPHP/CodaPHP.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down

0 comments on commit 66cf89d

Please sign in to comment.