2015-12-12 22:34:08 +00:00
|
|
|
|
|
|
|
import click
|
2015-12-13 15:11:22 +00:00
|
|
|
import json
|
2016-02-28 20:37:56 +00:00
|
|
|
import requests
|
2015-12-12 22:34:08 +00:00
|
|
|
from certidude import config
|
|
|
|
|
2015-12-13 15:11:22 +00:00
|
|
|
|
2015-12-12 22:34:08 +00:00
|
|
|
def publish(event_type, event_data):
|
|
|
|
"""
|
|
|
|
Publish event on push server
|
|
|
|
"""
|
2015-12-13 15:11:22 +00:00
|
|
|
if not isinstance(event_data, str):
|
|
|
|
from certidude.decorators import MyEncoder
|
|
|
|
event_data = json.dumps(event_data, cls=MyEncoder)
|
|
|
|
|
2016-02-28 20:37:56 +00:00
|
|
|
notification = requests.post(
|
|
|
|
config.PUSH_PUBLISH % config.PUSH_TOKEN,
|
|
|
|
data=event_data,
|
|
|
|
headers={"X-EventSource-Event": event_type, "User-Agent": "Certidude API"})
|
2015-12-13 15:11:22 +00:00
|
|
|
|
2015-12-12 22:34:08 +00:00
|
|
|
|