Skip to content

Commit 87a816d

Browse files
committed
Updated Readme.md + Fixed invalid parameters from Bexio Docs
1 parent 95eb933 commit 87a816d

File tree

9 files changed

+407
-10
lines changed

9 files changed

+407
-10
lines changed

.phpunit.cache/test-results

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

README.md

Lines changed: 282 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ This package was developed to give you a quick start to the Bexio API.
5151
- [Files](#files)
5252
- [Iban Payments](#iban-payments)
5353
- [Invoices](#invoices)
54+
- [Item Positions](#item-positions)
5455
- [Items](#items)
56+
- [Quotes](#quotes)
5557
- [Languages](#languages)
5658
- [Manual Entries](#manual-entries)
5759
- [Notes](#notes)
@@ -1608,7 +1610,95 @@ return response(base64_decode($pdf->content))
16081610
->header('Content-Length', $pdf->size);
16091611
```
16101612

1613+
### Item Positions
1614+
```php
1615+
/**
1616+
* Fetch A List Of Item Positions
1617+
*/
1618+
$itemPositions = $connector->send(new FetchAListOfItemPositionsRequest(
1619+
kb_document_id: 1,
1620+
kb_document_type: 'kb_offer'
1621+
))->dto();
1622+
```
1623+
1624+
```php
1625+
/**
1626+
* Fetch An Item Position
1627+
*/
1628+
$itemPosition = $connector->send(new FetchAnItemPositionRequest(
1629+
item_position_id: 1
1630+
))->dto();
1631+
```
1632+
1633+
```php
1634+
/**
1635+
* Create An Item Position
1636+
*/
1637+
$itemPosition = $connector->send(new CreateAnItemPositionRequest(
1638+
kb_document_id: 1,
1639+
itemPosition: new CreateEditItemPositionDTO(
1640+
kb_document_type: 'kb_offer',
1641+
type: 'KbPositionCustom',
1642+
amount: '1',
1643+
unit_id: 1,
1644+
account_id: 1,
1645+
tax_id: 1,
1646+
text: 'Test Item Position',
1647+
unit_price: '100.00',
1648+
discount_in_percent: '0',
1649+
)
1650+
))->dto();
1651+
```
1652+
1653+
```php
1654+
/**
1655+
* Edit An Item Position
1656+
*/
1657+
$itemPosition = $connector->send(new EditAnItemPositionRequest(
1658+
item_position_id: 1,
1659+
itemPosition: new CreateEditItemPositionDTO(
1660+
kb_document_type: 'kb_offer',
1661+
type: 'KbPositionCustom',
1662+
amount: '2',
1663+
unit_id: 1,
1664+
account_id: 1,
1665+
tax_id: 1,
1666+
text: 'Updated Item Position',
1667+
unit_price: '150.00',
1668+
discount_in_percent: '0',
1669+
)
1670+
))->dto();
1671+
```
16111672

1673+
```php
1674+
/**
1675+
* Delete An Item Position
1676+
*/
1677+
$response = $connector->send(new DeleteAnItemPositionRequest(
1678+
item_position_id: 1
1679+
));
1680+
```
1681+
1682+
```php
1683+
/**
1684+
* Create An Offer Item Position (with kb_document_type 'kb_offer' set by default)
1685+
*/
1686+
$offerItemPosition = new OfferItemPositionDTO(
1687+
type: 'KbPositionCustom',
1688+
amount: '1',
1689+
unit_id: 1,
1690+
account_id: 1,
1691+
tax_id: 1,
1692+
text: 'Test Offer Item Position',
1693+
unit_price: '100.00',
1694+
discount_in_percent: '0',
1695+
);
1696+
1697+
$itemPosition = $connector->send(new CreateAnItemPositionRequest(
1698+
kb_document_id: 1,
1699+
itemPosition: $offerItemPosition
1700+
))->dto();
1701+
```
16121702

16131703
### Languages
16141704
```php
@@ -2009,6 +2099,198 @@ $title = $connector->send(new DeleteATitleRequest(
20092099
));
20102100
```
20112101

2102+
### Quotes
2103+
```php
2104+
/**
2105+
* Fetch A List Of Quotes
2106+
*/
2107+
$quotes = $connector->send(new FetchAListOfQuotesRequest())->dto();
2108+
```
2109+
2110+
```php
2111+
/**
2112+
* Fetch A Quote
2113+
*/
2114+
$quote = $connector->send(new FetchAQuoteRequest(
2115+
quote_id: 1
2116+
))->dto();
2117+
```
2118+
2119+
```php
2120+
/**
2121+
* Search Quotes
2122+
*/
2123+
$quotes = $connector->send(new SearchQuotesRequest(
2124+
searchField: 'title',
2125+
searchTerm: 'Test'
2126+
))->dto();
2127+
```
2128+
2129+
```php
2130+
/**
2131+
* Create A Quote
2132+
*/
2133+
$contacts = $connector->send(new FetchAListOfContactsRequest);
2134+
$user = $connector->send(new FetchAuthenticatedUserRequest);
2135+
$languages = $connector->send(new FetchAListOfLanguagesRequest);
2136+
$banks = $connector->send(new FetchAListOfBankAccountsRequest);
2137+
$currencies = $connector->send(new FetchAListOfCurrenciesRequest);
2138+
$paymentTypes = $connector->send(new FetchAListOfPaymentTypesRequest);
2139+
$units = $connector->send(new FetchAListOfUnitsRequest);
2140+
$accounts = $connector->send(new FetchAListOfAccountsRequest);
2141+
$taxes = $connector->send(new FetchAListOfTaxesRequest(scope: 'active', types: 'sales_tax'));
2142+
2143+
$newQuote = QuoteDTO::fromArray([
2144+
'title' => 'Test Quote',
2145+
'contact_id' => $contacts->dto()->first()->id,
2146+
'user_id' => $user->dto()->id,
2147+
'pr_project_id' => null,
2148+
'language_id' => $languages->dto()->first()->id,
2149+
'bank_account_id' => $banks->dto()->first()->id,
2150+
'currency_id' => $currencies->dto()->first()->id,
2151+
'payment_type_id' => $paymentTypes->dto()->first()->id,
2152+
'mwst_type' => 1,
2153+
'mwst_is_net' => true,
2154+
'show_position_taxes' => true,
2155+
'is_valid_from' => now()->format('Y-m-d h:m:s'),
2156+
'is_valid_to' => now()->addDays(5)->format('Y-m-d h:m:s'),
2157+
'api_reference' => Str::uuid(),
2158+
'positions' => [
2159+
InvoicePositionDTO::fromArray([
2160+
'type' => 'KbPositionText',
2161+
'show_pos_nr' => true,
2162+
'text' => Str::uuid(),
2163+
]),
2164+
InvoicePositionDTO::fromArray([
2165+
'type' => 'KbPositionCustom',
2166+
'amount' => 1,
2167+
'unit_id' => $units->dto()->first()->id,
2168+
'account_id' => $accounts->dto()->filter(fn ($account) => $account->account_type_enum === AccountTypeEnum::ACTIVE_ACCOUNTS())->first()->id,
2169+
'tax_id' => $taxes->dto()->first()->id,
2170+
'text' => Str::uuid(),
2171+
'unit_price' => 100,
2172+
'discount_in_percent' => '0',
2173+
]),
2174+
],
2175+
]);
2176+
2177+
$quote = $connector->send(new CreateAQuoteRequest(quote: $newQuote))->dto();
2178+
```
2179+
2180+
```php
2181+
/**
2182+
* Edit A Quote
2183+
*/
2184+
$editQuote = $connector->send(new FetchAQuoteRequest(quote_id: 1))->dto();
2185+
2186+
$editQuote->title = 'Updated Quote Title';
2187+
2188+
$quote = $connector->send(new EditAQuoteRequest(quote_id: 1, quote: $editQuote));
2189+
```
2190+
2191+
```php
2192+
/**
2193+
* Delete A Quote
2194+
*/
2195+
$response = $connector->send(new DeleteAQuoteRequest(
2196+
quote_id: 1
2197+
));
2198+
```
2199+
2200+
```php
2201+
/**
2202+
* Issue A Quote
2203+
*/
2204+
$response = $connector->send(new IssueAQuoteRequest(
2205+
quote_id: 1
2206+
));
2207+
```
2208+
2209+
```php
2210+
/**
2211+
* Revert Issue A Quote
2212+
*/
2213+
$response = $connector->send(new RevertIssueAQuoteRequest(
2214+
quote_id: 1
2215+
));
2216+
```
2217+
2218+
```php
2219+
/**
2220+
* Accept A Quote
2221+
*/
2222+
$response = $connector->send(new AcceptAQuoteRequest(
2223+
quote_id: 1
2224+
));
2225+
```
2226+
2227+
```php
2228+
/**
2229+
* Decline A Quote
2230+
*/
2231+
$response = $connector->send(new DeclineAQuoteRequest(
2232+
quote_id: 1
2233+
));
2234+
```
2235+
2236+
```php
2237+
/**
2238+
* Reissue A Quote
2239+
*/
2240+
$response = $connector->send(new ReissueAQuoteRequest(
2241+
quote_id: 1
2242+
));
2243+
```
2244+
2245+
```php
2246+
/**
2247+
* Mark Quote As Sent
2248+
*/
2249+
$response = $connector->send(new MarkAsSentAQuoteRequest(
2250+
quote_id: 1
2251+
));
2252+
```
2253+
2254+
```php
2255+
/**
2256+
* Show PDF Of A Quote
2257+
*/
2258+
$pdf = $connector->send(new ShowPdfAQuoteRequest(
2259+
quote_id: 1
2260+
))->dto();
2261+
2262+
/**
2263+
* Saving PDF from response
2264+
*/
2265+
Storage::disk('local')->put('your/directory/'. $pdf->name, base64_decode($pdf->content));
2266+
2267+
/**
2268+
* Download PDF from response
2269+
*/
2270+
return response(base64_decode($pdf->content))
2271+
->header('Content-Type', $pdf->mime)
2272+
->header('Content-Disposition', 'attachment; filename="'.$pdf->name.'"')
2273+
->header('Content-Length', $pdf->size);
2274+
```
2275+
2276+
```php
2277+
/**
2278+
* Create Order From Quote
2279+
*/
2280+
$response = $connector->send(new CreateOrderFromQuoteRequest(
2281+
quote_id: 1
2282+
));
2283+
```
2284+
2285+
```php
2286+
/**
2287+
* Create Invoice From Quote
2288+
*/
2289+
$response = $connector->send(new CreateInvoiceFromQuoteRequest(
2290+
quote_id: 1
2291+
));
2292+
```
2293+
20122294
### Items
20132295
```php
20142296
/**

src/Dto/Quotes/QuoteDTO.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function __construct(
3636
public ?bool $mwst_is_net,
3737
public ?bool $show_position_taxes,
3838
public ?string $is_valid_from,
39-
public ?string $is_valid_to,
39+
public ?string $is_valid_until,
4040
public ?string $contact_address,
4141
public ?int $kb_item_status_id,
4242
public ?string $reference,
@@ -92,7 +92,7 @@ public static function fromArray(array $data): self
9292
mwst_is_net: Arr::get($data, 'mwst_is_net'),
9393
show_position_taxes: Arr::get($data, 'show_position_taxes'),
9494
is_valid_from: Arr::get($data, 'is_valid_from'),
95-
is_valid_to: Arr::get($data, 'is_valid_to'),
95+
is_valid_until: Arr::get($data, 'is_valid_until'),
9696
contact_address: Arr::get($data, 'contact_address'),
9797
kb_item_status_id: Arr::get($data, 'kb_item_status_id'),
9898
reference: Arr::get($data, 'reference'),

src/Requests/Quotes/CreateAQuoteRequest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ protected function filterQuote(Collection $quote): array
5757
'mwst_is_net',
5858
'show_position_taxes',
5959
'is_valid_from',
60-
'is_valid_to',
61-
'reference',
60+
'is_valid_until',
6261
'api_reference',
6362
'viewed_by_client_at',
6463
'template_slug',

src/Requests/Quotes/EditAQuoteRequest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ protected function filterQuote(Collection $quote): array
5858
'mwst_is_net',
5959
'show_position_taxes',
6060
'is_valid_from',
61-
'is_valid_to',
61+
'is_valid_until',
6262
'reference',
6363
'api_reference',
6464
'viewed_by_client_at',
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"statusCode": 200,
3+
"headers": {
4+
"Date": "Thu, 27 Nov 2025 09:01:12 GMT",
5+
"Content-Type": "application\/json",
6+
"Content-Length": "2",
7+
"Connection": "keep-alive",
8+
"CF-RAY": "9a5070879fdf8628-ZRH",
9+
"ratelimit-reset": "48",
10+
"x-ratelimit-remaining-minute": "987",
11+
"x-ratelimit-limit-minute": "1000",
12+
"ratelimit-remaining": "987",
13+
"ratelimit-limit": "1000",
14+
"Cache-Control": "no-store",
15+
"pragma": "no-cache",
16+
"vary": "Origin",
17+
"access-control-allow-origin": "https:\/\/office.bexio.com",
18+
"via": "1.1 google",
19+
"cf-cache-status": "DYNAMIC",
20+
"Server": "cloudflare"
21+
},
22+
"data": "[]",
23+
"context": []
24+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"statusCode": 200,
3+
"headers": {
4+
"Date": "Thu, 27 Nov 2025 09:01:10 GMT",
5+
"Content-Type": "application\/json",
6+
"Content-Length": "2",
7+
"Connection": "keep-alive",
8+
"CF-RAY": "9a50707d9b0bbaae-ZRH",
9+
"ratelimit-reset": "50",
10+
"x-ratelimit-limit-minute": "250",
11+
"x-ratelimit-remaining-minute": "249",
12+
"ratelimit-limit": "250",
13+
"ratelimit-remaining": "249",
14+
"Cache-Control": "no-store",
15+
"pragma": "no-cache",
16+
"vary": "Origin",
17+
"access-control-allow-origin": "https:\/\/office.bexio.com",
18+
"via": "1.1 google",
19+
"cf-cache-status": "DYNAMIC",
20+
"Server": "cloudflare"
21+
},
22+
"data": "[]",
23+
"context": []
24+
}

0 commit comments

Comments
 (0)