Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
PartnerInfoRequestBuilder.php
1<?php
2
4
9
11{
12 private Request $request;
13 private License $license;
14 private string $name;
15 private string $phone;
16 private string $email;
17
18 public function __construct(string $name, string $phone, string $email)
19 {
20 $this->name = $name;
21 $this->email = $email;
22 $this->phone = $phone;
23 $this->request = new Request;
24 $this->license = Application::getInstance()->getLicense();
25 }
26
27 public function setHeaders(): self
28 {
29 $headers = new HttpHeaders();
30 $this->request->setHeaders($headers);
31
32 return $this;
33 }
34
35 public function setUrl(): self
36 {
37 $url = new Uri($this->license->getDomainStoreLicense() . '/key_update.php');
38 $this->request->setUrl($url);
39
40 return $this;
41 }
42
43 public function setProxy(): self
44 {
45 $proxyData = [
46 'host' => \COption::GetOptionString("main", "update_site_proxy_addr", ""),
47 'port' => \COption::GetOptionString("main", "update_site_proxy_port", ""),
48 'user' => \COption::GetOptionString("main", "update_site_proxy_user", ""),
49 'password' => \COption::GetOptionString("main", "update_site_proxy_pass", ""),
50 ];
51
52 $this->request->setProxy($proxyData);
53
54 return $this;
55 }
56
57 public function setBody(): self
58 {
59 $portalInfo = new PortalInfo();
60 $parameters = [
61 'action' => 'send_partner_info',
62 'license_key' => $this->license->getHashLicenseKey(),
63 'partner_id' => $this->license->getPartnerId(),
64 'phone' => $this->phone,
65 'email' => $this->email,
66 'name' => $this->name,
67 'site' => $_SERVER['HTTP_HOST'],
68 ];
69
70 $this->request->setBody($parameters);
71
72 return $this;
73 }
74
75 public function build(): Request
76 {
77 return $this->request;
78 }
79}
__construct(string $name, string $phone, string $email)