def get_customer_id(cuid): app_id = get_helpscout_app_id() app_secret = get_helpscout_app_secret() hs = HelpScout(app_id, app_secret) for conversation in hs.hit('conversations', 'get', resource_id=cuid): customer_id = conversation["createdBy"]["id"] return customer_id
def get_conversation(cuid, params=None): app_id = get_helpscout_app_id() app_secret = get_helpscout_app_secret() hs = HelpScout(app_id, app_secret) conversation = hs.conversations.get(params=params, resource_id=cuid) if not conversation: raise ValueError( "Wrong json returned from help scout, must have an item attribute") return conversation
def add_note(cuid, body): app_id = get_helpscout_app_id() app_secret = get_helpscout_app_secret() hs = HelpScout(app_id, app_secret) # Inserting HTML code into HTML mail, snippet need to be HTML escaped body = html.escape(body) data = {"text": body} hs.conversations[cuid].notes.post(data=data) return True
def add_draft(cuid, body): app_id = get_helpscout_app_id() app_secret = get_helpscout_app_secret() hs = HelpScout(app_id, app_secret) customer_id = get_customer_id(cuid) if customer_id is None: return False # Inserting HTML code into HTML mail, snippet need to be HTML escaped body = html.escape(body) data = {"text": body, "draft": True, "customer": { "id": customer_id }, } hs.conversations[cuid].reply.post(data=data) return True
def _get_client( self, app_id=app_id, app_secret=app_secret, url=url, sleep=sleep, seconds=seconds, token=None): hs = HelpScout(app_id, app_secret, url, sleep, seconds) hs.access_token = token return hs