gds-api-adapters 52.2.1 → 52.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f8dc23aac5e0b989fd412af65284e640c45e2c0c8a35fdd83dab54fe7d3bff23
4
- data.tar.gz: 9c825a8925aebc63e18faa968e93234529b5c6e3347f54994c58ca778a1cc6f3
3
+ metadata.gz: bfe3fe1655cbbab5eb06404735072e949c146ba64eaf40b9fa539ae2a9a4c96a
4
+ data.tar.gz: aeea777a719c16e2a31ed8b12afe0e8d43ba2580a2169221b36a04533713b82c
5
5
  SHA512:
6
- metadata.gz: 0c8111b12ff9cd8e0900ec81bcd4075acb67a8f4522a4e7d165ea3466aa5a05b763838f7a1aaccb8b2c91d79e735a7ca5b0a1f554d50b7cf80670715f49bc5cf
7
- data.tar.gz: 999361d4a4cbdd7265a4050c354db0811a96ec0c6a1c2accba6e56a861d37961e14583e699968b4f1456443d64cacc802d8962e7a495b9cb09c8dab5b174ca53
6
+ metadata.gz: feeed49a9fc1c9677eaca9ad3a2124b74573c9e55aa8e57d8d5d2a79f2310774cd0f47dbf6d5bb73dad0f337d1d9a48526cc278cb6979dc8aa90349741d487bb
7
+ data.tar.gz: e8a4a687876c387fe1b544bab1aff9213cf34a0eedea0f35da1eb1608c27b33edf85f9ece29220f2f713dd652689fac53965fedc02585f45cd5efc8900cd82ec
@@ -127,22 +127,22 @@ class GdsApi::EmailAlertApi < GdsApi::Base
127
127
 
128
128
  # Get Subscriptions for a Subscriber
129
129
  # #
130
- # @param string Subscriber address
130
+ # @param integer Subscriber id
131
131
  #
132
132
  # @return [Hash] subscriber, subscriptions
133
- def get_subscriptions(address:)
134
- get_json("#{endpoint}/subscribers/#{address}/subscriptions")
133
+ def get_subscriptions(id:)
134
+ get_json("#{endpoint}/subscribers/#{id}/subscriptions")
135
135
  end
136
136
 
137
137
  # Patch a Subscriber
138
138
  # #
139
- # @param string Subscriber address
139
+ # @param integer Subscriber id
140
140
  # @param string Subscriber new_address
141
141
  #
142
142
  # @return [Hash] subscriber
143
- def change_subscriber(address:, new_address:)
143
+ def change_subscriber(id:, new_address:)
144
144
  patch_json(
145
- "#{endpoint}/subscribers/#{address}",
145
+ "#{endpoint}/subscribers/#{id}",
146
146
  new_address: new_address
147
147
  )
148
148
  end
@@ -6,16 +6,16 @@ module GdsApi
6
6
  module EmailAlertApi
7
7
  EMAIL_ALERT_API_ENDPOINT = Plek.find("email-alert-api")
8
8
 
9
- def email_alert_api_has_updated_subscriber(old_address, new_address)
10
- stub_request(:patch, subscriber_url(old_address))
9
+ def email_alert_api_has_updated_subscriber(id, new_address)
10
+ stub_request(:patch, subscriber_url(id))
11
11
  .to_return(
12
12
  status: 200,
13
- body: get_subscriber_response(new_address).to_json,
13
+ body: get_subscriber_response(id, new_address).to_json,
14
14
  )
15
15
  end
16
16
 
17
- def email_alert_api_does_not_have_updated_subscriber(address)
18
- stub_request(:patch, subscriber_url(address))
17
+ def email_alert_api_does_not_have_updated_subscriber(id)
18
+ stub_request(:patch, subscriber_url(id))
19
19
  .to_return(status: 404)
20
20
  end
21
21
 
@@ -32,16 +32,16 @@ module GdsApi
32
32
  .to_return(status: 404)
33
33
  end
34
34
 
35
- def email_alert_api_has_subscriber_subscriptions(address)
36
- stub_request(:get, subscriber_subscriptions_url(address))
35
+ def email_alert_api_has_subscriber_subscriptions(id, address)
36
+ stub_request(:get, subscriber_subscriptions_url(id))
37
37
  .to_return(
38
38
  status: 200,
39
- body: get_subscriber_subscriptions_response(address).to_json,
39
+ body: get_subscriber_subscriptions_response(id, address).to_json,
40
40
  )
