Class: Zendesk2::GetOrganizationTickets

Inherits:
Object
  • Object
show all
Includes:
Request
Defined in:
lib/zendesk2/get_organization_tickets.rb

Instance Attribute Summary

Attributes included from Request

#params

Instance Method Summary collapse

Methods included from Request

#call, cistern_included, #data, #delete!, #error!, #find!, #html_url_for, included, #mock_response, #page, #page_params!, #page_params?, #pluralize, #real, #real_request, #request_body, #request_params, #request_path, #resources, #response, #timestamp, #url_for

Instance Method Details

#mock(_params = {}) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/zendesk2/get_organization_tickets.rb', line 14

def mock(_params = {})
  organizations = data[:users].values.select { |u| u['organization_id'] == organization_id }
  requesters = organizations.map { |s| s['organization_id'] }

  tickets = data[:tickets].values.select { |t| requesters.include?(t['organization_id']) }

  page(tickets, root: 'tickets')
end

#organization_idObject



10
11
12
# File 'lib/zendesk2/get_organization_tickets.rb', line 10

def organization_id
  params.fetch('organization_id').to_i
end