gds-api-adapters 85.0.1 → 87.0.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 +4 -4
- data/Rakefile +7 -9
- data/lib/gds_api/imminence.rb +7 -38
- data/lib/gds_api/response.rb +1 -1
- data/lib/gds_api/test_helpers/imminence.rb +24 -3
- data/lib/gds_api/version.rb +1 -1
- metadata +6 -6
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: e981660988eed87b9cc48de790fe7d569e3f87f23d517f02b3de113dca5b54cb
         | 
| 4 | 
            +
              data.tar.gz: 29cc9f3064a3af6ea39fa0c58552577b092aa52a3549e2d2a268e9a601e018f8
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 5d0c4b0d21493fa6f352bd86bdfe181f0994e8803b60fd7233cf43848dc87389ce313042c8aa1499684f87496231267eb61bb0bd069b5c208ca596d4a203064b
         | 
| 7 | 
            +
              data.tar.gz: 91ee52e953390ec47e4b6e507c5b6591476acb4de98fa683a39ef4423ba3c9cf5fd3b02ec245eebe199467f4d277934e868e22e1523fbdcb8e437f45919b460c
         | 
    
        data/Rakefile
    CHANGED
    
    | @@ -22,16 +22,14 @@ task default: %i[lint test] | |
| 22 22 |  | 
| 23 23 | 
             
            require "pact_broker/client/tasks"
         | 
| 24 24 |  | 
| 25 | 
            -
             | 
| 25 | 
            +
            PactBroker::Client::PublicationTask.new do |task|
         | 
| 26 | 
            +
              task.consumer_version = ENV.fetch("PACT_CONSUMER_VERSION")
         | 
| 26 27 | 
             
              task.pact_broker_base_url = ENV.fetch("PACT_BROKER_BASE_URL")
         | 
| 27 | 
            -
               | 
| 28 | 
            -
                 | 
| 29 | 
            -
             | 
| 30 | 
            -
             | 
| 31 | 
            -
             | 
| 32 | 
            -
            PactBroker::Client::PublicationTask.new("branch") do |task|
         | 
| 33 | 
            -
              task.consumer_version = ENV.fetch("PACT_TARGET_BRANCH")
         | 
| 34 | 
            -
              configure_pact_broker_location(task)
         | 
| 28 | 
            +
              task.pact_broker_basic_auth = {
         | 
| 29 | 
            +
                username: ENV.fetch("PACT_BROKER_USERNAME"),
         | 
| 30 | 
            +
                password: ENV.fetch("PACT_BROKER_PASSWORD"),
         | 
| 31 | 
            +
              }
         | 
| 32 | 
            +
              task.pattern = ENV["PACT_PATTERN"] if ENV["PACT_PATTERN"]
         | 
| 35 33 | 
             
            end
         | 
| 36 34 |  | 
| 37 35 | 
             
            desc "Run the linter against changed files"
         | 
    
        data/lib/gds_api/imminence.rb
    CHANGED
    
    | @@ -2,55 +2,24 @@ require_relative "base" | |
| 2 2 |  | 
| 3 3 | 
             
            class GdsApi::Imminence < GdsApi::Base
         | 
| 4 4 | 
             
              def api_url(type, params)
         | 
| 5 | 
            -
                vals = %i[limit lat lng postcode].select { |p| params.include? p }
         | 
| 5 | 
            +
                vals = %i[limit lat lng postcode local_authority_slug].select { |p| params.include? p }
         | 
| 6 6 | 
             
                querystring = URI.encode_www_form(vals.map { |p| [p, params[p]] })
         | 
| 7 7 | 
             
                "#{@endpoint}/places/#{type}.json?#{querystring}"
         | 
| 8 8 | 
             
              end
         | 
| 9 9 |  | 
| 10 10 | 
             
              def places(type, lat, lon, limit = 5)
         | 
| 11 11 | 
             
                url = api_url(type, lat: lat, lng: lon, limit: limit)
         | 
| 12 | 
            -
                 | 
| 13 | 
            -
                places.map { |p| self.class.parse_place_hash(p) }
         | 
| 12 | 
            +
                get_json(url)
         | 
| 14 13 | 
             
              end
         | 
| 15 14 |  | 
| 16 | 
            -
              def places_for_postcode(type, postcode, limit = 5)
         | 
| 17 | 
            -
                 | 
| 18 | 
            -
                 | 
| 19 | 
            -
                 | 
| 20 | 
            -
             | 
| 21 | 
            -
             | 
| 22 | 
            -
              def self.parse_place_hash(place_hash)
         | 
| 23 | 
            -
                location = extract_location_hash(place_hash["location"])
         | 
| 24 | 
            -
                address = extract_address_hash(place_hash)
         | 
| 25 | 
            -
             | 
| 26 | 
            -
                place_hash.merge(location).merge(address)
         | 
| 15 | 
            +
              def places_for_postcode(type, postcode, limit = 5, local_authority_slug = nil)
         | 
| 16 | 
            +
                options = { postcode: postcode, limit: limit }
         | 
| 17 | 
            +
                options.merge!(local_authority_slug: local_authority_slug) if local_authority_slug
         | 
| 18 | 
            +
                url = api_url(type, options)
         | 
| 19 | 
            +
                get_json(url) || []
         | 
| 27 20 | 
             
              end
         | 
| 28 21 |  | 
| 29 22 | 
             
              def places_kml(type)
         | 
| 30 23 | 
             
                get_raw("#{@endpoint}/places/#{type}.kml").body
         | 
| 31 24 | 
             
              end
         | 
| 32 | 
            -
             | 
| 33 | 
            -
              # @private
         | 
| 34 | 
            -
              def self.extract_location_hash(location)
         | 
| 35 | 
            -
                # Deal with all known location formats:
         | 
| 36 | 
            -
                #   Old style: [latitude, longitude]; empty array for no location
         | 
| 37 | 
            -
                #   New style: hash with keys "longitude", "latitude"; nil for no location
         | 
| 38 | 
            -
                case location
         | 
| 39 | 
            -
                when Array
         | 
| 40 | 
            -
                  { "latitude" => location[0], "longitude" => location[1] }
         | 
| 41 | 
            -
                when Hash
         | 
| 42 | 
            -
                  location
         | 
| 43 | 
            -
                when nil
         | 
| 44 | 
            -
                  { "latitude" => nil, "longitude" => nil }
         | 
| 45 | 
            -
                end
         | 
| 46 | 
            -
              end
         | 
| 47 | 
            -
             | 
| 48 | 
            -
              # @private
         | 
| 49 | 
            -
              def self.extract_address_hash(place_hash)
         | 
| 50 | 
            -
                address_fields = [
         | 
| 51 | 
            -
                  place_hash["address1"],
         | 
| 52 | 
            -
                  place_hash["address2"],
         | 
| 53 | 
            -
                ].reject { |a| a.nil? || a == "" }
         | 
| 54 | 
            -
                { "address" => address_fields.map(&:strip).join(", ") }
         | 
| 55 | 
            -
              end
         | 
| 56 25 | 
             
            end
         | 
    
        data/lib/gds_api/response.rb
    CHANGED
    
    
| @@ -9,12 +9,33 @@ module GdsApi | |
| 9 9 |  | 
| 10 10 | 
             
                  def stub_imminence_has_places(latitude, longitude, details)
         | 
| 11 11 | 
             
                    query_hash = { "lat" => latitude, "lng" => longitude, "limit" => "5" }
         | 
| 12 | 
            -
                     | 
| 12 | 
            +
                    response_data = {
         | 
| 13 | 
            +
                      status: "ok",
         | 
| 14 | 
            +
                      content: "places",
         | 
| 15 | 
            +
                      places: details["details"],
         | 
| 16 | 
            +
                    }
         | 
| 17 | 
            +
                    stub_imminence_places_request(details["slug"], query_hash, response_data)
         | 
| 13 18 | 
             
                  end
         | 
| 14 19 |  | 
| 15 | 
            -
                  def  | 
| 20 | 
            +
                  def stub_imminence_has_multiple_authorities_for_postcode(addresses, slug, postcode, limit)
         | 
| 16 21 | 
             
                    query_hash = { "postcode" => postcode, "limit" => limit }
         | 
| 17 | 
            -
                     | 
| 22 | 
            +
                    response_data = {
         | 
| 23 | 
            +
                      status: "address-information-required",
         | 
| 24 | 
            +
                      content: "addresses",
         | 
| 25 | 
            +
                      addresses: addresses,
         | 
| 26 | 
            +
                    }
         | 
| 27 | 
            +
                    stub_imminence_places_request(slug, query_hash, response_data)
         | 
| 28 | 
            +
                  end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                  def stub_imminence_has_places_for_postcode(places, slug, postcode, limit, local_authority_slug)
         | 
| 31 | 
            +
                    query_hash = { "postcode" => postcode, "limit" => limit }
         | 
| 32 | 
            +
                    query_hash.merge!(local_authority_slug: local_authority_slug) if local_authority_slug
         | 
| 33 | 
            +
                    response_data = {
         | 
| 34 | 
            +
                      status: "ok",
         | 
| 35 | 
            +
                      content: "places",
         | 
| 36 | 
            +
                      places: places,
         | 
| 37 | 
            +
                    }
         | 
| 38 | 
            +
                    stub_imminence_places_request(slug, query_hash, response_data)
         | 
| 18 39 | 
             
                  end
         | 
| 19 40 |  | 
| 20 41 | 
             
                  def stub_imminence_places_request(slug, query_hash, return_data, status_code = 200)
         | 
    
        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:  | 
| 4 | 
            +
              version: 87.0.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- | 
| 11 | 
            +
            date: 2023-03-29 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. | 
| 271 | 
            +
                    version: 4.10.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. | 
| 278 | 
            +
                    version: 4.10.0
         | 
| 279 279 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 280 280 | 
             
              name: simplecov
         | 
| 281 281 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -410,14 +410,14 @@ required_ruby_version: !ruby/object:Gem::Requirement | |
| 410 410 | 
             
              requirements:
         | 
| 411 411 | 
             
              - - ">="
         | 
| 412 412 | 
             
                - !ruby/object:Gem::Version
         | 
| 413 | 
            -
                  version:  | 
| 413 | 
            +
                  version: '3.0'
         | 
| 414 414 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 415 415 | 
             
              requirements:
         | 
| 416 416 | 
             
              - - ">="
         | 
| 417 417 | 
             
                - !ruby/object:Gem::Version
         | 
| 418 418 | 
             
                  version: '0'
         | 
| 419 419 | 
             
            requirements: []
         | 
| 420 | 
            -
            rubygems_version: 3.4. | 
| 420 | 
            +
            rubygems_version: 3.4.10
         | 
| 421 421 | 
             
            signing_key: 
         | 
| 422 422 | 
             
            specification_version: 4
         | 
| 423 423 | 
             
            summary: Adapters to work with GDS APIs
         |