def __str__(self): format_str = "status:{s.status}, error:{s.error}, message:'{s.message}'".format( s=self) if self.params: format_str += ", params:{params}".format( params=encode_json(self.params)) return format_str
def handle_event(data, only=None, exclude=None): event_type = data["type"] event_action = data["action"] event_slug = event_type + "." + event_action if event_slug == "webhook_config.test": print("Test event received!") if only and event_slug not in only: return if exclude and event_slug in exclude: return print("Event received:", encode_json(data, indent=2))
def __repr__(self): return "{name}(id='{id}', json_attrs={json_attrs})".format( name=self.__class__.__name__, id=self.attrs.get("id"), json_attrs=encode_json(self.attrs, indent=2), )
def post(self, url, headers=None, data=None): json_data = encode_json(data) return self.send("POST", url, headers=headers, data=json_data)