Skip to content

Commit

Permalink
filter the URL for the post form request
Browse files Browse the repository at this point in the history
  • Loading branch information
faisal-alvi committed Oct 25, 2023
1 parent 7b71dc8 commit 94aba71
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions includes/Classifai/Providers/OpenAI/APIRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function get( string $url, array $options = [] ) {
*
* @return {string} The URL for the request.
*/
apply_filters( 'classifai_openai_api_request_get_url', $url, $options, $this->feature );
$url = apply_filters( 'classifai_openai_api_request_get_url', $url, $options, $this->feature );

/**
* Filter the options for the get request.
Expand All @@ -77,7 +77,7 @@ public function get( string $url, array $options = [] ) {
*
* @return {array} The options for the request.
*/
apply_filters( 'classifai_openai_api_request_get_options', $options, $url, $this->feature );
$options = apply_filters( 'classifai_openai_api_request_get_options', $options, $url, $this->feature );

$this->add_headers( $options );

Expand Down Expand Up @@ -129,7 +129,7 @@ public function post( string $url = '', array $options = [] ) {
*
* @return {string} The URL for the request.
*/
apply_filters( 'classifai_openai_api_request_post_url', $url, $options, $this->feature );
$url = apply_filters( 'classifai_openai_api_request_post_url', $url, $options, $this->feature );

/**
* Filter the options for the post request.
Expand All @@ -143,7 +143,7 @@ public function post( string $url = '', array $options = [] ) {
*
* @return {array} The options for the request.
*/
apply_filters( 'classifai_openai_api_request_post_options', $options, $url, $this->feature );
$options = apply_filters( 'classifai_openai_api_request_post_options', $options, $url, $this->feature );

$this->add_headers( $options );

Expand Down Expand Up @@ -176,6 +176,19 @@ public function post( string $url = '', array $options = [] ) {
* @return array|WP_Error
*/
public function post_form( string $url = '', array $body = [] ) {
/**
* Filter the URL for the post form request.
*
* @since 2.4.0
* @hook classifai_openai_api_request_post_form_url
*
* @param {string} $url The URL for the request.
* @param {string} $this->feature The feature name.
*
* @return {string} The URL for the request.
*/
$url = apply_filters( 'classifai_openai_api_request_post_form_url', $url, $this->feature );

$boundary = wp_generate_password( 24, false );
$payload = '';

Expand Down

0 comments on commit 94aba71

Please sign in to comment.