Skip to content

Commit

Permalink
Merge pull request #136 from Sysix/delivery-notes
Browse files Browse the repository at this point in the history
Delivery notes
  • Loading branch information
Sysix authored Dec 21, 2023
2 parents f4724c1 + 8a51519 commit 2492d57
Show file tree
Hide file tree
Showing 6 changed files with 278 additions and 87 deletions.
121 changes: 70 additions & 51 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,27 @@ $response = $client->update($entityId, $data);
$response = $api->country()->getAll();
```

### Invoices Endpoint
### Credit Notes Endpoint
```php
$voucherList = $api->invoice()->getVoucherListClient(); // see VoucherlistClient Documentation
$response = $api->invoice()->get($entityId);
$response = $api->invoice()->create($data);
$response = $api->invoice()->document($entityId); // get document ID
$response = $api->invoice()->document($entityId, true); // get file content
$response = $api->invoice()->document($entityId, true, 'image/*'); // accept only images
$response = $api->invoice()->document($entityId, true, 'application/xml'); // get XRechung XML File (if possible)
$voucherList = $api->creditNote()->getVoucherListClient(); // see VoucherlistClient Documentation
$response = $api->creditNote()->get($entityId);
$response = $api->creditNote()->create($data);
$response = $api->creditNote()->create($data, true); // finalized
$response = $api->creditNote()->document($entityId); // get document ID
$response = $api->creditNote()->document($entityId, true); // get file content
$response = $api->creditNote()->document($entityId, true, 'image/*'); // accept only images
$response = $api->creditNote()->document($entityId, true, 'application/xml'); // get XRechung XML File (if possible)
```

### Deliverys Notes Endpoint
```php
$voucherList = $api->deliveryNote()->getVoucherListClient(); // see VoucherlistClient Documentation
$response = $api->deliveryNote()->get($entityId);
$response = $api->deliveryNote()->create($data);
$response = $api->deliveryNote()->document($entityId); // get document ID
$response = $api->deliveryNote()->document($entityId, true); // get file content
$response = $api->deliveryNote()->document($entityId, true, 'image/*'); // accept only images
$response = $api->deliveryNote()->document($entityId, true, 'application/xml'); // get XRechung XML File (if possible)
```

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

### Order Confirmation Endpoint
### Event Subscriptions Endpooint
```php
$voucherList = $api->orderConfirmation()->getVoucherListClient(); // see VoucherlistClient Documentation
$response = $api->orderConfirmation()->get($entityId);
$response = $api->orderConfirmation()->create($data);
$response = $api->orderConfirmation()->document($entityId); // get document ID
$response = $api->orderConfirmation()->document($entityId, true); // get file content
$response = $api->orderConfirmation()->document($entityId, true, 'image/*'); // accept only images
$response = $api->orderConfirmation()->document($entityId, true, 'application/xml'); // get XRechung XML File (if possible)
// TODO: get
$response = $api->voucher()->create($data);
$response = $api->voucher()->delete($entityId);
$response = $api->voucher()->getAll();
```

### Quotation Endpoint
### File Endpoint
```php
$voucherList = $api->quotation()->getVoucherListClient(); // see VoucherlistClient Documentation
$response = $api->quotation()->get($entityId);
$response = $api->quotation()->create($data);
$response = $api->quotation()->document($entityId); // get document ID
$response = $api->quotation()->document($entityId, true); // get file content
$response = $api->quotation()->document($entityId, true, 'image/*'); // accept only images
$response = $api->quotation()->document($entityId, true, 'application/xml'); // get XRechung XML File (if possible)
$response = $api->file()->upload($filePath, $voucherType);
$response = $api->file()->get($entityId); // accept every file
$response = $api->file()->get($entityId, 'image/*'); // accept only images
$response = $api->file()->get($entityId, 'application/xml'); // get XRechung XML File (if possible)
```

### Voucher Endpoint
### Invoices Endpoint
```php
$response = $api->voucher()->get($entityId);
$response = $api->voucher()->create($data);
$response = $api->voucher()->update($entityId, $data);
$response = $api->voucher()->document($entityId); // get document ID
$response = $api->voucher()->document($entityId, true); // get file content
$response = $api->voucher()->document($entityId, true, 'image/*'); // accept only images
$response = $api->voucher()->document($entityId, true, 'application/xml'); // get XRechung XML File (if possible)
$response = $api->voucher()->upload($entitiyId, $filepath);
$voucherList = $api->invoice()->getVoucherListClient(); // see VoucherlistClient Documentation
$response = $api->invoice()->get($entityId);
$response = $api->invoice()->create($data);
$response = $api->invoice()->create($data, true); // finalized
$response = $api->invoice()->document($entityId); // get document ID
$response = $api->invoice()->document($entityId, true); // get file content
$response = $api->invoice()->document($entityId, true, 'image/*'); // accept only images
$response = $api->invoice()->document($entityId, true, 'application/xml'); // get XRechung XML File (if possible)
```


### Credit Notes Endpoint
### Order Confirmation Endpoint
```php
$voucherList = $api->creditNote()->getVoucherListClient(); // see VoucherlistClient Documentation
$response = $api->creditNote()->get($entityId);
$response = $api->creditNote()->create($data);
$response = $api->creditNote()->document($entityId); // get document ID
$response = $api->creditNote()->document($entityId, true); // get file content
$response = $api->creditNote()->document($entityId, true, 'image/*'); // accept only images
$response = $api->creditNote()->document($entityId, true, 'application/xml'); // get XRechung XML File (if possible)
$voucherList = $api->orderConfirmation()->getVoucherListClient(); // see VoucherlistClient Documentation
$response = $api->orderConfirmation()->get($entityId);
$response = $api->orderConfirmation()->create($data);
$response = $api->orderConfirmation()->document($entityId); // get document ID
$response = $api->orderConfirmation()->document($entityId, true); // get file content
$response = $api->orderConfirmation()->document($entityId, true, 'image/*'); // accept only images
$response = $api->orderConfirmation()->document($entityId, true, 'application/xml'); // get XRechung XML File (if possible)
```

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

### Quotation Endpoint
```php
$voucherList = $api->quotation()->getVoucherListClient(); // see VoucherlistClient Documentation
$response = $api->quotation()->get($entityId);
$response = $api->quotation()->create($data);
$response = $api->quotation()->create($data, true); // finalized
$response = $api->quotation()->document($entityId); // get document ID
$response = $api->quotation()->document($entityId, true); // get file content
$response = $api->quotation()->document($entityId, true, 'image/*'); // accept only images
$response = $api->quotation()->document($entityId, true, 'application/xml'); // get XRechung XML File (if possible)
```

### Recurring Templates Endpoint
```php

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

