Skip to content

Commit

Permalink
add nesbot/carbon
Browse files Browse the repository at this point in the history
Signed-off-by: B24io <app@b24.io>
  • Loading branch information
b24io-sdk committed Jul 9, 2024
1 parent 6f68aba commit 43fdb68
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 40 deletions.
8 changes: 5 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
# loyalty-php-sdk

## 3.4.0 Upcoming
## Upcoming

### Added
* add support for email account for contacts
* WIP add support for email account for contacts


## 3.3.0 (2024.07.10)

### Added

* add requirements:
* `nesbot/carbon` version `^2.*`,
* add `MobilePhoneItemResult` – information about mobile phone.
* add support for mobile phone for `ContactItemResult`
* add support for mobile phone for `CardItemResult`
Expand All @@ -19,6 +20,7 @@
* change signature for method `Loyalty\SDK\Services\Admin\Contacts::add`, argument `$mobilePhone` can be nullable.
* change signature for method `Loyalty\SDK\Services\Admin\Contacts::getById` from `ContactItemResult` to `ContactResult`
* change signature for method `Loyalty\SDK\Services\Admin\Cards::getById` from `CardItemResult` to `CardResult`
* change `DateTimeImmutable` to `CarbonImmutable` in all results

## 3.2.0 (2024.05.23)

Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"symfony/uid": "^5.4 || 7.*",
"symfony/filesystem": "^5.4 || 7.*",
"moneyphp/money": "^3.3 || 4.*",
"nesbot/carbon": "^2.0",
"giggsey/libphonenumber-for-php": "8.1.*",
"league/csv": "^9.0",
"mesilov/moneyphp-percentage": "0.1.0 || 0.2.0"
Expand Down
6 changes: 3 additions & 3 deletions src/Common/Result/Cards/CardItemResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use B24io\Loyalty\SDK\Common\Result\Contacts\MobilePhoneItemResult;
use B24io\Loyalty\SDK\Core\Exceptions\InvalidArgumentException;
use B24io\Loyalty\SDK\Core\Result\AbstractItem;
use DateTimeImmutable;
use Carbon\CarbonImmutable;
use Exception;
use Money\Currency;
use Money\Money;
Expand All @@ -21,8 +21,8 @@
* @property-read string $barcode
* @property-read Money $balance
* @property-read Percentage $percentage
* @property-read DateTimeImmutable $created
* @property-read DateTimeImmutable $modified
* @property-read CarbonImmutable $created
* @property-read CarbonImmutable $modified
* @property-read CardStatus $status
* @property-read string $externalId
* @property-read ?CardLevelItemResult $level
Expand Down
5 changes: 3 additions & 2 deletions src/Common/Result/Cards/CardLevelItemResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace B24io\Loyalty\SDK\Common\Result\Cards;

use B24io\Loyalty\SDK\Core\Result\AbstractItem;
use Carbon\CarbonImmutable;
use DateTimeImmutable;
use Exception;
use MoneyPHP\Percentage\Percentage;
Expand All @@ -18,8 +19,8 @@
* @property-read Percentage $defaultPercentage
* @property-read string $description
* @property-read string $externalId
* @property-read DateTimeImmutable $created
* @property-read DateTimeImmutable $modified
* @property-read CarbonImmutable $created
* @property-read CarbonImmutable $modified
*/
class CardLevelItemResult extends AbstractItem
{
Expand Down
3 changes: 2 additions & 1 deletion src/Common/Result/Transactions/TransactionItemResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use B24io\Loyalty\SDK\Common\Reason;
use B24io\Loyalty\SDK\Common\TransactionType;
use B24io\Loyalty\SDK\Core\Result\AbstractItem;
use Carbon\CarbonImmutable;
use DateTimeImmutable;
use Exception;
use Money\Currency;
Expand All @@ -19,7 +20,7 @@
* @property-read string $cardNumber
* @property-read Money $value
* @property-read TransactionType $type
* @property-read DateTimeImmutable $created
* @property-read CarbonImmutable $created
* @property-read Reason $reason
*/
class TransactionItemResult extends AbstractItem
Expand Down
5 changes: 2 additions & 3 deletions src/Core/Result/AbstractItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@
use ArrayIterator;
use B24io\Loyalty\SDK\Common\Reason;
use B24io\Loyalty\SDK\Core\Exceptions\ImmutableResultViolationException;
use DateTimeImmutable;
use Carbon\CarbonImmutable;
use Exception;
use IteratorAggregate;
use libphonenumber\PhoneNumberUtil;
use Money\Currencies\ISOCurrencies;
use Money\Parser\DecimalMoneyParser;
use Symfony\Component\Uid\Uuid;
Expand Down Expand Up @@ -58,7 +57,7 @@ public function __get($offset)
return (string)$this->data['external_id'];
case 'created':
case 'modified':
return new DateTimeImmutable($this->data[$offset]);
return new CarbonImmutable($this->data[$offset]);
case 'reason':
return new Reason(
$this->data[$offset]['id'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ X-LOYALTY-API-KEY-ADMIN: {{api_key_role_admin}}
Idempotency-Key: 123456-85d2-4e47-b568-4faa746e2213

{
"number": "1",
"barcode": "1",
"number": "155555",
"barcode": "144444",
"balance": {
"amount": "50.00",
"currency": "RUB"
},
"percentage": "5",
"contact_id": "0ff888bc-8b2a-47d9-88dc-da821eed1203",
"contact_id": "dc088068-9904-4272-b0a8-985a109582e1",
"card_level_id": null,
"affiliate_card_id": null,
"status": "active",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
###
GET https://{{host}}/api/{{api_version_prefix}}/{{api_key_client}}/admin/cards/e5956a62-b45c-4e9f-b881-6693ea99bcc3
GET https://{{host}}/api/{{api_version_prefix}}/{{api_key_client}}/admin/cards/a2da94f5-fa82-4f8e-973a-8aa8d15207f8
Accept: */*
Cache-Control: no-cache
Content-Type: application/json; charset=utf-8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,34 @@ Idempotency-Key: {{$uuid}}
"full_name": {
"name": "Иван22221113331",
"surname": "Иванов22221112133331",
"patronymic": "Иванович33333111112342342342341"
"patronymic": "Иванович33333"
},
"gender": "unknown",
"timezone": "Asia/Novosibirsk",
"birthday": "27.05.1984",
"external_ids": null,
"mobile_phone": "79780192051"
}

###
POST https://{{host}}/api/{{api_version_prefix}}/{{api_key_client}}/admin/contacts
Accept: */*
Cache-Control: no-cache
Content-Type: application/json; charset=utf-8
X-LOYALTY-API-KEY-ADMIN: {{api_key_role_admin}}
Idempotency-Key: {{$uuid}}

{
"full_name": {
"name": "Иван1",
"surname": "Иванов2",
"patronymic": "Иванович3"
},
"gender": "unknown",
"timezone": "Asia/Novosibirsk",
"birthday": "27.05.1984",
"external_ids": null,
"mobile_phone": "79780192058"
"mobile_phone": null
}

###
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,7 @@
###
POST https://{{host}}/api/{{api_version_prefix}}/{{api_key_client}}/admin/contacts
Accept: */*
Cache-Control: no-cache
Content-Type: application/json; charset=utf-8
X-LOYALTY-API-KEY-ADMIN: {{api_key_role_admin}}
Idempotency-Key: 123456-85d2-4e47-b568-4faa746e2213

{
"full_name": {
"name": "Иван1",
"surname": "Иванов1",
"patronymic": "Иванович1"
},
"timezone_utc_offset": null,
"gender": "male",
"birthday": null,
"external_ids": []
}

###
GET https://{{host}}/api/{{api_version_prefix}}/{{api_key_client}}/admin/contacts/74957029-e3b8-4419-8557-38a42140cc6d
# WTF 404??????
# GET https://{{host}}/api/{{api_version_prefix}}/{{api_key_client}}/admin/contacts/a2da94f5-fa82-4f8e-973a-8aa8d15207f8
GET https://{{host}}/api/{{api_version_prefix}}/{{api_key_client}}/admin/contacts/dc088068-9904-4272-b0a8-985a109582e1
Accept: */*
Cache-Control: no-cache
Content-Type: application/json; charset=utf-8
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
###
GET https://{{host}}/api/{{api_version_prefix}}/{{api_key_client}}/admin/contacts?orderBy=birthday&orderDirection=asc
GET https://{{host}}/api/{{api_version_prefix}}/{{api_key_client}}/admin/contacts?orderBy=modified&orderDirection=asc
Accept: */*
Cache-Control: no-cache
Content-Type: application/json; charset=utf-8
Expand Down

0 comments on commit 43fdb68

Please sign in to comment.