gds-api-adapters 91.1.0 → 92.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b228bbfeb3c6670abced9b88f27ff26a2ac8f202c65b4815e7e7bf095bb2f357
4
- data.tar.gz: dc1d051288ca8e31105dbb25c19f1c822c438b7b15c10a789f4f663fc8d39fa8
3
+ metadata.gz: 203960b7b78fe1527269cf50d08575639f7c051d05abc344c6a5dfe8f0eddd7c
4
+ data.tar.gz: cf6e7acc03b5e039ec901ea6dcfa1feefa8c7e0f60da0a8ad3c56b98d2f60aec
5
5
  SHA512:
6
- metadata.gz: ea46e87d73ad2440115c91e91d73c8aeeb018eca04b0c430bd9c2c5dba7e2041fcc18b62efc0b17631fd8b39cbc9b29098722e8e8404945cf584baef463a0368
7
- data.tar.gz: caf48a8612c247ac0f6c6e77d0bcf480f77aa74e15fe8ca63316411f818c5a66b36cddc15eb894068e5dfefbe4376b8d9023ae06e0a5b8a5aba5e7a10a623747
6
+ metadata.gz: 5e846253e545b8640a6cabb3ec4aec9cc66e6db5a05041b58527bd13499cece67be7998ee699d7ffc94197cbee532297dddff1040d4e9e709b3de991ddf8766f
7
+ data.tar.gz: b0460fa6b98bda9ba3540712c9d59fc895c8bf481b86a4d083385075b147db3a401d1273219281b094b1d5618e45d85631ee4008695c5b1ce1279a1ff94899df
@@ -48,98 +48,6 @@ class GdsApi::AssetManager < GdsApi::Base
48
48
  post_multipart("#{base_url}/assets", asset: asset)
49
49
  end
50
50
 
