Class: GdsApi::SupportApi

Inherits:
Base
  • Object
show all
Defined in:
lib/gds_api/support_api.rb

Instance Attribute Summary

Attributes inherited from Base

#options

Instance Method Summary collapse

Methods inherited from Base

#client, #create_client, #get_list, #initialize, #url_for_slug

Constructor Details

This class inherits a constructor from GdsApi::Base

Instance Method Details

#anonymous_feedback(params = {}) ⇒ Object



70
71
72
# File 'lib/gds_api/support_api.rb', line 70

def anonymous_feedback(params = {})
  post_json("#{endpoint}/anonymous-feedback", params)
end

#create_anonymous_long_form_contact(request_details) ⇒ Object



13
14
15
# File 'lib/gds_api/support_api.rb', line 13

def create_anonymous_long_form_contact(request_details)
  post_json("#{endpoint}/anonymous-feedback/long-form-contacts", long_form_contact: request_details)
end

#create_content_improvement_feedback(params) ⇒ Object



66
67
68
# File 'lib/gds_api/support_api.rb', line 66

def create_content_improvement_feedback(params)
  post_json("#{endpoint}/anonymous-feedback/content_improvement", params)
end

#create_feedback_export_request(request_details) ⇒ Object



17
18
19
# File 'lib/gds_api/support_api.rb', line 17

def create_feedback_export_request(request_details)
  post_json("#{endpoint}/anonymous-feedback/export-requests", export_request: request_details)
end

#create_global_export_request(request_details) ⇒ Object



21
22
23
# File 'lib/gds_api/support_api.rb', line 21

def create_global_export_request(request_details)
  post_json("#{endpoint}/anonymous-feedback/global-export-requests", global_export_request: request_details)
end

#create_page_improvement(params) ⇒ GdsApi::Response

Create a Page Improvement

Makes a POST request to the support api to create a Page Improvement.

)

Examples:

support_api.create_page_improvement(
  description: 'The title is wrong',
  path: 'http://gov.uk/service-manual/agile'

Parameters:

  • params (Hash)

    Any attributes that relate to a Page Improvement.

Returns:

  • (GdsApi::Response)

    The wrapped http response from the api. Responds to the following: :status a string that is either ‘success’ or ‘error’

Raises:



57
58
59
# File 'lib/gds_api/support_api.rb', line 57

def create_page_improvement(params)
  post_json("#{endpoint}/page-improvements", params)
end

#create_problem_report(request_details) ⇒ Object



5
6
7
# File 'lib/gds_api/support_api.rb', line 5

def create_problem_report(request_details)
  post_json("#{endpoint}/anonymous-feedback/problem-reports", problem_report: request_details)
end

#create_service_feedback(request_details) ⇒ Object



9
10
11
# File 'lib/gds_api/support_api.rb', line 9

def create_service_feedback(request_details)
  post_json("#{endpoint}/anonymous-feedback/service-feedback", service_feedback: request_details)
end

#document_type_listObject



87
88
89
# File 'lib/gds_api/support_api.rb', line 87

def document_type_list
  get_json("#{endpoint}/anonymous-feedback/document-types")
end

#document_type_summary(document_type, options = {}) ⇒ Object



91
92
93
94
# File 'lib/gds_api/support_api.rb', line 91

def document_type_summary(document_type, options = {})
  uri = "#{endpoint}/anonymous-feedback/document-types/#{document_type}" + query_string(options)
  get_json(uri)
end

#feedback_by_day(date, page = 1, per_page = 100) ⇒ Object



96
97
98
99
# File 'lib/gds_api/support_api.rb', line 96

def feedback_by_day(date, page = 1, per_page = 100)
  uri = "#{endpoint}/feedback-by-day/#{date.strftime('%Y-%m-%d')}?page=#{page}&per_page=#{per_page}"
  get_json(uri)
end

#feedback_export_request(id) ⇒ Object



101
102
103
# File 'lib/gds_api/support_api.rb', line 101

def feedback_export_request(id)
  get_json("#{endpoint}/anonymous-feedback/export-requests/#{id}")
end

#mark_reviewed_for_spam(request_details) ⇒ Object

Update multiple problem reports as reviewed for spam.

Makes a PUT request.

# @example

support_api.mark_reviewed_for_spam({ "1" => false, "2" => true }).to_h

#=> { “success” => true } (status: 200)

# @example

Where there is no problem report with ID of 1.

support_api.mark_reviewed_for_spam({ "1" => true }).to_h

#=> { “success” => false} (status: 400)

Parameters:

  • request_details (Hash)

    Containing keys that match IDs of Problem Reports mapped to a boolean value - true if that report is to be marked as spam, or false otherwise.



172
173
174
# File 'lib/gds_api/support_api.rb', line 172

def mark_reviewed_for_spam(request_details)
  put_json("#{endpoint}/anonymous-feedback/problem-reports/mark-reviewed-for-spam", reviewed_problem_report_ids: request_details)
end

#organisation(organisation_slug) ⇒ Object



83
84
85
# File 'lib/gds_api/support_api.rb', line 83

def organisation(organisation_slug)
  get_json("#{endpoint}/organisations/#{organisation_slug}")
end

#organisation_summary(organisation_slug, options = {}) ⇒ Object



74
75
76
77
# File 'lib/gds_api/support_api.rb', line 74

def organisation_summary(organisation_slug, options = {})
  uri = "#{endpoint}/anonymous-feedback/organisations/#{organisation_slug}" + query_string(options)
  get_json(uri)
end

#organisations_listObject



79
80
81
# File 'lib/gds_api/support_api.rb', line 79

def organisations_list
  get_json("#{endpoint}/organisations")
end

#problem_report_daily_totals_for(date) ⇒ Object



61
62
63
64
# File 'lib/gds_api/support_api.rb', line 61

def problem_report_daily_totals_for(date)
  date_string = date.strftime("%Y-%m-%d")
  get_json("#{endpoint}/anonymous-feedback/problem-reports/#{date_string}/totals")
end

#problem_reports(options = {}) ⇒ Object

Fetch a list of problem reports.

Makes a GET request.

If no options are supplied, the first page of unreviewed feedback is returned.

The results are ordered date descending.

# ==== Options [Hash]

  • :from_date - from date for list of reports.

  • :to_date - to date for list of reports.

  • :page - page number for reports.

  • :include_reviewed - if true, includes reviewed reports in the list.

# @example

support_api.problem_reports({ from_date: '2016-12-12', to_date: '2016-12-13', page: 1, include_reviewed: true }).to_h

#=> {
  results: [
    {
      id: 1,
      type: "problem-report",
      what_wrong: "Yeti",
      what_doing: "Skiing",
      url: "http://www.dev.gov.uk/skiing",
      referrer: "https://www.gov.uk/browse",
      user_agent: "Safari",
      path: "/skiing",
      marked_as_spam: false,
      reviewed: true,
      created_at: "2015-01-01T16:00:00.000Z"
    },
    ...
  ]
  total_count: 1000,
  current_page: 1,
  pages: 50,
  page_size: 50
}


146
147
148
149
# File 'lib/gds_api/support_api.rb', line 146

def problem_reports(options = {})
  uri = "#{endpoint}/anonymous-feedback/problem-reports" + query_string(options)
  get_json(uri)
end

#raise_support_ticket(params) ⇒ Object

SupportApi.raise_support_ticket(

subject: "Feedback for app",
tags: ["app_name"]
user_agent: "Safari",
description: "Ticket details go here.",

)



37
38
39
# File 'lib/gds_api/support_api.rb', line 37

def raise_support_ticket(params)
  post_json("#{endpoint}/support-tickets", params)
end