クラス
SyncAmazonAccount
ソース ソース
ファイル: src/API/SyncAmazonAccount.php
class SyncAmazonAccount extends ErrorStore
{
const NOT_LOGGED_IN = 'syncamzaccount_4001';
/**
* Populates custom error store
*
* @author Evan D Shaw <evandanielshaw@gmail.com>
*/
public function __construct() {
parent::__construct();
$this->populate();
}
/**
* Updates flag used to determine whether a login with Amazon should
* also force a login to Welcart or not
*
* @author Evan D Shaw <evandanielshaw@gmail.com>
* @param array $args
* @return GenericError|string
*/
public function updateSyncMeta($args) {
$sync = (bool)(int)$args['sync'];
if (!isset($_SESSION['usces_member']['ID']) || empty($_SESSION['usces_member']['ID'])) {
return $this->getErrorResponse(self::NOT_LOGGED_IN);
}
$memberId = (int)$_SESSION['usces_member']['ID'];
$memMeta = new MemberMeta($memberId);
$memMeta->updateAllowAmazonToWelcartLogin($sync);
return 'success';
}
/**
* Populates error store
*
* @author Evan D Shaw <evandanielshaw@gmail.com>
* @return void
* @throws InvalidArgumentException Thrown if duplicate errorcodes exist.
*/
public function populate() {
$this->addError(new GenericError(
self::NOT_LOGGED_IN,
self::NOT_LOGGED_IN,
401,
'You must be logged in to perform this action',
__('You are not logged in. Please login and try again.', 'wcexaap')
));
}
}
- __construct — Populates custom error store
- populate — Populates error store
- updateSyncMeta — Updates flag used to determine whether a login with Amazon should also force a login to Welcart or not