41
41
  end
42
42
 
43
- def email_alert_api_does_not_have_subscriber_subscriptions(address)
44
- stub_request(:get, subscriber_subscriptions_url(address))
43
+ def email_alert_api_does_not_have_subscriber_subscriptions(id)
44
+ stub_request(:get, subscriber_subscriptions_url(id))
45
45
  .to_return(status: 404)
46
46
  end
47
47
 
@@ -81,10 +81,10 @@ module GdsApi
81
81
  )
82
82
  end
83
83
 
84
- def get_subscriber_response(address)
84
+ def get_subscriber_response(id, address)
85
85
  {
86
86
  "subscriber" => {
87
- "id" => 1,
87
+ "id" => id,
88
88
  "address" => address
89
89
  }
90
90
  }
@@ -106,10 +106,10 @@ module GdsApi
106
106
  }
107
107
  end
108
108
 
109
- def get_subscriber_subscriptions_response(address)
109
+ def get_subscriber_subscriptions_response(id, address)
110
110
  {
111
111
  "subscriber" => {
112
- "id" => 1,
112
+ "id" => id,
113
113
  "address" => address
114
114
  },
115
115
  "subscriptions" => [
@@ -292,12 +292,12 @@ module GdsApi
292
292
  EMAIL_ALERT_API_ENDPOINT + "/subscribables/#{reference}"
293
293
  end
294
294
 
295
- def subscriber_url(address)
296
- EMAIL_ALERT_API_ENDPOINT + "/subscribers/#{address}"
295
+ def subscriber_url(id)
296
+ EMAIL_ALERT_API_ENDPOINT + "/subscribers/#{id}"
297
297
  end
298
298
 
299
- def subscriber_subscriptions_url(address)
300
- EMAIL_ALERT_API_ENDPOINT + "/subscribers/#{address}/subscriptions"
299
+ def subscriber_subscriptions_url(id)
300
+ EMAIL_ALERT_API_ENDPOINT + "/subscribers/#{id}/subscriptions"
301
301
  end
302
302
  end
303
303
  end
@@ -448,6 +448,35 @@ module GdsApi
448
448
  stub_request(:get, url).to_return(status: 200, body: links.to_json, headers: {})
449
449
  end
450
450
 
451
+ # Stub a request to get links for content ids
452
+ #
453
+ # @param [Hash] links the links for each content id
454
+ #
455
+ # @example
456
+ # publishing_api_has_links_for_content_ids(
457
+ # { "2878337b-bed9-4e7f-85b6-10ed2cbcd504" => {
458
+ # "links" => { "taxons" => ["eb6965c7-3056-45d0-ae50-2f0a5e2e0854"] }
459
+ # },
460
+ # "eec13cea-219d-4896-9c97-60114da23559" => {
461
+ # "links" => {}
462
+ # }
463
+ # }
464
+ # )
465
+ #
466
+ # @example
467
+ # Services.publishing_api.get_links_for_content_ids(["2878337b-bed9-4e7f-85b6-10ed2cbcd504"])
468
+ # => {
469
+ # "2878337b-bed9-4e7f-85b6-10ed2cbcd504" => {
470
+ # "links" => [
471
+ # "eb6965c7-3056-45d0-ae50-2f0a5e2e0854"
472
+ # ]
473
+ # }
474
+ # }
475
+ def publishing_api_has_links_for_content_ids(links)
476
+ url = PUBLISHING_API_V2_ENDPOINT + "/links/by-content-id"
477
+ stub_request(:post, url).with(body: { content_ids: links.keys }).to_return(status: 200, body: links.to_json, headers: {})
478
+ end
479
+
451
480
  # Stub GET /v2/links/:content_id to return a 404 response
452
481
  #
453
482
  # @param content_id [UUID]
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = '52.2.1'.freeze
2
+ VERSION = '52.3.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gds-api-adapters
3
3
  version: !ruby/object:Gem::Version
4
- version: 52.2.1
4
+ version: 52.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-20 00:00:00.000000000 Z
11
+ date: 2018-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: plek