Skip to content

Commit

Permalink
Merge pull request #460 from mercadopago/feature/mapping-lists
Browse files Browse the repository at this point in the history
Feature/mapping lists
  • Loading branch information
rhames07 authored Sep 29, 2023
2 parents 8f71eb4 + 72b20dc commit 6fabf8a
Show file tree
Hide file tree
Showing 65 changed files with 1,556 additions and 226 deletions.
7 changes: 4 additions & 3 deletions src/MercadoPago/Client/Customer/CustomerCardClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,17 @@ public function delete(string $customer_id, string $card_id, ?RequestOptions $re

/**
* Method responsible for getting list Customer Card.
* @param string $customer_id customer id. * @param \MercadoPago\Client\Common\RequestOptions request options to be sent.
* @param string $customer_id customer id.
* @param \MercadoPago\Client\Common\RequestOptions request options to be sent.
* @return \MercadoPago\Resources\CustomerCardResult found.
* @throws \MercadoPago\Exceptions\MPApiException if the request fails.
* @throws \Exception if the request fails.
*/
public function list(string $customer_id, ?RequestOptions $request_options = null): CustomerCardResult
{
$response = parent::send(sprintf(self::$URL_CUSTOMER_ID, $customer_id), HttpMethod::GET, null, null, $request_options);
$result = new CustomerCardResult();
$result->data = $response->getContent();
$result_data = array("data" => $response->getContent());
$result = Serializer::deserializeFromJson(CustomerCardResult::class, $result_data);
$result->setResponse($response);
return $result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use MercadoPago\MercadoPagoConfig;
use MercadoPago\Net\HttpMethod;
use MercadoPago\Resources\IdentificationTypeResult;
use MercadoPago\Serialization\Serializer;

/** Client responsible for performing identification type actions. */
final class IdentificationTypeClient extends MercadoPagoClient
Expand All @@ -29,8 +30,8 @@ public function __construct()
public function list(?RequestOptions $request_options = null): IdentificationTypeResult
{
$response = parent::send(self::$URL, HttpMethod::GET, null, null, $request_options);
$result = new IdentificationTypeResult();
$result->data = $response->getContent();
$result_data = array("data" => $response->getContent());
$result = Serializer::deserializeFromJson(IdentificationTypeResult::class, $result_data);
$result->setResponse($response);
return $result;
}
Expand Down
4 changes: 2 additions & 2 deletions src/MercadoPago/Client/Payment/PaymentRefundClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ public function get(int $payment_id, int $refund_id, ?RequestOptions $request_op
public function list(int $payment_id, ?RequestOptions $request_options = null): PaymentRefundResult
{
$response = parent::send(sprintf(self::$URL_WITH_PAYMENT_ID, strval($payment_id)), HttpMethod::GET, null, null, $request_options);
$result = new PaymentRefundResult();
$result->data = $response->getContent();
$result_data = array("data" => $response->getContent());
$result = Serializer::deserializeFromJson(PaymentRefundResult::class, $result_data);
$result->setResponse($response);
return $result;
}
Expand Down
5 changes: 3 additions & 2 deletions src/MercadoPago/Client/PaymentMethod/PaymentMethodClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use MercadoPago\MercadoPagoConfig;
use MercadoPago\Net\HttpMethod;
use MercadoPago\Resources\PaymentMethodResult;
use MercadoPago\Serialization\Serializer;

/** Client responsible for performing payment methods actions. */
final class PaymentMethodClient extends MercadoPagoClient
Expand All @@ -29,8 +30,8 @@ public function __construct()
public function get(?RequestOptions $request_options = null): PaymentMethodResult
{
$response = parent::send(self::$URL, HttpMethod::GET, null, null, $request_options);
$result = new PaymentMethodResult();
$result->data = $response->getContent();
$result_data = array("data" => $response->getContent());
$result = Serializer::deserializeFromJson(PaymentMethodResult::class, $result_data);
$result->setResponse($response);
return $result;
}
Expand Down
3 changes: 3 additions & 0 deletions src/MercadoPago/Resources/Common/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@ class Address

/** Street number. */
public ?string $street_number;

/** City. */
public ?string $city;
}
16 changes: 16 additions & 0 deletions src/MercadoPago/Resources/Common/Paging.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace MercadoPago\Resources\Common;

/** Paging class. */
class Paging
{
/** Total. */
public int $total;

/** Limit. */
public int $limit;

/** Offset. */
public int $offset;
}
11 changes: 0 additions & 11 deletions src/MercadoPago/Resources/Common/Result.php

This file was deleted.

18 changes: 0 additions & 18 deletions src/MercadoPago/Resources/Common/Search.php

This file was deleted.

72 changes: 72 additions & 0 deletions src/MercadoPago/Resources/Customer/CustomerCardListResult.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php

namespace MercadoPago\Resources\Customer;

use MercadoPago\Serialization\Mapper;

/** CustomerCardListResult class. */
class CustomerCardListResult
{
/** Class mapper. */
use mapper;

/** Id of the card. */
public ?string $id;

/** Id of the customer. */
public ?string $customer_id;

/** Month the card expires. */
public ?int $expiration_month;

/** Year the card expires. */
public ?int $expiration_year;

/** First six digits of the card. */
public ?string $first_six_digits;

/** Last four digits of the card. */
public ?string $last_four_digits;

/** Data related to the chosen payment method. */
public array|object|null $payment_method;

/** Security code of the card. */
public array|object|null $security_code;

/** Card issuer. */
public array|object|null $issuer;

/** Data related to the holder of the card, usually the customer. */
public array|object|null $cardholder;

/** Creation date of the record. */
public ?string $date_created;

/** Date the record was last updated. */
public ?string $date_last_updated;

/** Id of the user. */
public ?string $user_id;

/** Flag indicating if this is a record from production or test environment. */
public ?bool $live_mode;

/** Card number is. */
public ?string $card_number_id;

private $map = [
"payment_method" => "MercadoPago\Resources\Customer\PaymentMethod",
"security_code" => "MercadoPago\Resources\Customer\SecurityCode",
"issuer" => "MercadoPago\Resources\Customer\Issuer",
"cardholder" => "MercadoPago\Resources\Customer\Cardholder",
];

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

namespace MercadoPago\Resources\Customer;

use MercadoPago\Serialization\Mapper;

/** Customer class. */
class CustomerSearchResult
{
/** Class mapper. */
use mapper;

/** Id of the customer. */
public ?string $id;

/** Email of the customer. */
public ?string $email;

/** First name of the customer. */
public ?string $first_name;

/** Last name of the customer. */
public ?string $last_name;

/** Date registered. */
public ?string $date_registered;

/** Description. */
public ?string $description;

/** Date created. */
public ?string $date_created;

/** Date Last_updated. */
public ?string $date_last_updated;

/** Default card. */
public ?string $default_card;

/** Default address. */
public ?string $default_address;

/** Flag indicating if this is a record from production or test environment. */
public ?bool $live_mode;

/** Id of the user. */
public ?int $user_id;

/** Id of the merchant. */
public ?int $merchant_id;

/** Id of the client. */
public ?int $client_id;

/** Status of the customer. */
public ?string $status;

/** List cards of the customer. */
public array $cards;

/** List addresses of the customer. */
public array $addresses;

/** Phone of the customer. */
public array|object|null $phone;

/** Identification of the customer. */
public array|object|null $identification;

/** Address of the customer. */
public array|object|null $address;

private $map = [
"phone" => "MercadoPago\Resources\Common\Phone",
"identification" => "MercadoPago\Resources\Common\Identification",
"address" => "MercadoPago\Resources\Common\Address",
];

/**
* Method responsible for getting map of entities.
*/
public function getMap(): array
{
return $this->map;
}
}
22 changes: 20 additions & 2 deletions src/MercadoPago/Resources/CustomerCardResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,27 @@

namespace MercadoPago\Resources;

use MercadoPago\Resources\Common\Result;
use MercadoPago\Net\MPResource;
use MercadoPago\Serialization\Mapper;

/** Customer Card Result class. */
class CustomerCardResult extends Result
class CustomerCardResult extends MPResource
{
/** Class mapper. */
use Mapper;

/** Customer Card Result data. */
public array|object|null $data;

private $map = [
"data" => "MercadoPago\Resources\Customer\CustomerCardListResult",
];

/**
* Method responsible for getting map of entities.
*/
public function getMap(): array
{
return $this->map;
}
}
21 changes: 19 additions & 2 deletions src/MercadoPago/Resources/CustomerSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,30 @@
namespace MercadoPago\Resources;

use MercadoPago\Net\MPResource;
use MercadoPago\Serialization\Mapper;

/** Customer Search class. */
class CustomerSearch extends MPResource
{
/** Class mapper. */
use Mapper;

/** Search paging. */
public array $paging;
public array|object|null $paging;

/** Search results. */
public array $results;
public array|object|null $results;

private $map = [
"paging" => "MercadoPago\Resources\Common\Paging",
"results" => "MercadoPago\Resources\Customer\CustomerSearchResult",
];

/**
* Method responsible for getting map of entities.
*/
public function getMap(): array
{
return $this->map;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace MercadoPago\Resources\IdentificationType;

/** IdentificationTypeListResult class. */
class IdentificationTypeListResult
{
/** Identification type ID. */
public ?string $id;

/** Identification type name. */
public ?string $name;

/** Identification type type. */
public ?string $type;

/** Identification type min length. */
public ?int $min_length;

/** Identification type max length. */
public ?int $max_length;
}
19 changes: 18 additions & 1 deletion src/MercadoPago/Resources/IdentificationTypeResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,26 @@
namespace MercadoPago\Resources;

use MercadoPago\Net\MPResource;
use MercadoPago\Serialization\Mapper;

/** IdentificationTypeResult class. */
class IdentificationTypeResult extends MPResource
{
public array $data;
/** Class mapper. */
use Mapper;

/** Identification Type Result data. */
public array|object|null $data;

private $map = [
"data" => "MercadoPago\Resources\IdentificationType\IdentificationTypeListResult",
];

/**
* Method responsible for getting map of entities.
*/
public function getMap(): array
{
return $this->map;
}
}
Loading

0 comments on commit 6fabf8a

Please sign in to comment.