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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 50b8a8d1af674fd28b30b7448d6db9ea75a24fb0
4
- data.tar.gz: d10980131326a18a50b025be53155a0916ab6a19
3
+ metadata.gz: 358bf064a7109ec21703d589ad94f782883dcf90
4
+ data.tar.gz: 75b59ebe3c4a7d6a4f0e965cc3bd1136b18c50ee
5
5
  SHA512:
6
- metadata.gz: 33d6af7da6e7fe24f435ca236ade36aafe93d5097a4c298a527a976715b08baf3bc88635249dcad6abd78dbf6e41a2e7ff0bae0f67d8e9e3ceef761ef6be8444
7
- data.tar.gz: e18c56abeaf398171f3fd9046b4f12c7b65be1c3ccd9b90af4a1282382aaf9fd9da3f4352417e9a545d58e8ee68015d2f33d52e9b22951e6e090191c0a7c1727
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 organisations_api_has_organisations(organisation_slugs)
20
- organisation_slugs.each {|s| organisations_api_has_organisation(s) }
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
- organisation_slugs.each_slice(20) do |slugs|
23
- pages << slugs.map {|s| organisation_details_for_slug(s) }
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" => organisation_slugs.size,
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" => SecureRandom.uuid,
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
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = '18.3.1'
2
+ VERSION = '18.4.0'
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: 18.3.1
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-16 00:00:00.000000000 Z
11
+ date: 2015-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: plek