freshworks / fresh-samples

Samples of code created by freshdesk
184 stars 181 forks source link

filter for fetch tickets #35

Open codeagencybe opened 7 years ago

codeagencybe commented 7 years ago

?filter=new_and_my_open";

Any documentation how to expand this filter with a date range and customer/company? And how to fetch also the timetracking details from the ticket(s) (if any available)?

This looks very interesting to automatically fetch the time tracking from tickets created by company/customer John Doe but only the timetracking from a fix period e.g. 1 June 2016 until 30 June 2016 and pull them into invoicing application.

I need the time tracking with from a certain date range only, because old tickets can be re-opened and could cause double invoicing. So if I can fetch only records from past month, I'm good to go.

Thanks!

markthoma commented 6 years ago

I am also trying to pull something similar, but currently getting 404 error:



import requests
import datetime
import json

api_key = "_xxxx_"
domain = "_xxxx_.com"
password = ""

whoRaised = raw_input("Who raised the ticket(s)? ")
whenRaised = int(raw_input("How many days ago? "))
startDate = datetime.date.today() - datetime.timedelta(days = whenRaised)
print(startDate)
r = requests.get("https://"+ domain +"/api/v2/tickets?query=requester:whoRaised%20AND%20created_at:>startTime", auth = (api_key, password))

if r.status_code == 200:
    print "Request processed successfully, the response is given below" + r.content
else:
    print "Failed to read ticket, errors are displayed below,"
    print(r.status_code)
    response = json.loads(r.content)
    print response["errors"]
hrishikesh-p commented 6 years ago

The query parameter is available as part of the search api 'api/v2/search/tickets' but it does not support requestor filtering.

you can use the filter api to achieve the same result . See modified gist here -> https://gist.github.com/hrishikesh-p/bc63f9b4ff0ae5e7f784d8e01e5a2c0e/revisions