maxmind/minfraud-api-php

Documentation needs more examples

Opened this issue · 6 comments

Hello

This is not really an issue per say, more of a plea for further documentation examples and some help.

I'm currently trying to understand how I can access all of the data that I am getting back from a response

With,

$mf = new MinFraud($this->id, $this->key);

$request = $mf->withDevice([
    'ip_address' => $data->ip_address,
    'user_agent' => $data->user_agent,
])->withEmail([
    'address' => $data->address,
    'domain'  => $data->address_domain,
])->withBilling([
    'first_name' => $data->first_name,
    'last_name'  => $data->last_name,
]);

$response = $request->insights();

I do not understand why I cannot simply access, say, the latitude of the IP Address with:

$response->ipAddress->location->latitude or $response->ipAddress->location['latitude']

For a simpleton like myself I just need that extra bit of assistance / documentation on how to access and store this information.

Is there a method to get data by key? Is this a free trial account limitation, or.. ?

Cheers!

$response->ipAddress->location->latitude should work fine. What error are you getting? Please note that not all IP addresses will have coordinates. The return value would be null in that case.

Here's the data i'm trying to retrieve from the response:

$fraudDetection->id;
$fraudDetection->riskScore;
$fraudDetection->ipAddress->location->latitude;
$fraudDetection->ipAddress->location->longitude;
$fraudDetection->ipAddress->location->accuracy_radius;
$fraudDetection->ipAddress->continent->code;
$fraudDetection->ipAddress->country->iso_code;
$fraudDetection->ipAddress->country->is_high_risk;
$fraudDetection->ipAddress->city->names->en;
$fraudDetection->ipAddress->city->confidence;
$fraudDetection->ipAddress->traits->domain;
$fraudDetection->ipAddress->traits->isp;
$fraudDetection->ipAddress->traits->user_type;
$fraudDetection->email->isHighRisk;
$fraudDetection->email->isFree;
$fraudDetection->email->firstSeen;

I get unknown attribute on $fraudDetection->ipAddress->location->accuracy_radius of 5 but I can see it in the response object if I dump it.

$fraudDetection->ipAddress->location->longitude works actually.

Try:

$fraudDetection->ipAddress->location->accuracyRadius;
$fraudDetection->ipAddress->continent->code;
$fraudDetection->ipAddress->country->isoCode;
$fraudDetection->ipAddress->country->isHighRisk;

See the API docs for the full list of property names.

This open issue seems to be the only place where this behaviour is documented.. :-(

Could please anyone explain me the correct syntax for the non working

$fraudDetection->ipAddress->city->names->en;

names is an array. $fraudDetection->ipAddress->city->name will likely do what you want unless you set locales in the options array. If you want to specify the locale explicitly, you could do $fraudDetection->ipAddress->city->names['en'].

names is an array. $fraudDetection->ipAddress->city->name will likely do what you want unless you set locales in the options array. If you want to specify the locale explicitly, you could do $fraudDetection->ipAddress->city->names['en'].

Thanks that did the trick. But it would have been nice if this would have been found in the documentation or the example script and not as open issue on github ;-)