Skip to content

Commit 2492d57

Browse files
authored
Merge pull request #136 from Sysix/delivery-notes
Delivery notes
2 parents f4724c1 + 8a51519 commit 2492d57

File tree

6 files changed

+278
-87
lines changed

6 files changed

+278
-87
lines changed

README.md

Lines changed: 70 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,27 @@ $response = $client->update($entityId, $data);
7979
$response = $api->country()->getAll();
8080
```
8181

82-
### Invoices Endpoint
82+
### Credit Notes Endpoint
8383
```php
84-
$voucherList = $api->invoice()->getVoucherListClient(); // see VoucherlistClient Documentation
85-
$response = $api->invoice()->get($entityId);
86-
$response = $api->invoice()->create($data);
87-
$response = $api->invoice()->document($entityId); // get document ID
88-
$response = $api->invoice()->document($entityId, true); // get file content
89-
$response = $api->invoice()->document($entityId, true, 'image/*'); // accept only images
90-
$response = $api->invoice()->document($entityId, true, 'application/xml'); // get XRechung XML File (if possible)
84+
$voucherList = $api->creditNote()->getVoucherListClient(); // see VoucherlistClient Documentation
85+
$response = $api->creditNote()->get($entityId);
86+
$response = $api->creditNote()->create($data);
87+
$response = $api->creditNote()->create($data, true); // finalized
88+
$response = $api->creditNote()->document($entityId); // get document ID
89+
$response = $api->creditNote()->document($entityId, true); // get file content
90+
$response = $api->creditNote()->document($entityId, true, 'image/*'); // accept only images
91+
$response = $api->creditNote()->document($entityId, true, 'application/xml'); // get XRechung XML File (if possible)
92+
```
93+
94+
### Deliverys Notes Endpoint
95+
```php
96+
$voucherList = $api->deliveryNote()->getVoucherListClient(); // see VoucherlistClient Documentation
97+
$response = $api->deliveryNote()->get($entityId);
98+
$response = $api->deliveryNote()->create($data);
99+
$response = $api->deliveryNote()->document($entityId); // get document ID
100+
$response = $api->deliveryNote()->document($entityId, true); // get file content
101+
$response = $api->deliveryNote()->document($entityId, true, 'image/*'); // accept only images
102+
$response = $api->deliveryNote()->document($entityId, true, 'application/xml'); // get XRechung XML File (if possible)
91103
```
92104

93105
### Down Payment Invoices Endpoint
@@ -101,50 +113,43 @@ $response = $api->downPaymentInvoice()->document($entityId, true, 'image/*'); //
101113
$response = $api->downPaymentInvoice()->document($entityId, true, 'application/xml'); // get XRechung XML File (if possible)
102114
```
103115

104-
### Order Confirmation Endpoint
116+
### Event Subscriptions Endpooint
105117
```php
106-
$voucherList = $api->orderConfirmation()->getVoucherListClient(); // see VoucherlistClient Documentation
107-
$response = $api->orderConfirmation()->get($entityId);
108-
$response = $api->orderConfirmation()->create($data);
109-
$response = $api->orderConfirmation()->document($entityId); // get document ID
110-
$response = $api->orderConfirmation()->document($entityId, true); // get file content
111-
$response = $api->orderConfirmation()->document($entityId, true, 'image/*'); // accept only images
112-
$response = $api->orderConfirmation()->document($entityId, true, 'application/xml'); // get XRechung XML File (if possible)
118+
// TODO: get
119+
$response = $api->voucher()->create($data);
120+
$response = $api->voucher()->delete($entityId);
121+
$response = $api->voucher()->getAll();
113122
```
114123

115-
### Quotation Endpoint
124+
### File Endpoint
116125
```php
117-
$voucherList = $api->quotation()->getVoucherListClient(); // see VoucherlistClient Documentation
118-
$response = $api->quotation()->get($entityId);
119-
$response = $api->quotation()->create($data);
120-
$response = $api->quotation()->document($entityId); // get document ID
121-
$response = $api->quotation()->document($entityId, true); // get file content
122-
$response = $api->quotation()->document($entityId, true, 'image/*'); // accept only images
123-
$response = $api->quotation()->document($entityId, true, 'application/xml'); // get XRechung XML File (if possible)
126+
$response = $api->file()->upload($filePath, $voucherType);
127+
$response = $api->file()->get($entityId); // accept every file
128+
$response = $api->file()->get($entityId, 'image/*'); // accept only images
129+
$response = $api->file()->get($entityId, 'application/xml'); // get XRechung XML File (if possible)
124130
```
125131

