### Install Webling API PHP Client Source: https://context7.com/gitze/webling-api-docu/llms.txt Installs the lightweight PHP wrapper for the Webling REST API using Composer. Requires PHP >= 5.6, cURL, and JSON. ```bash composer require usystems/webling-api-php ``` -------------------------------- ### Install Webling API Client Source: https://context7.com/gitze/webling-api-docu/llms.txt Install the Webling API client library using Composer. This is recommended for Symfony projects using the Webling Bundle and requires PHP 7.x or higher. ```bash composer require terminal42/webling-api ^2.0@dev ``` -------------------------------- ### Key API Operations Source: https://github.com/gitze/webling-api-docu/blob/main/examples/example_3_webling-plugin/WEBLING_API_DOCUMENTATION.md Provides examples for common member-related operations: getting, creating, updating, deleting members, and retrieving groups. ```APIDOC ## Key API Operations ### Get Member Retrieves a member's details, utilizing a cache if available. - **Method**: GET - **Endpoint**: `/member/{memberId}` ### Create Member Creates a new member with the provided data. - **Method**: POST - **Endpoint**: `/member` - **Request Body**: Member data ### Update Member Updates an existing member's information. - **Method**: PUT - **Endpoint**: `/member/{memberId}` - **Request Body**: Updated member data ### Delete Member Deletes a member. - **Method**: DELETE - **Endpoint**: `/member/{memberId}` - **Success Response**: Status code 200 ### Get Groups Retrieves a list of all member groups. ``` -------------------------------- ### Batch Processing Example Source: https://github.com/gitze/webling-api-docu/blob/main/examples/example_3_webling-plugin/WEBLING_API_DOCUMENTATION.md Demonstrates how to efficiently retrieve multiple members using batch requests to the Webling API. ```APIDOC ## Batch Processing Example ### Description This example shows how to fetch multiple members in batches by first retrieving group members and then making batch GET requests for individual member details. ### Method POST ### Endpoint /batch ### Request Body ```json { "requests": [ { "method": "GET", "path": "/member/{id}" } ] } ``` ### Response Example ```json [ { "statusCode": 200, "data": { ... member details ... } } ] ``` ``` -------------------------------- ### Test GET Request with Mock HTTP Client Source: https://github.com/gitze/webling-api-docu/blob/main/examples/example_1_webling-api-php/COMPLETE_DOCUMENTATION.md Tests the client's ability to perform a GET request by mocking the HTTP client and verifying the response status code and data. ```php getMockBuilder('Webling\API\CurlHttp') ->disableOriginalConstructor() ->getMock(); $mockResponse = new Response(200, '{"test": "data"}'); $mockHttp->method('request')->willReturn($mockResponse); $client = new Client('https://demo.webling.ch', 'test_key'); // Inject mock $reflection = new \ReflectionClass($client); $property = $reflection->getProperty('http'); $property->setAccessible(true); $property->setValue($client, $mockHttp); $response = $client->get('/test'); $this->assertEquals(200, $response->getStatusCode()); $this->assertEquals(['test' => 'data'], $response->getData()); } public function testPostRequest() { $mockHttp = $this->getMockBuilder('Webling\API\CurlHttp') ->disableOriginalConstructor() ->getMock(); $mockResponse = new Response(201, '{"id": 123}'); $mockHttp->method('request')->willReturn($mockResponse); $client = new Client('https://demo.webling.ch', 'test_key'); $reflection = new \ReflectionClass($client); $property = $reflection->getProperty('http'); $property->setAccessible(true); $property->setValue($client, $mockHttp); $response = $client->post('/member', ['name' => 'Test']); $this->assertEquals(201, $response->getStatusCode()); } public function testApiErrorHandling() { $this->setExpectedException('Webling\API\ClientException'); $mockHttp = $this->getMockBuilder('Webling\API\CurlHttp') ->disableOriginalConstructor() ->getMock(); $mockHttp->method('request')->willThrowException( new ClientException('Connection failed') ); $client = new Client('https://demo.webling.ch', 'test_key'); $reflection = new \ReflectionClass($client); $property = $reflection->getProperty('http'); $property->setAccessible(true); $property->setValue($client, $mockHttp); $client->get('/test'); } } ``` -------------------------------- ### Webling API PHP Image Proxy Example Source: https://github.com/gitze/webling-api-docu/blob/main/examples/example_1_webling-api-php/WEBLING_API_PHP_DOCUMENTATION.md This example demonstrates how to serve images from Webling API using a proxy. It utilizes a cache adapter to store member data and retrieves image URLs to be served with the correct content type. ```php // examples/image_proxy.php $client = new Webling\API\Client(ENDPOINT, API_KEY); $cache = new Webling\Cache\Cache($client, new FileCacheAdapter()); $member = $cache->getObject('member', 123); $imageUrl = $member['properties']['ProfileImage']['href']; header('Content-Type: ' . $member['properties']['ProfileImage']['mimeType']); echo $client->getBinary($imageUrl)->getRawData(); ``` -------------------------------- ### Initialize Webling API Client Source: https://github.com/gitze/webling-api-docu/blob/main/examples/example_1_webling-api-php/README.md Instantiate the client with the API endpoint and your API key. Basic GET, PUT, POST, and DELETE requests can be made. ```php $api = new Webling\API\Client('https://demo.webling.ch','MY_APIKEY'); $response = $api->get('member/123'); if ($response->getStatusCode() < 400) { var_dump($response->getData()); // returns the parsed JSON var_dump($response->getRawData()); // returns the raw response string } $response = $api->put('/member', $data); $response = $api->post('/member', $data); $response = $api->delete('/member/123'); ``` -------------------------------- ### Get All Field Definitions (GET /definition) Source: https://context7.com/gitze/webling-api-docu/llms.txt Retrieves the complete field definitions for all object types. Useful for dynamically generating forms. Supports a simplified format. ```bash curl -H "apikey: MY_API_KEY" \ "https://demo.webling.ch/api/1/definition" ``` ```bash curl -H "apikey: MY_API_KEY" \ "https://demo.webling.ch/api/1/definition?format=simple" ``` -------------------------------- ### Admin Menu Setup Source: https://github.com/gitze/webling-api-docu/blob/main/examples/example_3_webling-plugin/WEBLING_API_DOCUMENTATION.md Defines the structure of the WordPress admin menu for the Webling plugin, including top-level and sub-menu pages. ```APIDOC ## Admin Menu Setup ### Description This code sets up the main menu and sub-menu items for the Webling plugin within the WordPress administration area, allowing users to access settings, member lists, and forms. ### Hook `admin_menu` ``` -------------------------------- ### Webling Query Language: Starts With Filter Source: https://context7.com/gitze/webling-api-docu/llms.txt Filter members whose 'Name' property starts with a specified string using the `FILTER` operator. ```bash # Beginnt mit curl -G "https://demo.webling.ch/api/1/member" \ -H "apikey: MY_API_KEY" \ --data-urlencode 'filter=`Name` FILTER "Mu"' ``` -------------------------------- ### Get Changes Since Timestamp (GET /changes/{timestamp}) Source: https://context7.com/gitze/webling-api-docu/llms.txt Fetches all objects modified or deleted since a given Unix timestamp. Ideal for incremental synchronization. Also shows how to replicate changes based on revision. ```bash # Alle Änderungen seit 1. Januar 2024 curl -H "apikey: MY_API_KEY" \ "https://demo.webling.ch/api/1/changes/1704067200" ``` ```bash # Synchronisation basierend auf Revision curl -H "apikey: MY_API_KEY" \ "https://demo.webling.ch/api/1/replicate/4800" ``` -------------------------------- ### Webling API PHP CLI Usage Example Source: https://github.com/gitze/webling-api-docu/blob/main/examples/example_1_webling-api-php/WEBLING_API_PHP_DOCUMENTATION.md This script provides a command-line interface for interacting with the Webling API. It supports commands like 'get-member' and 'clear-cache', utilizing environment variables for endpoint and API key configuration. ```php // bin/webling #!/usr/bin/env php get('/member/'.$argv[2]); print_r($response->getData()); break; case 'clear-cache': $cache->clearCache(); echo "Cache cleared\n"; break; } ``` -------------------------------- ### Get Account Template by ID Source: https://github.com/gitze/webling-api-docu/blob/main/webling-api.html Retrieves a specific account template by its ID. The ID is a required URI parameter. ```http GET /accounttemplate/4023 ``` -------------------------------- ### Filtering Members Source: https://github.com/gitze/webling-api-docu/blob/main/webling-api.html Examples demonstrating how to filter members based on various criteria, including direct fields, linked objects, and logical operators. ```APIDOC ## Filtering Members ### Description Examples demonstrating how to filter members based on various criteria, including direct fields, linked objects, and logical operators. ### Endpoint `/api/1/member` ### Query Parameters #### Filter Examples - `filter=`Vorname` = "Hans" OR `Name` = "Weber" - `filter=`$parents.$id = 555` (Filter by membergroup ID) - `filter=`$parents.title = "Vorstand"` (Filter by membergroup title) - `filter=NOT($parents.$id = 100)` (Exclude members from a specific membergroup) - `filter=`ID` IN (22, 45, 67)` (Filter by multiple IDs) - `filter=`Status` IN ("Aktiv", "Passiv", "Ehrenmitglied")` (Filter by multiple status values) - `filter=`E-Mail` IS EMPTY` (Find members with an empty E-Mail field) - `filter=NOT(`E-Mail` IS EMPTY)` (Find members with a non-empty E-Mail field) - `filter=AGE(`Geburtstag`) = 22` (Filter by age) - `filter=MONTH(`Geburtstag`) = 8` (Filter by birthday month) - `filter=`Eintrittsdatum` > TODAY()` (Filter by future entry dates) - `filter=`Eintrittsdatum` <= "2018-06-23"` (Filter by date) - `filter=`Mehrfachauswahlfeld` IS ["Wert"]` (Filter multi-enum field) - `filter=`Mehrfachauswahlfeld` CONTAINS ALL OF ["Wert", "Wert 1"]` (Filter multi-enum field) - `filter=`Mehrfachauswahlfeld` CONTAINS NONE OF ["Wert 1", "Wert 2"]` (Filter multi-enum field) - `filter=`Mehrfachauswahlfeld` CONTAINS ANY OF ["Wert 2"]` (Filter multi-enum field) - `filter=$links.debitor.$id=851` (Filter by linked debitor ID) - `filter=$links.debitor.state="open"` (Filter by linked debitor state) - `filter=$links.debitor.$links.revenue.amount = 100` (Filter by linked revenue amount) - `filter=$links.comment.$id > 0` (Find members with comments) - `filter=`Vorname` = "Tim" AND $ancestors.$id = 550` (Search in group and subgroups) - `filter=$writable=true` (Filter by write access) ### Sorting Examples - `order=`Vorname` ASC` (Sort by first name ascending) - `sort=DAY(`Geburtstag`) ASC` (Sort by birthday day ascending) ### Request Example ``` https://demo.webling.ch/api/1/member?filter=`Vorname` = "Hans" OR `Name` = "Weber"&apikey=__YOUR_API_KEY__ ``` ### Response #### Success Response (200) Returns a list of members matching the filter criteria. ``` -------------------------------- ### List Account Templates Source: https://github.com/gitze/webling-api-docu/blob/main/webling-api.html Retrieves a list of account templates, optionally filtered and sorted. Use `format=full` to get full objects instead of IDs. ```http GET /accounttemplate?filter=&order=title ASC&format= ``` -------------------------------- ### Get Accounttemplate Source: https://github.com/gitze/webling-api-docu/blob/main/webling-api.html Retrieves a specific account template by its ID. ```APIDOC ## GET /accounttemplate/{id} ### Description Retrieves a specific account template by its ID. ### Method GET ### Endpoint /accounttemplate/{id} #### Path Parameters - **id** (number) - Required - Example: `4023`. The ID of the account template. ### Response #### Success Response (200) - **body** (object) - JSON Representation of the Accounttemplate. ### Response Example ```json { "type": "accounttemplate", "readonly": false, "properties": { "title": "Kasse" }, "children": {}, "links": { "account": [ 3603, 3658, 3722 ] }, "parents": [ 4022 ] } ``` ``` -------------------------------- ### WordPress Admin Menu Setup Source: https://github.com/gitze/webling-api-docu/blob/main/examples/example_3_webling-plugin/WEBLING_API_DOCUMENTATION.md Registers the main 'Webling' menu item in the WordPress admin area, along with submenus for 'Member Lists' and 'Forms'. This code should be hooked into the 'admin_menu' action. ```php add_action('admin_menu', function() { add_menu_page( 'Webling Settings', 'Webling', 'manage_options', 'webling-settings', 'webling_render_settings_page', 'dashicons-groups', 80 ); add_submenu_page( 'webling-settings', 'Member Lists', 'Member Lists', 'manage_options', 'webling-memberlists', 'webling_render_memberlists_page' ); add_submenu_page( 'webling-settings', 'Forms', 'Forms', 'manage_options', 'webling-forms', 'webling_render_forms_page' ); }); ``` -------------------------------- ### Get API Key by ID Source: https://github.com/gitze/webling-api-docu/blob/main/webling-api.html Retrieves a specific API key by its ID. The ID is a required URI parameter. ```http GET /apikey/1793 ``` -------------------------------- ### Custom Exception Handling for Webling API in PHP Source: https://github.com/gitze/webling-api-docu/blob/main/examples/example_1_webling-api-php/WEBLING_API_PHP_DOCUMENTATION.md This example demonstrates how to catch and handle Webling API client exceptions. It includes a basic try-catch block for invalid endpoints and a retry mechanism for transient errors, with exponential backoff. ```php try { $client->get('/invalid/endpoint'); } catch (Webling\API\ClientException $e) { error_log("API Error {$e->getCode()}: {$e->getMessage()}"); // Handle 4xx/5xx errors } // Retry mechanism $retries = 0; do { try { return $client->get('/member/123'); } catch (ClientException $e) { $retries++; sleep(2 ** $retries); } } while ($retries < 3); ``` -------------------------------- ### Filtering Linked and Child Objects Source: https://github.com/gitze/webling-api-docu/blob/main/webling-api.html Examples of filtering based on properties of linked objects and child entries within groups. ```APIDOC ## Filtering Linked and Child Objects ### Description Examples of filtering based on properties of linked objects and child entries within groups. This allows for complex queries across related data. ### Endpoint `/api/1/entrygroup` or `/api/1/membergroup` ### Query Parameters #### Filter Examples - `entrygroup?filter=$children.entry.$links.debitor.$links.member.$label filter "Meier"` Combine $links and $children to find all entrygroups that have links to a debitor with the $label “Meier”. - `membergroup?filter=$children.member.PLZ > 9000` Get all membergroups that have members with a PLZ over 9000. ### Request Example ``` entrygroup?filter=$children.entry.$links.debitor.$links.member.$label filter "Meier" ``` ### Response #### Success Response (200) Returns a list of entrygroups or membergroups matching the specified criteria. ``` -------------------------------- ### List API Keys Source: https://github.com/gitze/webling-api-docu/blob/main/webling-api.html Retrieves a list of API key IDs, optionally filtered and sorted. Use `format=full` to get full objects instead of IDs. ```http GET /apikey?filter=&order=title ASC&format= ``` -------------------------------- ### Webling API Key Operations Source: https://github.com/gitze/webling-api-docu/blob/main/examples/example_3_webling-plugin/WEBLING_API_DOCUMENTATION.md Provides functions for common Webling API operations: getting a member (with caching), creating, updating, deleting members, and retrieving member groups. Includes basic error handling for updates. ```php public function getMember($memberId) { return $this->cache->getObject('member', $memberId); } public function createMember($data) { return $this->client->post('/member', $data); } public function updateMember($memberId, $data) { try { return $this->client->put("/member/$memberId", $data); } catch (Webling\API\ClientException $e) { error_log("Member update failed: " . $e->getMessage()); return false; } } public function deleteMember($memberId) { $response = $this->client->delete("/member/$memberId"); return $response->getStatusCode() === 200; } public function getGroups() { return $this->cache->getRoot('membergroup')['children']; } ``` -------------------------------- ### Initialize Webling API Client with Options Source: https://github.com/gitze/webling-api-docu/blob/main/examples/example_1_webling-api-php/README.md Create a new client instance with custom connection timeout, transfer timeout, and user agent settings. ```php $options = [ 'connecttimeout' => 5, // connection timeout in seconds 'timeout' => 10, // transfer timeout 'useragent' => 'My Custom User-Agent' // custom user agent ]; $api = new Webling\API\Client('https://demo.webling.ch','MY_APIKEY', $options); ``` -------------------------------- ### Direct API Access with Client Source: https://context7.com/gitze/webling-api-docu/llms.txt Demonstrates how to initialize the Webling API client and make a direct API call to retrieve members. ```APIDOC ## Direct API Access with Client ### Description This section shows how to install the Webling API client library using Composer and how to instantiate the client for direct API calls. ### Installation ```bash composer require terminal42/webling-api ^2.0@dev ``` ### Usage ```php get('member'); ``` ``` -------------------------------- ### Webling API PHP Client Basic Usage Source: https://context7.com/gitze/webling-api-docu/llms.txt Demonstrates initializing the client, fetching a list of members, retrieving individual member details, creating a new member, updating a member, and deleting a member. ```php 5, 'timeout' => 10, 'useragent' => 'MeinProjekt/1.0' ] ); // Mitgliederliste abrufen und einzeln laden $response = $client->get('/member'); if ($response->getStatusCode() === 200) { $data = $response->getData(); // dekodiertes JSON-Array foreach ($data['objects'] as $memberId) { $memberResp = $client->get('/member/' . $memberId); if ($memberResp->getStatusCode() === 200) { $m = $memberResp->getData(); echo $m['properties']['Vorname'] . ' ' . $m['properties']['Name'] . PHP_EOL; } } } else { echo 'Fehler: ' . $response->getStatusCode() . ' – ' . $response->getRawData(); } // Neues Mitglied anlegen $response = $client->post('/member', [ 'type' => 'member', 'properties' => ['Vorname' => 'Lena', 'Name' => 'Schmidt'], 'parents' => [1], 'links' => [] ]); echo 'Neue ID: ' . $response->getData(); // z. B. 999 // Mitglied aktualisieren $client->put('/member/999', ['properties' => ['Status' => 'Passivmitglied']]); // Mitglied löschen $client->delete('/member/999'); ``` -------------------------------- ### Client Configuration Source: https://github.com/gitze/webling-api-docu/blob/main/examples/example_3_webling-plugin/WEBLING_API_DOCUMENTATION.md Shows how to configure the Webling API client with hostname, API key, and custom timeout settings, including integrating a WordPress cache adapter. ```APIDOC ## Client Configuration ### Description This snippet illustrates the initialization of the Webling API client with necessary credentials and connection options. It also demonstrates setting up a custom cache adapter for improved performance. ### Initialization ```php $client = new Webling\API\Client( get_option('webling_hostname'), get_option('webling_apikey'), [ 'connecttimeout' => 15, 'timeout' => 30, 'useragent' => 'Webling WordPress Plugin/3.9.0', 'ssl_verify' => WP_DEBUG ? false : true ] ); // Custom WordPress cache adapter $adapter = new WordpressCacheAdapter(); $cache = new Webling\Cache\Cache($client, $adapter); ``` -------------------------------- ### Get Apikey Source: https://github.com/gitze/webling-api-docu/blob/main/webling-api.html Retrieves a specific API key by its ID. ```APIDOC ## GET /apikey/{id} ### Description Retrieves a specific apikey by its ID. ### Method GET ### Endpoint /apikey/{id} #### Path Parameters - **id** (number) - Required - Example: `1793`. The ID of the apikey. ### Response #### Success Response (200) - **body** (object) - JSON Representation of the Apikey. ### Response Example ```json { "type": "apikey", "readonly": false, "properties": { "title": "Api Key", "custommemberaccess": { "552": "+r", "555": "+r+w", "558": "+r" }, "customfinanceaccess": { "800": "+r+w", "1814": "+r" }, "memberaccess": "custom", "financeaccess": "custom", "articleaccess": "none", "administrator": false }, "children": {}, "parents": [], "links": {} } ``` ``` -------------------------------- ### Configure Webling API Client and Cache Source: https://github.com/gitze/webling-api-docu/blob/main/examples/example_3_webling-plugin/WEBLING_API_DOCUMENTATION.md Initializes the Webling API client with WordPress options for hostname and API key, and sets up a custom cache adapter. The SSL verification is conditionally set based on WP_DEBUG. ```php $client = new Webling\API\Client( get_option('webling_hostname'), get_option('webling_apikey'), [ 'connecttimeout' => 15, 'timeout' => 30, 'useragent' => 'Webling WordPress Plugin/3.9.0', 'ssl_verify' => WP_DEBUG ? false : true ] ); // Custom WordPress cache adapter $adapter = new WordpressCacheAdapter(); $cache = new Webling\Cache\Cache($client, $adapter); ``` -------------------------------- ### Retrieve Store Configuration with cURL Source: https://context7.com/gitze/webling-api-docu/llms.txt Fetches the store's configuration details, including name, domain, language, and API status. ```bash # Store-Konfiguration curl -H "apikey: MY_API_KEY" \ "https://demo.webling.ch/api/1/config" ``` -------------------------------- ### Get Member Source: https://github.com/gitze/webling-api-docu/blob/main/webling-api.html Retrieves a specific member's details using their unique ID. ```APIDOC ## GET /member/{id} ### Description Get a member by their ID. ### Method GET ### Endpoint /member/{id} ### Parameters #### Path Parameters - **id** (number) - Required - Member ID ### Response #### Success Response (200) - **Body** (object) - JSON Representation of the Member. ``` -------------------------------- ### Initialize Webling API Client Source: https://context7.com/gitze/webling-api-docu/llms.txt Instantiate the Webling API client with your subdomain, API key, and desired API version. This client can be used for direct API calls. ```php get('member'); ``` -------------------------------- ### Get members with write access Source: https://github.com/gitze/webling-api-docu/blob/main/webling-api.html Filter members to retrieve only those for which the current user has write permissions. ```http member?filter=$writable=true ``` -------------------------------- ### Get members with open debitors Source: https://github.com/gitze/webling-api-docu/blob/main/webling-api.html Filter members who have associated debitors with a specific status, like 'open'. ```http member?filter=$links.debitor.state="open" ``` -------------------------------- ### Webling API Client and Member Sync in WordPress Source: https://context7.com/gitze/webling-api-docu/llms.txt This snippet demonstrates how to configure the Webling API client within a WordPress environment using `usystems/webling-api-php` and a `WordpressCacheAdapter`. It also shows a function for synchronizing members in batches, leveraging the cache for efficiency. Ensure the `usystems/webling-api-php` dependency is declared in your `composer.json`. ```php 15, 'timeout' => 30, 'useragent' => 'Webling WordPress Plugin/3.9.0', 'ssl_verify' => WP_DEBUG ? false : true ] ); $adapter = new WordpressCacheAdapter(); // nutzt WordPress Transients $cache = new Webling\Cache\Cache($client, $adapter); // Mitglieder in Batches synchronisieren function syncAllMembers($client) { $groups = $client->get('/membergroup')->getData()['objects']; $members = []; foreach ($groups as $groupId) { $resp = $client->get("/membergroup/$groupId"); if ($resp->getStatusCode() === 200) { $members = array_merge($members, $resp->getData()['children']); } } // Verarbeitung in 50er-Batches foreach (array_chunk($members, 50) as $chunk) { foreach ($chunk as $memberId) { $member = $cache->getObject('member', $memberId); // Mitglied in WordPress-Datenbank schreiben oder anzeigen } } } ``` -------------------------------- ### Configuration and Quota Source: https://context7.com/gitze/webling-api-docu/llms.txt Retrieve the store configuration (name, domain, language, API status) or the currently used and maximum resources (members, bookings, storage). ```APIDOC ## GET /config, GET /quota ### Description Retrieves the store configuration (name, domain, language, API status) or the currently used and maximum resources (members, bookings, storage). ### Method GET ### Endpoint /config /quota ### Parameters None ### Request Example ```bash # Store configuration curl -H "apikey: MY_API_KEY" \ "https://demo.webling.ch/api/1/config" # Quota overview curl -H "apikey: MY_API_KEY" \ "https://demo.webling.ch/api/1/quota" ``` ### Response #### Success Response (200) - **config**: - **name** (string) - The name of the store. - **domain** (string) - The domain of the store. - **language** (string) - The language of the store. - **apiEnabled** (boolean) - Indicates if the API is enabled. - **quota**: - **members** (object) - Object containing used and max member count. - **used** (integer) - The number of members currently used. - **max** (integer) - The maximum number of members allowed. - **bookings** (object) - Object containing used and max booking count. - **storage** (object) - Object containing used and max storage in bytes. ``` -------------------------------- ### Get members linked to a debitor with a specific amount Source: https://github.com/gitze/webling-api-docu/blob/main/webling-api.html Filter members based on the amount associated with their linked debitors. ```http member?filter=$links.debitor.$links.revenue.amount = 100 ``` -------------------------------- ### Änderungen seit einem Zeitstempel abrufen Source: https://context7.com/gitze/webling-api-docu/llms.txt Gibt alle seit dem angegebenen Unix-Zeitstempel geänderten und gelöschten Objekte zurück. Ideal für inkrementelle Synchronisierung externer Systeme. ```APIDOC ## GET /changes/{timestamp} ### Description Gibt alle seit dem angegebenen Unix-Zeitstempel geänderten und gelöschten Objekte zurück. Ideal für inkrementelle Synchronisierung externer Systeme. ### Method GET ### Endpoint /api/1/changes/{timestamp} ### Parameters #### Path Parameters - **timestamp** (integer) - Required - Unix timestamp to retrieve changes since. ### Request Example ```bash # Alle Änderungen seit 1. Januar 2024 curl -H "apikey: MY_API_KEY" \ "https://demo.webling.ch/api/1/changes/1704067200" ``` ### Response #### Success Response (200) - **objects** (object) - Contains lists of changed object IDs per type (e.g., member, debitor). - **deleted** (array) - List of deleted object IDs. - **revision** (integer) - The current revision number. - **version** (integer) - The API version. #### Response Example ```json { "objects": { "member": [123, 456], "debitor": [78] }, "deleted": [99, 101], "revision": 4892, "version": 42 } ``` ``` -------------------------------- ### Create Accounttemplate Source: https://github.com/gitze/webling-api-docu/blob/main/webling-api.html Creates a new account template and returns its ID. ```APIDOC ## POST /accounttemplate ### Description Creates an accounttemplate. Returns the ID of the newly created accounttemplate. ### Method POST ### Endpoint /accounttemplate #### Request Body - **type** (string) - Required - The type of the object, should be "accounttemplate". - **readonly** (boolean) - Optional - Indicates if the template is read-only. - **properties** (object) - Required - Properties of the account template, including a 'title'. - **children** (object) - Optional - Child elements of the template. - **links** (object) - Optional - Links to other resources, e.g., 'account'. - **parents** (array) - Optional - IDs of parent resources. ### Request Example ```json { "type": "accounttemplate", "readonly": false, "properties": { "title": "Kasse" }, "children": {}, "links": { "account": [ 3603, 3658, 3722 ] }, "parents": [ 4022 ] } ``` ### Response #### Success Response (201) - **body** (number) - The ID of the newly created accounttemplate. ### Response Example ``` 18010 ``` ``` -------------------------------- ### Get Member Image Source: https://github.com/gitze/webling-api-docu/blob/main/webling-api.html Retrieves a member's image associated with a specific field name. Supports different image sizes. ```APIDOC ## GET /member/{id}/image/{fieldname}.{extension} ### Description Get Image of a member by fieldname. ### Method GET ### Endpoint /member/{id}/image/{fieldname}.{extension} ### Parameters #### Path Parameters - **id** (number) - Required - Member ID - **fieldname** (string) - Required - Name of the datafield - **extension** (string) - Required - File extension of the image #### Query Parameters - **size** (string) - Optional - Preferred image size. Choices: `original` (default), `thumb`, `mini` ### Response #### Success Response (200) - **Body** - The image data. ``` -------------------------------- ### Get membergroups with members in a specific postal code range Source: https://github.com/gitze/webling-api-docu/blob/main/webling-api.html Filter membergroups based on properties of their child members, such as postal code. ```http membergroup?filter=$children.member.PLZ > 9000 ``` -------------------------------- ### Build Simple Query with QueryBuilder Source: https://context7.com/gitze/webling-api-docu/llms.txt Construct a simple query to find members by first and last name using the QueryBuilder. This ensures type-safe Webling Query Language strings. ```php where('Vorname')->isEqualTo('Max') ->andWhere('Name')->isEqualTo('Muster') ->build(); // Ergebnis: `Vorname` = "Max" AND `Name` = "Muster" ``` -------------------------------- ### Get members linked to a specific debitor Source: https://github.com/gitze/webling-api-docu/blob/main/webling-api.html Filter members based on their links to other entities, such as debitors, by specifying the debitor's ID. ```http member?filter=$links.debitor.$id=851 ``` -------------------------------- ### Test POST Request with Mock HTTP Client Source: https://github.com/gitze/webling-api-docu/blob/main/examples/example_1_webling-api-php/COMPLETE_DOCUMENTATION.md Verifies the client's POST request functionality using a mocked HTTP client, checking the response status code. ```php getMockBuilder('Webling\API\CurlHttp') ->disableOriginalConstructor() ->getMock(); $mockResponse = new Response(201, '{"id": 123}'); $mockHttp->method('request')->willReturn($mockResponse); $client = new Client('https://demo.webling.ch', 'test_key'); $reflection = new \ReflectionClass($client); $property = $reflection->getProperty('http'); $property->setAccessible(true); $property->setValue($client, $mockHttp); $response = $client->post('/member', ['name' => 'Test']); $this->assertEquals(201, $response->getStatusCode()); } public function testApiErrorHandling() { $this->setExpectedException('Webling\API\ClientException'); $mockHttp = $this->getMockBuilder('Webling\API\CurlHttp') ->disableOriginalConstructor() ->getMock(); $mockHttp->method('request')->willThrowException( new ClientException('Connection failed') ); $client = new Client('https://demo.webling.ch', 'test_key'); $reflection = new \ReflectionClass($client); $property = $reflection->getProperty('http'); $property->setAccessible(true); $property->setValue($client, $mockHttp); $client->get('/test'); } } ``` -------------------------------- ### Get Member Response Body Source: https://github.com/gitze/webling-api-docu/blob/main/webling-api.html This JSON object represents a successful response when retrieving a member. It includes detailed properties and associated links. ```json { "type": "member", "readonly": false, "properties": { "Vorname": "Quentin", "Name": "Moser", "Firma": null, "Strasse": "Kirchgasse 32", "PLZ": "9000", "Ort": "St. Gallen", "Telefon": "079 336 47 50", "Mobile": "077 336 47 50", "E-Mail": "Moser@nospam-webling.ch", "Lizenz": "Junior", "Geschlecht": "m", "Geburtstag": "1997-07-13", "Checkbox": false, "Mitgliederbild": { "href": "/api/1/member/504/image/Mitgliederbild.jpg", "size": 325743, "name": "Mitgliederbild.jpg", "lastmodified": "2015-05-15 11:26:55", "dimensions": { "width": 640, "height": 480 } }, "Datei": { "href": "/api/1/member/504/file/Datei.pdf", "size": 117539, "name": "Datei.pdf", "lastmodified": "2015-05-15 11:26:55" } }, "children": {}, "parents": [ 555 ], "links": { "debitor": [ 883, 1136, 1900, 2388 ] } } ``` -------------------------------- ### Webling API PHP Client with FileCacheAdapter Source: https://context7.com/gitze/webling-api-docu/llms.txt Implements caching using FileCacheAdapter to check for changes via the /changes endpoint, loading only modified objects. Requires a writable cache directory. Demonstrates fetching root objects, individual objects, multiple objects, and binary data. ```php './webling_cache']); $cache = new Webling\Cache\Cache($client, $adapter); // Wurzel-Objekt abrufen (z. B. Mitgliedergruppe mit IDs) $root = $cache->getRoot('member'); // Antwort: ["objects" => [506, 507, 508], "roots" => [1]] // Einzelnes Objekt aus dem Cache holen $member = $cache->getObject('member', 506); echo $member['properties']['Vorname']; // "Max" // Mehrere Objekte auf einmal laden (effizient) $members = $cache->getObjects('member', [506, 507, 508]); foreach ($members as $m) { echo $m['properties']['Vorname'] . ' ' . $m['properties']['Name'] . PHP_EOL; } // Binärdaten (z. B. Mitgliederbild) abrufen $imageHref = $member['properties']['Mitgliederbild']['href']; $binary = $cache->getObjectBinary('member', 506, $imageHref); file_put_contents('bild.jpg', $binary); // Cache bei Änderungen aktualisieren $cache->updateCache(); // Gesamten Cache leeren $cache->clearCache(); ``` -------------------------------- ### Create Account Template Source: https://github.com/gitze/webling-api-docu/blob/main/webling-api.html Creates a new account template. The request body should contain the template's properties. Returns the ID of the newly created template. ```http POST /accounttemplate ``` ```json { "type": "accounttemplate", "readonly": false, "properties": { "title": "Kasse" }, "children": {}, "links": { "account": [ 3603, 3658, 3722 ] }, "parents": [ 4022 ] } ``` -------------------------------- ### Get Membergroup Title in PHP Source: https://github.com/gitze/webling-api-docu/blob/main/webling-api.html Retrieves the title of a specific member group using its ID. Requires API URL and an API key. ```php $apiurl = "https://demo.webling.ch"; $apikey = ""; $url = $apiurl . "/api/1/membergroup/1?apikey=" . $apikey; $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $data = json_decode(curl_exec($curl), true); echo $data["properties"]["title"]; ``` -------------------------------- ### Create New Member in PHP Source: https://github.com/gitze/webling-api-docu/blob/main/webling-api.html Creates a new member with specified properties and assigns them to a member group. Requires API URL and an API key. Returns the ID of the newly created member upon success. ```php $apiurl = "https://demo.webling.ch"; $apikey = ""; $curl = curl_init(); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode(array( "properties" => array( "Vorname" => "Fritz", "Name" => "Meier", "E-Mail" => "fritz.meier@example.ch" ), // ID of the membergroup where the member should be added, replace with your own ID "parents" => array(550) ))); curl_setopt($curl, CURLOPT_URL, $apiurl . "/api/1/member?apikey=" . $apikey); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($curl); $code = curl_getinfo($curl, CURLINFO_HTTP_CODE); if ($code != 201) { echo 'Error: '. $response . ' HTTP-Status Code: '.$code; } else { echo 'Creation successful. ID of new member: '.$response; } ``` -------------------------------- ### Create Apikey Source: https://github.com/gitze/webling-api-docu/blob/main/webling-api.html Creates a new API key and returns its ID. ```APIDOC ## POST /apikey ### Description Creates an apikey. Returns the ID of the newly created apikey. ### Method POST ### Endpoint /apikey #### Request Body - **type** (string) - Required - The type of the object, should be "apikey". - **readonly** (boolean) - Optional - Indicates if the key is read-only. - **properties** (object) - Required - Properties of the API key, including title, access permissions, and administrator status. - **children** (object) - Optional - Child elements. - **parents** (array) - Optional - IDs of parent resources. - **links** (object) - Optional - Links to other resources. ### Request Example ```json { "type": "apikey", "readonly": false, "properties": { "title": "Api Key", "custommemberaccess": { "552": "+r", "555": "+r+w", "558": "+r" }, "customfinanceaccess": { "800": "+r+w", "1814": "+r" }, "memberaccess": "custom", "financeaccess": "custom", "articleaccess": "none", "administrator": false }, "children": {}, "parents": [], "links": {} } ``` ### Response #### Success Response (201) - **body** (number) - The ID of the newly created apikey. ### Response Example ``` 1793 ``` ``` -------------------------------- ### Create New Member with cURL Source: https://context7.com/gitze/webling-api-docu/llms.txt Creates a new member by sending a JSON payload with member properties, parent IDs, and links. The response is the new member's ID. ```bash # Neues Mitglied erstellen curl -X POST \ -H "apikey: MY_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "type": "member", "properties": { "Vorname": "Anna", "Name": "Meier", "E-Mail": "anna.meier@example.com", "Status": "Aktivmitglied" }, "parents": [1], "links": {} }' \ "https://demo.webling.ch/api/1/member" ``` -------------------------------- ### Get members from a specific group and sort by name Source: https://github.com/gitze/webling-api-docu/blob/main/webling-api.html Filter members by their parent group ID and sort the results by a specific field in ascending order. ```http member?filter=$parents.$id = 555&order=`Vorname` ASC ``` -------------------------------- ### Combine links and children to find entrygroups linked to members with a specific label Source: https://github.com/gitze/webling-api-docu/blob/main/webling-api.html Demonstrates a complex query combining links and children to filter entrygroups based on linked member properties. ```http entrygroup?filter=$children.entry.$links.debitor.$links.member.$label filter "Meier" ```