Skip to content

Commit 4dd706d

Browse files
committed
2 parents 3f7ba6a + 093a1ce commit 4dd706d

File tree

4 files changed

+54
-4
lines changed

4 files changed

+54
-4
lines changed

src/Account/Entities/InvoiceQuery.php

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

33
namespace UKFast\SDK\Account\Entities;
44

5+
use DateTime;
6+
57
class InvoiceQuery
68
{
79
/**
@@ -44,6 +46,21 @@ class InvoiceQuery
4446
*/
4547
public $contactMethod;
4648

49+
/**
50+
* @var string
51+
*/
52+
public $resolution;
53+
54+
/**
55+
* @var \DateTime
56+
*/
57+
public $resolutionDate;
58+
59+
/**
60+
* @var string
61+
*/
62+
public $status;
63+
4764
/**
4865
* InvoiceQuery constructor.
4966
*
@@ -55,6 +72,10 @@ public function __construct($item = null)
5572
return;
5673
}
5774

75+
$resolutionDate = ($item->resolution_date != null)
76+
? DateTime::createFromFormat(DateTime::ISO8601, $item->resolution_date)
77+
: null;
78+
5879
$this->id = $item->id;
5980
$this->contactId = $item->contact_id;
6081
$this->amount = $item->amount;
@@ -63,5 +84,8 @@ public function __construct($item = null)
6384
$this->proposedSolution = $item->proposed_solution;
6485
$this->invoiceIds = $item->invoice_ids;
6586
$this->contactMethod = $item->contact_method;
87+
$this->resolution = $item->resolution;
88+
$this->resolutionDate = $resolutionDate;
89+
$this->status = $item->status;
6690
}
6791
}

src/Account/InvoiceQueryClient.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,25 @@ class InvoiceQueryClient extends BaseClient
1111
{
1212
protected $basePath = 'account/';
1313

14+
/**
15+
* Gets a paginated response of all invoice queries
16+
*
17+
* @param int $page
18+
* @param int $perPage
19+
* @param array $filters
20+
* @return Page
21+
* @throws \GuzzleHttp\Exception\GuzzleException
22+
*/
23+
public function getPage($page = 1, $perPage = 15, $filters = [])
24+
{
25+
$page = $this->paginatedRequest('v1/invoice-queries', $page, $perPage, $filters);
26+
$page->serializeWith(function ($item) {
27+
return new InvoiceQuery($item);
28+
});
29+
30+
return $page;
31+
}
32+
1433
/**
1534
* Gets an individual invoice query
1635
*
@@ -64,7 +83,7 @@ protected function invoiceQueryToJson($invoiceQuery)
6483
'what_was_received' => $invoiceQuery->whatWasReceived,
6584
'proposed_solution' => $invoiceQuery->proposedSolution,
6685
'invoice_ids' => $invoiceQuery->invoiceIds,
67-
'contact_method' => $invoiceQuery->contactMethod,
86+
'contact_method' => $invoiceQuery->contactMethod
6887
];
6988

7089
return json_encode($payload);

src/PSS/ReplyClient.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ public function create($requestId, $reply)
7575
*/
7676
public function upload($replyId, $name, $content)
7777
{
78+
$name = urlencode($name);
7879
$uri = "v1/replies/$replyId/attachments/$name";
7980
$response = $this->request('POST', $uri, $content);
8081

tests/Account/InvoiceQueryTest.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ public function get_invoice_query_by_id()
3232
2456789,
3333
1245678
3434
],
35-
"contact_method" => "email"
35+
"contact_method" => "email",
36+
"resolution" => "This issue was resolved.",
37+
"resolution_date" => '2019-10-25T00:00:00+01:00',
38+
"status" => "Submitted"
3639
],
3740
"meta" => []
3841
])),
@@ -55,6 +58,9 @@ public function get_invoice_query_by_id()
5558
$this->assertEquals("Resolve the difference", $invoiceQuery->proposedSolution);
5659
$this->assertEquals([2514571, 2456789, 1245678], $invoiceQuery->invoiceIds);
5760
$this->assertEquals("email", $invoiceQuery->contactMethod);
61+
$this->assertEquals("This issue was resolved.", $invoiceQuery->resolution);
62+
$this->assertInstanceOf(DateTime::class, $invoiceQuery->resolutionDate);
63+
$this->assertEquals("Submitted", $invoiceQuery->status);
5864
}
5965

6066
/**
@@ -67,13 +73,13 @@ public function check_self_response_parses_query_response()
6773
'id' => 123
6874
],
6975
'meta' => (object) [
70-
'location' => 'https://api.ukfast.io/account/v1/invoices/query/123'
76+
'location' => 'https://api.ukfast.io/account/v1/invoice-queries/123'
7177
],
7278
];
7379

7480
$selfResponse = new SelfResponse($response);
7581

7682
$this->assertEquals(123, $selfResponse->getId());
77-
$this->assertEquals('https://api.ukfast.io/account/v1/invoices/query/123', $selfResponse->getLocation());
83+
$this->assertEquals('https://api.ukfast.io/account/v1/invoice-queries/123', $selfResponse->getLocation());
7884
}
7985
}

0 commit comments

Comments
 (0)