1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
policy.php
См. документацию.
1<?php
2/* NOT FOR RELEASE*/
3namespace Bitrix\Sale\TradingPlatform\Ebay;
4
5use Bitrix\Main\ArgumentNullException;
6use Bitrix\Main\ArgumentOutOfRangeException;
7use Bitrix\Main\Web\HttpClient;
8use Bitrix\Main\SystemException;
9use Bitrix\Main\Text\Encoding;
10use Bitrix\Sale\TradingPlatform\Logger;
11use Bitrix\Sale\TradingPlatform\Xml2Array;
12
13class Policy
14{
15 protected $http;
16 protected $authToken = "";
17 protected $siteId = "";
18
19 const TYPE_RETURN = 0;
20 const TYPE_PAYMENT = 1;
21 const TYPE_SHIPPING = 2;
22 const URL = "https://svcs.ebay.com/services/selling/v1/SellerProfilesManagementService";
23
24 public function __construct($authToken, $siteId)
25 {
26 if($authToken == '')
27 throw new ArgumentNullException("authToken");
28
29 if($siteId == '')
30 throw new ArgumentNullException("siteId");
31
32 $this->authToken = $authToken;
33 $this->siteId = $siteId;
34
35 $this->http = new HttpClient(array(
36 "version" => "1.1",
37 "socketTimeout" => 30,
38 "streamTimeout" => 30,
39 "redirect" => true,
40 "redirectMax" => 5,
41 ));
42 }
43
44 public function getItemsList()
45 {
46 static $result = null;
47
48 if($result === null)
50
51 return $result;
52 }
53
58 public function getPoliciesNames($type)
59 {
60 $policiesList = $this->getItemsList();
61
62 if(empty($policiesList))
63 return array();
64
65 if($type == self::TYPE_RETURN)
66 $policyBranch = $policiesList["returnPolicyProfileList"]["ReturnPolicyProfile"];
67 elseif($type == self::TYPE_PAYMENT)
68 $policyBranch = $policiesList["paymentProfileList"]["PaymentProfile"];
69 elseif($type == self::TYPE_SHIPPING)
70 $policyBranch = $policiesList["shippingPolicyProfile"]["ShippingPolicyProfile"];
71 else
72 throw new ArgumentOutOfRangeException("type");
73
74 if(empty($policyBranch) || !is_array($policyBranch))
75 return array();
76
77 $result = array();
78 $policies = Xml2Array::normalize($policyBranch);
79
80 foreach($policies as $policy)
81 {
82 if(
83 isset($policy["profileName"])
84 && $policy["profileName"] <> ''
85 && isset($policy["profileId"])
86 && $policy["profileId"] <> ''
87 )
88 {
89 $result[$policy["profileId"]] = $policy["profileName"];
90 }
91 }
92
93 return $result;
94 }
95
96 protected function getItems()
97 {
98 $data = '<?xml version="1.0" encoding="utf-8"?>
99 <getSellerProfilesRequest xmlns="http://www.ebay.com/marketplace/sellings">
100 </getSellerProfilesRequest>';
101
102 return $this->sendRequest("getSellerProfiles", $data);
103 }
104
105 protected function sendRequest($operationName, $data)
106 {
107 $this->http->setHeader("X-EBAY-SOA-CONTENT-TYPE", "text/xml");
108 $this->http->setHeader("X-EBAY-SOA-GLOBAL-ID", "EBAY-RU");
109 $this->http->setHeader("X-EBAY-SOA-SERVICE-NAME", "SellerProfilesManagementService");
110 $this->http->setHeader("X-EBAY-SOA-OPERATION-NAME", $operationName); //addSellerProfile getSellerProfiles
111 $this->http->setHeader("X-EBAY-SOA-REQUEST-DATA-FORMAT", "XML");
112 $this->http->setHeader("X-EBAY-SOA-RESPONSE-DATA-FORMAT", "XML");
113 $this->http->setHeader("X-EBAY-SOA-SECURITY-TOKEN", $this->authToken);
114
115 $result = $this->http->post(self::URL, $data);
116 $errors = $this->http->getError();
117
118 if (!$result && !empty($errors))
119 {
120 $strError = "";
121
122 foreach($errors as $errorCode => $errMes)
123 $strError .= $errorCode.": ".$errMes;
124
125 Ebay::log(Logger::LOG_LEVEL_INFO, "EBAY_POLICY_REQUEST_ERROR", $operationName, $strError, $this->siteId);
126 }
127 else
128 {
129 $status = $this->http->getStatus();
130
131 if ($status != 200)
132 Ebay::log(Logger::LOG_LEVEL_INFO, "EBAY_POLICY_REQUEST_HTTP_ERROR", $operationName, 'HTTP error code: '.$status, $this->siteId);
133 }
134
135 return $result;
136 }
137}
$type
Определения options.php:106
static log($level, $type, $itemId, $description, $siteId)
Определения ebay.php:161
sendRequest($operationName, $data)
Определения policy.php:105
getPoliciesNames($type)
Определения policy.php:58
__construct($authToken, $siteId)
Определения policy.php:24
const LOG_LEVEL_INFO
Определения logger.php:16
static convert($xmlData)
Определения xml2array.php:15
static normalize(array $branch)
Определения xml2array.php:69
$data['IS_AVAILABLE']
Определения .description.php:13
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
<? if( $useEditor3):?>< tr class="heading">< td colspan="2"><? echo GetMessage("FILEMAN_OPTION_SPELL_SET");?></td ></tr ><? if(function_exists( 'pspell_config_create')):$use_pspell_checked=(COption::GetOptionString( $module_id, "use_pspell", "Y")=="Y") ? "checked" :"";?>< tr >< td valign="top">< label for="use_pspell"><?echo GetMessage("FILEMAN_OPTION_USE_PSPELL");?></label >< br >< a title="<?echo GetMessage("FILEMAN_OPTION_ADDISH_DICS_TITLE");?> http
Определения options.php:1473
$result
Определения get_property_values.php:14
$errors
Определения iblock_catalog_edit.php:74
$strError
Определения options_user_settings.php:4
$status
Определения session.php:10
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393