gds-api-adapters 9.1.0 → 9.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -37,4 +37,8 @@ class GdsApi::NeedApi < GdsApi::Base
37
37
  # author params: { "author" => { ... } }"
38
38
  delete_json!("#{endpoint}/needs/#{CGI.escape(need_id.to_s)}/closed", author)
39
39
  end
40
+
41
+ def create_note(note)
42
+ post_json!("#{endpoint}/notes", note)
43
+ end
40
44
  end
@@ -1,24 +1,24 @@
1
1
  require_relative 'base'
2
2
 
3
3
  class GdsApi::Support < GdsApi::Base
4
- def create_foi_request(request_details, options = {})
5
- post_json!("#{base_url}/foi_requests", { :foi_request => request_details }, options[:headers] || {})
4
+ def create_foi_request(request_details)
5
+ post_json!("#{base_url}/foi_requests", { :foi_request => request_details })
6
6
  end
7
7
 
8
- def create_problem_report(request_details, options = {})
9
- post_json!("#{base_url}/anonymous_feedback/problem_reports", { :problem_report => request_details }, options[:headers] || {})
8
+ def create_problem_report(request_details)
9
+ post_json!("#{base_url}/anonymous_feedback/problem_reports", { :problem_report => request_details })
10
10
  end
11
11
 
12
- def create_named_contact(request_details, options = {})
13
- post_json!("#{base_url}/named_contacts", { :named_contact => request_details }, options[:headers] || {})
12
+ def create_named_contact(request_details)
13
+ post_json!("#{base_url}/named_contacts", { :named_contact => request_details })
14
14
  end
15
15
 
16
- def create_anonymous_long_form_contact(request_details, options = {})
17
- post_json!("#{base_url}/anonymous_feedback/long_form_contacts", { :long_form_contact => request_details }, options[:headers] || {})
16
+ def create_anonymous_long_form_contact(request_details)
17
+ post_json!("#{base_url}/anonymous_feedback/long_form_contacts", { :long_form_contact => request_details })
18
18
  end
19
19
 
20
- def create_service_feedback(request_details, options = {})
21
- post_json!("#{base_url}/anonymous_feedback/service_feedback", { :service_feedback => request_details }, options[:headers] || {})
20
+ def create_service_feedback(request_details)
21
+ post_json!("#{base_url}/anonymous_feedback/service_feedback", { :service_feedback => request_details })
22
22
  end
23
23
 
24
24
  def feedback_url(slug)
@@ -77,6 +77,12 @@ module GdsApi
77
77
  headers: {}
78
78
  )
79
79
  end
80
+
81
+ def stub_create_note(note_details = nil)
82
+ post_stub = stub_request(:post, NEED_API_ENDPOINT + "/notes")
83
+ post_stub.with(:body => note_details.to_json) unless note_details.nil?
84
+ post_stub.to_return(:status => 201)
85
+ end
80
86
  end
81
87
  end
82
88
  end
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = '9.1.0'
2
+ VERSION = '9.2.0'
3
3
  end
@@ -238,4 +238,22 @@ describe GdsApi::NeedApi do
238
238
  assert_requested reopen_stub
239
239
  end
240
240
  end
241
+
242
+ describe "creating notes" do
243
+ it "should send a post request" do
244
+ fields = {
245
+ "text" => "test",
246
+ "need_id" => "100001",
247
+ "author" => {
248
+ "name" => "Winston Smith-Churchill",
249
+ "email" => "winston@alphagov.co.uk"
250
+ }
251
+ }
252
+ request_stub = stub_create_note(fields)
253
+
254
+ @api.create_note(fields)
255
+
256
+ assert_requested(request_stub)
257
+ end
258
+ end
241
259
  end
@@ -22,16 +22,6 @@ describe GdsApi::Support do
22
22
  assert_requested(stub_post)
23
23
  end
24
24
 
25
- it "can add a custom header onto the FOI request to the support app" do
26
- stub_request(:post, "#{@base_api_url}/foi_requests")
27
-
28
- @api.create_foi_request({}, headers: { "X-Varnish" => "12345"})
29
-
30
- assert_requested(:post, %r{/foi_requests}) do |request|
31
- request.headers["X-Varnish"] == "12345"
32
- end
33
- end
34
-
35
25
  it "throws an exception when the support app isn't available" do
36
26
  support_isnt_available
37
27
 
@@ -62,16 +52,6 @@ describe GdsApi::Support do
62
52
  assert_requested(stub_post)
63
53
  end
64
54
 
65
- it "can add a custom header onto the problem_report request to the support app" do
66
- stub_request(:post, "#{@base_api_url}/anonymous_feedback/problem_reports")
67
-
68
- @api.create_problem_report({}, headers: { "X-Varnish" => "12345"})
69
-
70
- assert_requested(:post, %r{/problem_reports}) do |request|
71
- request.headers["X-Varnish"] == "12345"
72
- end
73
- end
74
-
75
55
  it "can create a named contact" do
76
56
  request_details = {certain: "details"}
77
57
 
@@ -84,16 +64,6 @@ describe GdsApi::Support do
84
64
  assert_requested(stub_post)
85
65
  end
86
66
 
87
- it "can add a custom header onto the named_contact request to the support app" do
88
- stub_request(:post, "#{@base_api_url}/named_contacts")
89
-
90
- @api.create_named_contact({}, headers: { "X-Varnish" => "12345"})
91
-
92
- assert_requested(:post, %r{/named_contacts}) do |request|
93
- request.headers["X-Varnish"] == "12345"
94
- end
95
- end
96
-
97
67
  it "throws an exception when the support app isn't available" do
98
68
  support_isnt_available
99
69
 
@@ -112,16 +82,6 @@ describe GdsApi::Support do
112
82
  assert_requested(stub_post)
113
83
  end
114
84
 
115
- it "can add a custom header onto the service feedback to the support app" do
116
- stub_request(:post, "#{@base_api_url}/anonymous_feedback/service_feedback")
117
-
118
- @api.create_service_feedback({}, headers: { "X-Varnish" => "12345"})
119
-
120
- assert_requested(:post, %r{/service_feedback}) do |request|
121
- request.headers["X-Varnish"] == "12345"
122
- end
123
- end
124
-
125
85
  it "throws an exception when the support app isn't available" do
126
86
  support_isnt_available
127
87
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gds-api-adapters
3
3
  version: !ruby/object:Gem::Version
4
- version: 9.1.0
4
+ version: 9.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-02-24 00:00:00.000000000 Z
12
+ date: 2014-02-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: plek
@@ -367,7 +367,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
367
367
  version: '0'
368
368
  segments:
369
369
  - 0
370
- hash: 2182195135345570645
370
+ hash: 3249051588083426737
371
371
  required_rubygems_version: !ruby/object:Gem::Requirement
372
372
  none: false
373
373
  requirements:
@@ -376,7 +376,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
376
376
  version: '0'
377
377
  segments:
378
378
  - 0
379
- hash: 2182195135345570645
379
+ hash: 3249051588083426737
380
380
  requirements: []
381
381
  rubyforge_project:
382
382
  rubygems_version: 1.8.23