codebar-ag / laravel-bexio
Bexio与Laravel集成
v1.2
2024-04-03 09:28 UTC
Requires
- php: >=8.2
- guzzlehttp/guzzle: ^7.8
- illuminate/contracts: ^11.0
- laravel/framework: ^11
- saloonphp/cache-plugin: ^3.0
- saloonphp/laravel-plugin: ^3.2
- saloonphp/saloon: ^3.4
- spatie/laravel-data: ^4.4
- spatie/laravel-enum: ^3.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^2.8
- laravel/pint: ^1.13
- nunomaduro/collision: ^8.1
- orchestra/testbench: ^9.0
- pestphp/pest: ^2.31
- pestphp/pest-plugin-laravel: ^2.2
- phpstan/extension-installer: ^1.3
- phpstan/phpstan-deprecation-rules: ^1.1
- phpstan/phpstan-phpunit: ^1.3
- spatie/laravel-ray: ^1.33
README
本包旨在帮助您快速开始使用Bexio API。
💡什么是Bexio?
Bexio是一款面向自由职业者、小型企业和初创企业的基于云的简单商业软件。
🛠要求
身份验证
当前支持的认证方法有
⚙️安装
您可以通过composer安装此包
composer require codebar-ag/laravel-bexio
可选地,您可以使用以下命令发布配置文件
php artisan vendor:publish --provider="CodebarAg\Bexio\BexioServiceProvider" --tag="config"
您可以将以下环境变量添加到您的.env
文件中
BEXIO_API_TOKEN= # Your Bexio API token
您可以从您的Bexio仪表板获取API令牌
使用方法
要使用此包,您需要创建一个BexioConnector实例。
use CodebarAg\Bexio\BexioConnector; ... $connector = new BexioConnector();
响应
以下响应目前支持用于检索响应体
有关更多信息,请参阅https://docs.saloon.dev/the-basics/responses
枚举
我们为以下值提供了枚举
注意:当在响应上使用dto方法时,枚举值将被转换为相应的枚举类。
DTOs
我们为以下内容提供了DTOs
除了上述内容外,我们还为以下内容的创建和编辑请求提供了DTOs
注意:这是与请求和响应交互的首选方法,但是您仍然可以使用json、object和collect方法,并将数组传递给请求。
示例
use CodebarAg\DocuWare\BexioConnector; // You can either set the token in the constructor or in the .env file // PROVIDE TOKEN IN CONSTRUCTOR $connector = new BexioConnector(token: 'your-token'); // OR // PROVIDE TOKEN IN .ENV FILE $connector = new BexioConnector();
账户
/** * Fetch A List Of Account Groups */ $accountGroups = $connector->send(new FetchAListOfAccountGroupsRequest())->dto();
/** * Fetch A List Of Accounts */ $accounts = $connector->send(new FetchAListOfAccountsRequest())->dto();
/** * Search Accounts */ $accounts = $connector->send(new SearchAccountsRequest( searchField: 'Name', searchTerm: 'Something' ))->dto();
地址
/** * Fetch A List Of Addresses */ $addresses = $connector->send(new FetchAListOfAddressesRequest())->dto();
/** * Fetch An Address */ $address = $connector->send(new FetchAnAddressRequest( id: 1 ))->dto();
/** * Search Addresses */ $addresses = $connector->send(new SearchAddressesRequest( searchField: 'Name', searchTerm: 'Something' ))->dto();
/** * Create Address */ $address = $connector->send(new CreateAddressRequest( data: new CreateEditAddressDTO( name: 'Test', subject: 'Test Subject', description: 'This is a test', address: 'Test Address', postcode: '1234', city: 'Test City', ) ));
/** * Edit Address */ $address = $connector->send(new EditAnAddressRequest( id: 1, data: new CreateEditAddressDTO( name: 'Test Edit', subject: 'Test Subject Edit', description: 'This is a test edit', address: 'Test Address Edit', postcode: '4567', city: 'Test City Edit', ) ));
/** * Delete Address */ $address = $connector->send(new DeleteAnAddressRequest( id: 1 ));
银行账户
/** * Fetch A List Of Bank Accounts */ $bankAccounts = $connector->send(new FetchAListOfBankAccountsRequest())->dto();
/** * Fetch A Single Bank Account */ $bankAccount = $connector->send(new FetchASingleBankAccountRequest( id: 1 ))->dto();
商业年份
/** * Fetch A List Of Business Years */ $businessYears = $connector->send(new FetchAListOfBusinessYearsRequest())->dto();
/** * Fetch A Business Year */ $businessYear = $connector->send(new FetchABusinessYearRequest( id: 1 ))->dto();
日历年份
/** * Fetch A List Of Calendar Years */ $calendarYears = $connector->send(new FetchAListOfCalendarYearsRequest())->dto();
/** * Fetch A Calendar Year */ $calendarYear = $connector->send(new FetchACalendarYearRequest( id: 1 ))->dto();
公司档案
/** * Fetch A List Of Company Profiles */ $companyProfiles = $connector->send(new FetchAListOfCompanyProfilesRequest())->dto();
/** * Fetch A Company Profile */ $companyProfile = $connector->send(new FetchACompanyProfileRequest( id: 1 ))->dto();
附加地址
/** * Fetch A List Of Contact Additional Addresses */ $contactAdditionalAddresses = $connector->send(new FetchAListOfContactAdditionalAddressesRequest( contactId: 1 ))->dto();
/** * Fetch A Contact Additional Address */ $contactAdditionalAddress = $connector->send(new FetchAContactAdditionalAddressRequest( contactId: 1, id: 1 ))->dto();
/** * Search Contact Additional Address */ $contactAdditionalAddresses = $connector->send(new SearchContactAdditionalAddressesRequest( contactId: 1, searchField: 'Name', searchTerm: 'Something' ))->dto();
/** * Create Contact Additional Address */ $contactAdditionalAddress = $connector->send(new CreateContactAdditionalAddressRequest( contactId: 1, data: new CreateEditContactAdditionalAddressDTO( name: 'Test', subject: 'Test Subject', description: 'This is a test', address: 'Test Address', postcode: '1234', city: 'Test City', ) ));
/** * Edit Contact Additional Address */ $contactAdditionalAddress = $connector->send(new EditAContactAdditionalAddressRequest( contactId: 1, id: 9, data: new CreateEditContactAdditionalAddressDTO( name: 'Test Edit', subject: 'Test Subject Edit', description: 'This is a test edit', address: 'Test Address Edit', postcode: '4567', city: 'Test City Edit', ) ));
/** * Delete Contact Additional Address */ $contactAdditionalAddress = $connector->send(new DeleteAContactAdditionalAddressRequest( contactId: 1, id: 9, ));
联系人组
/** * Fetch A List Of Contact Groups */ $contactGroups = $connector->send(new FetchAListOfContactGroupsRequest())->dto();
/** * Fetch A Contact Group */ $contactGroup = $connector->send(new FetchAContactGroupRequest( id: 1 ))->dto();
/** * Search Contact Groups */ $contactGroups = $connector->send(new SearchContactGroupsRequest( searchField: 'Name', searchTerm: 'Something' ))->dto();
/** * Create Contact Group */ $contactGroup = $connector->send(new CreateContactGroupRequest( data: new CreateEditContactGroupDTO( name: 'Name' ) ));
/** * Edit Contact Group */ $contactGroup = $connector->send(new EditAContactGroupRequest( id: 1, data: new CreateEditContactGroupDTO( name: 'Name' ) ));
/** * Delete Contact Group */ $contactGroup = $connector->send(new DeleteAContactGroupRequest( id: 1 ));
联系人关系
/** * Fetch A List Of Contact Relations */ $contactRelations = $connector->send(new FetchAListOfContactRelationsRequest())->dto();
/** * Fetch A Contact Relation */ $contactRelation = $connector->send(new FetchAContactRelationRequest( id: 1 ))->dto();
/** * Search Contact Relations */ $contactRelations = $connector->send(new SearchContactRelationsRequest( searchField: 'Name', searchTerm: 'Something' ))->dto();
/** * Create Contact Relation */ $contactRelation = $connector->send(new CreateContactRelationRequest( data: new CreateEditContactRelationDTO( contact_id: 1, contact_sub_id: 2, description: 'Something', ) ));
/** * Edit Contact Relation */ $contactRelation = $connector->send(new EditAContactRelationRequest( id: 1, data: new CreateEditContactRelationDTO( contact_id: 1, contact_sub_id: 2, description: 'Something', ) ));
/** * Delete Contact Relation */ $contactRelation = $connector->send(new DeleteAContactRelationRequest( id: 1 ));
联系人
/** * Fetch A List Of Contacts */ $contacts = $connector->send(new FetchAListOfContactsRequest())->dto();
/** * Fetch A Contact */ $contact = $connector->send(new FetchAContactRequest( id: 1 ))->dto();
/** * Search Contacts */ $contacts = $connector->send(new SearchContactsRequest( searchField: 'Name', searchTerm: 'Something' ))->dto();
/** * Create Contact */ $contact = $connector->send(new CreateContactRequest( data: new CreateEditContactDTO( user_id: 1, owner_id: 1, contact_type_id: 1, name_1: 'Name' ) ));
/** * Bulk Create Contacts */ $contact = $connector->send(new BulkCreateContactsRequest( data: [ new CreateEditContactDTO( user_id: 1, owner_id: 1, contact_type_id: 1, name_1: 'Name' ), new CreateEditContactDTO( user_id: 1, owner_id: 1, contact_type_id: 1, name_1: 'Name 2' ) ] ));
/** * Edit Contact */ $contact = $connector->send(new EditAContactRequest( id: 1, data: new CreateEditContactDTO( user_id: 1, owner_id: 1, contact_type_id: 1, name_1: 'Name' ) ));
/** * Delete Contact */ $contact = $connector->send(new DeleteAContactRequest( id: 1 ));
/** * Restore Contact */ $contact = $connector->send(new RestoreAContactRequest( id: 1 ));
联系人行业
/** * Fetch A List Of Contact Sectors */ $contactSectors = $connector->send(new FetchAListOfContactSectorsRequest())->dto();
/** * Search Contact Sectors */ $contactSectors = $connector->send(new SearchContactSectorsRequest( searchField: 'Name', searchTerm: 'Something' ))->dto();
货币
/** * Fetch A List Of Currencies */ $currencies = $connector->send(new FetchAListOfCurrenciesRequest())->dto();
/** * Fetch A Currency */ $currency = $connector->send(new FetchACurrencyRequest( id: 1 ))->dto();
/** * Create Currency */ $currency = $connector->send(new CreateCurrencyRequest( data: new CreateCurrencyDTO( name: 'JPY', round_factor: 0.05, ) ));
/** * Edit Currency */ $currency = $connector->send(new EditACurrencyRequest( id: 1, data: new EditCurrencyDTO( round_factor: 0.05, ) ));
/** * Delete Currency */ $currency = $connector->send(new DeleteACurrencyRequest( id: 1 ));
/** * Fetch All Possible Currency Codes */ $currencyCodes = $connector->send(new FetchAllPossibleCurrencyCodesRequest())->dto();
/** * Fetch Exchange Rates For Currencies */ $exchangeRates = $connector->send(new FetchExchangeRatesForCurrenciesRequest( currencyId: 1 ))->dto();
文件
/** * Fetch A List Of Files */ $files = $connector->send(new FetchAListOfFilesRequest())->dto();
/** * Get A Single File */ $file = $connector->send(new GetASingleFileRequest( id: 1 ))->dto();
/** * Show A File Usage */ $fileUsage = $connector->send(new ShowAFileUsageRequest( id: 1 ))->dto();
/** * Get A File Preview */ $filePreview = $connector->send(new GetAFilePreviewRequest( id: 1 ))->stream();
/** * Download File Download */ $fileDownload = $connector->send(new DownloadFileDownloadRequest( id: 1 ))->stream();
/** * Create A File */ $file = $connector->send(new CreateAFileRequest( data: [ new MultipartValue( name: 'picture', value: fopen(__DIR__ . 'image.png', 'r'), ) ], ));
/** * Edit A File */ $file = $connector->send(new EditAFileRequest( id: 1, data: new EditFileDTO( name: 'Test name edited', is_archived: false, source_type: 'web', ) ));
/** * Delete A File */ $file = $connector->send(new DeleteAFileRequest( id: 1 ));
IBAN付款
/** * Fetch An Iban Payment */ $payment = $connector->send(new GetIbanPaymentRequest( bank_account_id: 1, payment_id: 3 ))->dto();
/** * Create Iban Payment */ $payment = $connector->send(new CreateIbanPaymentRequest( bank_account_id: 1, data: new CreateEditIbanPaymentDTO( instructed_amount: [ 'currency' => 'CHF', 'amount' => 100, ], recipient: [ 'name' => 'Müller GmbH', 'street' => 'Sonnenstrasse', 'zip' => 8005, 'city' => 'Zürich', 'country_code' => 'CH', 'house_number' => 36, ], iban: 'CH8100700110005554634', execution_date: '2024-01-08', is_salary_payment: false, is_editing_restricted: false, message: 'Rechnung 1234', allowance_type: 'no_fee', ) ))->dto();
/** * Update Iban Payment * * NOTE: THE PAYMENT MUST HAVE A STATUS OF OPEN TO BE UPDATED */ $payment = $connector->send(new EditIbanPaymentRequest( bank_account_id: 1, payment_id: 3, iban: 'CH8100700110005554634', id: 3, data: new CreateEditIbanPaymentDTO( instructed_amount: [ 'currency' => 'CHF', 'amount' => 100, ], recipient: [ 'name' => 'Müller GmbH', 'street' => 'Colchester Place', 'zip' => 8005, 'city' => 'Zürich', 'country_code' => 'CH', 'house_number' => 36, ], iban: 'CH8100700110005554634', execution_date: '2024-01-08', is_salary_payment: false, is_editing_restricted: false, message: 'Rechnung 1234', allowance_type: 'no_fee', ) ))->dto();
手动条目
/** * Fetch A List Of Manual Entries */ $manualEntries = $connector->send(new FetchAListOfManualEntriesRequest())->dto();
/** * Fetch Files Of Accounting Entry */ $files = $connector->send(new FetchFilesOfAccountingEntryRequest( manual_entry_id: 1, entry_id: 1 ))->dto();
/** * Fetch File Of Accounting Entry Line */ $file = $connector->send(new FetchFileOfAccountingEntryLineRequest( manual_entry_id: 1, entry_id: 1, line_id: 1 ))->dto();
/** * Create Manual Entry */ $manualEntry = $connector->send(new CreateManualEntryRequest( data: new CreateManualEntryDTO( type: 'manual_single_entry', date: '2023-12-13', reference_nr: '1234', entries: collect([ new CreateEntryDTO( debit_account_id: 89, credit_account_id: 90, tax_id: 10, tax_account_id: 89, description: 'Something', amount: 100, currency_id: 1, currency_factor: 1, ), ]), ) ));
/** * Add File To Accounting Entry Line */ $manualEntry = $connector->send(new AddFileToAccountingEntryLineRequest( manual_entry_id: 1, entry_id: 1, data: new AddFileDTO( name: 'fileName', absolute_file_path_or_stream: fopen('image.png', 'r'), filename: 'image.png', ) ));
/** * Get Next Reference Number */ $referenceNumber = $connector->send(new GetNextReferenceNumberRequest())->dto();
备注
/** * Fetch A List Of Notes */ $notes = $connector->send(new FetchAListOfNotesRequest())->dto();
/** * Fetch A Note */ $note = $connector->send(new FetchANoteRequest( id: 1 ))->dto();
/** * Search Notes */ $notes = $connector->send(new SearchNotesRequest( searchField: 'Name', searchTerm: 'Something' ))->dto();
/** * Create Note */ $note = $connector->send(new CreateNoteRequest( data: new CreateEditNoteDTO( title: 'Test', content: 'Test Content', is_public: true, ) ));
/** * Edit Note */ $note = $connector->send(new EditANoteRequest( id: 1, data: new CreateEditNoteDTO( title: 'Test Edit', content: 'Test Content Edit', is_public: true, ) ));
/** * Delete Note */ $note = $connector->send(new DeleteANoteRequest( id: 1 ));
付款
/** * Fetch A List Of Payments */ $payments = $connector->send(new FetchAListOfPaymentsRequest())->dto();
/** * Cancel A Payment */ $payment = $connector->send(new CancelAPaymentRequest( payment_id: 1 ))->dto();
/** * Delete A Payment */ $payment = $connector->send(new DeleteAPaymentRequest( payment_id: 1 ))->json();
二维码付款
/** * Fetch A Qr Payment */ $payment = $connector->send(new GetQrPaymentRequest( bank_account_id: 1, payment_id: 4 ))->dto();
/** * Create A Qr Payment */ $connector->send(new CreateQrPaymentRequest( bank_account_id: 1, data: new CreateEditQrPaymentDTO( instructed_amount: [ 'currency' => 'CHF', 'amount' => 100, ], recipient: [ 'name' => 'Müller GmbH', 'street' => 'Sonnenstrasse', 'zip' => 8005, 'city' => 'Zürich', 'country_code' => 'CH', 'house_number' => 36, ], execution_date: '2024-01-08', iban: 'CH8100700110005554634', qr_reference_nr: null, additional_information: null, is_editing_restricted: false, ) ))->dto();
/** * Update A Qr Payment * * NOTE: THE PAYMENT MUST HAVE A STATUS OF OPEN TO BE UPDATED */ $payment = $connector->send(new EditQrPaymentRequest( bank_account_id: 1, payment_id: 4, iban: '8100700110005554634', id: 4, data: new CreateEditQrPaymentDTO( instructed_amount: [ 'currency' => 'CHF', 'amount' => 100, ], recipient: [ 'name' => 'Müller GmbH', 'street' => 'Colchester Place', 'zip' => 8005, 'city' => 'Zürich', 'country_code' => 'CH', 'house_number' => 36, ], execution_date: '2024-01-08', iban: 'CH8100700110005554634', ) ))->dto();
报告
/** * Journal */ $journals = $connector->send(new JournalRequest())->dto();
问候语
/** * Fetch A List Of Salutations */ $salutations = $connector->send(new FetchAListOfSalutationsRequest())->dto();
/** * Fetch A Salutation */ $salutation = $connector->send(new FetchASalutationRequest( id: 1 ))->dto();
/** * Search Salutations */ $salutations = $connector->send(new SearchSalutationsRequest( searchField: 'Name', searchTerm: 'Something' ))->dto();
/** * Create Salutation */ $salutation = $connector->send(new CreateSalutationRequest( data: new CreateEditSalutationDTO( name: 'Test', is_archived: false, ) ));
/** * Edit Salutation */ $salutation = $connector->send(new EditASalutationRequest( id: 1, data: new CreateEditSalutationDTO( name: 'Test Edit', is_archived: false, ) ));
/** * Delete Salutation */ $salutation = $connector->send(new DeleteASalutationRequest( id: 1 ));
税项
/** * Fetch A List Of Taxes */ $taxes = $connector->send(new FetchAListOfTaxesRequest())->dto();
/** * Fetch A Tax */ $tax = $connector->send(new FetchATaxRequest( id: 1 ))->dto();
/** * Delete A Tax */ $tax = $connector->send(new DeleteATaxRequest( id: 1 ));
标题
/** * Fetch A List Of Titles */ $titles = $connector->send(new FetchAListOfTitlesRequest())->dto();
/** * Fetch A Title */ $title = $connector->send(new FetchATitleRequest( id: 1 ))->dto();
/** * Search Titles */ $titles = $connector->send(new SearchTitlesRequest( searchField: 'Name', searchTerm: 'Something' ))->dto();
/** * Create Title */ $title = $connector->send(new CreateTitleRequest( data: new CreateEditTitleDTO( name: 'Test', is_archived: false, ) ));
/** * Edit Title */ $title = $connector->send(new EditATitleRequest( id: 1, data: new CreateEditTitleDTO( name: 'Test Edit', is_archived: false, ) ));
/** * Delete Title */ $title = $connector->send(new DeleteATitleRequest( id: 1 ));
增值税期
/** * Fetch A List Of VAT Periods */ $vatPeriods = $connector->send(new FetchAListOfVatPeriodsRequest())->dto();
/** * Fetch A VAT Period */ $vatPeriod = $connector->send(new FetchAVatPeriodRequest( id: 1 ))->dto();
🚧测试
复制您的phpunit.xml文件。
cp phpunit.xml.dist phpunit.xml
运行测试
./vendor/bin/pest
📝变更日志
请参阅CHANGELOG以获取最近的变化。
✏️贡献
请参阅CONTRIBUTING以获取详细信息。
composer test
代码风格
./vendor/bin/pint
🧑💻安全漏洞
请查阅我们的安全策略以了解报告安全漏洞。
🙏致谢
🎭许可
MIT许可(MIT)。请参阅许可文件以获取更多信息。