rebase on oct-10-2023
This commit is contained in:
@@ -10,7 +10,8 @@ use Yoast\WP\SEO\Helpers\Options_Helper;
|
||||
*/
|
||||
class Wincher_Account_Action {
|
||||
|
||||
const ACCOUNT_URL = 'https://api.wincher.com/beta/account';
|
||||
const ACCOUNT_URL = 'https://api.wincher.com/beta/account';
|
||||
const UPGRADE_CAMPAIGN_URL = 'https://api.wincher.com/v1/yoast/upgrade-campaign';
|
||||
|
||||
/**
|
||||
* The Wincher_Client instance.
|
||||
@@ -63,4 +64,39 @@ class Wincher_Account_Action {
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the upgrade campaign.
|
||||
*
|
||||
* @return object The response object.
|
||||
*/
|
||||
public function get_upgrade_campaign() {
|
||||
try {
|
||||
$result = $this->client->get( self::UPGRADE_CAMPAIGN_URL );
|
||||
$type = $result['type'];
|
||||
$months = $result['months'];
|
||||
|
||||
// We display upgrade discount only if it's a rate discount and positive months.
|
||||
if ( $type === 'RATE' && $months && $months > 0 ) {
|
||||
$discount = $result['value'];
|
||||
|
||||
return (object) [
|
||||
'discount' => $discount,
|
||||
'months' => $months,
|
||||
'status' => 200,
|
||||
];
|
||||
}
|
||||
|
||||
return (object) [
|
||||
'discount' => null,
|
||||
'months' => null,
|
||||
'status' => 200,
|
||||
];
|
||||
} catch ( \Exception $e ) {
|
||||
return (object) [
|
||||
'status' => $e->getCode(),
|
||||
'error' => $e->getMessage(),
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user