1, // 1 for woocommerce 'token' => Options::generateConnectionToken(), 'name' => get_bloginfo( 'name' ), 'homeUrl' => home_url(), 'adminUrl' => admin_url(), 'apiUrl' => Rest::getApiUrl(), ) ); } public static function sendCart( ?string $carId, array $content ): ?string { $http = new AppHttp(); $body = array_filter( $content, function ( $item ) { return ! is_null( $item ); } ); if ( is_null( $carId ) ) { $response = $http->blocking()->post( '/api/v1/carts', $body ); $body = wp_remote_retrieve_body( $response ); if ( is_wp_error( $body ) || ! ( wp_remote_retrieve_response_code( $response ) < 300 ) ) { return null; } return json_decode( $body )->data->id; } else { $http->patch( sprintf( '/api/v1/carts/%s', $carId ), $body ); return null; } } public static function cartMarkAsCompleted( string $id, ?string $recoveredBy = null ) { self::nonBlocking()->patch( sprintf( '/api/v1/carts/%s/completed', $id ), array( 'recoveredBy' => $recoveredBy, ) ); } /** * @param string $id * @return void */ public static function pingCart( string $id ) { self::patch( sprintf( '/api/v1/carts/%s/ping', $id ) ); } public static function trackOpen( string $recoveryId, string $cartId ) { self::nonBlocking()->patch( "/api/v1/recoveries/$recoveryId/carts/$cartId/opened" ); } public static function trackClick( string $recoveryId, string $cartId ) { self::nonBlocking()->patch( "/api/v1/recoveries/$recoveryId/carts/$cartId/clicked" ); } public static function uninstall() { self::nonBlocking()->post( '/api/v1/uninstall' ); } }