-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
social profiles support for contacts
- Loading branch information
Showing
4 changed files
with
256 additions
and
1 deletion.
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
25 changes: 25 additions & 0 deletions
25
src/AmoCRM/Collections/SocialProfiles/SocialProfilesCollection.php
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,25 @@ | ||
<?php | ||
|
||
namespace AmoCRM\Collections\SocialProfiles; | ||
|
||
use AmoCRM\Collections\BaseApiCollection; | ||
use AmoCRM\Models\SocialProfiles\SocialProfileModel; | ||
|
||
/** | ||
* Class SocialProfiles | ||
* | ||
* @package AmoCRM\Collections\SocialProfiles | ||
* | ||
* @method null|SocialProfileModel current() | ||
* @method null|SocialProfileModel last() | ||
* @method null|SocialProfileModel first() | ||
* @method null|SocialProfileModel offsetGet($offset) | ||
* @method SocialProfilesCollection offsetSet($offset, SocialProfileModel $value) | ||
* @method SocialProfilesCollection prepend(SocialProfileModel $value) | ||
* @method SocialProfilesCollection add(SocialProfileModel $value) | ||
* @method null|SocialProfileModel getBy($key, $value) | ||
*/ | ||
class SocialProfilesCollection extends BaseApiCollection | ||
{ | ||
public const ITEM_CLASS = SocialProfileModel::class; | ||
} |
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
182 changes: 182 additions & 0 deletions
182
src/AmoCRM/Models/SocialProfiles/SocialProfileModel.php
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,182 @@ | ||
<?php | ||
|
||
namespace AmoCRM\Models\SocialProfiles; | ||
|
||
use AmoCRM\Exceptions\NotAvailableForActionException; | ||
use AmoCRM\Models\BaseApiModel; | ||
|
||
/** | ||
* Class SocialProfileModel | ||
* | ||
* @package AmoCRM\Models\SocialProfiles | ||
*/ | ||
class SocialProfileModel extends BaseApiModel | ||
{ | ||
/** | ||
* @var string|null | ||
*/ | ||
protected $id; | ||
|
||
/** | ||
* @var string|null | ||
*/ | ||
protected $name; | ||
|
||
/** | ||
* @var string|null | ||
*/ | ||
protected $avatar; | ||
|
||
/** | ||
* @var string|null | ||
*/ | ||
protected $sourceName; | ||
|
||
/** | ||
* @var array|null | ||
*/ | ||
protected $data; | ||
|
||
/** | ||
* @param array $socialProfile | ||
* | ||
* @return self | ||
*/ | ||
public static function fromArray(array $socialProfile): self | ||
{ | ||
$model = new static(); | ||
|
||
$model | ||
->setId($socialProfile['id']) | ||
->setName($socialProfile['name']) | ||
->setAvatar($socialProfile['avatar']) | ||
->setSourceName($socialProfile['source_name']) | ||
->setData($socialProfile['data']); | ||
|
||
return $model; | ||
} | ||
|
||
/** | ||
* @return string|null | ||
*/ | ||
public function getId(): ?string | ||
{ | ||
return $this->id; | ||
} | ||
|
||
/** | ||
* @param string|null $id | ||
* | ||
* @return SocialProfileModel | ||
*/ | ||
public function setId(?string $id): SocialProfileModel | ||
{ | ||
$this->id = $id; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @return string|null | ||
*/ | ||
public function getName(): ?string | ||
{ | ||
return $this->name; | ||
} | ||
|
||
/** | ||
* @param string|null $name | ||
* | ||
* @return SocialProfileModel | ||
*/ | ||
public function setName(?string $name): SocialProfileModel | ||
{ | ||
$this->name = $name; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @return string|null | ||
*/ | ||
public function getAvatar(): ?string | ||
{ | ||
return $this->avatar; | ||
} | ||
|
||
/** | ||
* @param string|null $avatar | ||
* | ||
* @return SocialProfileModel | ||
*/ | ||
public function setAvatar(?string $avatar): SocialProfileModel | ||
{ | ||
$this->avatar = $avatar; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @return string|null | ||
*/ | ||
public function getSourceName(): ?string | ||
{ | ||
return $this->sourceName; | ||
} | ||
|
||
/** | ||
* @param string|null $sourceName | ||
* | ||
* @return SocialProfileModel | ||
*/ | ||
public function setSourceName(?string $sourceName): SocialProfileModel | ||
{ | ||
$this->sourceName = $sourceName; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @return array|null | ||
*/ | ||
public function getData(): ?array | ||
{ | ||
return $this->data; | ||
} | ||
|
||
/** | ||
* @param array|null $data | ||
* | ||
* @return SocialProfileModel | ||
*/ | ||
public function setData(?array $data): SocialProfileModel | ||
{ | ||
$this->data = $data; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function toArray(): array | ||
{ | ||
return [ | ||
'id' => $this->getId(), | ||
'name' => $this->getName(), | ||
'avatar' => $this->getAvatar(), | ||
'source_name' => $this->getSourceName(), | ||
'data' => $this->getData(), | ||
]; | ||
} | ||
|
||
/** | ||
* @param string|null $requestId | ||
* @return array | ||
* @throws NotAvailableForActionException | ||
*/ | ||
public function toApi(?string $requestId = "0"): array | ||
{ | ||
throw new NotAvailableForActionException(); | ||
} | ||
} |