51
- # Creates a Whitehall asset given a hash with +file+ & +legacy_url_path+
52
- # (required) and +legacy_etag+ & +legacy_last_modified+ (optional) attributes
53
- #
54
- # Makes a +POST+ request to the asset manager api to create a Whitehall asset.
55
- #
56
- # The asset must be provided as a +Hash+ with a +file+ attribute that behaves
57
- # like a +File+ object and a +legacy_url_path+ attribute. The +content-type+
58
- # that the asset manager will subsequently serve will be based *only* on the
59
- # file's extension (derived from +#path+). If you supply a +content-type+ via,
60
- # for example +ActionDispatch::Http::UploadedFile+ or another multipart
61
- # wrapper, it will be ignored.
62
- #
63
- # The +legacy_url_path+ attribute is used to specify the public URL path at
64
- # which the asset should be served by the Asset Manager. This differs from
65
- # `#create_asset` where Asset Manager itself determines the public URL path to
66
- # be used and returns that to the publishing app in the response. This
67
- # endpoint is intended to be an interim measure which will help us migrate
68
- # assets from Whitehall into Asset Manager without needing to change the URLs.
69
- # The end goal is for Asset Manager to determine the public URL path for all
70
- # assets including Whitehall assets. At that point this endpoint will become
71
- # redundant and should be removed.
72
- #
73
- # There may be restrictions on the format of the `legacy_url_path`. If the
74
- # supplied path is not valid, a `GdsApi::HTTPUnprocessableEntity` exception
75
- # will be raised.
76
- #
77
- # The optional +legacy_etag+ & +legacy_last_modified+ attributes allow the
78
- # client to specify the values that should be used in the `ETag` &
79
- # `Last-Modified` response headers when the asset is requested via its public
80
- # URL. They are only intended to be used for migrating existing Whitehall
81
- # assets to Asset Manager so that we can avoid wholesale cache invalidation.
82
- # New Whitehall assets should not specify values for these attributes; Asset
83
- # Manager will generate suitable values.
84
- #
85
- # Note: this endpoint should only be used by the Whitehall Admin app and not
86
- # by any other publishing apps.
87
- #
88
- # @param asset [Hash] The attributes for the asset to send to the api. Must
89
- # contain +file+, which behaves like a +File+, and +legacy_url_path+, a
90
- # +String+. May contain +legacy_etag+, a +String+, and
91
- # +legacy_last_modified+, a +Time+ object. All other attributes will be
92
- # ignored.
93
- #
94
- # @return [GdsApi::Response] The wrapped http response from the api. Behaves
95
- # both as a +Hash+ and an +OpenStruct+, and responds to the following:
96
- # :id the URL of the asset
97
- # :name the filename of the asset that will be served
98
- # :content_type the content_type of the asset
99
- # :file_url the URL from which the asset will be served when it has
100
- # passed a virus scan
101
- # :state One of 'unscanned', 'clean', or 'infected'. Unless the state is
102
- # 'clean' the asset at the :file_url will redirect to a
103
- # placeholder
104
- #
105
- # @raise [HTTPErrorResponse] if the request returns an error
106
- #
107
- # @example Upload a file from disk
108
- # response = asset_manager.create_asset(
109
- # file: File.new('image.jpg', 'r'),
110
- # legacy_url_path: '/government/uploads/path/to/image.jpg'
111
- # )
112
- # response['id'] #=> "http://asset-manager.dev.gov.uk/assets/576bbc52759b74196b000012"
113
- # response['content_type'] #=> "image/jpeg"
114
- # @example Upload a file from a Rails param, (typically a multipart wrapper)
115
- # params[:file] #=> #<ActionDispatch::Http::UploadedFile:0x007fc60b43c5c8
116
- # # @content_type="application/foofle",
117
- # # @original_filename="cma_case_image.jpg",
118
- # # @tempfile="spec/support/images/cma_case_image.jpg">
119
- #
120
- # # Though we sent a file with a +content_type+ of 'application/foofle',
121
- # # this was ignored
122
- # response = asset_manager.create_asset(
123
- # file: params[:file]
124
- # legacy_url_path: '/government/uploads/path/to/cma_case_image.jpg'
125
- # )
126
- # response['content_type'] #=> "image/jpeg"
127
- def create_whitehall_asset(asset)
128
- post_multipart("#{base_url}/whitehall_assets", asset: asset)
129
- end
130
-
131
- # Fetches a Whitehall asset's metadata given the legacy URL path
132
- #
133
- # @param legacy_url_path [String] The Whitehall asset identifier.
134
- # @return [GdsApi::Response] A response object containing the parsed JSON
135
- # response. If the asset cannot be found, +GdsApi::HTTPNotFound+ will be
136
- # raised.
137
- #
138
- # @raise [HTTPErrorResponse] if the request returns an error
139
- def whitehall_asset(legacy_url_path)
140
- get_json("#{base_url}/whitehall_assets/#{uri_encode(legacy_url_path)}")
141
- end
142
-
143
51
  # Updates an asset given a hash with one +file+ attribute
144
52
  #
145
53
  # Makes a +PUT+ request to the asset manager api to update an asset.
@@ -94,6 +94,19 @@ class GdsApi::EmailAlertApi < GdsApi::Base
94
94
  get_json("#{endpoint}/subscriber-lists/#{uri_encode(slug)}")
95
95
  end
96
96
 
97
+ # Get a Subscriber List
98
+ #
99
+ # @param [path] path of page for subscriber list
100
+ #
101
+ # @return [Hash] {
102
+ # subscriber_list_count
103
+ # all_notify_count
104
+ # }
105
+
106
+ def get_subscriber_list_metrics(path:)
107
+ get_json("#{endpoint}/subscriber-lists/metrics#{path}")
108
+ end
109
+
97
110
  # Get a Subscription
98
111
  #
99
112
  # @return [Hash] subscription: {
@@ -6,7 +6,7 @@ module GdsApi
6
6
  end
7
7
 
8
8
  def headers
9
- header_data.reject { |_k, v| (v.nil? || v.empty?) }
9
+ header_data.reject { |_k, v| v.nil? || v.empty? }
10
10
  end
11
11
 
12
12
  def clear_headers
@@ -31,14 +31,9 @@ module GdsApi
31
31
  .to_return(body: "Some file content", status: 200)
