{"id":22559484,"url":"https://github.com/webparking/logic4-client","last_synced_at":"2025-04-10T09:27:09.030Z","repository":{"id":204892602,"uuid":"707058720","full_name":"webparking/logic4-client","owner":"webparking","description":"Unofficial Logic4 API client","archived":false,"fork":false,"pushed_at":"2025-03-28T09:34:17.000Z","size":1306,"stargazers_count":6,"open_issues_count":2,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-09T19:53:12.811Z","etag":null,"topics":["client","logic4","php","webparking"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/webparking.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-19T06:28:33.000Z","updated_at":"2025-03-27T14:32:46.000Z","dependencies_parsed_at":"2024-01-09T11:43:09.334Z","dependency_job_id":"5af3d6de-7bcd-45b7-b5ca-eca705fd5065","html_url":"https://github.com/webparking/logic4-client","commit_stats":null,"previous_names":["webparking/logic4-client"],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webparking%2Flogic4-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webparking%2Flogic4-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webparking%2Flogic4-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webparking%2Flogic4-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/webparking","download_url":"https://codeload.github.com/webparking/logic4-client/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248190914,"owners_count":21062373,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["client","logic4","php","webparking"],"created_at":"2024-12-07T21:07:04.511Z","updated_at":"2025-04-10T09:27:09.009Z","avatar_url":"https://github.com/webparking.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Header image](./assets/webparking_logic4_client.png)\n\n![Packagist](https://img.shields.io/packagist/v/webparking/logic4-client.svg?style=flat-round\u0026logo=packagist)\n![License](https://img.shields.io/packagist/l/webparking/logic4-client.svg?style=flat-round)\n![Github stars](https://img.shields.io/github/stars/webparking/logic4-client?style=flat-round\u0026logo=github)\n![Downloads](https://img.shields.io/packagist/dt/webparking/logic4-client.svg?style=flat-round)\n\n# Logic4 client\nPlease note that this API client is not created or maintained by Logic4. For questions about Logic4 or it's API please contact Logic4 support. \n\n## Installation \nYou can install the package via composer:\n```bash\ncomposer require webparking/logic4-client\n``` \n\n## Configuration\nIn order to use the Logic4 API, you need to configure the `AccessTokenManager` with your credentials. You can do this by calling the `configure` method on the `AccessTokenManager` instance.\n \nThe following configuration options are required\n- `public_key` - The public key of your Logic4 account\n- `company_key` - The company key of your Logic4 account\n- `username` - The username of your Logic4 account\n- `secret_key` - The secret key of your Logic4 account\n- `password` - The password of your Logic4 account\n- `administration_id` - The administration id of your Logic4 account\n\nThe access token is automatically refreshed when it expires and stored in the cache. The cache object is set using the `$cache` property on the `AccessTokenManager` class and should implement the `Psr\\SimpleCache\\CacheInterface` interface.\n\nAfter configuring the `AccessTokenManager` you can use any request class in your application without having to worry about the access token and other middleware.\n\n### Example configuration\n```php\n# In this example, we load the configuration from a .env file.\n$dotEnv = Dotenv\\Dotenv::createImmutable(__DIR__);\n$credentials = $dotEnv-\u003eload()\n\n# We use the ArrayStore for testing purposes, but you can use any cache implementation that implements the Psr\\SimpleCache\\CacheInterface interface.\n$cache = new \\Illuminate\\Cache\\Repository(new \\Illuminate\\Cache\\ArrayStore());\n    \n$tokenManager = new \\Webparking\\Logic4Client\\AccessTokenManager($cache);\n$tokenManager-\u003econfigure($credentials);\n\n# Initialize the ClientFactory using the AccessTokenManager\n$clientFactory = new \\Webparking\\Logic4Client\\ClientFactory($tokenManager);\n\n# Initialize the request class using the ClientFactory\n$request = new \\Webparking\\Logic4Client\\Requests\\ProductRequest($clientFactory);\n$request-\u003egetProducts([\n    'DebtorId' =\u003e 1,\n]);\n```\n\n## Laravel integration\nIntegration with Laravel is easily done by configuring the `AccessTokenManager` after it has been resolved by the Laravel IoC Container.\n\nAdd the following code to your `AppServiceProvider` class:\n\n```php\nuse Webparking\\Logic4Client\\AccessTokenManager;\n\n$this-\u003eapp\n    -\u003eafterResolving(AccessTokenManager::class, fn (AccessTokenManager $tokenManager) =\u003e $tokenManager-\u003econfigure([\n        'public_key' =\u003e config('services.logic4.public_key'),\n        'company_key' =\u003e config('services.logic4.company_key'),\n        'username' =\u003e config('services.logic4.username'),\n        'secret_key' =\u003e config('services.logic4.secret_key'),\n        'password' =\u003e config('services.logic4.password'),\n        'administration_id' =\u003e config('services.logic4.administration_id'),\n    ]));\n```\n\nThis makes it possible to directly use any request class in your application without having to worry about the access token and other middleware.\n\n### Example request\n\n```php\nuse Webparking\\Logic4Client\\Requests\\ProductRequest;\nuse Webparking\\Logic4Client\\Data\\Product;\nuse Illuminate\\Support\\Collection;\n\n/** @return array\u003cProduct\u003e */\npublic function index(ProductRequest $productRequest, int $debtorId): array\n{\n    $products = $productRequest-\u003egetProducts([\n        'DebtorId' =\u003e $debtorId,\n    ]);\n    \n    return iterator_to_array($products);\n}\n```\n\n## Testing\nYou can test the package by running `./vendor/bin/phpunit` in the root of the project. Make sure install the dependencies by running `composer install` before running the tests.\n\n```bash\ncomposer install\n./vendor/bin/phpunit\n```\n\n### Preventing stray requests\nIf you would like to ensure that all requests sent via the client have been mocked throughout your individual test or complete test suite, you can call the `preventStrayRequests` method on the `\\Webparking\\Logic4Client\\ClientFactory` class. After calling this method, any requests that do not have a corresponding mock will throw an exception rather than making the actual request:\n\n```php\n// turns on stray request prevention\n\\Webparking\\Logic4Client\\ClientFactory::preventStrayRequests();\n\n// an exception is thrown if the request is not mocked\n$request-\u003egetProducts(['DebtorId' =\u003e 1]);\n\n// turns off stray request prevention\n\\Webparking\\Logic4Client\\ClientFactory::preventStrayRequests(false);\n\n// no exception is thrown and will make the actual request\n$request-\u003egetProducts(['DebtorId' =\u003e 1]);\n```\n\n## Contributing\nPlease report any issue you find in the issues page. Pull requests are more than welcome.\n\n### Generating endpoints\n\nThe endpoints can automatically be generated using the `generate` command. This command will generate a request class for each endpoint and a client class that can be used to instantiate the request classes.\n\n```bash\nmake generate\n``` \n\n## License\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebparking%2Flogic4-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebparking%2Flogic4-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebparking%2Flogic4-client/lists"}