Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug fix #51

Merged
merged 2 commits into from
Nov 26, 2024
Merged
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
103 changes: 103 additions & 0 deletions src/Resources/AffiliateSeller.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,107 @@ public function searchCreatorOnMarketplace($query = [], $body = [])
RequestOptions::JSON => $body,
], 202406);
}

public function generateAffiliateProductPromotionLink($product_id)
{
return $this->call('POST', 'products/'.$product_id.'/promotion_link/generate');
}

public function searchSampleApplicationsFulfillments($application_id, $body = [])
{
return $this->call('POST', 'sample_applications/'.$application_id.'/fulfillments/search', [
RequestOptions::JSON => $body,
], 202409);
}

public function reviewSampleApplications($application_id, $review_result, $reject_reason = '')
{
return $this->call('POST', 'sample_applications/'.$application_id.'/review', [
RequestOptions::JSON => [
'review_result' => $review_result,
'reject_reason' => $reject_reason,
],
], 202409);
}

public function getOpenCollaborationSampleRules($product_ids)
{
return $this->call('GET', 'open_collaborations/sample_rules', [
RequestOptions::QUERY => [
'product_ids' => static::dataTypeCast('array', $product_ids),
],
], 202410);
}

public function searchSampleApplications($query = [], $body = [])
{
$query = array_merge([
'page_size' => 20,
], $query);

return $this->call('POST', 'sample_applications/search', [
RequestOptions::QUERY => $query,
RequestOptions::JSON => $body,
], 202409);
}

public function editOpenCollaborationSampleRule($body = [])
{
return $this->call('POST', 'open_collaborations/sample_rules', [
RequestOptions::JSON => $body,
], 202410);
}

public function removeTargetCollaboration($target_collaboration_id)
{
return $this->call('DELETE', 'target_collaborations/'.$target_collaboration_id,
[], 202409);
}

public function queryTargetCollaborationDetail($target_collaboration_id)
{
return $this->call('GET', 'target_collaborations/'.$target_collaboration_id,
[], 202409);
}

public function searchTargetCollaborations($query = [], $body = [])
{
$query = array_merge([
'page_size' => 20,
], $query);

return $this->call('POST', 'target_collaborations/search', [
RequestOptions::QUERY => $query,
RequestOptions::JSON => $body,
], 202409);
}

public function updateTargetCollaboration($target_collaboration_id, $body)
{
return $this->call('PUT', 'target_collaborations/'.$target_collaboration_id, [
RequestOptions::JSON => $body,
], 202409);
}

public function searchOpenCollaboration($query = [], $body = [])
{
$query = array_merge([
'page_size' => 20,
], $query);

return $this->call('POST', 'open_collaborations/search', [
RequestOptions::QUERY => $query,
RequestOptions::JSON => $body,
], 202409);
}

public function getOpenCollaborationSettings()
{
return $this->call('GET', 'open_collaboration_settings', [], 202409);
}

public function removeOpenCollaboration($product_id)
{
return $this->call('DELETE', 'open_collaborations/products/'.$product_id, [], 202409);
}
}
2 changes: 1 addition & 1 deletion src/Resources/Fulfillment.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public function splitOrders($order_id, $splittable_groups)
return $this->call('POST', 'orders/'.$order_id.'/split', [
RequestOptions::JSON => [
'order_id' => $order_id,
'splittable_groups' => static::dataTypeCast('array', $splittable_groups),
'splittable_groups' => $splittable_groups,
],
]);
}
Expand Down
78 changes: 78 additions & 0 deletions tests/Resources/AffiliateSellerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,82 @@ public function testSearchCreatorOnMarketplace()
$this->caller->searchCreatorOnMarketplace();
$this->assertPreviousRequest('POST', 'affiliate_seller/202406/marketplace_creators/search');
}

public function testGenerateAffiliateProductPromotionLink()
{
$this->caller->generateAffiliateProductPromotionLink(1);
$this->assertPreviousRequest('POST', 'affiliate_seller/'.self::TEST_API_VERSION.'/products/1/promotion_link/generate');
}

public function testSearchSampleApplicationsFulfillments()
{
$this->caller->searchSampleApplicationsFulfillments(1);
$this->assertPreviousRequest('POST', 'affiliate_seller/202409/sample_applications/1/fulfillments/search');
}

public function testReviewSampleApplications()
{
$this->caller->reviewSampleApplications(1, '', '');
$this->assertPreviousRequest('POST', 'affiliate_seller/202409/sample_applications/1/review');
}

public function testGetOpenCollaborationSampleRules()
{
$this->caller->getOpenCollaborationSampleRules([]);
$this->assertPreviousRequest('GET', 'affiliate_seller/202410/open_collaborations/sample_rules');
}

public function testSearchSampleApplications()
{
$this->caller->searchSampleApplications();
$this->assertPreviousRequest('POST', 'affiliate_seller/202409/sample_applications/search');
}

public function testEditOpenCollaborationSampleRule()
{
$this->caller->editOpenCollaborationSampleRule([]);
$this->assertPreviousRequest('POST', 'affiliate_seller/202410/open_collaborations/sample_rules');
}

public function testRemoveTargetCollaboration()
{
$this->caller->removeTargetCollaboration(1);
$this->assertPreviousRequest('DELETE', 'affiliate_seller/202409/target_collaborations/1');
}

public function testQueryTargetCollaborationDetail()
{
$this->caller->queryTargetCollaborationDetail(1);
$this->assertPreviousRequest('GET', 'affiliate_seller/202409/target_collaborations/1');
}

public function testSearchTargetCollaborations()
{
$this->caller->searchTargetCollaborations();
$this->assertPreviousRequest('POST', 'affiliate_seller/202409/target_collaborations/search');
}

public function testUpdateTargetCollaboration()
{
$this->caller->updateTargetCollaboration(1, []);
$this->assertPreviousRequest('PUT', 'affiliate_seller/202409/target_collaborations/1');
}

public function testSearchOpenCollaboration()
{
$this->caller->searchOpenCollaboration();
$this->assertPreviousRequest('POST', 'affiliate_seller/202409/open_collaborations/search');
}

public function testGetOpenCollaborationSettings()
{
$this->caller->getOpenCollaborationSettings();
$this->assertPreviousRequest('GET', 'affiliate_seller/202409/open_collaboration_settings');
}

public function testRemoveOpenCollaboration()
{
$this->caller->removeOpenCollaboration(1);
$this->assertPreviousRequest('DELETE', 'affiliate_seller/202409/open_collaborations/products/1');
}
}