gds-api-adapters 18.3.1 → 18.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gds_api/test_helpers/organisations.rb +17 -8
- data/lib/gds_api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 358bf064a7109ec21703d589ad94f782883dcf90
|
4
|
+
data.tar.gz: 75b59ebe3c4a7d6a4f0e965cc3bd1136b18c50ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24396827c28be4d5e1eb0ace99ebaf6c3a7fa56d3e544ce82ca11af71f2a7d78cee52ff75a665e1c91cd2e9847b382415598d21730aa7af226352e2c803e60cb
|
7
|
+
data.tar.gz: 4f6f807c0e5b192964c693aa83fd06b9097427db330ce51fa8bdac200972377a624791f575faa9e4b093ad0242814a450f6d8f1f4464baf00475660fc9f0daea
|
@@ -11,22 +11,32 @@ module GdsApi
|
|
11
11
|
ORGANISATIONS_API_ENDPOINT = Plek.current.find('whitehall-admin')
|
12
12
|
PUBLIC_HOST = Plek.current.find('www')
|
13
13
|
|
14
|
+
def organisations_api_has_organisations(organisation_slugs)
|
15
|
+
bodies = organisation_slugs.map { |slug| organisation_for_slug(slug) }
|
16
|
+
organisations_api_has_organisations_with_bodies(bodies)
|
17
|
+
end
|
18
|
+
|
14
19
|
# Sets up the index endpoints for the given organisation slugs
|
15
20
|
# The stubs are setup to paginate in chunks of 20
|
16
21
|
#
|
17
22
|
# This also sets up the individual endpoints for each slug
|
18
23
|
# by calling organisations_api_has_organisation below
|
19
|
-
def
|
20
|
-
|
24
|
+
def organisations_api_has_organisations_with_bodies(organisation_bodies)
|
25
|
+
# Stub API call to the endpoint for an individual organisation
|
26
|
+
organisation_bodies.each do |body|
|
27
|
+
slug = body["details"]["slug"]
|
28
|
+
organisations_api_has_organisation(slug, body)
|
29
|
+
end
|
30
|
+
|
21
31
|
pages = []
|
22
|
-
|
23
|
-
pages <<
|
32
|
+
organisation_bodies.each_slice(20) do |bodies|
|
33
|
+
pages << bodies
|
24
34
|
end
|
25
35
|
|
26
36
|
pages.each_with_index do |page, i|
|
27
37
|
page_details = plural_response_base.merge({
|
28
38
|
"results" => page,
|
29
|
-
"total" =>
|
39
|
+
"total" => organisation_bodies.size,
|
30
40
|
"pages" => pages.size,
|
31
41
|
"current_page" => i + 1,
|
32
42
|
"page_size" => 20,
|
@@ -71,7 +81,7 @@ module GdsApi
|
|
71
81
|
#
|
72
82
|
# if the slug contains 'ministry' the format will be set to 'Ministerial department'
|
73
83
|
# otherwise it will be set to 'Executive agency'
|
74
|
-
def organisation_details_for_slug(slug)
|
84
|
+
def organisation_details_for_slug(slug, content_id=SecureRandom.uuid)
|
75
85
|
{
|
76
86
|
"id" => "#{ORGANISATIONS_API_ENDPOINT}/api/organisations/#{slug}",
|
77
87
|
"title" => titleize_slug(slug, :title_case => true),
|
@@ -86,7 +96,7 @@ module GdsApi
|
|
86
96
|
"organisation_logo_type_class_name" => (slug =~ /ministry/ ? "single-identity" : "eo"),
|
87
97
|
"closed_at" => nil,
|
88
98
|
"govuk_status" => (slug =~ /ministry/ ? "live" : "joining"),
|
89
|
-
"content_id" =>
|
99
|
+
"content_id" => content_id,
|
90
100
|
},
|
91
101
|
"parent_organisations" => [
|
92
102
|
{
|
@@ -102,7 +112,6 @@ module GdsApi
|
|
102
112
|
],
|
103
113
|
}
|
104
114
|
end
|
105
|
-
|
106
115
|
end
|
107
116
|
end
|
108
117
|
end
|
data/lib/gds_api/version.rb
CHANGED
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: 18.
|
4
|
+
version: 18.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Stewart
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: plek
|