sellvation / onewelcome
此包的最新版本(v1.0.4)没有可用的许可信息。
OneWelcome API
v1.0.4
2024-09-12 08:01 UTC
Requires
- php: ^7.3
- ext-json: *
- beberlei/assert: ^v2.9
- guzzlehttp/guzzle: ^7.0
- nesbot/carbon: 2.x-dev
Requires (Dev)
- brianium/paratest: dev-master
- phpro/grumphp: ^1.5
- phpstan/phpstan: 1.6.x-dev
- phpunit/phpunit: 9.5.x-dev
- slevomat/coding-standard: 7.x-dev
README
创建API客户端
use Sellvation\OneWelcome\APIClient; //Create client $httpClient = new GuzzleHttp\Client(); $apiClient = new APIClient($httpClient);
创建配置
use Sellvation\OneWelcome\Config\APIConfig; //Configuration $authenticationURL = getenv('AUTHENTICATION_URL'); $clientId = getenv('CLIENT_ID'); $clientSecret = getenv('CLIENT_SECRET'); $scope = getenv('SCOPE'); $username = getenv('USERNAME'); $password = getenv('PASSWORD'); //Create config object for authentication $config = new APIConfig($authenticationURL, $clientId, $clientSecret, $scope, $username, $password);
获取凭证
try { $credentials = $apiClient->obtainCredentials($config); $credentials->getAccessToken(); $credentials->getExpiresAt(); $credentials->... } catch (AssertionFailedException | APIException $exception) { var_dump($exception->getMessage()); }
注意:由于凭证有效期为3600秒,可以存储获取到的凭证。无需对每个API请求都检索凭证。
Scim API
通过用户ID获取用户信息
use Sellvation\OneWelcome\Scim\ScimClient; try { $scimAPI = new ScimClient($apiClient, $credentials); $user = $scimAPI->getUserById('61b7688b-9efd-4d79-a14a-18e3966132c5'); $user->getName(); $user->getId(); $user->getPrimaryEmailAddress(); $user->... } catch (AssertionFailedException | APIException $exception) { var_dump($exception->getMessage()); }
RITM API
通过用户ID获取用户信息
use Sellvation\OneWelcome\RITM\RITMClient; try { $ritmAPI = new RITMClient($apiClient, $credentials); $user = $ritmAPI->getUserById('61b7688b-9efd-4d79-a14a-18e3966132c5'); $user->getFirstName(); $user->getUUID(); $user->getEmailCollection(); $user->... } catch (AssertionFailedException | APIException $exception) { var_dump($exception->getMessage()); }
同意API
通过用户ID获取同意
use Sellvation\OneWelcome\Consent\ConsentClient; try { $consentAPI = new ConsentClient($apiClient, $credentials); $consents = $consentAPI->getConsentByUserId('61b7688b-9efd-4d79-a14a-18e3966132c5'); foreach($consents as $consent) { $consent->getConsentId(); $consent->... $consent->getDocumentInfo()->getName(); $consent->getDocumentInfo()->... } //Create consent $consent = $consentAPI->createConsent('61b7688b-9efd-4d79-a14a-18e3966132c5', '1', new Carbon()); //Delete consent for user $consentAPI->deleteAllConsent('61b7688b-9efd-4d79-a14a-18e3966132c5'); } catch (AssertionFailedException | APIException $exception) { var_dump($exception->getMessage()); }
通知API
通过事件检索通知
use Sellvation\OneWelcome\Notification\NotificationClient; try { $notificationAPI = new NotificationClient($apiClient, $credentials); $notification = $notificationAPI->getNotificationBySubscriptionId('6229a671acdc77154125cec6'); $notification->getPage(); $notification->getSize(); foreach($notification->getEventCollection() as $event) { $event->getTypeId(); $event->getName(); $event->getUserId(); $event->... } } catch (AssertionFailedException | APIException $exception) { var_dump($exception->getMessage()); }
回退
如果API由于某些原因抛出异常,您可以获取原始请求对象。
echo $apiClient->getOriginalResponse()->getStatusCode(); echo $apiClient->getOriginalResponse()->getBody();
许可
此存档中的文件是根据GNU通用公共许可证发布的。您可以在LICENSE.md中找到此许可证的副本。
请稍后访问我们https://sellvation.nl