Advertisement
Guest User

Untitled

a guest
Aug 26th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. # This script assumes you have instantiated a ZendeskAPI::Client and assigned it to 'client'
  2.  
  3. ticket = client.tickets.find(:id => 4060)
  4. comments = ticket.comments.fetch
  5.  
  6. # Iterate over comments and show comment value and value for the 'public' attribute (using example json public comments are 'bar' and private are 'foo')
  7. comments.each do |c|
  8. puts "the comment value is #{c.body}"
  9. puts "the comments 'public' attribute is #{c.public}"
  10. end;nil
  11.  
  12. # Iterate over comments with select() which takes a comparison and filters out any items where the comparison does not match
  13. # var_filtered = array.select {|iteratee| iteratee.predicate == filter_criteria}
  14. public_comments = comments.select {|c| c.public == true}
  15.  
  16. # Should only output comments with 'bar' in value (and description)
  17. public_comments.each do |c|
  18. puts c.body
  19. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement