<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">package t::Mock::MapItZurich;

use JSON::MaybeXS;
use Web::Simple;

has json =&gt; (
    is =&gt; 'lazy',
    default =&gt; sub {
        JSON-&gt;new-&gt;pretty-&gt;allow_blessed-&gt;convert_blessed;
    },
);

sub dispatch_request {
    my $self = shift;

    sub (GET + /areas/**) {
        my ($self, $areas) = @_;
        my $response = {
            "423017" =&gt; {"parent_area" =&gt; undef, "generation_high" =&gt; 4, "all_names" =&gt; {}, "id" =&gt; 423017, "codes" =&gt; {}, "name" =&gt; "Zurich", "country" =&gt; "G", "type_name" =&gt; "OpenStreetMap Layer 8", "generation_low" =&gt; 4, "country_name" =&gt; "Global", "type" =&gt; "O08"}
        };
        my $json = $self-&gt;json-&gt;encode($response);
        return [ 200, [ 'Content-Type' =&gt; 'application/json' ], [ $json ] ];
    },

    sub (GET + /point/**) {
        my ($self, $point) = @_;
        my $response = {
            "423017" =&gt; {"parent_area" =&gt; undef, "generation_high" =&gt; 4, "all_names" =&gt; {}, "id" =&gt; 423017, "codes" =&gt; {}, "name" =&gt; "Zurich", "country" =&gt; "G", "type_name" =&gt; "OpenStreetMap Layer 8", "generation_low" =&gt; 4, "country_name" =&gt; "Global", "type" =&gt; "O08"}
        };
        my $json = $self-&gt;json-&gt;encode($response);
        return [ 200, [ 'Content-Type' =&gt; 'application/json' ], [ $json ] ];
    },

    sub (GET + /area/*/example_postcode) {
        my ($self, $area) = @_;
        my $json = $self-&gt;json-&gt;encode({});
        return [ 200, [ 'Content-Type' =&gt; 'application/json' ], [ $json ] ];
    },

    sub (GET + /area/*/children) {
        my ($self, $area) = @_;
        my $json = $self-&gt;json-&gt;encode({});
        return [ 200, [ 'Content-Type' =&gt; 'application/json' ], [ $json ] ];
    },
}

LWP::Protocol::PSGI-&gt;register(t::Mock::MapItZurich-&gt;to_psgi_app, host =&gt; 'mapit.zurich');

__PACKAGE__-&gt;run_if_script;
</pre></body></html>