Skip to content

Commit 920dc71

Browse files
committed
docs: update README with enhanced contact operations, including search functionality and improved examples
1 parent 800c6f5 commit 920dc71

File tree

1 file changed

+49
-20
lines changed

1 file changed

+49
-20
lines changed

README.md

Lines changed: 49 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@ This is a [bexio API](https://docs.bexio.com) client, built with [`saloonphp/sal
44

55
## Introduction
66

7-
The bexio API PHP Client allows you to interact with the bexio API seamlessly. It provides a simple and intuitive interface to manage contacts, sales orders, accounting, and more. As we come from the Laravel world we gave this client a Laravel-like feel.
7+
The bexio API PHP Client allows you to interact with the bexio API seamlessly. It provides a simple and intuitive interface to manage contacts, sales orders, accounting, and more. As we come from the Laravel world we gave this client a Laravel-like feel but still keeping it framework agnostic.
88

99
## Installation
1010

1111
```sh
1212
composer require gigerit/bexio-api-client
1313
```
1414

15-
## Examples
15+
## Quick Start
1616

17-
### Contacts
17+
### Basic Contact Operations
1818

1919
Get a Contact by ID:
2020

2121
```php
2222
use Bexio\BexioClient;
23-
use Bexio\Resources\Contact;
23+
use Bexio\Resources\Contacts\Contacts\Contact;
2424

2525
$client = new BexioClient('API_TOKEN');
2626

@@ -37,7 +37,7 @@ Get all Contacts:
3737

3838
```php
3939
use Bexio\BexioClient;
40-
use Bexio\Resources\Contact;
40+
use Bexio\Resources\Contacts\Contacts\Contact;
4141

4242
$client = new BexioClient('API_TOKEN');
4343

@@ -56,47 +56,76 @@ Create a Contact:
5656

5757
```php
5858
use Bexio\BexioClient;
59-
use Bexio\Resources\Contact;
59+
use Bexio\Resources\Contacts\Contacts\Contact;
60+
use Bexio\Resources\Contacts\Contacts\Enums\ContactType;
6061

6162
$client = new BexioClient('API_TOKEN');
6263

63-
// Create a new Contact
64+
// Create a new Person Contact
6465
$contact = new Contact(
65-
name_1: 'John Doe',
66+
contact_type_id: ContactType::PERSON,
67+
name_1: 'Doe', // Last name
68+
name_2: 'John', // First name
69+
address: 'Main Street 123',
70+
postcode: '8000',
71+
city: 'Zurich',
72+
country_id: 1,
73+
74+
user_id: 1,
75+
owner_id: 1,
6676
);
6777

6878
// Save the Contact
6979
$contact->attachClient($client)->save();
7080
```
7181

72-
Combine actions:
82+
Update a Contact:
7383

7484
```php
7585
use Bexio\BexioClient;
76-
use Bexio\Resources\Contact;
86+
use Bexio\Resources\Contacts\Contacts\Contact;
7787

7888
$client = new BexioClient('API_TOKEN');
7989

80-
// Get the Contact with the ID 1
90+
// Get the Contact with ID 1
8191
$contact = Contact::useClient($client)->find(1);
8292

83-
// Access the Contact properties
84-
echo $contact->id;
85-
echo $contact->name_1;
86-
echo $contact->mail;
87-
88-
// Simply update the Contact properties
89-
$contact->name_1 = 'Jane Doe';
93+
// Update the Contact properties
94+
$contact->name_2 = 'Jane';
95+
$contact->mail = '[email protected]';
9096

9197
// Send the changes back to bexio
9298
$contact->save();
9399
```
94100

95-
See [Tests](tests/Resources) for more examples.
101+
Search Contacts:
102+
103+
```php
104+
use Bexio\BexioClient;
105+
use Bexio\Resources\Contacts\Contacts\Contact;
106+
use Bexio\Support\Data\SearchCriteria;
107+
108+
$client = new BexioClient('API_TOKEN');
109+
110+
// Search contacts with criteria
111+
$contacts = Contact::useClient($client)
112+
->query()
113+
->where('name_1', SearchCriteria::LIKE, 'John')
114+
->where('city', SearchCriteria::EQUAL, 'Zurich')
115+
->search();
116+
```
96117

97118
## Documentation
98119

99-
- [Contacts Documentation](docs/CONTACTS.md) - Comprehensive guide for all contact-related resources
120+
For detailed documentation and advanced usage examples, see:
121+
122+
### Resource Guides
123+
124+
- **[Contacts Documentation](docs/CONTACTS.md)** - Comprehensive guide for Contacts, Contact Relations, Contact Groups, Contact Sectors, Additional Addresses, Salutations, and Titles
125+
126+
### Additional Resources
127+
128+
- [Tests](tests/Resources) - Unit tests with practical examples
100129

101130
## Data Transfer Objects
102131

0 commit comments

Comments
 (0)