1: <?php
2: namespace Izberg\Resource;
3: use Izberg\Resource;
4:
5: class Merchant extends Resource
6: {
7: public function get_list($params, $accept_type) {
8: return self::$Izberg->Call("application/" . self::$Izberg->getAppNamespace() . "/merchants/", 'GET', $params, $accept_type);
9: }
10:
11: public function get_catalog($merchant_id = null, $params = null, $accept_type = 'Accept: application/xml')
12: {
13: if (!$merchant_id)
14: $merchant_id = $this->id;
15: $channel = $this->get_channel($merchant_id);
16: return self::$Izberg->Call("product_channel/" . $channel->id . "/viewer/?format=xml", 'GET', $params, $accept_type);
17: }
18:
19: public function get_channel($merchant_id = null, $params = null)
20: {
21: if (!$merchant_id)
22: $merchant_id = $this->id;
23: return self::$Izberg->Call("merchant/".$merchant_id."/active_products_channel/", 'GET', $params);
24: }
25:
26: public function getCurrent($api_key = '')
27: {
28: if ($this->id && $api_key == '')
29: return $this;
30: try
31: {
32: $seller = self::$Izberg->Call("merchant/", 'GET', array('api_key' => $api_key));
33: }
34: catch (Exception\GenericException $e)
35: {
36: $seller = false;
37: }
38: if (!isset($seller->meta->total_count))
39: $seller = false;
40: else if ($seller->meta->total_count == 0)
41: $seller = false;
42: else
43: $this->hydrate($seller->objects[0]);
44: return $this;
45: }
46:
47: public function getCatalog($params = null, $accept_type = 'Accept: application/xml')
48: {
49: return $this->get_catalog($this->id, $params , $accept_type);
50: }
51: }
52: