diff --git a/src/Example/FullSettingsRequired/AutoGrantBusinessVerification.php b/src/Example/FullSettingsRequired/AutoGrantBusinessVerification.php index 9cb1a04..64b8171 100644 --- a/src/Example/FullSettingsRequired/AutoGrantBusinessVerification.php +++ b/src/Example/FullSettingsRequired/AutoGrantBusinessVerification.php @@ -9,8 +9,9 @@ require '../Includes/ExampleSettings.php'; use SkillDisplay\PHPToolKit\Verification\Issuer; -// Automatically grant a Business-Verification (e.g.: after completing an exam) if the SkillDisplay username is known +// Automatically grant a Business-Verification (e.g.: after completing an exam) if the SkillDisplay username is known. +// The number 567 is the optional campaignId the verification is attributed to. // In order to grant an Educational Verification you just need to exchange the constant to VERIFICATION_EDUCATIONAL // (your Verifier Account needs the according permissions) $myVerificationTool = new Issuer($mySettings); -$myVerificationTool->outputResponse($myVerificationTool->issueVerification(193, '--skilldisplay-user-email--', VERIFICATION_BUSINESS)); +$myVerificationTool->outputResponse($myVerificationTool->issueVerification(193, '--skilldisplay-user-email--', VERIFICATION_BUSINESS, 567)); diff --git a/src/Verification/Issuer.php b/src/Verification/Issuer.php index d53f6de..cf8c5b1 100644 --- a/src/Verification/Issuer.php +++ b/src/Verification/Issuer.php @@ -25,13 +25,16 @@ class Issuer * @param string $useremail E-Mail of the User who should receive the verification * @param string $vtype one of VERIFICATION_SELF, VERIFICATION_EDUCATIONAL, VERIFICATION_BUSINESS, VERIFICATION_CERTIFICATION * @param bool $isSkillSet + * @param int $campaignId + * * @return array */ private function generateSignedRequestData( int $ID, string $useremail, string $vtype, - bool $isSkillSet = false + bool $isSkillSet = false, + int $campaignId = 0 ): array { if ($isSkillSet) { $requestData['SkillSetId'] = $ID; @@ -43,6 +46,9 @@ class Issuer $requestData['VerifierId'] = $this->settings->getVerifierID(); $requestData['Username'] = $useremail; $requestData['AutoConfirm'] = true; + if ($campaignId) { + $requestData['CampaignId'] = $campaignId; + } $requestData['Signature'] = ''; $json = json_encode($requestData); @@ -72,15 +78,17 @@ class Issuer * @param string $useremail E-Mail of the SkillDisplay user for whom you want to verify the skill * @param string $vtype Verification type, one of the constants in /src/Constants/VerificationTypes.php * @param bool $isSkillSet is the passed ID that of a SkillSet (else it is a single skill, also default) + * @param int $campaignId An optional campaign ID the verification is attributed to * @return ResponseInterface */ public function issueVerification( int $skillID, string $useremail, string $vtype, - bool $isSkillSet = false + bool $isSkillSet = false, + int $campaignId = 0 ): ResponseInterface { - $requestData = $this->generateSignedRequestData($skillID, $useremail, $vtype, $isSkillSet); + $requestData = $this->generateSignedRequestData($skillID, $useremail, $vtype, $isSkillSet, $campaignId); $client = new \GuzzleHttp\Client(); $request = new Request( diff --git a/src/Verification/Link.php b/src/Verification/Link.php index 2d6a31d..988c69f 100644 --- a/src/Verification/Link.php +++ b/src/Verification/Link.php @@ -81,9 +81,13 @@ class Link /** * @param string $vtype one of VERIFICATION_SELF, VERIFICATION_EDUCATIONAL, VERIFICATION_BUSINESS, VERIFICATION_CERTIFICATION + * @param int|null $id The ID of the skill or skillset + * @param string $type one of SKILL or SKILL_SET + * @param int $campaignId An optional campaign ID the verification is attributed to * @return string URL to a Verification that a user can click, he/she will see the Verification interface and can choose a verifier + * @throws \Exception */ - public function getVerificationLink(string $vtype, ?int $id = null, string $type = self::SKILL): string + public function getVerificationLink(string $vtype, ?int $id = null, string $type = self::SKILL, int $campaignId = 0): string { if ($type !== static::SKILL && $type !== static::SKILL_SET) { throw new \Exception('$type has to be "' . static::SKILL . '" or "' . static::SKILL_SET . '" but "' . $type . '" given.', 1600774955); @@ -95,7 +99,7 @@ class Link throw new \InvalidArgumentException('No ID provided.', 1599723825); } - $link = $this->settings->getMySkillDisplayUrl() . '/skillup/' . $type . '/' . $id . '/0/'; + $link = $this->settings->getMySkillDisplayUrl() . '/skillup/' . $type . '/' . $id . '/0/' . ($campaignId ?: ''); switch ($vtype) { case VERIFICATION_EDUCATIONAL: $link .= '2'; @@ -116,9 +120,13 @@ class Link /** * @param string $vtype one of VERIFICATION_SELF, VERIFICATION_EDUCATIONAL, VERIFICATION_BUSINESS, VERIFICATION_CERTIFICATION + * @param int|null $id The ID of the skill or skillset + * @param string $type one of SKILL or SKILL_SET + * @param int $campaignId An optional campaign ID the verification is attributed to * @return string SVG Button to a Verification that a user can click, he/she will see the Verification interface and can choose a verifier + * @throws \Exception */ - public function getVerificationButton(string $vtype, ?int $id = null, string $type = self::SKILL): string + public function getVerificationButton(string $vtype, ?int $id = null, string $type = self::SKILL, int $campaignId = 0): string { switch ($vtype) { case VERIFICATION_EDUCATIONAL: @@ -135,7 +143,7 @@ class Link break; } return <<