32
32
  end
33
33
 
34
- def stub_asset_manager_has_a_whitehall_asset(legacy_url_path, atts)
35
- response = atts.merge("_response_info" => { "status" => "ok" })
36
-
37
- stub_request(:get, "#{ASSET_MANAGER_ENDPOINT}/whitehall_assets/#{legacy_url_path}")
38
- .to_return(body: response.to_json, status: 200)
39
-
34
+ def stub_asset_manager_has_a_whitehall_media_asset(legacy_url_path, content)
40
35
  stub_request(:get, "#{ASSET_MANAGER_ENDPOINT}/#{legacy_url_path}")
41
- .to_return(body: "Some file content", status: 200)
36
+ .to_return(body: content, status: 200)
42
37
  end
43
38
 
44
39
  def stub_asset_manager_does_not_have_an_asset(id)
@@ -50,15 +45,6 @@ module GdsApi
50
45
  .to_return(body: response.to_json, status: 404)
51
46
  end
52
47
 
53
- def stub_asset_manager_does_not_have_a_whitehall_asset(legacy_url_path)
54
- response = {
55
- "_response_info" => { "status" => "not found" },
56
- }
57
-
58
- stub_request(:get, "#{ASSET_MANAGER_ENDPOINT}/whitehall_assets/#{legacy_url_path}")
59
- .to_return(body: response.to_json, status: 404)
60
- end
61
-
62
48
  # This can take a string of an exact url or a hash of options
63
49
  #
64
50
  # with a string:
@@ -164,6 +164,16 @@ module GdsApi
164
164
  stub_request(:any, %r{\A#{EMAIL_ALERT_API_ENDPOINT}})
165
165
  end
166
166
 
167
+ def stub_get_subscriber_list_metrics(path:, response:)
168
+ stub_request(:get, "#{EMAIL_ALERT_API_ENDPOINT}/subscriber-lists/metrics#{path}")
169
+ .to_return(status: 200, body: response)
170
+ end
171
+
172
+ def stub_get_subscriber_list_metrics_not_found(path:)
173
+ stub_request(:get, "#{EMAIL_ALERT_API_ENDPOINT}/subscriber-lists/metrics#{path}")
174
+ .to_return(status: 404)
175
+ end
176
+
167
177
  def assert_email_alert_api_content_change_created(attributes = nil)
168
178
  if attributes
169
179
  matcher = lambda do |request|
@@ -97,7 +97,7 @@ module GdsApi
97
97
 
98
98
  def convert_to_query_string_params(parameters)
99
99
  # convert nil to an empty string, otherwise query param is not expressed correctly
100
- parameters.each { |key, _value| parameters[key] = "" if parameters[key].nil? }
100
+ parameters.each_key { |key| parameters[key] = "" if parameters[key].nil? }
101
101
  parameters
102
102
  end
103
103
 
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = "91.1.0".freeze
2
+ VERSION = "92.1.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: 91.1.0
4
+ version: 92.1.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: 2023-09-14 00:00:00.000000000 Z
11
+ date: 2024-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -268,14 +268,14 @@ dependencies:
268
268
  requirements:
269
269
  - - '='
270
270
  - !ruby/object:Gem::Version
271
- version: 4.12.0
271
+ version: 4.13.0
272
272
  type: :development
273
273
  prerelease: false
274
274
  version_requirements: !ruby/object:Gem::Requirement
275
275
  requirements:
276
276
  - - '='
277
277
  - !ruby/object:Gem::Version
278
- version: 4.12.0
278
+ version: 4.13.0
279
279
  - !ruby/object:Gem::Dependency
280
280
  name: simplecov
281
281
  requirement: !ruby/object:Gem::Requirement
@@ -417,7 +417,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
417
417
  - !ruby/object:Gem::Version
418
418
  version: '0'
419
419
  requirements: []
420
- rubygems_version: 3.4.19
420
+ rubygems_version: 3.5.4
421
421
  signing_key:
422
422
  specification_version: 4
423
423
  summary: Adapters to work with GDS APIs