### Voucher Endpoint
```php
$response = $api->voucher()->get($entityId);
$response = $api->voucher()->create($data);
$response = $api->voucher()->update($entityId, $data);
$response = $api->voucher()->document($entityId); // get document ID
$response = $api->voucher()->document($entityId, true); // get file content
$response = $api->voucher()->document($entityId, true, 'image/*'); // accept only images
$response = $api->voucher()->document($entityId, true, 'application/xml'); // get XRechung XML File (if possible)
$response = $api->voucher()->upload($entitiyId, $filepath);
```

### Voucherlist Endpoint
```php
Expand Down Expand Up @@ -230,15 +258,6 @@ $client->updatedDateTo = new \DateTime('2023-12-01');
$response = $client->getPage(0);
```

### File Endpoint
```php
$response = $api->file()->upload($filePath, $voucherType);
$response = $api->file()->get($entityId); // accept every file
$response = $api->file()->get($entityId, 'image/*'); // accept only images
$response = $api->file()->get($entityId, 'application/xml'); // get XRechung XML File (if possible)
```


### get JSON from Success and Error Response

```php
Expand Down
53 changes: 29 additions & 24 deletions src/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Sysix\LexOffice\Clients\Contact;
use Sysix\LexOffice\Clients\Country;
use Sysix\LexOffice\Clients\CreditNote;
use Sysix\LexOffice\Clients\DeliveryNote;
use Sysix\LexOffice\Clients\DownPaymentInvoice;
use Sysix\LexOffice\Clients\Event;
use Sysix\LexOffice\Clients\File;
Expand Down Expand Up @@ -94,19 +95,33 @@ public function country(): Country
return new Country($this);
}

public function creditNote(): CreditNote
{
return new CreditNote($this);
}

public function deliveryNote(): DeliveryNote
{
return new DeliveryNote($this);
}
public function downPaymentInvoice(): DownPaymentInvoice
{
return new DownPaymentInvoice($this);
}

public function event(): Event
{
return new Event($this);
}

public function invoice(): Invoice
public function file(): File
{
return new Invoice($this);
return new File($this);
}

public function downPaymentInvoice(): DownPaymentInvoice
public function invoice(): Invoice
{
return new DownPaymentInvoice($this);
return new Invoice($this);
}

public function orderConfirmation(): OrderConfirmation
Expand All @@ -123,44 +138,34 @@ public function paymentCondition(): PaymentCondition
{
return new PaymentCondition($this);
}

public function creditNote(): CreditNote
public function postingCategory(): PostingCategory
{
return new CreditNote($this);
return new PostingCategory($this);
}

public function quotation(): Quotation
public function profile(): Profile
{
return new Quotation($this);
return new Profile($this);
}

public function voucher(): Voucher
public function quotation(): Quotation
{
return new Voucher($this);
return new Quotation($this);
}

public function recurringTemplate(): RecurringTemplate
{
return new RecurringTemplate($this);
}

public function voucherlist(): VoucherList
{
return new VoucherList($this);
}

public function profile(): Profile
public function voucher(): Voucher
{
return new Profile($this);
return new Voucher($this);
}

public function postingCategory(): PostingCategory
public function voucherlist(): VoucherList
{
return new PostingCategory($this);
return new VoucherList($this);
}

public function file(): File
{
return new File($this);
}
}
24 changes: 24 additions & 0 deletions src/Clients/DeliveryNote.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

declare(strict_types=1);

namespace Sysix\LexOffice\Clients;

use Sysix\LexOffice\BaseClient;
use Sysix\LexOffice\Clients\Traits\CreateTrait;
use Sysix\LexOffice\Clients\Traits\DocumentClientTrait;
use Sysix\LexOffice\Clients\Traits\GetTrait;
use Sysix\LexOffice\Clients\Traits\VoucherListTrait;

class DeliveryNote extends BaseClient
{
use GetTrait;
use CreateTrait;
use VoucherListTrait;
use DocumentClientTrait;

protected string $resource = 'delivery-notes';

/** @var string[] */
protected array $voucherListTypes = ['deliverynote'];
}
3 changes: 0 additions & 3 deletions src/Interfaces/ApiInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@

namespace Sysix\LexOffice\Interfaces;

use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;

interface ApiInterface
{
public function __construct(string $apiKey, ClientInterface $client);

/**
* @param string[] $headers
*/
Expand Down
20 changes: 11 additions & 9 deletions tests/ApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Sysix\LexOffice\Clients\Contact;
use Sysix\LexOffice\Clients\Country;
use Sysix\LexOffice\Clients\CreditNote;
use Sysix\LexOffice\Clients\DeliveryNote;
use Sysix\LexOffice\Clients\DownPaymentInvoice;
use Sysix\LexOffice\Clients\Event;
use Sysix\LexOffice\Clients\File;
Expand Down Expand Up @@ -37,22 +38,23 @@ public function testClients(): void
{
$stub = $this->createApiMockObject(new Response());

$this->assertInstanceOf(Country::class, $stub->country());
$this->assertInstanceOf(Contact::class, $stub->contact());
$this->assertInstanceOf(Country::class, $stub->country());
$this->assertInstanceOf(CreditNote::class, $stub->creditNote());
$this->assertInstanceOf(DeliveryNote::class, $stub->deliveryNote());
$this->assertInstanceOf(DownPaymentInvoice::class, $stub->downPaymentInvoice());
$this->assertInstanceOf(Event::class, $stub->event());
$this->assertInstanceOf(File::class, $stub->file());
$this->assertInstanceOf(Invoice::class, $stub->invoice());
$this->assertInstanceOf(DownPaymentInvoice::class, $stub->downPaymentInvoice());
$this->assertInstanceOf(OrderConfirmation::class, $stub->orderConfirmation());
$this->assertInstanceOf(Quotation::class, $stub->quotation());
$this->assertInstanceOf(Voucher::class, $stub->voucher());
$this->assertInstanceOf(VoucherList::class, $stub->voucherlist());
$this->assertInstanceOf(Profile::class, $stub->profile());
$this->assertInstanceOf(CreditNote::class, $stub->creditNote());
$this->assertInstanceOf(Payment::class, $stub->payment());
$this->assertInstanceOf(PaymentCondition::class, $stub->paymentCondition());
$this->assertInstanceOf(File::class, $stub->file());
$this->assertInstanceOf(RecurringTemplate::class, $stub->recurringTemplate());
$this->assertInstanceOf(PostingCategory::class, $stub->postingCategory());
$this->assertInstanceOf(Profile::class, $stub->profile());
$this->assertInstanceOf(Quotation::class, $stub->quotation());
$this->assertInstanceOf(RecurringTemplate::class, $stub->recurringTemplate());
$this->assertInstanceOf(Voucher::class, $stub->voucher());
$this->assertInstanceOf(VoucherList::class, $stub->voucherlist());
}

public function testApiUrl(): void
Expand Down
Loading

0 comments on commit 2492d57

Please sign in to comment.