{"id":16388747,"url":"https://github.com/timostamm/json-client","last_synced_at":"2025-02-22T15:59:33.988Z","repository":{"id":57069974,"uuid":"133050373","full_name":"timostamm/json-client","owner":"timostamm","description":"A simple client for JSON APIs using Guzzle and the Symfony Serializer.","archived":false,"fork":false,"pushed_at":"2023-04-17T13:53:59.000Z","size":50,"stargazers_count":1,"open_issues_count":1,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-14T10:49:33.849Z","etag":null,"topics":["api","guzzle","http","json","serializer","symfony"],"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/timostamm.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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":"2018-05-11T14:30:19.000Z","updated_at":"2023-04-17T10:02:24.000Z","dependencies_parsed_at":"2024-11-09T05:41:50.315Z","dependency_job_id":null,"html_url":"https://github.com/timostamm/json-client","commit_stats":{"total_commits":28,"total_committers":1,"mean_commits":28.0,"dds":0.0,"last_synced_commit":"81e680f4e9aca87c78b71f70314e97e3ad04b199"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timostamm%2Fjson-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timostamm%2Fjson-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timostamm%2Fjson-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timostamm%2Fjson-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/timostamm","download_url":"https://codeload.github.com/timostamm/json-client/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240199172,"owners_count":19763820,"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","guzzle","http","json","serializer","symfony"],"created_at":"2024-10-11T04:29:48.636Z","updated_at":"2025-02-22T15:59:33.964Z","avatar_url":"https://github.com/timostamm.png","language":"PHP","readme":"# json-client\n\n[![build](https://github.com/timostamm/json-client/workflows/CI/badge.svg)](https://github.com/timostamm/json-client/actions?query=workflow:\"CI\")\n![Packagist PHP Version](https://img.shields.io/packagist/dependency-v/timostamm/json-client/php)\n[![GitHub tag](https://img.shields.io/github/tag/timostamm/json-client?include_prereleases=\u0026sort=semver\u0026color=blue)](https://github.com/timostamm/json-client/releases/)\n[![License](https://img.shields.io/badge/License-MIT-blue)](#license)\n\nA simple client for JSON APIs using Guzzle and the Symfony \nSerializer.\n\nTo implement a API client, you can extend AbstractApiClient \nand write your methods, using the Guzzle Http Client to transmit.\n\n\n```PHP\nclass MyClient extends AbstractApiClient {\n    \n    \n    /**\n     * @throws TransferException\n     */\n    public function send(Model $model):void\n    {\n        // The data will automatically be \n        // serialized to JSON. \n        $this-\u003ehttp-\u003epost('model', [\n            'data' =\u003e $model\n        ]);\n    }\n    \n    \n    /**\n     * @param int $id\n     * @throws TransferException\n     * @returns Model \n     */\n    public function get(int $id):Model\n    {\n        return $this-\u003ehttp-\u003eget('model/'.$id, [\n            'deserialize_to' =\u003e Model::class\n        ]);\n    }\n\n\n}\n```\n\nAll functionality is implemented as middleware, the \n`AbstractApiClient` just configures the Guzzle `HandlerStack` for you. \n\n\n\n### Provided middleware \n\n\n#### Serialization\n\nSee `DeserializeResponseMiddleware` and `SerializeRequestBodyMiddleware`.\n\n\n#### Server error messages\n\n`ServerMessageMiddleware` provides support for JSON error messages. \n\n\n#### Response expectations\n\nIf you want to make sure that a response has a specific header, content \ntype or other feature, use `ResponseExpectationMiddleware`. \n\n\n#### Logging\n\nThere is also middleware to log all HTTP requests (and corresponding \nresponse or exception), see `HttpLoggingMiddleware` \n\nAn adapter for `Psr\\Log\\LoggerInterface` is available.\n\nThis middleware is not added by default because the order is \nimportant: The `HttpLoggingMiddleware` must be added last.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimostamm%2Fjson-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftimostamm%2Fjson-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimostamm%2Fjson-client/lists"}