-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b5281e4
commit b8ad092
Showing
3 changed files
with
183 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
<?php | ||
|
||
namespace Omnimail\Silverpop\Requests; | ||
|
||
use Omnimail\Silverpop\Responses\GroupMembersResponse; | ||
use Omnimail\Silverpop\Responses\Consent; | ||
|
||
/** | ||
* https://api-campaign-us-2.goacoustic.com/restdoc/#!/databases/consent_get_get_10 | ||
*/ | ||
class ConsentInformationRequest extends SilverpopBaseRequest | ||
{ | ||
|
||
/** | ||
* Silverpop database ID. | ||
* | ||
* @var int | ||
*/ | ||
protected $database_id; | ||
|
||
protected string $channel = 'SMS'; | ||
|
||
protected string $shortCode; | ||
|
||
/** | ||
* Qualifier, aka text to join. | ||
* | ||
* This is the SMS number that a person would send text to to consent. | ||
* | ||
* @var string | ||
* | ||
*/ | ||
protected $qualifier; | ||
|
||
/** | ||
* Destination - this is generally the phone number with country code but no leading zeros. | ||
* @var int | ||
*/ | ||
protected $destination; | ||
|
||
private int $phone; | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getDatabaseId() { | ||
return $this->database_id; | ||
} | ||
|
||
/** | ||
* @param int $database_id | ||
*/ | ||
public function setDatabaseId($database_id) { | ||
$this->database_id = $database_id; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function getPhone() { | ||
return $this->phone; | ||
} | ||
|
||
/** | ||
* @param int $phone | ||
*/ | ||
public function setPhone(int $phone) { | ||
$this->phone = $phone; | ||
} | ||
|
||
/** | ||
* Get Response | ||
* | ||
* @return GroupMembersResponse | ||
*/ | ||
public function getResponse() { | ||
$result = $this->requestData(); | ||
$response = new Consent($result['data']); | ||
return $response; | ||
} | ||
|
||
/** | ||
* Request data from the provider. | ||
*/ | ||
protected function requestData() { | ||
return $this->silverPop->restGet( | ||
$this->getDatabaseId(), | ||
'databases', | ||
['consent', $this->channel . '-' . $this->getShortCode(), $this->getPhone()]); | ||
} | ||
|
||
/** | ||
* Get defaults for the api. | ||
* | ||
* @return array | ||
*/ | ||
public function getDefaultParameters(): array { | ||
return [ | ||
'endpoint' => 'https://api-campaign-us-4.goacoustic.com', | ||
]; | ||
} | ||
|
||
public function getShortCode(): string { | ||
return $this->shortCode; | ||
} | ||
|
||
public function setShortCode(string $shortCode): self { | ||
$this->shortCode = $shortCode; | ||
return $this; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
/** | ||
* Created by IntelliJ IDEA. | ||
* User: emcnaughton | ||
* Date: 5/4/17 | ||
* Time: 7:34 AM | ||
*/ | ||
|
||
namespace Omnimail\Silverpop\Responses; | ||
|
||
use SilverpopConnector\SilverpopConnector; | ||
use SilverpopConnector\SilverpopConnectorException; | ||
use Omnimail\Exception\InvalidRequestException; | ||
|
||
class Consent { | ||
|
||
/** | ||
* @var array | ||
*/ | ||
protected $data = []; | ||
|
||
/** | ||
* @return int|null | ||
*/ | ||
public function getStatus(): string { | ||
return $this->data['status']; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function getTimestamp(): int { | ||
return strtotime($this->data['consentDate']); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getSource(): ?string { | ||
return $this->data['consentSource']; | ||
} | ||
|
||
/** | ||
* @var SilverpopConnector | ||
*/ | ||
protected $silverPop; | ||
|
||
public function __construct($data) { | ||
$this->data = $data; | ||
} | ||
|
||
} |