rebase on oct-10-2023

This commit is contained in:
Rachit Bhargava
2023-10-10 17:23:21 -04:00
parent d37566ffb6
commit d096058d7d
4789 changed files with 254611 additions and 307223 deletions

View File

@@ -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(),
];
}
}
}