class Zendesk2::GetViewTickets
Public Instance Methods
mock(_params = {})
click to toggle source
# File lib/zendesk2/get_view_tickets.rb, line 14 def mock(_params = {}) view = find!(:views, view_id) operators = Array(view['conditions']['all']).map do |c| operator = 'is' == c.fetch('operator') ? :eql? : :!= key = c.fetch('field') value = c.fetch('value').to_s [operator, key, value] end tickets = operators.inject(data[:tickets].values) do |r, (o, k, v)| r.select { |t| t[k].to_s.public_send(o, v) } end any_operators = Array(view['conditions']['any']).map do |c| operator = 'is' == c.fetch('operator') ? :eql? : :!= key = c.fetch('field') value = c.fetch('value').to_s [operator, key, value] end any_operators.any? && tickets.select! { |t| any_operators.find { |(o, k, v)| t[k].to_s.public_send(o, v) } } page(tickets, root: 'tickets') end
view_id()
click to toggle source
# File lib/zendesk2/get_view_tickets.rb, line 10 def view_id params.fetch('view_id').to_i end