public function parseNorthstarUserResponse($response) {
    // Check response contains correct data.
    if (!is_array($response) || empty($response[0]) || empty($response[1])) {
      throw new Exception(
        '- Unexpected Northstar response:' . var_export($response, true)
      );
    }

    // Check HTTP code.
    list($user, $httpCode) = $response;
    if ($httpCode === 201) {
      echo '- Northstar user created.' . PHP_EOL;
    } elseif ($httpCode === 200) {
      echo '- Northstar user loaded or updated.' . PHP_EOL;
    } else {
      throw new Exception(
        '- Unexpected Northstar http code:' . $httpCode
        . 'user: ' . var_export($user, true)
      );
    }

    // Check user user.
    if (empty($user->data) || empty($user->data->id)) {
      throw new Exception(
        '- Unexpected user user:'. var_export($user->data, true)
      );
    }

    return $user->data;
  }
public function parseNorthstarUserResponse($response) {
    // Check response contains correct data.
    if (!is_array($response) || empty($response[0]) || empty($response[1])) {
      throw new Exception(
        '- Unexpected Northstar response:' . var_export($response, true)
      );
    }

    // Check HTTP code.
    list($user, $httpCode) = $response;
    if ($httpCode === 201) {
      echo '- Northstar user created.' . PHP_EOL;
    } elseif ($httpCode === 200) {
      echo '- Northstar user loaded or updated.' . PHP_EOL;
    } else {
      throw new Exception(
        '- Unexpected Northstar http code:' . $httpCode
        . 'user: ' . var_export($user, true)
      );
    }

    // Check user user.
    if (empty($user->data) || empty($user->data->id)) {
      throw new Exception(
        '- Unexpected user user:'. var_export($user->data, true)
      );
    }

    return $user->data;
  }
public function parseNorthstarUserResponse ( $ response ) { // Check response contains correct data. if ( ! is_array ( $ response ) || empty ( $ response [ 0 ] ) || empty ( $ response [ 1 ] ) ) { throw new Exception ( '- Unexpected Northstar response:' . var_export ( $ response , true ) ) ; } // Check HTTP code. list ( $ user , $ httpCode ) = $ response ; if ( $ httpCode === 201 ) { echo '- Northstar user created.' . PHP_EOL ; } elseif ( $ httpCode === 200 ) { echo '- Northstar user loaded or updated.' . PHP_EOL ; } else { throw new Exception ( '- Unexpected Northstar http code:' . $ httpCode . 'user: ' . var_export ( $ user , true ) ) ; } // Check user user. if ( empty ( $ user -> data ) || empty ( $ user -> data -> id ) ) { throw new Exception ( '- Unexpected user user:' . var_export ( $ user -> data , true ) ) ; } return $ user -> data ; }
Parse Northstar user response, throw exception on failure.
Parse Northstar user response throw exception on failure .