Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,11 @@ private function _make_request( $type, $endpoint, $query = [] ) {
],
];

if ( ! empty( $query ) && ! empty( $query['json'] ) && empty( $params['json'] ) ) {
$params['json'] = $query['json'];
unset( $query['json'] );
}

if ( ! empty( $query ) && empty( $params['query'] ) ) {
$params['query'] = $query;
}
Expand Down
15 changes: 10 additions & 5 deletions tests/ApiMethodsTraitsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,9 @@ public function test_delete_media() {
* Test Client::stats_media
*/
public function test_stats_media() {
$stats = $this->client->stats_media( $this->media->hashed_id );
$stats = $this->client->stats_media( $this->video->hashed_id );

$this->assertInternalTupe( 'object', $stats );
$this->assertInternalType( 'object', $stats );
$this->assertObjectHasAttribute( 'stats', $stats );
}

Expand All @@ -221,9 +221,12 @@ public function test_show_account() {
* Test Client::create_customizations
*/
public function test_create_customizations() {
$customizations = $this->client->create_customizations( $this->video->hashed_id, [ 'playerColor' => 'ffffcc' ] );
$customizations = $this->client->create_customizations( $this->video->hashed_id, [ 'json' => [ 'playerColor' => 'ffffcc' ] ] );

$this->assertEquals( 201, $this->client->last_response_code );
$this->assertInternalType( 'object', $customizations );
$this->assertObjectHasAttribute( 'playerColor', $customizations );
$this->assertEquals( 'ffffcc', $customizations->playerColor );
}

/**
Expand All @@ -232,10 +235,12 @@ public function test_create_customizations() {
* @depends test_create_customizations
*/
public function test_show_customizations() {
$customizations = $this->client->create_customizations( $this->video->hashed_id, [ 'json' => [ 'playerColor' => 'ffffcc' ] ] );
$customizations = $this->client->show_customizations( $this->video->hashed_id );

$this->assertInternalType( 'object', $customizations );
$this->assertObjectHasAttribute( 'playerColor', $customizations );
$this->assertEquals('ffffcc', $customizations->playerColor);
}

/**
Expand All @@ -244,8 +249,8 @@ public function test_show_customizations() {
* @depends test_show_customizations
*/
public function test_update_customizations() {
$customizations = $this->client->show_customizations( $this->video->hashed_id );
$customizations = $this->client->update_customizations( $this->video->hashed_id, [ 'playerColor' => 'ccffff' ] );
$customizations = $this->client->create_customizations( $this->video->hashed_id, [ 'json' => [ 'playerColor' => 'ffffcc' ] ] );
$customizations = $this->client->update_customizations( $this->video->hashed_id, [ 'json' => [ 'playerColor' => 'ccffff' ] ] );

$this->assertInternalType( 'object', $customizations );
$this->assertObjectHasAttribute( 'playerColor', $customizations );
Expand Down