Skip to content

Commit

Permalink
🚧 Working on create collection feature.
Browse files Browse the repository at this point in the history
  • Loading branch information
NickVries committed Feb 15, 2024
1 parent 9a53b38 commit e2085bd
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/Feature/MyParcelComApi/CollectionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

use DateTime;
use MyParcelCom\ApiSdk\Collection\CollectionInterface as ResourceCollectionInterface;
use MyParcelCom\ApiSdk\Resources\Collection;
use MyParcelCom\ApiSdk\Resources\CollectionTime;
use MyParcelCom\ApiSdk\Resources\Interfaces\CollectionInterface;
use MyParcelCom\ApiSdk\Tests\TestCase;

Expand Down Expand Up @@ -58,4 +60,18 @@ public function testItRetrievesASingleCollection(): void
$this->assertEquals('8d8d63aa-032b-4674-990b-706551a2bf23', $collection->getId());
$this->assertEquals('Test', $collection->getDescription());
}

public function testItCreatesANewCollection(): void
{
$newCollection = new Collection();
$newCollection->setDescription('Some description');
$newCollection->setCollectionTime(
(new CollectionTime())->setFrom(123456789)->setTo(987654321)
);

$collection = $this->api->createCollection($newCollection);

$this->assertInstanceOf(CollectionInterface::class, $collection);
$this->assertEquals('Test collection 3', $collection->getDescription());
}
}
71 changes: 71 additions & 0 deletions tests/Stubs/post/https---api-collections.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"data": {
"id": "8d8d63aa-032b-4674-990b-706551a2bf23",
"type": "collections",
"attributes": {
"description": "Test create",
"collection_time": {
"from": 1708085160,
"to": 1708096680
},
"register": false,
"address": {
"street_1": "200 Westminster Bridge Rd",
"postal_code": "SE1 7UT",
"city": "London",
"country_code": "GB",
"company": "MyParcel.com",
"first_name": "MP",
"last_name": "Sender",
"email": "[email protected]",
"phone_number": "+31 85 208 5997"
},
"tracking_code": "TRK-1234567890",
"created_at": 1707991769
},
"links": {
"self": "https:\/\/api.localhost.private\/collections\/8d8d63aa-032b-4674-990b-706551a2bf23"
},
"relationships": {
"shop": {
"data": {
"id": "1ebabb0e-9036-4259-b58e-2b42742bb86a",
"type": "shops"
},
"links": {
"related": "https:\/\/api.localhost.private\/shops\/1ebabb0e-9036-4259-b58e-2b42742bb86a"
}
},
"status": {
"data": {
"id": "583e311f-8f03-4b34-84dd-5a82305ce5a8",
"type": "statuses"
},
"links": {
"related": "https:\/\/api.localhost.private\/statuses\/583e311f-8f03-4b34-84dd-5a82305ce5a8"
}
},
"shipments": {
"data": [
{
"id": "65e10ca7-5e34-40da-9da5-928f8aa57f97",
"type": "shipments"
},
{
"id": "872960ef-2a2c-4ab5-9a36-01478fd20276",
"type": "shipments"
}
]
},
"contract": {
"data": {
"id": "be5c82fd-e936-440a-a5d8-9a3124d86fcf",
"type": "contracts"
},
"links": {
"related": "https:\/\/api.localhost.private\/contracts\/be5c82fd-e936-440a-a5d8-9a3124d86fcf"
}
}
}
}
}

0 comments on commit e2085bd

Please sign in to comment.