-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Alexsisukin/beneficiaryV5
Заполнение/чтение данных о рекламодателе api v5
- Loading branch information
Showing
12 changed files
with
363 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
require '../vendor/autoload.php'; | ||
|
||
$client = new \Promopult\YandexBusinessApi\Client( | ||
new \Promopult\YandexBusinessApi\Config(getenv('__ACCESS_TOKEN__')), | ||
new \GuzzleHttp\Client() | ||
); | ||
|
||
$response = $client | ||
->getCampaignBeneficiaryV5(getenv('__CAMPAIGN_ID__')); | ||
|
||
var_dump($response); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
use Promopult\YandexBusinessApi\Dto\CampaignClient; | ||
use Promopult\YandexBusinessApi\Dto\CampaignContract; | ||
use Promopult\YandexBusinessApi\Dto\CampaignContractor; | ||
use Promopult\YandexBusinessApi\Enum\CampaignClientTypeEnum; | ||
use Promopult\YandexBusinessApi\Enum\CampaignContractorTypeEnum; | ||
use Promopult\YandexBusinessApi\Enum\CampaignContractSubjectTypeEnum; | ||
|
||
require '../vendor/autoload.php'; | ||
|
||
$client = new \Promopult\YandexBusinessApi\Client( | ||
new \Promopult\YandexBusinessApi\Config(getenv('__ACCESS_TOKEN__')), | ||
new \GuzzleHttp\Client() | ||
); | ||
|
||
$campaign_client = new CampaignClient( | ||
type: CampaignClientTypeEnum::LEGAL, | ||
name: 'Зимина Виктория Романовна', | ||
okveds: ['47.91.2'], | ||
inn: '7727563778' | ||
); | ||
$campaign_contractor = new CampaignContractor( | ||
type: CampaignContractorTypeEnum::PHYSICAL, | ||
name: 'Данилова Василиса Викторовна', | ||
inn: '588093656296', | ||
phoneNum: '+7 (911) 222 22 21' | ||
); | ||
|
||
$contract = new CampaignContract( | ||
type: \Promopult\YandexBusinessApi\Enum\CampaignContractTypeEnum::CONTRACT, | ||
number: '123456789', | ||
date: '2023-07-17', | ||
amount: '200000', | ||
isVat: true, | ||
subjectType: CampaignContractSubjectTypeEnum::DISTRIBUTION, | ||
); | ||
|
||
$response = $client | ||
->setCampaignBeneficiaryV5(getenv('__CAMPAIGN_ID__'), $campaign_client, $campaign_contractor, $contract); | ||
|
||
var_dump($response); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace Promopult\YandexBusinessApi\Dto; | ||
|
||
class CampaignBeneficiary | ||
{ | ||
public function __construct( | ||
public CampaignClient $client, | ||
public CampaignContractor $contractor, | ||
public CampaignContract $contract | ||
) { | ||
} | ||
|
||
public static function fromArray(array $data): self | ||
{ | ||
return new self( | ||
client: CampaignClient::fromArray($data['client']), | ||
contractor: CampaignContractor::fromArray($data['contractor']), | ||
contract: CampaignContract::fromArray($data['contract']), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace Promopult\YandexBusinessApi\Dto; | ||
|
||
class CampaignClient | ||
{ | ||
public function __construct( | ||
public string $type, | ||
public string $name, | ||
public array $okveds, | ||
public ?string $inn = null, | ||
public ?string $phoneNum = null, | ||
public ?string $epayNumber = null, | ||
public ?string $oksmNumber = null, | ||
public ?string $vat = null, | ||
public ?string $regNumber = null, | ||
) { | ||
} | ||
|
||
public static function fromArray(array $data): self | ||
{ | ||
return new self( | ||
type: $data['type'], | ||
name: $data['name'], | ||
okveds: $data['okveds'], | ||
inn: $data['inn'] ?? null, | ||
phoneNum: $data['phoneNum'] ?? null, | ||
epayNumber: $data['epayNumber'] ?? null, | ||
oksmNumber: $data['oksmNumber'] ?? null, | ||
vat: $data['vat'] ?? null, | ||
regNumber: $data['regNumber'] ?? null, | ||
); | ||
} | ||
|
||
public function toArray(): array | ||
{ | ||
return array_filter((array) $this); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace Promopult\YandexBusinessApi\Dto; | ||
|
||
class CampaignContract | ||
{ | ||
public function __construct( | ||
public string $type, | ||
public string $number, | ||
public string $date, | ||
public float $amount, | ||
public bool $isVat, | ||
public ?string $actionType = null, | ||
public ?string $subjectType = null, | ||
) { | ||
} | ||
|
||
public static function fromArray(array $data): self | ||
{ | ||
return new self( | ||
type: $data['type'], | ||
number: $data['number'], | ||
date: $data['date'], | ||
amount: $data['amount'], | ||
isVat: $data['isVat'], | ||
actionType: $data['actionType'] ?? null, | ||
subjectType: $data['subjectType'] ?? null, | ||
); | ||
} | ||
|
||
public function toArray(): array | ||
{ | ||
return array_filter((array) $this); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace Promopult\YandexBusinessApi\Dto; | ||
|
||
class CampaignContractor | ||
{ | ||
public function __construct( | ||
public string $type, | ||
public string $name, | ||
public ?string $inn = null, | ||
public ?string $phoneNum = null, | ||
public ?string $epayNumber = null, | ||
public ?string $oksmNumber = null, | ||
public ?string $vat = null, | ||
public ?string $regNumber = null, | ||
) { | ||
} | ||
|
||
public static function fromArray(array $data): self | ||
{ | ||
return new self( | ||
type: $data['type'], | ||
name: $data['name'], | ||
inn: $data['inn'] ?? null, | ||
phoneNum: $data['phoneNum'] ?? null, | ||
epayNumber: $data['epayNumber'] ?? null, | ||
oksmNumber: $data['oksmNumber'] ?? null, | ||
vat: $data['vat'] ?? null, | ||
regNumber: $data['regNumber'] ?? null, | ||
); | ||
} | ||
|
||
public function toArray(): array | ||
{ | ||
return array_filter((array) $this); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace Promopult\YandexBusinessApi\Enum; | ||
|
||
class CampaignClientTypeEnum | ||
{ | ||
/** | ||
* Иностранное юридическое лицо | ||
*/ | ||
public const FOREIGN_LEGAL = 'FOREIGN_LEGAL'; | ||
/** | ||
* Иностранное физическое лицо | ||
*/ | ||
public const FOREIGN_PHYSICAL = 'FOREIGN_PHYSICAL'; | ||
/** | ||
* ИП | ||
*/ | ||
public const INDIVIDUAL = 'INDIVIDUAL'; | ||
/** | ||
* Юридическое лицо | ||
*/ | ||
public const LEGAL = 'LEGAL'; | ||
/** | ||
* Физическое лицо | ||
*/ | ||
public const PHYSICAL = 'PHYSICAL'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace Promopult\YandexBusinessApi\Enum; | ||
|
||
class CampaignContractActionTypeEnum | ||
{ | ||
/** | ||
* Действия в целях распространения рекламы | ||
*/ | ||
public const DISTRIBUTION = 'distribution'; | ||
/** | ||
* Заключение договоров | ||
*/ | ||
public const CONCLUDE = 'conclude'; | ||
/** | ||
* Коммерческое представительство | ||
*/ | ||
public const COMMERCIAL = 'commercial'; | ||
/** | ||
* Иное | ||
*/ | ||
public const OTHER = 'other'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace Promopult\YandexBusinessApi\Enum; | ||
|
||
class CampaignContractSubjectTypeEnum | ||
{ | ||
/** | ||
* Договор на организацию распространения рекламы | ||
*/ | ||
public const ORG_DISTRIBUTION = 'org-distribution'; | ||
/** | ||
* Посредничество | ||
*/ | ||
public const MEDIATION = 'mediation'; | ||
/** | ||
* Договор на распространение рекламы | ||
*/ | ||
public const DISTRIBUTION = 'distribution'; | ||
/** | ||
* Иное | ||
*/ | ||
public const OTHER = 'other'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace Promopult\YandexBusinessApi\Enum; | ||
|
||
class CampaignContractTypeEnum | ||
{ | ||
/** | ||
* Договор оказания услуг | ||
*/ | ||
public const CONTRACT = 'contract'; | ||
/** | ||
* Посреднический договор | ||
*/ | ||
public const INTERMEDIARY_CONTRACT = 'intermediary-contract'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace Promopult\YandexBusinessApi\Enum; | ||
|
||
class CampaignContractorTypeEnum | ||
{ | ||
/** | ||
* Иностранное юридическое лицо | ||
*/ | ||
public const FOREIGN_LEGAL = 'FOREIGN_LEGAL'; | ||
/** | ||
* Иностранное физическое лицо | ||
*/ | ||
public const FOREIGN_PHYSICAL = 'FOREIGN_PHYSICAL'; | ||
/** | ||
* ИП | ||
*/ | ||
public const INDIVIDUAL = 'INDIVIDUAL'; | ||
/** | ||
* Юридическое лицо | ||
*/ | ||
public const LEGAL = 'LEGAL'; | ||
/** | ||
* Физическое лицо | ||
*/ | ||
public const PHYSICAL = 'PHYSICAL'; | ||
} |