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(options = {}) ⇒ Object


50
51
52
53
# File 'lib/gds_api/support_api.rb', line 50

def anonymous_feedback(options = {})
  uri = "#{endpoint}/anonymous-feedback" + query_string(options)
  get_json(uri)
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_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:


41
42
43
# File 'lib/gds_api/support_api.rb', line 41

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


68
69
70
# File 'lib/gds_api/support_api.rb', line 68

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

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


72
73
74
75
# File 'lib/gds_api/support_api.rb', line 72

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

#feedback_export_request(id) ⇒ Object


77
78
79
# File 'lib/gds_api/support_api.rb', line 77

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.


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

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


64
65
66
# File 'lib/gds_api/support_api.rb', line 64

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

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


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

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

#organisations_listObject


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

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

#problem_report_daily_totals_for(date) ⇒ Object


45
46
47
48
# File 'lib/gds_api/support_api.rb', line 45

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
}

122
123
124
125
# File 'lib/gds_api/support_api.rb', line 122

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