1 | <?php |
||
8 | class Helper |
||
9 | { |
||
10 | protected $client = null; |
||
11 | |||
12 | 21 | public function __construct(Client $client) |
|
16 | |||
17 | /** |
||
18 | * Get simplified fields list for given category |
||
19 | * @param integer $idCategory id of category in question |
||
20 | * @return array of fields metadata |
||
21 | */ |
||
22 | 2 | public function getFieldsByCategory($idCategory) |
|
42 | |||
43 | /** |
||
44 | * Create new auction |
||
45 | * |
||
46 | * @throws Exception on failure |
||
47 | * |
||
48 | * @param Auction $auction Auction to create |
||
49 | * @param integer $localId - local item id, required by WebAPI |
||
50 | * @return integer id of created auction |
||
51 | */ |
||
52 | 2 | public function newAuction(AuctionInterface $auction, $localId) |
|
66 | |||
67 | |||
68 | /** |
||
69 | * Finish a single auction |
||
70 | * @param integer $auctionId itemId of auction to finish |
||
71 | * @param integer $cancelAllBids whether to cancel all bids |
||
72 | * @param string $finishCancelReason reason |
||
73 | * @return array |
||
74 | */ |
||
75 | 4 | public function finishAuction($auctionId, $cancelAllBids = 0, $finishCancelReason = '') |
|
79 | |||
80 | |||
81 | /** |
||
82 | * Finish a single auction |
||
83 | * @param array $auctionIds itemIds of auctions to finish |
||
84 | * @param integer $cancelAllBids whether to cancel all bids |
||
85 | * @param string $finishCancelReason reason |
||
86 | * @return array |
||
87 | */ |
||
88 | 8 | public function finishAuctions(array $auctionIds, $cancelAllBids = 0, $finishCancelReason = '') |
|
100 | |||
101 | /** |
||
102 | * Change quantity of items available in auction |
||
103 | * @param integer $auctionId itemId of auction to change quantity |
||
104 | * @param integer $newQuantity new quantity to set |
||
105 | * @return array |
||
106 | */ |
||
107 | 1 | public function changeQuantity($auctionId, $newQuantity) |
|
114 | |||
115 | |||
116 | /** |
||
117 | * Return site journal deals |
||
118 | * @param integer $journalStart start point (dealEventId) |
||
119 | * @return array |
||
120 | */ |
||
121 | 3 | public function getSiteJournalDeals($journalStart = 0) |
|
122 | { |
||
123 | 3 | $response = $this->client->doGetSiteJournalDeals(['journalStart' => $journalStart]); |
|
124 | 3 | if (isset($response->siteJournalDeals->item)) { |
|
125 | 2 | return array_map(function($deal){ |
|
126 | 2 | return new Deal($deal); |
|
127 | 2 | }, $response->siteJournalDeals->item); |
|
128 | } |
||
129 | |||
130 | 1 | throw new Exception("Unable to get site journal deals: " . print_r($response, 1)); |
|
131 | } |
||
132 | |||
133 | |||
134 | /** |
||
135 | * @param integer $itemId id of auction to get |
||
136 | * @return Auction | null |
||
137 | */ |
||
138 | public function getAuctionByItemId($itemId) |
||
149 | |||
150 | |||
151 | /** |
||
152 | * Directly call WebAPI method (prefixed by "do") |
||
153 | * @param string $name method name |
||
154 | * @param [type] $args method arguments |
||
155 | * @return [type] [description] |
||
156 | */ |
||
157 | 3 | public function __call($name, $args) |
|
165 | |||
166 | } |
||
167 |
If you implement
__call
and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__call
is implemented by a parent class and only the child class knows which methods exist: