Skip to content

Commit 242a65c

Browse files
committed
- catch up with 1.46 java-framework
1 parent 6fec789 commit 242a65c

10 files changed

Lines changed: 318 additions & 4 deletions

src/API/Request.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,27 @@ public static function getDealsRequest(DealRequest $dealRequest)
3535
return $r;
3636
}
3737

38+
/**
39+
* This request provides access to all current and upcoming lightning deals.
40+
* You can request a specific lightning deal by specifying an ASIN or get the complete list.
41+
* Our lightning deals information is updated every 10 minutes.
42+
*
43+
*
44+
* @param int domainId Amazon locale of the product {@link AmazonLocale}
45+
* @param string asin The ASIN to retrieve the lightning deal for or null to retrieve all lightning deals
46+
* @return Request
47+
*/
48+
public static function getLightningDealRequest($domainId, $asin = null)
49+
{
50+
$r = new Request();
51+
$r->path = "lightningdeal";
52+
$r->parameter["domain"] = $domainId;
53+
if ($asin != null)
54+
$r->parameter["asin"] = $asin;
55+
56+
return $r;
57+
}
58+
3859
/**
3960
* Retrieve category objects using their node ids and (optional) their parent tree.
4061
*

src/API/Response.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
<?php
2-
namespace Keepa\API;
1+
<?php namespace Keepa\API;
32

43
/**
54
* Common Keepa API Response
@@ -140,6 +139,12 @@ class Response
140139
*/
141140
public $totalResults = null;
142141

142+
/**
143+
* A list of lightning deals.
144+
* @var \Keepa\objects\LightningDeal[]|null
145+
*/
146+
public $lightningDeals = null;
147+
143148
function __construct(Request $request)
144149
{
145150
$this->request = $request;

src/objects/AmazonLocale.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,4 @@ class AmazonLocale
2020
const MX = 11;
2121
const BR = 12;
2222
const AU = 13;
23-
const NL = 14;
24-
const TR = 15;
2523
}

