Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to fetch threads of a ticket #7

Open
ca-dsgn opened this issue Dec 10, 2021 · 6 comments · May be fixed by #8
Open

How to fetch threads of a ticket #7

ca-dsgn opened this issue Dec 10, 2021 · 6 comments · May be fixed by #8
Assignees
Labels
documentation Improvements or additions to documentation enhancement New feature or request help wanted Extra attention is needed question Further information is requested

Comments

@ca-dsgn
Copy link

ca-dsgn commented Dec 10, 2021

Hi @thomas-kl1,

I just successfully fetched the data of a ticket via

$ticketDataObject = $gateway->getOperationPool()->getReadOperation('tickets')->get($params["ticket_id"]);

The response I get is this (via print_r):

Zoho\Desk\Model\DataObject Object
--
  | (
  | [entityIdFieldName:protected] => id
  | [data:protected] => Array
  | (
  | [modifiedTime] => 2021-12-09T08:17:06.000Z
  | [subCategory] =>
  | [statusType] => Open
  | [subject] => WG: xxx
  | [dueDate] =>
  | [departmentId] => 182834000000006907
  | [channel] => Email
  | [onholdTime] =>
  | [language] => German
  | [source] => Array
  | (
  | [appName] =>
  | [extId] =>
  | [permalink] =>
  | [type] => SYSTEM
  | [appPhotoURL] =>
  | )
  |  
  | [resolution] =>
  | [sharedDepartments] => Array
  | (
  | )
  |  
  | [closedTime] =>
  | [approvalCount] => 0
  | [isOverDue] =>
  | [isTrashed] =>
  | [createdTime] => 2021-12-07T12:57:57.000Z
  | [id] => 182834000006120001
  | [isResponseOverdue] =>
  | [customerResponseTime] => 2021-12-08T07:42:14.000Z
  | [productId] =>
  | [contactId] => 182834000006131069
  | [threadCount] => 7
  | [secondaryContacts] => Array
  | (
  | )
  |  
  | [priority] =>
  | [classification] =>
  | [commentCount] => 0
  | [taskCount] => 1
  | [accountId] => 
  | [phone] => 
  | [webUrl] => 
  | [isSpam] =>
  | [status] => 
  | [entitySkills] => Array
  | (
  | )
  |  
  | [ticketNumber] => 861
  | [sentiment] =>
  | [customFields] => Array
  | (
  | [Rückmeldung bevorzugt per] =>
  | [Link zu Angebot] =>
  | [Rückmeldung erwünscht bis] =>
  | )
  |  
  | [isArchived] =>
  | [description] =>
  | [timeEntryCount] => 0
  | [channelRelatedInfo] =>
  | [responseDueDate] =>
  | [isDeleted] =>
  | [modifiedBy] => 182834000000069005
  | [followerCount] => 0
  | [email] => xxx
  | [layoutDetails] => Array
  | (
  | [id] => 182834000000083011
  | [layoutName] => Sales
  | )
  |  
  | [channelCode] =>
  | [isFollowing] =>
  | [cf] => Array
  | (
  | [cf_link_zu_angebot] =>
  | [cf_ruckmeldung_bevorzugt] =>
  | [cf_ruckmeldung_erwunscht_bis] =>
  | )
  |  
  | [slaId] =>
  | [layoutId] => 182834000000083011
  | [assigneeId] => 182834000000069005
  | [createdBy] => 182834000000069005
  | [teamId] =>
  | [tagCount] => 0
  | [attachmentCount] => 0
  | [isEscalated] =>
  | [category] =>
  | )
  |  
  | )

I can see in the threadCount, that there are 7 replies on this ticket. My question is, how can I get those threads?

I found this specific information in the zoho desk api documentation, but I am not sure how to implement this using your php interface:

https://desk.zoho.com/DeskAPIDocument#Threads#Threads_Listconversations

Thank you in advance for your help.

Best,
Christian

@thomas-kl1
Copy link
Owner

Hi @ca-dsgn

Thank you for using this lib!
Could you try the following?

`$criteriaBuilder = new ListCriteriaBuilder();

$gateway->getOperationPool()->getListOperation('tickets', [$params["ticket_id"], 'threads'])->get($criteriaBuilder->create())`

It's not documented but you can pass extra arguments to the operation processors

@ca-dsgn
Copy link
Author

ca-dsgn commented Dec 11, 2021

Hi @thomas-kl1,

thank you for your quick reply and support on this. I really appreciate, that you share this library and that I don't have to implement it by myself completely from scratch ;-)

I inserted your snippet in my code, but I got this fatal error:

Fatal error: Uncaught Error: Call to undefined method Zoho\Desk\Model\Operation\ListOperation::get()

But I looked into the ListOperation class and checked, that the function should be getList() instead of get().

So by using

$criteriaBuilder = new ListCriteriaBuilder();

$gateway->getOperationPool()->getListOperation('tickets', [$params["ticket_id"], 'threads'])->get($criteriaBuilder->create())

I am receiving the threads of the ticket. So working perfect now. Thank you so much!

I have one more question regarding the create action for a ticket:

In your sample code you have this snippet:

$ticketDataObject = $gateway->getDataObjectFactory()->create('tickets', /* Entity values */);

try {
    $ticketDataObject = $gateway->getOperationPool()->getCreateOperation('tickets')->create($ticketDataObject);
} catch (CouldNotSaveException $e) {
    // Handle the exception...
}

Could you give a sample of the section /* Entity values */? Is this an object, which has the same structure like the object that the get action gives back? Or is it a associative array?

Thank you very much in advance.

Best,
Christian

@thomas-kl1
Copy link
Owner

Hi @ca-dsgn glad it helps you and it's working! Indeed the method is getList, not get, my bad..

Regarding the data object factory, the entity values must be an associative array of key-value pair. So it's easy an convenient to create generic data objects :)

If you appreciate the SDK you can add a ⭐, it helps me to who is using it :)

@thomas-kl1 thomas-kl1 self-assigned this Dec 11, 2021
@thomas-kl1 thomas-kl1 added documentation Improvements or additions to documentation question Further information is requested labels Dec 11, 2021
@ca-dsgn
Copy link
Author

ca-dsgn commented Dec 11, 2021

Hi @thomas-kl1

Ok, great. Thank you for your quick reply on this.

I have one more question:

I just realized, that the resultList objects only contain a summary property, which has a limited number of charaters and then a "..." at the end. So it is just a short summary.

In the documentation of Zoho Desk, I saw, that there should be another field "content" beside "summary", which contains the entire value of the thread. But I couldn't find this field in the response.

https://desk.zoho.com/DeskAPIDocument#Threads

Do you have any idea how to get the entire text of the thread?

@thomas-kl1
Copy link
Owner

@ca-dsgn seems it's not possible to get the full content within a list. So I guess you have to fetch the list to get the IDs of the thread so you can fetch them individually.

I need to check if a hack is possible or if I need to implement a new operators for subtypes. When I designed the SDK I didn't used much subtypes such as threads so it doesn't really handle all fine. However I'm thinking of adding a new method to allows it (along the setEntityType).
I don't know yet when I can work on it, maybe tonight or Monday

@ca-dsgn
Copy link
Author

ca-dsgn commented Dec 11, 2021

@thomas-kl1 Wow, thank you so much for your great support!

@thomas-kl1 thomas-kl1 added the enhancement New feature or request label Dec 11, 2021
@thomas-kl1 thomas-kl1 linked a pull request Dec 11, 2021 that will close this issue
@thomas-kl1 thomas-kl1 added the help wanted Extra attention is needed label Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants