Skip to content

Commit b983d77

Browse files
committed
OrderItemFile renamed to File and moved. SyncVariantFileResponse replaced by File
1 parent 9d002c3 commit b983d77

File tree

7 files changed

+26
-98
lines changed

7 files changed

+26
-98
lines changed
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
<?php
22

3-
namespace Printful\Structures\Order;
3+
namespace Printful\Structures;
44

5-
use Printful\Structures\BaseItem;
6-
7-
class OrderItemFile extends BaseItem
5+
class File extends BaseItem
86
{
97

108
const TYPE_PREVIEW = 'preview';
@@ -97,7 +95,7 @@ class OrderItemFile extends BaseItem
9795

9896
/**
9997
* @param array $raw
100-
* @return OrderItemFile
98+
* @return File
10199
*/
102100
public static function fromArray(array $raw)
103101
{

src/Structures/Order/OrderItemCreationParameters.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace Printful\Structures\Order;
44

5+
use Printful\Structures\File;
6+
57
class OrderItemCreationParameters
68
{
79
/**
@@ -35,7 +37,7 @@ class OrderItemCreationParameters
3537
public $sku;
3638

3739
/**
38-
* @var OrderItemFile[]
40+
* @var File[]
3941
*/
4042
private $files = [];
4143

@@ -80,7 +82,7 @@ public function addOption($id, $value)
8082
}
8183

8284
/**
83-
* @return OrderItemFile[]
85+
* @return File[]
8486
*/
8587
public function getFiles()
8688
{

src/Structures/Order/OrderLineItem.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Printful\Structures\Order;
44

55
use Printful\Structures\BaseItem;
6+
use Printful\Structures\File;
67

78
class OrderLineItem extends BaseItem
89
{
@@ -43,7 +44,7 @@ class OrderLineItem extends BaseItem
4344
public $name;
4445

4546
/**
46-
* @var OrderItemFile[]
47+
* @var File[]
4748
*/
4849
public $files = [];
4950

@@ -81,7 +82,7 @@ public static function fromArray(array $raw)
8182
$item->sku = $raw['sku'];
8283

8384
foreach ($raw['files'] as $v) {
84-
$item->files[] = OrderItemFile::fromArray($v);
85+
$item->files[] = File::fromArray($v);
8586
}
8687

8788
foreach ($raw['options'] as $v) {

src/Structures/Sync/Requests/SyncVariantRequestFile.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
namespace Printful\Structures\Sync\Requests;
44

55
use Printful\Exceptions\PrintfulSdkException;
6+
use Printful\Structures\File;
67

78
class SyncVariantRequestFile
89
{
9-
const TYPE_DEFAULT = 'default';
10-
1110
/** @var string */
12-
public $type = self::TYPE_DEFAULT;
11+
public $type = File::TYPE_DEFAULT;
1312

1413
/** @var int */
1514
public $id;
@@ -27,7 +26,7 @@ public static function fromArray(array $array)
2726
{
2827
$file = new SyncVariantRequestFile;
2928

30-
$file->type = isset($array['type']) ? (string)$array['type'] : self::TYPE_DEFAULT;
29+
$file->type = isset($array['type']) ? (string)$array['type'] : File::TYPE_DEFAULT;
3130
$file->id = isset($array['id']) ? (int)$array['id'] : null;
3231
$file->url = isset($array['url']) ? (string)$array['url'] : null;
3332

src/Structures/Sync/Responses/SyncVariantFileResponse.php

Lines changed: 0 additions & 80 deletions
This file was deleted.

src/Structures/Sync/Responses/SyncVariantResponse.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Printful\Structures\Sync\Responses;
44

55
use Printful\Structures\BaseItem;
6+
use Printful\Structures\File;
67

78
class SyncVariantResponse extends BaseItem
89
{
@@ -33,7 +34,7 @@ class SyncVariantResponse extends BaseItem
3334
/** @var SyncVariantProductResponse */
3435
public $product;
3536

36-
/** @var SyncVariantFileResponse[] */
37+
/** @var File[] */
3738
public $files = [];
3839

3940
/** @var SyncVariantOptionResponse[] */
@@ -61,7 +62,7 @@ public static function fromArray(array $array)
6162

6263
$variantFiles = (array)$array['files'] ?: [];
6364
foreach ($variantFiles as $file) {
64-
$variant->files[] = SyncVariantFileResponse::fromArray($file);
65+
$variant->files[] = File::fromArray($file);
6566
}
6667

6768
$variantOptions = (array)$array['options'] ?: [];

tests/Order/OrderCreationAndRetrievalTest.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use Printful\Structures\Order\OrderCostsItem;
88
use Printful\Structures\Order\OrderCreationParameters;
99
use Printful\Structures\Order\OrderItemCreationParameters;
10-
use Printful\Structures\Order\OrderItemFile;
10+
use Printful\Structures\File;
1111
use Printful\Structures\Order\OrderList;
1212
use Printful\Structures\Order\RecipientCreationParameters;
1313
use Printful\Tests\TestCase;
@@ -19,6 +19,9 @@ class OrderCreationAndRetrievalTest extends TestCase
1919
*/
2020
private $printfulOrder;
2121

22+
/**
23+
* @throws Exception
24+
*/
2225
protected function setUp()
2326
{
2427
parent::setUp();
@@ -64,7 +67,7 @@ public function testOrderCanBeUpdated()
6467
$itemParams->quantity = 1;
6568
$itemParams->retailPrice = 23.99;
6669
$itemParams->addFile(
67-
OrderItemFile::TYPE_DEFAULT,
70+
File::TYPE_DEFAULT,
6871
'https://pbs.twimg.com/profile_images/1044686525/Get_Some.jpg'
6972
);
7073
$params->addItem($itemParams);
@@ -98,6 +101,10 @@ public function testOrderListCanBeRetrieved()
98101
self::assertInstanceOf(OrderList::class, $orderList, 'Order List retrieved');
99102
}
100103

104+
/**
105+
* @throws \Printful\Exceptions\PrintfulApiException
106+
* @throws \Printful\Exceptions\PrintfulException
107+
*/
101108
public function testOrderCostsCanBeEstimated()
102109
{
103110
$externalId = uniqid();
@@ -139,7 +146,7 @@ private function getTestOrderParams()
139146
$itemParams->name = 'Some item name';
140147
$itemParams->sku = '00000000';
141148
$itemParams->addFile(
142-
OrderItemFile::TYPE_DEFAULT,
149+
File::TYPE_DEFAULT,
143150
'https://placeholdit.imgix.net/~text?txtsize=200&txt=2400%C3%972400&w=2400&h=2400'
144151
);
145152
$params->addItem($itemParams);

0 commit comments

Comments
 (0)