Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
details.php
1<?php
2
4
7
8class Details extends Entity
9{
10 protected function requestData()
11 {
12 $data = '<?xml version="1.0" encoding="utf-8"?>
13 <GeteBayDetailsRequest xmlns="urn:ebay:apis:eBLBaseComponents">
14 <RequesterCredentials>
15 <eBayAuthToken>'.$this->authToken.'</eBayAuthToken>
16 </RequesterCredentials>
17 </GeteBayDetailsRequest>';
18
19 $dataXml = $this->apiCaller->sendRequest("GeteBayDetails", $data);
20
21 if(mb_strtolower(SITE_CHARSET) != 'utf-8')
22 $dataXml = Encoding::convertEncoding($dataXml, 'UTF-8', SITE_CHARSET);
23
24 $result = Xml2Array::convert($dataXml);
25 return $result;
26 }
27
28 protected function getData()
29 {
30 $result = array();
31 $ttl = 2592000; //month
32 $cacheManager = \Bitrix\Main\Application::getInstance()->getManagedCache();
33 $cacheId = "BITRIX_SALE_TRADINGPLATFORM_EBAY_API_DETAILS_".$this->siteId;
34
35 if($cacheManager->read($ttl, $cacheId))
36 $result = $cacheManager->get($cacheId);
37
38 if(empty($result))
39 {
40 $result = $this->requestData();
41
42 if(!empty($result))
43 $cacheManager->set($cacheId, $result);
44 }
45
46 return $result;
47 }
48
49 public function getListShipping()
50 {
51 static $result = null;
52
53 if($result === null)
54 {
55 $result = array();
56 $data = $this->getData();
57
58 if(isset($data["ShippingServiceDetails"]) && is_array($data["ShippingServiceDetails"]))
59 {
60 foreach($data["ShippingServiceDetails"] as $service)
61 {
62 if(!in_array($service["ShippingService"], self::getUsableDeliveries()))
63 continue;
64
65 $result[$service["ShippingService"]] = $service["Description"];
66 }
67 }
68 }
69
70 return $result;
71 }
72
73 public static function getUsableDeliveries()
74 {
75 return array(
76 'RU_ExpeditedDelivery','RU_ExpeditedMoscowOnly','RU_StandardDelivery','RU_StandardMoscowOnly',
77 'RU_EconomyDelivery', 'RU_OvernightDelivery', 'RU_LocalPickup'
78 );
79 }
80
81 public function getListPayments()
82 {
83 static $result = null;
84
85 if($result === null)
86 {
87 $result = array();
88 $data = $this->getData();
89
90 if(isset($data["PaymentOptionDetails"]) && is_array($data["PaymentOptionDetails"]))
91 {
92 $data["PaymentOptionDetails"] = Xml2Array::normalize($data["PaymentOptionDetails"]);
93
94 foreach($data["PaymentOptionDetails"] as $payment)
95 {
96 if(!in_array($payment["PaymentOption"], self::getUsablePaySystems()))
97 continue;
98
99 $result[$payment["PaymentOption"]] = $payment["Description"];
100 }
101 }
102 }
103
104 return $result;
105 }
106
107 public static function getUsablePaySystems()
108 {
109 return array('PayPal');
110 }
111
112
113}
static convert($xmlData, $convertCharset=true)
Definition xml2array.php:15
static normalize(array $branch)
Definition xml2array.php:75