126-
### Voucher Endpoint
132+
### Invoices Endpoint
127133
```php
128-
$response = $api->voucher()->get($entityId);
129-
$response = $api->voucher()->create($data);
130-
$response = $api->voucher()->update($entityId, $data);
131-
$response = $api->voucher()->document($entityId); // get document ID
132-
$response = $api->voucher()->document($entityId, true); // get file content
133-
$response = $api->voucher()->document($entityId, true, 'image/*'); // accept only images
134-
$response = $api->voucher()->document($entityId, true, 'application/xml'); // get XRechung XML File (if possible)
135-
$response = $api->voucher()->upload($entitiyId, $filepath);
134+
$voucherList = $api->invoice()->getVoucherListClient(); // see VoucherlistClient Documentation
135+
$response = $api->invoice()->get($entityId);
136+
$response = $api->invoice()->create($data);
137+
$response = $api->invoice()->create($data, true); // finalized
138+
$response = $api->invoice()->document($entityId); // get document ID
139+
$response = $api->invoice()->document($entityId, true); // get file content
140+
$response = $api->invoice()->document($entityId, true, 'image/*'); // accept only images
141+
$response = $api->invoice()->document($entityId, true, 'application/xml'); // get XRechung XML File (if possible)
136142
```
137143

138-
139-
### Credit Notes Endpoint
144+
### Order Confirmation Endpoint
140145
```php
141-
$voucherList = $api->creditNote()->getVoucherListClient(); // see VoucherlistClient Documentation
142-
$response = $api->creditNote()->get($entityId);
143-
$response = $api->creditNote()->create($data);
144-
$response = $api->creditNote()->document($entityId); // get document ID
145-
$response = $api->creditNote()->document($entityId, true); // get file content
146-
$response = $api->creditNote()->document($entityId, true, 'image/*'); // accept only images
147-
$response = $api->creditNote()->document($entityId, true, 'application/xml'); // get XRechung XML File (if possible)
146+
$voucherList = $api->orderConfirmation()->getVoucherListClient(); // see VoucherlistClient Documentation
147+
$response = $api->orderConfirmation()->get($entityId);
148+
$response = $api->orderConfirmation()->create($data);
149+
$response = $api->orderConfirmation()->document($entityId); // get document ID
150+
$response = $api->orderConfirmation()->document($entityId, true); // get file content
151+
$response = $api->orderConfirmation()->document($entityId, true, 'image/*'); // accept only images
152+
$response = $api->orderConfirmation()->document($entityId, true, 'application/xml'); // get XRechung XML File (if possible)
148153
```
149154

150155
### Payment Endpoint
@@ -167,6 +172,18 @@ $response = $api->postingCategory()->getAll();
167172
$response = $api->profile()->get();
168173
```
169174

175+
### Quotation Endpoint
176+
```php
177+
$voucherList = $api->quotation()->getVoucherListClient(); // see VoucherlistClient Documentation
178+
$response = $api->quotation()->get($entityId);
179+
$response = $api->quotation()->create($data);
180+
$response = $api->quotation()->create($data, true); // finalized
181+
$response = $api->quotation()->document($entityId); // get document ID
182+
$response = $api->quotation()->document($entityId, true); // get file content
183+
$response = $api->quotation()->document($entityId, true, 'image/*'); // accept only images
184+
$response = $api->quotation()->document($entityId, true, 'application/xml'); // get XRechung XML File (if possible)
185+
```
186+
170187
### Recurring Templates Endpoint
171188
```php
172189