src/objects/LightningDeal.php

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
<?php
2+
3+
namespace Keepa\objects;
4+
5+
/**
6+
* About:
7+
* A best sellers ASIN list of a specific category.
8+
* <p>
9+
* Returned by:
10+
* Request Best Sellers
11+
*/
12+
class LightningDeal
13+
{
14+
15+
/**
16+
* The domainId of the products Amazon locale <br>
17+
* {@link AmazonLocale}
18+
* @var int
19+
*/
20+
public $domainId;
21+
22+
/**
23+
* The ASIN of the product
24+
* @var int
25+
*/
26+
public $lastUpdate;
27+
28+
/**
29+
* The ASIN of the product
30+
* @var string
31+
*/
32+
public $asin;
33+
34+
/**
35+
* Title of the product. Caution: may contain HTML markup in rare cases.
36+
* @var string
37+
*/
38+
public $title;
39+
40+
/**
41+
* The name of seller offering this deal.
42+
* @var string|null
43+
*/
44+
public $sellerName;
45+
46+
/**
47+
* The seller id of the merchant offering this deal.
48+
* @var string|null
49+
*/
50+
public $sellerId;
51+
52+
/**
53+
* A unique ID for this deal.
54+
* @var string
55+
*/
56+
public $dealId;
57+
58+
/**
59+
* The discounted price of this deal. Available once the deal has started. -1 if the deal’s state is upcoming. The price is an integer of the respective Amazon locale’s smallest currency unit (e.g. euro cents or yen).
60+
* @var int
61+
*/
62+
public $dealPrice;
63+
64+
/**
65+
* The regular price of this product. Available once the deal has started. -1 if the deal’s state is upcoming. The price is an integer of the respective Amazon locale’s smallest currency unit (e.g. euro cents or yen).
66+
* @var int
67+
*/
68+
public $currentPrice;
69+
70+
71+
/**
72+
* The name of the primary image of the product. null if not available.
73+
* @var string|null
74+
*/
75+
public $image;
76+
77+
/**
78+
* Whether or not the deal is Prime eligible.
79+
* @var boolean
80+
*/
81+
public $isPrimeEligible;
82+
83+
/**
84+
* Whether or not the deal is fulfilled by Amazon.
85+
* @var boolean
86+
*/
87+
public $isFulfilledByAmazon;
88+
89+
/**
90+
* Whether or not the price is restricted by MAP (Minimum Advertised Price).
91+
* @var boolean
92+
*/
93+
public $isMAP;
94+
95+
/**
96+
* The rating of the product. A rating is an integer from 0 to 50 (e.g. 45 = 4.5 stars).
97+
* @var int
98+
*/
99+
public $rating;
100+
101+
/**
102+
* The product’s review count.
103+
* @var int
104+
*/
105+
public $totalReviews;
106+
107+
/**
108+
* The state of the deal.
109+
* @var string
110+
*/
111+
public $dealState;
112+
113+
/**
114+
* The start time of this lighting deal, in Keepa Time minutes. Note that due to the delay in our data collection the deal price might not be available immediately once the deal has started on Amazon.<br>
115+
* Use {@link KeepaTime#keepaMinuteToUnixInMillis(int)} (long)} to get an uncompressed timestamp (Unix epoch time).
116+
* @var int
117+
*/
118+
public $startTime;
119+
120+
/**
121+
* The end time of this lighting deal, in Keepa Time minutes.<br>
122+
* Use {@link KeepaTime#keepaMinuteToUnixInMillis(int)} (long)} to get an uncompressed timestamp (Unix epoch time).
123+
* @var int
124+
*/
125+
public $endTime;
126+
127+
/**
128+
* The percentage claimed of the lighting deal. Since lightning deals have limited stock, this number may change fast on Amazon, but due to the delay of our data collection the provided value may be outdated.
129+
* @var int
130+
*/
131+
public $percentClaimed;
132+
133+
/**
134+
* The provided discount of this deal, according to Amazon. May be in reference to the list price, not the current price.
135+
* @var int
136+
*/
137+
public $percentOff;
138+
139+
/**
140+
* The provided discount of this deal, according to Amazon. May be in reference to the list price, not the current price.
141+
* @var \Keepa\helper\VariationAttributeObject[]|null
142+
*/
143+
public $variation;
144+
145+
146+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
namespace Keepa\objects;
4+
5+
/**
6+
* About:
7+
* A best sellers ASIN list of a specific category.
8+
* <p>
9+
* Returned by:
10+
* Request Best Sellers
11+
*/
12+
class MerchantBrandStatistics
13+
{
14+
15+
/**
16+
* the brand (in all lower-case)
17+
* @var string
18+
*/
19+
public $brand;
20+
21+
/**
22+
* the number of products this merchant sells with this brand
23+
* @var int
24+
*/
25+
public $productCount;
26+
27+
/**
28+
* the 30 day average sales rank of these products
29+
* @var int
30+
*/
31+
public $avg30SalesRank;
32+
33+
/**
34+
* how many of these products have an Amazon offer
35+
* @var string
36+
*/
37+
public $productCountWithAmazonOffer;
38+
39+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
namespace Keepa\objects;
4+
5+
/**
6+
* About:
7+
* A best sellers ASIN list of a specific category.
8+
* <p>
9+
* Returned by:
10+
* Request Best Sellers
11+
*/
12+
class MerchantCategoryStatistics
13+
{
14+
15+
/**
16+
* the category id
17+
* @var int
18+
*/
19+
public $catId;
20+
21+
/**
22+
* the number of products this merchant sells with this category
23+
* @var int
24+
*/
25+
public $productCount;
26+
27+
/**
28+
* the 30 day average sales rank of these products
29+
* @var int
30+
*/
31+
public $avg30SalesRank;
32+
33+
/**
34+
* how many of these products have an Amazon offer
35+
* @var string
36+
*/
37+
public $productCountWithAmazonOffer;
38+
39+
}

src/objects/Offer.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,12 @@ class Offer
130130
*/
131131
public $isScam = null;
132132

133+
/**
134+
* Indicating whether or not the offer ships from China.
135+
* @var bool|null
136+
*/
137+
public $shipsFromChina;
138+
133139
/**
134140
* True if the seller is Amazon (e.g. "Amazon.com").
135141
* <p>

src/objects/Seller.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ class Seller
6363
*/
6464
public $isScammer = null;
6565

66+
/**
67+
* Indicating whether or not the offer ships from China.
68+
* @var bool|null
69+
*/
70+
public $shipsFromChina = null;
71+
6672
/**
6773
* Boolean value indicating whether or not the seller currently has FBA listings.<br>
6874
* This value is usually correct, but could be set to false even if the seller has FBA listings, since we are not always aware of all<br>
@@ -103,4 +109,37 @@ class Seller
103109
* @var int[]|null
104110
*/
105111
public $totalStorefrontAsins = null;
112+
113+
114+
/**
115+
* Statistics about the primary categories of this seller. Based on our often incomplete and outdated product offers data.
116+
* @var MerchantCategoryStatistics[]|null
117+
*/
118+
public $sellerCategoryStatistics = null;
119+
120+
/**
121+
* Statistics about the primary brands of this seller. Based on our often incomplete and outdated product offers data.
122+
* @var MerchantBrandStatistics[]|null
123+
*/
124+
public $sellerBrandStatistics = null;
125+
126+
127+
/**
128+
*
129+
* @var int
130+
*/
131+
public $currentRating = null;
132+
133+
/**
134+
*
135+
* @var int
136+
*/
137+
public $currentRatingCount = null;
138+
139+
/**
140+
*
141+
* @var int
142+
*/
143+
public $ratingsLast30Days = null;
144+
106145
}

src/tests/LightingDealTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
namespace Keepa\tests;
4+
5+
use Keepa\API\Request;
6+
use Keepa\objects\AmazonLocale;
7+
8+
class LightingDealTest extends abstractTest
9+
{
10+
public function testRun()
11+
{
12+
$request = Request::getLightningDealRequest(AmazonLocale::DE);
13+
$response = $this->api->sendRequestWithRetry($request);
14+
15+
self::assertEquals($response->status, "OK");
16+
self::assertNotNull($response->lightningDeals);
17+
self::assertGreaterThan(0, count($response->lightningDeals));
18+
}
19+
20+
}

src/tests/SellerRequestTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,6 @@ public function testStoreFrontAsins()
5959
self::assertNotNull($response->sellers);
6060
self::assertEquals(1, count($response->sellers));
6161
self::assertGreaterThan(0, count($response->sellers['A2L77EE7U53NWQ']->totalStorefrontAsins));
62+
self::assertNotNull($response->sellers['A2L77EE7U53NWQ']->shipsFromChina);
6263
}
6364
}

0 commit comments

Comments
 (0)