-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Endpoint.php
95 lines (87 loc) · 2.56 KB
/
Endpoint.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
namespace AmazonBusinessApi;
use InvalidArgumentException;
/***************************/
/** Region/endpoint pairs **/
/***************************/
class Endpoint
{
// North America
public const NA = [
'url' => 'https://na.business-api.amazon.com',
'region' => 'us-east-1',
];
// Europe
public const EU = [
'url' => 'https://eu.business-api.amazon.com',
'region' => 'eu-west-1',
];
// Far East
public const FE = [
'url' => 'https://jp.business-api.amazon.com/',
'region' => 'us-west-2',
];
/**
* Returns the endpoint for the marketplace with the given ID.
*
* @param string $marketplaceId The identifier for the marketplace. (required)
*
* @throws InvalidArgumentException
* @return array of the endpoint details
*
* @link https://developer-docs.amazon.com/amazon-business/docs/marketplace-ids
*/
public static function getByMarketplaceId(string $marketplaceId) {
$map = [
// North America.
// Canada
'A2EUQ1WTGCTBG2' => 'NA',
// US.
'ATVPDKIKX0DER' => 'NA',
// Europe.
// United Arab Emirates (U.A.E.).
'A2VIGQ35RCS4UG' => 'EU',
// Belgium.
'AMEN7PMS3EDWL' => 'EU',
// Germany.
'A1PA6795UKMFR9' => 'EU',
// Egypt.
'ARBP9OOSHTCHU' => 'EU',
// Spain.
'A1RKKUPIHCS9HS' => 'EU',
// France.
'A13V1IB3VIYZZH' => 'EU',
// UK.
'A1F83G8C2ARO7P' => 'EU',
// India.
'A21TJRUUN4KGV' => 'EU',
// Italy.
'APJ6JRA9NG5V4' => 'EU',
// Netherlands.
'A1805IZSGTT6HS' => 'EU',
// Poland.
'A1C3SOZRARQ6R3' => 'EU',
// Saudi Arabia.
'A17E79C6D8DWNP' => 'EU',
// Sweden.
'A2NODRKZP88ZB9' => 'EU',
// Turkey.
'A33AVAJ2PDY3EV' => 'EU',
// Far East.
// Singapore.
'A19VAU5U5O7RUS' => 'FE',
// Australia.
'A39IBJ37TRP1C6' => 'FE',
// Japan.
'A1VC38T7YXB528' => 'FE',
];
if (!isset($map[$marketplaceId])) {
throw new InvalidArgumentException(sprintf(
'Unknown marketplace ID "%s".',
$marketplaceId
));
}
$region = $map[$marketplaceId];
return constant("\AmazonBusinessApi\Endpoint::$region");
}
}