@@ -184,6 +201,17 @@ $response = $client->getPage(0);
184201
$response = $api->recurringTemplate()->get($entityId);
185202
```
186203

204+
### Voucher Endpoint
205+
```php
206+
$response = $api->voucher()->get($entityId);
207+
$response = $api->voucher()->create($data);
208+
$response = $api->voucher()->update($entityId, $data);
209+
$response = $api->voucher()->document($entityId); // get document ID
210+
$response = $api->voucher()->document($entityId, true); // get file content
211+
$response = $api->voucher()->document($entityId, true, 'image/*'); // accept only images
212+
$response = $api->voucher()->document($entityId, true, 'application/xml'); // get XRechung XML File (if possible)
213+
$response = $api->voucher()->upload($entitiyId, $filepath);
214+
```
187215

188216
### Voucherlist Endpoint
189217
```php
@@ -230,15 +258,6 @@ $client->updatedDateTo = new \DateTime('2023-12-01');
230258
$response = $client->getPage(0);
231259
```
232260

233-
### File Endpoint
234-
```php
235-
$response = $api->file()->upload($filePath, $voucherType);
236-
$response = $api->file()->get($entityId); // accept every file
237-
$response = $api->file()->get($entityId, 'image/*'); // accept only images
238-
$response = $api->file()->get($entityId, 'application/xml'); // get XRechung XML File (if possible)
239-
```
240-
241-
242261
### get JSON from Success and Error Response
243262

244263
```php

src/Api.php

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Sysix\LexOffice\Clients\Contact;
1515
use Sysix\LexOffice\Clients\Country;
1616
use Sysix\LexOffice\Clients\CreditNote;
17+
use Sysix\LexOffice\Clients\DeliveryNote;
1718
use Sysix\LexOffice\Clients\DownPaymentInvoice;
1819
use Sysix\LexOffice\Clients\Event;
1920
use Sysix\LexOffice\Clients\File;
@@ -94,19 +95,33 @@ public function country(): Country
9495
return new Country($this);
9596
}
9697

98+
public function creditNote(): CreditNote
99+
{
100+
return new CreditNote($this);
101+
}
102+
103+
public function deliveryNote(): DeliveryNote
104+
{
105+
return new DeliveryNote($this);
106+
}
107+
public function downPaymentInvoice(): DownPaymentInvoice
108+
{
109+
return new DownPaymentInvoice($this);
110+
}
111+
97112
public function event(): Event
98113
{
99114
return new Event($this);
100115
}
101116

102-
public function invoice(): Invoice
117+
public function file(): File
103118
{
104-
return new Invoice($this);
119+
return new File($this);
105120
}
106121

107-
public function downPaymentInvoice(): DownPaymentInvoice
122+
public function invoice(): Invoice
108123
{
109-
return new DownPaymentInvoice($this);
124+
return new Invoice($this);
110125
}
111126

112127
public function orderConfirmation(): OrderConfirmation
@@ -123,44 +138,34 @@ public function paymentCondition(): PaymentCondition
123138
{
124139
return new PaymentCondition($this);
125140
}
126-
127-
public function creditNote(): CreditNote
141+
public function postingCategory(): PostingCategory
128142
{
129-
return new CreditNote($this);
143+
return new PostingCategory($this);
130144
}
131145

132-
public function quotation(): Quotation
146+
public function profile(): Profile
133147
{
134-
return new Quotation($this);
148+
return new Profile($this);
135149
}
136150

137-
public function voucher(): Voucher
151+
public function quotation(): Quotation
138152
{
139-
return new Voucher($this);
153+
return new Quotation($this);
140154
}
141155

142156
public function recurringTemplate(): RecurringTemplate
143157
{
144158
return new RecurringTemplate($this);
145159
}
146160

147-
public function voucherlist(): VoucherList
148-
{
149-
return new VoucherList($this);
150-
}
151-
152-
public function profile(): Profile
161+
public function voucher(): Voucher
153162
{
154-
return new Profile($this);
163+
return new Voucher($this);
155164
}
156165

157-
public function postingCategory(): PostingCategory
166+
public function voucherlist(): VoucherList
158167
{
159-
return new PostingCategory($this);
168+
return new VoucherList($this);
160169
}
161170

162-
public function file(): File
163-
{
164-
return new File($this);
165-
}
166171
}

