-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new phone outputs #177
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -15,6 +15,12 @@ class Insights implements \JsonSerializable | |||||
*/ | ||||||
public readonly BillingAddress $billingAddress; | ||||||
|
||||||
/** | ||||||
* @var Phone an object containing minFraud date related to the billing | ||||||
* phone used in the transaction | ||||||
*/ | ||||||
public readonly Phone $billingPhone; | ||||||
|
||||||
/** | ||||||
* @var CreditCard an object containing minFraud data about the credit | ||||||
* card used in the transaction | ||||||
|
@@ -81,6 +87,12 @@ class Insights implements \JsonSerializable | |||||
*/ | ||||||
public readonly ShippingAddress $shippingAddress; | ||||||
|
||||||
/** | ||||||
* @var Phone an object containing minFraud date related to the shipping | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
* phone used in the transaction | ||||||
*/ | ||||||
public readonly Phone $shippingPhone; | ||||||
|
||||||
/** | ||||||
* @var array This array contains \MaxMind\MinFraud\Model\Warning objects | ||||||
* detailing issues with the request that was sent, such as | ||||||
|
@@ -108,11 +120,13 @@ public function __construct(array $response, array $locales = ['en']) | |||||
$this->warnings = $warnings; | ||||||
|
||||||
$this->billingAddress = new BillingAddress($response['billing_address'] ?? []); | ||||||
$this->billingPhone = new Phone($response['billing_phone'] ?? []); | ||||||
$this->creditCard = new CreditCard($response['credit_card'] ?? []); | ||||||
$this->device = new Device($response['device'] ?? []); | ||||||
$this->email = new Email($response['email'] ?? []); | ||||||
$this->ipAddress = new IpAddress($response['ip_address'] ?? [], $locales); | ||||||
$this->shippingAddress = new ShippingAddress($response['shipping_address'] ?? []); | ||||||
$this->shippingPhone = new Phone($response['shipping_phone'] ?? []); | ||||||
} | ||||||
|
||||||
public function jsonSerialize(): array | ||||||
|
@@ -124,6 +138,11 @@ public function jsonSerialize(): array | |||||
$js['billing_address'] = $billingAddress; | ||||||
} | ||||||
|
||||||
$billingPhone = $this->billingPhone->jsonSerialize(); | ||||||
if (!empty($billingPhone)) { | ||||||
$js['billing_phone'] = $billingPhone; | ||||||
} | ||||||
|
||||||
$creditCard = $this->creditCard->jsonSerialize(); | ||||||
if (!empty($creditCard)) { | ||||||
$js['credit_card'] = $creditCard; | ||||||
|
@@ -163,6 +182,11 @@ public function jsonSerialize(): array | |||||
$js['shipping_address'] = $shippingAddress; | ||||||
} | ||||||
|
||||||
$shippingPhone = $this->shippingPhone->jsonSerialize(); | ||||||
if (!empty($shippingPhone)) { | ||||||
$js['shipping_phone'] = $shippingPhone; | ||||||
} | ||||||
|
||||||
if (!empty($this->warnings)) { | ||||||
$warnings = []; | ||||||
foreach ($this->warnings as $warning) { | ||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MaxMind\MinFraud\Model; | ||
|
||
/** | ||
* Model containing information about the billing or shipping phone number. | ||
*/ | ||
class Phone implements \JsonSerializable | ||
{ | ||
/** | ||
* @var string|null the two-character ISO 3166-1 country code for the | ||
* country associated with the phone number | ||
*/ | ||
public readonly ?string $country; | ||
|
||
/** | ||
* @var bool|null This is `true` if the phone number is a Voice over | ||
* Internet Protocol (VoIP) number allocated by a regulator. | ||
* It is `false` if the phone number is not a VoIP number | ||
* allocated by a regulator. It is `null` if a valid number | ||
* was not provided or if we do not have data for the number. | ||
*/ | ||
public readonly ?bool $isVoip; | ||
|
||
/** | ||
* @var string|null The name of the original network operator associated with | ||
* the phone number. This property does not reflect phone numbers | ||
* that have been ported from the original operator to another, | ||
* nor does it identify mobile virtual network operators. | ||
*/ | ||
public readonly ?string $networkOperator; | ||
|
||
/** | ||
* @var string|null One of the following values: `fixed` or `mobile`. Additional | ||
* values may be added in the future. | ||
*/ | ||
public readonly ?string $numberType; | ||
|
||
public function __construct(?array $response) | ||
{ | ||
$this->country = $response['country'] ?? null; | ||
$this->isVoip = $response['is_voip'] ?? null; | ||
$this->networkOperator = $response['network_operator'] ?? null; | ||
$this->numberType = $response['number_type'] ?? null; | ||
} | ||
|
||
public function jsonSerialize(): array | ||
{ | ||
$js = []; | ||
|
||
if ($this->country !== null) { | ||
$js['country'] = $this->country; | ||
} | ||
|
||
if ($this->isVoip !== null) { | ||
$js['is_voip'] = $this->isVoip; | ||
} | ||
|
||
if ($this->networkOperator !== null) { | ||
$js['network_operator'] = $this->networkOperator; | ||
} | ||
|
||
if ($this->numberType !== null) { | ||
$js['number_type'] = $this->numberType; | ||
} | ||
|
||
return $js; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace MaxMind\Test\MinFraud\Model; | ||
|
||
use MaxMind\MinFraud\Model\Phone; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* @coversNothing | ||
* | ||
* @internal | ||
*/ | ||
class PhoneTest extends TestCase | ||
{ | ||
public function testPhone(): void | ||
{ | ||
$array = [ | ||
'country' => 'US', | ||
'is_voip' => true, | ||
'network_operator' => 'Verizon/1', | ||
'number_type' => 'fixed', | ||
]; | ||
$phone = new Phone($array); | ||
|
||
$this->assertSame( | ||
$array['country'], | ||
$phone->country, | ||
'country' | ||
); | ||
|
||
$this->assertSame( | ||
$array['is_voip'], | ||
$phone->isVoip, | ||
'isVoip' | ||
); | ||
|
||
$this->assertSame( | ||
$array['network_operator'], | ||
$phone->networkOperator, | ||
'networkOperator' | ||
); | ||
|
||
$this->assertSame( | ||
$array['number_type'], | ||
$phone->numberType, | ||
'numberType' | ||
); | ||
|
||
$this->assertSame( | ||
$array, | ||
$phone->jsonSerialize(), | ||
'correctly implements JsonSerializable' | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.