-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
carycheng
committed
Oct 3, 2018
1 parent
ccd5c3d
commit 567ea52
Showing
7 changed files
with
362 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ | |
'task', | ||
'task_assignment', | ||
'user', | ||
'webhook', | ||
'watermark', | ||
'web_link', | ||
])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# coding: utf-8 | ||
from __future__ import unicode_literals | ||
|
||
from .base_object import BaseObject | ||
|
||
|
||
class Webhook(BaseObject): | ||
"""Represents a Box Webhook.""" | ||
|
||
_item_type = 'webhook' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
Webhooks | ||
======== | ||
|
||
Webhooks enable you to attach event triggers to Box files and folders. Event triggers monitor events on Box objects and notify your application when they occur. A webhook notifies your application by sending HTTP requests to a URL of your choosing. | ||
|
||
<!-- START doctoc generated TOC please keep comment here to allow auto update --> | ||
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> | ||
|
||
|
||
- [Get Information about Webhook](#get-information-about-webhook) | ||
- [List all Webhooks](#list-all-webhooks) | ||
- [Create Webhook](#create-webhook) | ||
- [Delete Webhook](#delete-webhook) | ||
- [Update Webhook](#update-webhook) | ||
|
||
<!-- END doctoc generated TOC please keep comment here to allow auto update --> | ||
|
||
Get Information about Webhook | ||
----------------------------- | ||
|
||
To retrieve information about a webhook, use `webhook.get(fields=None)` | ||
|
||
```python | ||
webhook_info = client.webhook('1234').get() | ||
``` | ||
|
||
List all Webhooks | ||
----------------- | ||
|
||
To retrieve an iterable of all webhooks in the enterprise, use `client.get_webhooks(limit=None, marker=None, fields=None)` | ||
|
||
```python | ||
webhooks = client.get_webhooks() | ||
for webhook in webhooks: | ||
# Do something | ||
``` | ||
|
||
Create Webhook | ||
-------------- | ||
|
||
To create a webhook on a specified target, use `client.create_webhook(target, triggers, address)` | ||
|
||
You can create a webhook on either a `file` or a `folder`. For a full list of triggers, see [here](https://developer.box.com/v2.0/reference#webhooks-v2) | ||
|
||
```python | ||
folder = client.folder('1111') | ||
created_webhook = client.create_webhook(folder, ['FILE.UPLOADED', 'FILE.PREVIEWED'], 'https://example.com') | ||
``` | ||
|
||
Delete Webhook | ||
-------------- | ||
|
||
To delete a webhook, use `webhook.delete()` | ||
|
||
```python | ||
client.webhook('1234').delete() | ||
``` | ||
|
||
Update Webhook | ||
-------------- | ||
|
||
To update a webhook, use `webhook.update_info(data)` | ||
|
||
```python | ||
update_object = { | ||
triggers: ['FILE.COPIED'], | ||
address: 'https://newexample.com', | ||
} | ||
updated_webhook = client.webhook('1234').update_info(update_object) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.