{"id":22177606,"url":"https://github.com/ntidev/nti-community-client","last_synced_at":"2025-03-24T18:25:22.081Z","repository":{"id":189206807,"uuid":"680188632","full_name":"ntidev/nti-community-client","owner":"ntidev","description":"PHP Client to connect to community insided admin REST API.","archived":false,"fork":false,"pushed_at":"2023-08-23T12:51:15.000Z","size":32,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-29T23:15:38.571Z","etag":null,"topics":[],"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/ntidev.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-18T14:56:25.000Z","updated_at":"2023-08-18T18:29:25.000Z","dependencies_parsed_at":null,"dependency_job_id":"29e77f5b-81ba-4ff0-8132-5413a55ac9ee","html_url":"https://github.com/ntidev/nti-community-client","commit_stats":null,"previous_names":["ntidev/nti-community-client"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ntidev%2Fnti-community-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ntidev%2Fnti-community-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ntidev%2Fnti-community-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ntidev%2Fnti-community-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ntidev","download_url":"https://codeload.github.com/ntidev/nti-community-client/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245326573,"owners_count":20597062,"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":[],"created_at":"2024-12-02T08:29:54.461Z","updated_at":"2025-03-24T18:25:22.054Z","avatar_url":"https://github.com/ntidev.png","language":"PHP","funding_links":["https://paypal.me/mbarghash?locale.x=en_US"],"categories":[],"sub_categories":[],"readme":"[![Latest Version](https://img.shields.io/github/v/tag/MohammadWaleed/keycloak-admin-client.svg?style=flat-square)](https://github.com/ntidev/nti-community-client/releases)\n\n[![Total Downloads](https://img.shields.io/packagist/dt/mohammad-waleed/keycloak-admin-client.svg?style=flat-square)](https://packagist.org/packages/mohammad-waleed/keycloak-admin-client)\n\n[![Donate](https://img.shields.io/badge/Paypal-Donate-blue?style=flat-square)](https://paypal.me/mbarghash?locale.x=en_US)\n\n- [Introduction](#introduction)\n- [How to use](#how-to-use)\n- [Customization](#customization)\n- [Supported APIs](#supported-apis)\n\t- [Users](#users)\n\t- [Root](#root)\n\n\n# Introduction\n\nThis is a php client to connect to Community Insided admin rest apis with no headache.\n\nFeatures:\n1. Easy to use\n2. No need to get token or generate it - it's already handled by the client\n3. No need to specify any urls other than the base uri\n4. No encode/decode for json just data as you expect\n\n# How to use\n\n#### 1. Create new client\n\n```php\n$client = NTI\\CommunityClient\\Admin\\CommunityClient::factory([\n    'realm' =\u003e 'master',\n    'username' =\u003e 'admin',\n    'password' =\u003e '1234',\n    'client_id' =\u003e 'admin-cli',\n    'client_secret' =\u003e 'sfdasd',\n    'baseUri' =\u003e 'http://127.0.0.1:8180',\n]);\n```\n\n#### 2. Use it\n\n```php\n$client-\u003egetUsers();\n\n//Result\n// Array of users\n/*\nArray\n(\n    [0] =\u003e Array\n        (\n            'userid' =\u003e 1\n            'usergroupid' =\u003e 0\n            'membergroupids' =\u003e\n            'displaygroupid' =\u003e 0\n            'username' =\u003e Anthony\n            'email' =\u003e no-reply+anthony@insided.com\n            'posts' =\u003e 5\n            'deleted_posts' =\u003e 0\n            'options' =\u003e 1024\n            'autosubscribe' =\u003e 1\n            'customoptions' =\u003e 7\n            'topics' =\u003e 7\n            'solved' =\u003e 1\n            'ipaddress' =\u003e\n            'usertitle' =\u003e Pioneer\n            'customtitle' =\u003e 1\n            'pmunread' =\u003e 1\n            'subscriptions' =\u003e 22\n            'pmtotal' =\u003e 1\n            'following' =\u003e 0\n            'followers' =\u003e 0\n            'avatar' =\u003e https://uploads-us-west-2.insided.com/alliant-en-sandbox/icon/200x200/4032f252-3c4a-46d7-83a0-5733ca2c3418.png\n            'signature' =\u003e\n            'reputation' =\u003e 2\n            'lastvisit' =\u003e 1614769533\n            'lastactivity' =\u003e 1606228559\n            'insided_sso_customeruid' =\u003e\n            'reviewcount' =\u003e 0\n            'ratingcount' =\u003e 0\n            'lastpostid' =\u003e 127\n            'lastpost' =\u003e 1614771269\n            'joindate' =\u003e 1403085355\n            'likes' =\u003e 2\n            'likes_given' =\u003e 3\n            'blogposts' =\u003e 0\n            'researches' =\u003e 0\n            'rank_id' =\u003e 5\n            'rank_name' =\u003e Inspiring\n            'rank_display_name' =\u003e Inspiring\n            'rank_avatar_icon' =\u003e\n            'rank_avatar_icon_thumb' =\u003e\n            'is_moderator' =\u003e 0\n      )\n)\n\n\n$client-\u003egetUser([\n    'id' =\u003e '39839a9b-de08-4d2c-b91a-a6ce2595b1f3'\n]);\n\n//Result\n\nArray(\n    'userid' =\u003e 3\n    'usergroupid' =\u003e 0\n    'membergroupids' =\u003e\n    'displaygroupid' =\u003e 0\n    'username' =\u003e Eliza\n    'email' =\u003e no-reply+eliza@insided.com\n    'posts' =\u003e 3\n    'deleted_posts' =\u003e 0\n    'options' =\u003e 1024\n    'autosubscribe' =\u003e 1\n    'customoptions' =\u003e 7\n    'topics' =\u003e 11\n    'solved' =\u003e 1\n    'ipaddress' =\u003e 54.182.244.102\n    'usertitle' =\u003e\n    'customtitle' =\u003e 0\n    'pmunread' =\u003e 0\n    'subscriptions' =\u003e 22\n    'pmtotal' =\u003e 1\n    'following' =\u003e 0\n    'followers' =\u003e 0\n    'avatar' =\u003e https://uploads-us-west-2.insided.com/alliant-en-sandbox/icon/200x200/e481abd7-8942-4617-974a-0fa6c9d3a403.png\n    'signature' =\u003e\n    'reputation' =\u003e 2\n    'lastvisit' =\u003e 1662977253\n    'lastactivity' =\u003e 1662982021\n    'insided_sso_customeruid' =\u003e\n    'reviewcount' =\u003e 0\n    'ratingcount' =\u003e 0\n    'lastpostid' =\u003e 142\n    'lastpost' =\u003e 1662977570\n    'joindate' =\u003e 1563816419\n    'likes' =\u003e 2\n    'likes_given' =\u003e 1\n    'blogposts' =\u003e 0\n    'researches' =\u003e 0\n    'rank_id' =\u003e 8\n    'rank_name' =\u003e New Participant\n    'rank_display_name' =\u003e New Participant\n    'rank_avatar_icon' =\u003e\n    'rank_avatar_icon_thumb' =\u003e\n    'is_moderator' =\u003e 0\n)\n\n$client-\u003ecreateUser(['data' =\u003e [\n            'email' =\u003e 'test@test.com',\n            'username' =\u003e 'test',\n            'password' =\u003e true,\n            'user_role' =\u003e [\n                    'roles.registered',\n                    'Option A',\n                    'Option B',\n                    'Other'\n                ],\n                'profile_field' =\u003e [\n                    '12' =\u003e 'Smith',\n                    '34' =\u003e 'John'\n                ],\n                'sso' =\u003e [\n                    'facebook' =\u003e '333ABBDDD',\n                    'oauth2' =\u003e '4545ag63274'],\n                ]]);\n\n//Result\nArray(\n    'user' =\u003e Array(\n            'username' =\u003e 'test'\n            'email' =\u003e 'test@test.com',\n            'joindate' =\u003e '1692394871'\n            'userid' =\u003e 25\n            'sso' =\u003e Array()\n        )\n)\n\n\n$client-\u003edeleteUser([\n    'id' =\u003e 1\n]);\n*/\n```\n\n# Customization\n\n### Supported credentials\n\nIt is possible to change the credential's type used to authenticate by changing the configuration of the Community Insided client.\n\nCurrently, the following credentials are supported\n- password credentials, used by default\n  - to authenticate with a user account\n  ````php\n  $client = NTI\\CommunityClient\\Admin\\CommunityClient::factory([\n      ...\n      'grant_type' =\u003e 'password',\n      'username' =\u003e 'admin',\n      'password' =\u003e '1234',\n  ]);\n  ````\n- client credentials\n  - to authenticate with a client service account\n  ````php\n  $client = NTI\\CommunityClient\\Admin\\CommunityClient::factory([\n      ...\n      'grant_type' =\u003e 'client_credentials',\n      'client_id' =\u003e 'admin-cli',\n      'client_secret' =\u003e '84ab3d98-a0c3-44c7-b532-306f222ce1ff',\n  ]);\n  ````\n\n### Injecting middleware\n\nIt is possible to inject [Guzzle client middleware](https://docs.guzzlephp.org/en/stable/handlers-and-middleware.html#middleware) \nin the Community Insided client configuration using the `middlewares` keyword.\n\nFor example: \n```php \nuse GuzzleHttp\\Middleware;\nuse Psr\\Http\\Message\\RequestInterface;\n\n$client = NTI\\CommunityClient\\Admin\\CommunityClient::factory([\n    ...\n    'middlewares' =\u003e [\n        // throws exceptions when request fails\n        Middleware::httpErrors(),\n        // other custom middlewares\n        Middleware::mapRequest(function (RequestInterface $request) {\n            return $request;\n        }),\n    ],\n]);\n```\n\n### Changing how the token is saved and stored\n\nBy default, the token is saved at runtime. This means that the previous token is not used when creating a new client.\n\nYou can customize how the token is stored in the client configuration by implementing your own `TokenStorage`, \nan interface which describes how the token is stored and retrieved.\n```php \nclass CustomTokenStorage implements TokenStorage \n{\n    public function getToken() \n    {\n        // TODO\n    }\n    \n    public function saveToken(array $token)\n    {\n        // TODO\n    }\n}\n\n$client = NTI\\CommunityClient\\Admin\\CommunityClient::factory([\n    ...\n    'token_storage' =\u003e new CustomTokenStorage(),\n]);\n```\n\n### Custom Community Insided endpoints\n\nIt is possible to inject [Guzzle Service Operations](https://guzzle3.readthedocs.io/webservice-client/guzzle-service-descriptions.html#operations)\nin the Community Insided configuration using the `custom_operations` keyword. This way you can extend the built-in supported endpoints with custom.\n\n```php\n$client = CommunityClient::factory([\n...\n    'custom_operations' =\u003e [\n        'getUsersByAttribute' =\u003e [\n            'uri' =\u003e '/auth/realms/{realm}/userapi-rest/users/search-by-attr',\n            'description' =\u003e 'Get users by attribute Returns a list of users, filtered according to query parameters',\n            'httpMethod' =\u003e 'GET',\n            'parameters' =\u003e [\n                'realm' =\u003e [\n                    'location' =\u003e 'uri',\n                    'description' =\u003e 'The Realm name',\n                    'type' =\u003e 'string',\n                    'required' =\u003e true,\n                ],\n                'attr' =\u003e [\n                    'location' =\u003e 'query',\n                    'type' =\u003e 'string',\n                    'required' =\u003e true,\n                ],\n                'value' =\u003e [\n                    'location' =\u003e 'query',\n                    'type' =\u003e 'string',\n                    'required' =\u003e true,\n                ],\n            ],\n        ],\n    ]\n]);\n```\n\n\n# Supported APIs\n\n ## [Users]()\n\n| API                                                                                                                                                                |    Function Name    | Supported |\n|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|:-------------------:|:---------:|\n| Returns a Json User. The profile_field option in the request body provides a way to add profile fields to the registration.                                        \n| The key refers to an existing profile field id.                                                                                                                    |     createUser      |    ✔️     |\n| Note that profile fields can be set as mandatory registration fields.                                                                                              \n| Get users Returns a list of users, filtered according to query parameters                                                                                          |      getUsers       |    ✔️     |\n| GET /{realm}/users/count                                                                                                                                           |    getUserCount     |    ✔️     |\n| Get representation of the user                                                                                                                                     |       getUser       |   ️️️✔️   |\n| Update the user                                                                                                                                                    |     updateUser      |   ️️️✔️   |\n| Delete the user                                                                                                                                                    |     deleteUser      |   ️️️✔️   |\n| Get consents granted by the user                                                                                                                                   |                     |    ️✔️    |\n| Revoke consent and offline tokens for particular client from user                                                                                                  |                     |     ❌     |\n| Disable all credentials for a user of a specific type                                                                                                              |                     |     ❌     |\n| Send a update account email to the user An email contains a link the user can click to perform a set of required actions.                                          | executeActionsEmail |    ✔️     |\n| Get social logins associated with the user                                                                                                                         |                     |    ✔️     |\n| Add a social login provider to the user                                                                                                                            |                     |    ✔️     |\n| Remove a social login provider from user                                                                                                                           |                     |    ✔️     |\n| GET /{realm}/users/{id}/groups                                                                                                                                     |    getUserGroups    |    ✔️     |\n| GET /{realm}/users/{id}/groups/count                                                                                                                               | getUserGroupsCount  |    ✔️     |\n| PUT /{realm}/users/{id}/groups/{groupId}                                                                                                                           |   addUserToGroup    |    ✔️     | \n| DELETE /{realm}/users/{id}/groups/{groupId}                                                                                                                        | deleteUserFromGroup |    ✔️     |\n| Impersonate the user                                                                                                                                               |   impersonateUser   |    ✔️     |\n| Remove all user sessions associated with the user Also send notification to all clients that have an admin URL to invalidate the sessions for the particular user. |     logoutUser      |    ✔️     |\n| Get offline sessions associated with the user and client                                                                                                           |                     |     ❌     |\n| Remove TOTP from the user                                                                                                                                          |                     |     ❌     |\n| Set up a new password for the user.                                                                                                                                |  resetUserPassword  |    ✔️     |\n| Send an email-verification email to the user An email contains a link the user can click to verify their email address.                                            |   sendVerifyEmail   |    ✔️     |\n| Get sessions associated with the user                                                                                                                              |   getUserSessions   |    ✔️     |\n| Get credentials associated with the user                                                                                                                           | getUserCredentials  |    ✔️     |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fntidev%2Fnti-community-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fntidev%2Fnti-community-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fntidev%2Fnti-community-client/lists"}