Skip to content
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

Fix $city type #493

Merged
merged 1 commit into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion src/MercadoPago/Resources/Common/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@

namespace MercadoPago\Resources\Common;

use MercadoPago\Serialization\Mapper;

/** Address class. */
class Address
{
/** Class mapper. */
use Mapper;

/** Addess ID. */
public ?string $id;

Expand All @@ -18,5 +23,17 @@ class Address
public ?int $street_number;

/** City. */
public ?string $city;
public array|object|null $city;

private $map = [
"city" => "MercadoPago\Resources\Common\City"
];

/**
* Method responsible for getting map of entities.
*/
public function getMap(): array
{
return $this->map;
}
}
13 changes: 13 additions & 0 deletions src/MercadoPago/Resources/Common/City.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace MercadoPago\Resources\Common;

/** City class. */
class City
{
/** City ID. */
public ?string $id;

/** City name. */
public ?string $name;
}
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public function testSearchSuccess(): void
$this->assertNotNull($search_result->results);
$this->assertSame(1, count($search_result->results));
$this->assertSame($created_customer->id, $search_result->results[0]->id);
$this->assertSame("São Paulo", $search_result->results[0]->address->city->name);
}

public function testSearchWithRequestOptionsFailure(): void
Expand All @@ -122,7 +123,13 @@ public function testSearchWithRequestOptionsFailure(): void
private function createRequest(string $email): array
{
$request = [
"email" => $email
"email" => $email,
'address' => [
'zip_code' => '01001000',
'street_name' => 'Rua Exemplo',
'street_number' => 123,
'city' => ["name" => "São Paulo"]
],
];
return $request;
}
Expand Down
Loading