Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

Commit

Permalink
Merge pull request #10 from bluehost/hotfix/bh_cdata-variable-typo
Browse files Browse the repository at this point in the history
Fix $bh_cdata variable name typo
  • Loading branch information
circlecube authored Aug 19, 2022
2 parents 84a7dae + e497dd0 commit 03f5a43
Showing 1 changed file with 27 additions and 24 deletions.
51 changes: 27 additions & 24 deletions includes/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,13 @@ class Customer {
public static function collect() {
$bh_cdata = Transient::get( self::TRANSIENT );

if ( $bh_data &&
if ( $bh_cdata &&
is_array( $bh_cdata ) &&
! array_key_exists( 'signup_date', $bh_cdata ) ||
! array_key_exists( 'plan_subtype', $bh_cdata ) ) {
(
! array_key_exists( 'signup_date', $bh_cdata ) ||
! array_key_exists( 'plan_subtype', $bh_cdata )
)
) {
$bh_cdata = false;
Transient::delete( self::TRANSIENT );
}
Expand All @@ -62,7 +65,7 @@ public static function collect() {

/**
* Prepopulate with provided data.
*
*
* @param string $path of desired API endpoint
* @return object|false of response data in json format
*/
Expand All @@ -73,9 +76,9 @@ public static function provided( $path ) {
case '/hosting-account-info':
$key = self::get_cdata_key_by_path( $path );
$provided = \get_option( $key );
if (
! empty( $provided )
&& is_string( $provided )
if (
! empty( $provided )
&& is_string( $provided )
&& is_object( $decoded = json_decode( $provided ) )
) {
$provided = $decoded;
Expand All @@ -95,7 +98,7 @@ public static function provided( $path ) {
*/
private static function get_cdata_key_by_path( $path ) {
switch( $path ) {
case '/hosting-account-info':
case '/hosting-account-info':
return self::PROVIDED_GUAPI;
case '/onboarding-info':
return self::PROVIDED_MOLE;
Expand All @@ -104,12 +107,12 @@ private static function get_cdata_key_by_path( $path ) {

/**
* Connect to API with token via AccessToken Class in Bluehost Plugin
*
*
* @param string $path of desired API endpoint
* @return object of response data in json format
*/
public static function connect( $path ) {

if ( ! $path ) {
return;
}
Expand All @@ -122,7 +125,7 @@ public static function connect( $path ) {

// refresh token if needed
AccessToken::maybe_refresh_token();

// construct request
$token = AccessToken::get_token();
$user_id = AccessToken::get_user();
Expand All @@ -144,22 +147,22 @@ public static function connect( $path ) {

/**
* Connect to the hosting info (guapi) endpoint and format response into hiive friendly data
*
*
* @return array of relevant data
*/
public static function get_account_info(){

$info = array();
$response = self::connect( '/hosting-account-info' );

// exit if response is not object
if ( ! is_object( $response ) ) {
return $info;
}

// transfer relevant data to $info array
$info['customer_id'] = AccessToken::get_user();

if (
isset( $response->affiliate ) &&
is_object( $response->affiliate ) &&
Expand All @@ -184,7 +187,7 @@ public static function get_account_info(){
}
}


if ( isset( $response->plan ) && is_object( $response->plan ) ) {

// using property_exists in case of null value
Expand All @@ -209,7 +212,7 @@ public static function get_account_info(){
return $info;
}


/**
* Connect to the onboarding info (mole) endpoint and format response into hiive friendly data
*
Expand All @@ -226,7 +229,7 @@ public static function get_onboarding_info(){
}

// transfer existing relevant data to $info array
if (
if (
isset( $response->description ) &&
is_object( $response->description )
) {
Expand All @@ -244,9 +247,9 @@ public static function get_onboarding_info(){
}
}
}


if (

if (
isset( $response->site_intentions ) &&
is_object( $response->site_intentions )
) {
Expand Down Expand Up @@ -284,7 +287,7 @@ public static function get_onboarding_info(){

/**
* Normalize blog
*
*
* For now this is just 0 or 20 values, but in the future we can update based on other factors and treat as a blog score
*/
public static function normalize_blog( $blog ){
Expand All @@ -301,7 +304,7 @@ public static function normalize_blog( $blog ){

/**
* Normalize store
*
*
* For now this is just 0 or 20 values, but in the future we can update based on other factors and treat as a store score
*/
public static function normalize_store( $store ){
Expand All @@ -323,9 +326,9 @@ public static function normalize_store( $store ){
* 1 When selected comfort level is second closest to "A little" and "Continue" is clicked
* 2 When selected comfort level is second closest to "Very" and "Continue" is clicked
* 3 When selected comfort level is closest to "Very" and "Continue" is clicked
*
*
* @param string $comfort value returned from api for comfort_creating_sites
* @return integer representing normalized comfort level
* @return integer representing normalized comfort level
*/
public static function normalize_comfort( $comfort ){

Expand Down Expand Up @@ -354,7 +357,7 @@ public static function normalize_comfort( $comfort ){
* diy_with_help When "A little Help" is clicked
* do_it_for_me When "Built for you" is clicked
* skip When "Skip this step" is clicked
*
*
* @param string $help value returned from api for help_needed
* @return integer representing normalized help level
*/
Expand Down

0 comments on commit 03f5a43

Please sign in to comment.