src/Clients/DeliveryNote.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Sysix\LexOffice\Clients;
6+
7+
use Sysix\LexOffice\BaseClient;
8+
use Sysix\LexOffice\Clients\Traits\CreateTrait;
9+
use Sysix\LexOffice\Clients\Traits\DocumentClientTrait;
10+
use Sysix\LexOffice\Clients\Traits\GetTrait;
11+
use Sysix\LexOffice\Clients\Traits\VoucherListTrait;
12+
13+
class DeliveryNote extends BaseClient
14+
{
15+
use GetTrait;
16+
use CreateTrait;
17+
use VoucherListTrait;
18+
use DocumentClientTrait;
19+
20+
protected string $resource = 'delivery-notes';
21+
22+
/** @var string[] */
23+
protected array $voucherListTypes = ['deliverynote'];
24+
}

src/Interfaces/ApiInterface.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,11 @@
44

55
namespace Sysix\LexOffice\Interfaces;
66

7-
use Psr\Http\Client\ClientInterface;
87
use Psr\Http\Message\RequestInterface;
98
use Psr\Http\Message\ResponseInterface;
109

1110
interface ApiInterface
1211
{
13-
public function __construct(string $apiKey, ClientInterface $client);
14-
1512
/**
1613
* @param string[] $headers
1714
*/

tests/ApiTest.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Sysix\LexOffice\Clients\Contact;
1010
use Sysix\LexOffice\Clients\Country;
1111
use Sysix\LexOffice\Clients\CreditNote;
12+
use Sysix\LexOffice\Clients\DeliveryNote;
1213
use Sysix\LexOffice\Clients\DownPaymentInvoice;
1314
use Sysix\LexOffice\Clients\Event;
1415
use Sysix\LexOffice\Clients\File;
@@ -37,22 +38,23 @@ public function testClients(): void
3738
{
3839
$stub = $this->createApiMockObject(new Response());
3940

40-
$this->assertInstanceOf(Country::class, $stub->country());
4141
$this->assertInstanceOf(Contact::class, $stub->contact());
42+
$this->assertInstanceOf(Country::class, $stub->country());
43+
$this->assertInstanceOf(CreditNote::class, $stub->creditNote());
44+
$this->assertInstanceOf(DeliveryNote::class, $stub->deliveryNote());
45+
$this->assertInstanceOf(DownPaymentInvoice::class, $stub->downPaymentInvoice());
4246
$this->assertInstanceOf(Event::class, $stub->event());
47+
$this->assertInstanceOf(File::class, $stub->file());
4348
$this->assertInstanceOf(Invoice::class, $stub->invoice());
44-
$this->assertInstanceOf(DownPaymentInvoice::class, $stub->downPaymentInvoice());
4549
$this->assertInstanceOf(OrderConfirmation::class, $stub->orderConfirmation());
46-
$this->assertInstanceOf(Quotation::class, $stub->quotation());
47-
$this->assertInstanceOf(Voucher::class, $stub->voucher());
48-
$this->assertInstanceOf(VoucherList::class, $stub->voucherlist());
49-
$this->assertInstanceOf(Profile::class, $stub->profile());
50-
$this->assertInstanceOf(CreditNote::class, $stub->creditNote());
5150
$this->assertInstanceOf(Payment::class, $stub->payment());
5251
$this->assertInstanceOf(PaymentCondition::class, $stub->paymentCondition());
53-
$this->assertInstanceOf(File::class, $stub->file());
54-
$this->assertInstanceOf(RecurringTemplate::class, $stub->recurringTemplate());
5552
$this->assertInstanceOf(PostingCategory::class, $stub->postingCategory());
53+
$this->assertInstanceOf(Profile::class, $stub->profile());
54+
$this->assertInstanceOf(Quotation::class, $stub->quotation());
55+
$this->assertInstanceOf(RecurringTemplate::class, $stub->recurringTemplate());
56+
$this->assertInstanceOf(Voucher::class, $stub->voucher());
57+
$this->assertInstanceOf(VoucherList::class, $stub->voucherlist());
5658
}
5759

5860
public function testApiUrl(): void

0 commit comments

Comments
 (0)