File size: 1,507 Bytes
d2897cd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php

namespace Mautic\CoreBundle\IpLookup;

class GeobytesLookup extends AbstractRemoteDataLookup
{
    public string $forwarderfor        = '';
    public string $remoteip            = '';
    public string $ipaddress           = '';
    public string $certainty           = '';
    public string $internet            = '';
    public string $regionlocationcode  = '';
    public string $code                = '';
    public string $locationcode        = '';
    public string $cityid              = '';
    public string $fqcn                = '';
    public string $capital             = '';
    public string $nationalitysingular = '';
    public string $population          = '';
    public string $nationalityplural   = '';
    public string $mapreference        = '';
    public string $currency            = '';
    public string $currencycode        = '';
    public string $title               = '';

    public function getAttribution(): string
    {
        return '<a href="http://geobytes.com/" target="_blank">Geobytes</a> offers both free (16,000 lookups per hour) and VIP (paid) offerings.';
    }

    protected function getUrl(): string
    {
        return "http://getcitydetails.geobytes.com/GetCityDetails?fqcn={$this->ip}";
    }

    protected function parseResponse($response)
    {
        $data = json_decode($response);
        foreach ($data as $key => $value) {
            $key        = str_replace('geobytes', '', $key);
            $this->$key = $value;
        }
    }
}