Skip to content

Commit

Permalink
refactor request arg retrieval for api requests
Browse files Browse the repository at this point in the history
  • Loading branch information
manewc committed Sep 23, 2024
1 parent 1bc6198 commit dcd3f22
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/api/class-jw-player-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,13 @@ public function request_url( string $last_modified_date, int $batch_size ): stri
* @return array
*/
public function request_args( string $type = '' ): array {
$default_args = [
return [
'user-agent' => $this->user_agent(),
'headers' => [
'Authorization' => 'Bearer ' . $this->api_secret,
'Content-Type' => 'application/json',
],
];

return 'vip' === $type
? $default_args
: array_merge( $default_args, [ 'timeout' => 3 ] );
}

/**
Expand Down Expand Up @@ -147,12 +143,17 @@ public function request_latest_videos( string $updated_after, int $batch_size ):
3,
5,
3,
$this->request_args( 'vip' )
$this->request_args()
);
} else {
$api_request = wp_remote_get(
$request_url,
$this->request_args()
wp_parse_args(
$this->request_args(),
[
'timeout' => 3,
]
)
);
}

Expand Down

0 comments on commit dcd3f22

Please sign in to comment.