{"id":16233593,"url":"https://github.com/scaytrase/json-rpc-client","last_synced_at":"2025-03-19T14:31:38.192Z","repository":{"id":60774679,"uuid":"50160682","full_name":"scaytrase/json-rpc-client","owner":"scaytrase","description":"JSON-RPC 2.0 implementation","archived":false,"fork":false,"pushed_at":"2017-06-21T10:35:23.000Z","size":54,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-28T19:21:10.071Z","etag":null,"topics":["api","json-rpc","json-rpc-api","json-rpc-client","json-rpc2"],"latest_commit_sha":null,"homepage":null,"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/scaytrase.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-01-22T05:49:49.000Z","updated_at":"2023-11-22T20:12:50.000Z","dependencies_parsed_at":"2022-10-04T15:46:37.259Z","dependency_job_id":null,"html_url":"https://github.com/scaytrase/json-rpc-client","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scaytrase%2Fjson-rpc-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scaytrase%2Fjson-rpc-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scaytrase%2Fjson-rpc-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scaytrase%2Fjson-rpc-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/scaytrase","download_url":"https://codeload.github.com/scaytrase/json-rpc-client/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243997127,"owners_count":20380981,"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":["api","json-rpc","json-rpc-api","json-rpc-client","json-rpc2"],"created_at":"2024-10-10T13:13:15.213Z","updated_at":"2025-03-19T14:31:37.917Z","avatar_url":"https://github.com/scaytrase.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/scaytrase/json-rpc-client.svg?branch=master)](https://travis-ci.org/scaytrase/json-rpc-client)\n[![Code Coverage](https://scrutinizer-ci.com/g/scaytrase/json-rpc-client/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/scaytrase/json-rpc-client/?branch=master)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/scaytrase/json-rpc-client/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/scaytrase/json-rpc-client/?branch=master)\n[![SensioLabsInsight](https://insight.sensiolabs.com/projects/9706918a-39d4-4822-8e25-d0a01182b10b/mini.png)](https://insight.sensiolabs.com/projects/9706918a-39d4-4822-8e25-d0a01182b10b)\n\n\n[![Latest Stable Version](https://poser.pugx.org/scaytrase/json-rpc-client/v/stable)](https://packagist.org/packages/scaytrase/json-rpc-client)\n[![Total Downloads](https://poser.pugx.org/scaytrase/json-rpc-client/downloads)](https://packagist.org/packages/scaytrase/json-rpc-client)\n[![Latest Unstable Version](https://poser.pugx.org/scaytrase/json-rpc-client/v/unstable)](https://packagist.org/packages/scaytrase/json-rpc-client)\n\n# JSON-RPC 2.0 Client implementation\n\nExtension of [`scaytrase/rpc-common`](https://github.com/scaytrase/rpc-common) \n\n * JSON RPC Interfaces\n * JSON RPC client\n * Async with Guzzle\n * Automatic batch with multiple requests or `LazyClientDecorator`\n\n[JSON-RPC 2.0 Specification](http://www.jsonrpc.org/specification)\n\n## Usage\n\n1. Configure a [Guzzle client](http://docs.guzzlephp.org/en/latest/).\n2. Instantiate the client:\n\n```php\nuse ScayTrase\\Api\\JsonRpc\\JsonRpcClient;\n\n$client = new JsonRpcClient($guzzleClient, 'http://endpoint/url/');\n```\n\n4. Optionally pass the ID generator as third argument and the PSR-3 logger as the fourth argument\n\nSimple UUID generator and PSR-3 `NullLogger` are used by default. ID is generated for `RpcRequestInterface` instances.\nIf request is instance of `JsonRpcRequestInterface` and does not contain an ID assigned, the request is traited as \nnotification request and will not receive the response from server.\n\n5. Create a `RpcRequestInterface` instance\n\nWith `JsonRpcRequest` class:\n\n```php\n$request = new \\ScayTrase\\Api\\JsonRpc\\JsonRpcRequest('my/method', ['param1' =\u003e 'val1'], 'request_id');\n$notification = new \\ScayTrase\\Api\\JsonRpc\\JsonRpcRequest('my/method', ['param1' =\u003e 'val1']);\n```\n\nWith `JsonRpcNotification` class:\n```php\n$notification = new \\ScayTrase\\Api\\JsonRpc\\JsonRpcNotification('my/method', ['param1' =\u003e 'val1']);\n```\n\nWith custom `RpcRequestInterface` implementation:\n\n```php\nfinal class MyRpcRequest implements \\ScayTrase\\Api\\Rpc\\RpcRequestInterface \n{\n    public function getMethod() \n    {\n        return 'my/method';\n    }\n    \n    public function getParameters() \n    {\n        return ['param1' =\u003e 'val1'];      \n    }\n}\n\n$request = new MyRpcRequest;\n```\n\n6. Call the client\n\n```php\n/** @var \\ScayTrase\\Api\\Rpc\\RpcClientInterface $client */\n/** @var \\ScayTrase\\Api\\Rpc\\RpcRequestInterface $request */\n \n$collection = $client-\u003einvoke($request);\n$collection = $client-\u003einvoke([$request]);\n```\n\nThe collection object contains the mapping between the requests and the responses\n\n```php\n/** @var \\ScayTrase\\Api\\Rpc\\RpcRequestInterface $request */\n/** @var \\ScayTrase\\Api\\Rpc\\ResponseCollectionInterface $collection */\n\n$response = $collection-\u003egetResponse($request);\n```\n\n## Decorating\n\nRefer [`scaytrase/rpc-common`](https://github.com/scaytrase/rpc-common) base library for some\nuseful decorators:\n\n* `CacheableRpcClient`\n* `LazyRpcClient`\n* `LoggableRpcClient`\n* `ProfiledClient`\n* `TraceableClient`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscaytrase%2Fjson-rpc-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscaytrase%2Fjson-rpc-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscaytrase%2Fjson-rpc-client/lists"}