├── .editorconfig
├── .github
└── logo.png
├── .gitignore
├── .phpcs.xml
├── .travis.yml
├── LICENSE
├── README.md
├── composer.json
├── examples
├── .env.dist
├── account_actions.php
├── bootstrap.php
├── calls.php
├── catalog_rights.php
├── catalogs_actions.php
├── catalogs_elements_actions.php
├── chained_list_custom_field_actions.php
├── chat_templates_actions.php
├── companies_actions.php
├── contacts_actions.php
├── currencies_actions.php
├── custom_field_groups_actions.php
├── custom_field_select_actions.php
├── custom_fields_actions.php
├── customers_actions.php
├── error_printer.php
├── exchange_api_key.php
├── file_custom_field_actions.php
├── files_actions.php
├── get_account_subdomain.php
├── get_token.php
├── invoices_actions.php
├── leads_actions.php
├── leads_complex_actions.php
├── links_actions.php
├── links_chat_actions.php
├── links_mass_actions.php
├── long_lived_token.php
├── loss_reasons_actions.php
├── monetary_custom_field_actions.php
├── notes_actions.php
├── parse_disposable_token.php
├── pipelines_actions.php
├── roles_actions.php
├── segments_actions.php
├── short_links_actions.php
├── sources_actions.php
├── statuses_actions.php
├── subscriptions_actions.php
├── tags_actions.php
├── talks_actions.php
├── tasks_actions.php
├── token_actions.php
├── transactions_actions.php
├── unsorted_actions.php
├── user_context_actions.php
├── users_actions.php
├── webhooks_actions.php
├── website_buttons_actions.php
└── widgets_actions.php
├── phpunit.xml
├── src
└── AmoCRM
│ ├── Client
│ ├── AmoCRMApiClient.php
│ ├── AmoCRMApiClientFactory.php
│ ├── AmoCRMApiRequest.php
│ └── LongLivedAccessToken.php
│ ├── Collections
│ ├── BaseApiCollection.php
│ ├── CallsCollection.php
│ ├── CatalogElementsCollection.php
│ ├── CatalogsCollection.php
│ ├── ChatLinksCollection.php
│ ├── Chats
│ │ └── Templates
│ │ │ ├── Buttons
│ │ │ └── ButtonsCollection.php
│ │ │ ├── ReviewsCollection.php
│ │ │ └── TemplatesCollection.php
│ ├── CompaniesCollection.php
│ ├── ContactsCollection.php
│ ├── CurrenciesCollection.php
│ ├── CustomFieldGroupsCollection.php
│ ├── CustomFields
│ │ ├── CustomFieldEnumsCollection.php
│ │ ├── CustomFieldNestedCollection.php
│ │ ├── CustomFieldRequiredStatusesCollection.php
│ │ └── CustomFieldsCollection.php
│ ├── CustomFieldsValuesCollection.php
│ ├── Customers
│ │ ├── CustomersCollection.php
│ │ ├── Segments
│ │ │ └── SegmentsCollection.php
│ │ ├── Statuses
│ │ │ └── StatusesCollection.php
│ │ └── Transactions
│ │ │ └── TransactionsCollection.php
│ ├── EventTypesCollections.php
│ ├── EventsCollections.php
│ ├── FileLinksCollection.php
│ ├── FilePreviewsCollection.php
│ ├── FilesCollection.php
│ ├── Interfaces
│ │ └── HasPagesInterface.php
│ ├── Leads
│ │ ├── LeadsCollection.php
│ │ ├── LossReasons
│ │ │ └── LossReasonsCollection.php
│ │ ├── Pipelines
│ │ │ ├── PipelinesCollection.php
│ │ │ └── Statuses
│ │ │ │ ├── StatusesCollection.php
│ │ │ │ └── StatusesDescriptionsCollection.php
│ │ └── Unsorted
│ │ │ ├── FormsUnsortedCollection.php
│ │ │ ├── SipUnsortedCollection.php
│ │ │ └── UnsortedCollection.php
│ ├── LinksCollection.php
│ ├── NotesCollection.php
│ ├── NullTagsCollection.php
│ ├── RolesCollection.php
│ ├── ShortLinks
│ │ └── ShortLinksCollection.php
│ ├── SocialProfiles
│ │ └── SocialProfilesCollection.php
│ ├── Sources
│ │ ├── SourceServicesCollection.php
│ │ ├── SourceServicesPagesCollection.php
│ │ └── WebsiteButtonsCollection.php
│ ├── SourcesCollection.php
│ ├── SubscriptionsCollection.php
│ ├── TagsCollection.php
│ ├── TaskTypesCollection.php
│ ├── TasksCollection.php
│ ├── Traits
│ │ ├── EntityApiTrait.php
│ │ └── PagesTrait.php
│ ├── UsersCollection.php
│ ├── UsersGroupsCollection.php
│ ├── WebhooksCollection.php
│ └── Widgets
│ │ ├── SettingsTemplatesCollection.php
│ │ └── WidgetsCollection.php
│ ├── Contracts
│ └── Support
│ │ ├── Arrayable.php
│ │ └── Jsonable.php
│ ├── EntitiesServices
│ ├── Account.php
│ ├── BaseEntity.php
│ ├── BaseEntityIdEntity.php
│ ├── BaseEntityTypeEntity.php
│ ├── BaseEntityTypeEntityIdEntity.php
│ ├── Calls.php
│ ├── CatalogElements.php
│ ├── Catalogs.php
│ ├── Chats
│ │ └── Templates.php
│ ├── Companies.php
│ ├── Contacts.php
│ ├── Currencies.php
│ ├── CustomFieldGroups.php
│ ├── CustomFields.php
│ ├── Customers
│ │ ├── BonusPoints.php
│ │ ├── Customers.php
│ │ ├── Statuses.php
│ │ └── Transactions.php
│ ├── EntityFiles.php
│ ├── EntityNotes.php
│ ├── EntitySubscriptions.php
│ ├── EntityTags.php
│ ├── EventTypes.php
│ ├── Events.php
│ ├── Files.php
│ ├── HasDeleteMethodInterface.php
│ ├── HasLinkMethodInterface.php
│ ├── Interfaces
│ │ ├── HasPageMethodsInterface.php
│ │ └── HasParentEntity.php
│ ├── Leads.php
│ ├── Leads
│ │ ├── LossReasons.php
│ │ ├── Pipelines.php
│ │ └── Statuses.php
│ ├── Links.php
│ ├── Products.php
│ ├── Roles.php
│ ├── Segments.php
│ ├── ShortLinks.php
│ ├── Sources.php
│ ├── Sources
│ │ └── WebsiteButtons.php
│ ├── Talks.php
│ ├── Tasks.php
│ ├── Traits
│ │ ├── LinkMethodsTrait.php
│ │ ├── PageMethodsTrait.php
│ │ └── WithParentEntityMethodsTrait.php
│ ├── Unsorted.php
│ ├── Users.php
│ ├── Webhooks.php
│ └── Widgets.php
│ ├── Enum
│ ├── Chats
│ │ └── Templates
│ │ │ ├── Attachment
│ │ │ └── TypesEnum.php
│ │ │ └── Buttons
│ │ │ └── ButtonsEnums.php
│ ├── Invoices
│ │ └── BillStatusEnumCode.php
│ ├── InvoicesCustomFieldsEnums.php
│ ├── PayerCustomFieldsTypesEnums.php
│ ├── Sources
│ │ └── SourceServiceTypeEnum.php
│ ├── SuppliersCustomFieldsEnums.php
│ └── Tags
│ │ └── TagColorsEnum.php
│ ├── Exceptions
│ ├── AmoCRMApiConnectExceptionException.php
│ ├── AmoCRMApiErrorResponseException.php
│ ├── AmoCRMApiException.php
│ ├── AmoCRMApiHttpClientException.php
│ ├── AmoCRMApiNoContentException.php
│ ├── AmoCRMApiPageNotAvailableException.php
│ ├── AmoCRMApiTooManyRedirectsException.php
│ ├── AmoCRMApiTooManyRequestsException.php
│ ├── AmoCRMMissedTokenException.php
│ ├── AmoCRMoAuthApiException.php
│ ├── BadTypeException.php
│ ├── CollectionAndResponseKeysNotIndenticalException.php
│ ├── CollectionKeysNotSequentialException.php
│ ├── DisposableTokenExpiredException.php
│ ├── DisposableTokenInvalidDestinationException.php
│ ├── DisposableTokenVerificationFailedException.php
│ ├── InvalidArgumentException.php
│ ├── NotAvailableForActionException.php
│ └── StringCollectionKeyException.php
│ ├── Filters
│ ├── BaseEntityFilter.php
│ ├── BaseRangeFilter.php
│ ├── CatalogElementsFilter.php
│ ├── CatalogsFilter.php
│ ├── ChatLinksFilter.php
│ ├── Chats
│ │ └── TemplatesFilter.php
│ ├── CompaniesFilter.php
│ ├── ContactsFilter.php
│ ├── CurrenciesFilter.php
│ ├── CustomFieldsFilter.php
│ ├── CustomersFilter.php
│ ├── EntitiesLinksFilter.php
│ ├── EventsFilter.php
│ ├── Interfaces
│ │ ├── HasOrderInterface.php
│ │ └── HasPagesInterface.php
│ ├── LeadsFilter.php
│ ├── LinksFilter.php
│ ├── NotesFilter.php
│ ├── PagesFilter.php
│ ├── SourcesFilter.php
│ ├── TagsFilter.php
│ ├── TasksFilter.php
│ ├── Traits
│ │ ├── ArrayOrNumericFilterTrait.php
│ │ ├── ArrayOrStringFilterTrait.php
│ │ ├── IntOrIntRangeFilterTrait.php
│ │ ├── OrderTrait.php
│ │ └── PagesFilterTrait.php
│ ├── UnsortedFilter.php
│ ├── UnsortedSummaryFilter.php
│ └── WebhooksFilter.php
│ ├── Helpers
│ ├── CustomFieldHelper.php
│ └── EntityTypesInterface.php
│ ├── Models
│ ├── AccountDomainModel.php
│ ├── AccountModel.php
│ ├── AccountSettings
│ │ ├── AmojoRights.php
│ │ ├── DateTimeSettings.php
│ │ ├── InvoicesSettings.php
│ │ ├── TaskType.php
│ │ └── UsersGroup.php
│ ├── BaseApiModel.php
│ ├── BotDisposableTokenModel.php
│ ├── CallModel.php
│ ├── CatalogElementModel.php
│ ├── CatalogModel.php
│ ├── ChatLinkModel.php
│ ├── Chats
│ │ └── Templates
│ │ │ ├── AttachmentModel.php
│ │ │ ├── Buttons
│ │ │ ├── AbstractButtonModel.php
│ │ │ ├── TextButtonModel.php
│ │ │ └── UrlButtonModel.php
│ │ │ ├── ReviewModel.php
│ │ │ └── TemplateModel.php
│ ├── CompanyModel.php
│ ├── ContactModel.php
│ ├── CurrencyModel.php
│ ├── CustomFieldGroupModel.php
│ ├── CustomFields
│ │ ├── BirthdayCustomFieldModel.php
│ │ ├── CategoryCustomFieldModel.php
│ │ ├── ChainedList.php
│ │ ├── ChainedListCustomFieldModel.php
│ │ ├── ChainedLists.php
│ │ ├── CheckboxCustomFieldModel.php
│ │ ├── CustomFieldModel.php
│ │ ├── DateCustomFieldModel.php
│ │ ├── DateTimeCustomFieldModel.php
│ │ ├── EnumModel.php
│ │ ├── Factories
│ │ │ └── CustomFieldModelFactory.php
│ │ ├── FileCustomFieldModel.php
│ │ ├── ItemsCustomFieldModel.php
│ │ ├── LegalEntityCustomFieldModel.php
│ │ ├── LinkedEntityCustomFieldModel.php
│ │ ├── MonetaryCustomFieldModel.php
│ │ ├── MultiselectCustomFieldModel.php
│ │ ├── MultitextCustomFieldModel.php
│ │ ├── NestedModel.php
│ │ ├── NumericCustomFieldModel.php
│ │ ├── OrgLegalNameCustomFieldModel.php
│ │ ├── PayerCustomFieldModel.php
│ │ ├── PriceCustomFieldModel.php
│ │ ├── RadiobuttonCustomFieldModel.php
│ │ ├── RequiredStatusModel.php
│ │ ├── SelectCustomFieldModel.php
│ │ ├── SmartAddressCustomFieldModel.php
│ │ ├── StreetAddressCustomFieldModel.php
│ │ ├── SupplierCustomFieldModel.php
│ │ ├── TextCustomFieldModel.php
│ │ ├── TextareaCustomFieldModel.php
│ │ ├── TrackingDataCustomFieldModel.php
│ │ ├── UrlCustomFieldModel.php
│ │ └── WithEnumCustomFieldModel.php
│ ├── CustomFieldsValues
│ │ ├── BaseCustomFieldValuesModel.php
│ │ ├── BirthdayCustomFieldValuesModel.php
│ │ ├── CategoryCustomFieldValuesModel.php
│ │ ├── ChainedListCustomFieldValuesModel.php
│ │ ├── CheckboxCustomFieldValuesModel.php
│ │ ├── DateCustomFieldValuesModel.php
│ │ ├── DateTimeCustomFieldValuesModel.php
│ │ ├── Factories
│ │ │ ├── CustomFieldValueCollectionFactory.php
│ │ │ ├── CustomFieldValueModelFactory.php
│ │ │ └── CustomFieldValuesModelFactory.php
│ │ ├── FileCustomFieldValuesModel.php
│ │ ├── ItemsCustomFieldValuesModel.php
│ │ ├── LegalEntityCustomFieldValuesModel.php
│ │ ├── LinkedEntityCustomFieldValuesModel.php
│ │ ├── MonetaryCustomFieldValuesModel.php
│ │ ├── MultiselectCustomFieldValuesModel.php
│ │ ├── MultitextCustomFieldValuesModel.php
│ │ ├── NumericCustomFieldValuesModel.php
│ │ ├── OrgLegalNameCustomFieldValuesModel.php
│ │ ├── PayerCustomFieldValuesModel.php
│ │ ├── PriceCustomFieldValuesModel.php
│ │ ├── RadiobuttonCustomFieldValuesModel.php
│ │ ├── SelectCustomFieldValuesModel.php
│ │ ├── SmartAddressCustomFieldValuesModel.php
│ │ ├── StreetAddressCustomFieldValuesModel.php
│ │ ├── SupplierCustomFieldValuesModel.php
│ │ ├── TextCustomFieldValuesModel.php
│ │ ├── TextareaCustomFieldValuesModel.php
│ │ ├── TrackingDataCustomFieldValuesModel.php
│ │ ├── UrlCustomFieldValuesModel.php
│ │ ├── ValueCollections
│ │ │ ├── BaseCustomFieldValueCollection.php
│ │ │ ├── BirthdayCustomFieldValueCollection.php
│ │ │ ├── CategoryCustomFieldValueCollection.php
│ │ │ ├── ChainedListCustomFieldValueCollection.php
│ │ │ ├── CheckboxCustomFieldValueCollection.php
│ │ │ ├── DateCustomFieldValueCollection.php
│ │ │ ├── DateTimeCustomFieldValueCollection.php
│ │ │ ├── FileCustomFieldValueCollection.php
│ │ │ ├── ItemsCustomFieldValueCollection.php
│ │ │ ├── LegalEntityCustomFieldValueCollection.php
│ │ │ ├── LinkedEntityCustomFieldValueCollection.php
│ │ │ ├── MonetaryCustomFieldValueCollection.php
│ │ │ ├── MultiselectCustomFieldValueCollection.php
│ │ │ ├── MultitextCustomFieldValueCollection.php
│ │ │ ├── NullCustomFieldValueCollection.php
│ │ │ ├── NumericCustomFieldValueCollection.php
│ │ │ ├── OrgLegalNameCustomFieldValueCollection.php
│ │ │ ├── PayerCustomFieldValueCollection.php
│ │ │ ├── PriceCustomFieldValueCollection.php
│ │ │ ├── RadiobuttonCustomFieldValueCollection.php
│ │ │ ├── SelectCustomFieldValueCollection.php
│ │ │ ├── SmartAddressCustomFieldValueCollection.php
│ │ │ ├── StreetAddressCustomFieldValueCollection.php
│ │ │ ├── SupplierCustomFieldValueCollection.php
│ │ │ ├── TextCustomFieldValueCollection.php
│ │ │ ├── TextareaCustomFieldValueCollection.php
│ │ │ ├── TrackingDataCustomFieldValueCollection.php
│ │ │ └── UrlCustomFieldValueCollection.php
│ │ └── ValueModels
│ │ │ ├── BaseArrayCustomFieldValueModel.php
│ │ │ ├── BaseCustomFieldValueModel.php
│ │ │ ├── BaseEnumCodeCustomFieldValueModel.php
│ │ │ ├── BaseEnumCustomFieldValueModel.php
│ │ │ ├── BirthdayCustomFieldValueModel.php
│ │ │ ├── CategoryCustomFieldValueModel.php
│ │ │ ├── ChainedListCustomFieldValueModel.php
│ │ │ ├── CheckboxCustomFieldValueModel.php
│ │ │ ├── DateCustomFieldValueModel.php
│ │ │ ├── DateTimeCustomFieldValueModel.php
│ │ │ ├── FileCustomFieldValueModel.php
│ │ │ ├── ItemsCustomFieldValueModel.php
│ │ │ ├── LegalEntityCustomFieldValueModel.php
│ │ │ ├── LinkedEntityCustomFieldValueModel.php
│ │ │ ├── MonetaryCustomFieldValueModel.php
│ │ │ ├── MultiselectCustomFieldValueModel.php
│ │ │ ├── MultitextCustomFieldValueModel.php
│ │ │ ├── NumericCustomFieldValueModel.php
│ │ │ ├── OrgLegalNameCustomFieldValueModel.php
│ │ │ ├── PayerCustomFieldValueModel.php
│ │ │ ├── PriceCustomFieldValueModel.php
│ │ │ ├── RadiobuttonCustomFieldValueModel.php
│ │ │ ├── SelectCustomFieldValueModel.php
│ │ │ ├── SmartAddressCustomFieldValueModel.php
│ │ │ ├── StreetAdressCustomFieldValueModel.php
│ │ │ ├── SupplierCustomFieldValueModel.php
│ │ │ ├── TextCustomFieldValueModel.php
│ │ │ ├── TextareaCustomFieldValueModel.php
│ │ │ ├── TrackingDataCustomFieldValueModel.php
│ │ │ └── UrlCustomFieldValueModel.php
│ ├── Customers
│ │ ├── BonusPointsActionModel.php
│ │ ├── CustomerModel.php
│ │ ├── Segments
│ │ │ └── SegmentModel.php
│ │ ├── Statuses
│ │ │ └── StatusModel.php
│ │ └── Transactions
│ │ │ └── TransactionModel.php
│ ├── DisposableTokenModel.php
│ ├── EventModel.php
│ ├── EventTypeModel.php
│ ├── Factories
│ │ ├── EntityFactory.php
│ │ ├── NoteFactory.php
│ │ ├── UnsortedMetadataFactory.php
│ │ └── UnsortedModelFactory.php
│ ├── FileLinkModel.php
│ ├── Files
│ │ ├── FileModel.php
│ │ ├── FilePreviewModel.php
│ │ └── FileUploadModel.php
│ ├── Interfaces
│ │ ├── CallInterface.php
│ │ ├── CanBeLinkedInterface.php
│ │ ├── CanReturnDeletedInterface.php
│ │ ├── ComplexTagsManagerInterface.php
│ │ ├── EntityApiInterface.php
│ │ ├── HasIdInterface.php
│ │ └── TypeAwareInterface.php
│ ├── InvoiceWarningModel.php
│ ├── LeadModel.php
│ ├── Leads
│ │ ├── LossReasons
│ │ │ └── LossReasonModel.php
│ │ └── Pipelines
│ │ │ ├── PipelineModel.php
│ │ │ └── Statuses
│ │ │ ├── StatusDescriptionModel.php
│ │ │ └── StatusModel.php
│ ├── LinkModel.php
│ ├── NoteModel.php
│ ├── NoteType
│ │ ├── AiResultNote.php
│ │ ├── AmoMailMessageNote.php
│ │ ├── AttachmentNote.php
│ │ ├── BaseServiceMessageNote.php
│ │ ├── BillPaidNote.php
│ │ ├── CallInNote.php
│ │ ├── CallNote.php
│ │ ├── CallOutNote.php
│ │ ├── ChatNote.php
│ │ ├── CommonNote.php
│ │ ├── DropboxNote.php
│ │ ├── ExtendedServiceMessageNote.php
│ │ ├── FollowedLinkNote.php
│ │ ├── GeolocationNote.php
│ │ ├── InvoicePaidNote.php
│ │ ├── MessageCashierNote.php
│ │ ├── NoParamNote.php
│ │ ├── OnlyTextParamNote.php
│ │ ├── ServiceMessageNote.php
│ │ ├── SiteVisitNote.php
│ │ ├── SmsInNote.php
│ │ ├── SmsNote.php
│ │ ├── SmsOutNote.php
│ │ ├── TargetingInNote.php
│ │ ├── TargetingNote.php
│ │ ├── TargetingOutNote.php
│ │ ├── TransactionNote.php
│ │ └── ZoomMeetingNote.php
│ ├── ProductsSettingsModel.php
│ ├── Rights
│ │ └── RightModel.php
│ ├── RoleModel.php
│ ├── ShortLinks
│ │ └── ShortLinkModel.php
│ ├── SocialProfiles
│ │ └── SocialProfileModel.php
│ ├── SourceModel.php
│ ├── Sources
│ │ ├── SourceServiceModel.php
│ │ ├── SourceServicePageModel.php
│ │ ├── SourceServiceParams.php
│ │ ├── WebsiteButtonCreateRequestModel.php
│ │ ├── WebsiteButtonCreateResponseModel.php
│ │ ├── WebsiteButtonModel.php
│ │ └── WebsiteButtonUpdateRequestModel.php
│ ├── SubscriptionModel.php
│ ├── TagModel.php
│ ├── TalkModel.php
│ ├── Talks
│ │ └── TalkCloseActionModel.php
│ ├── TaskModel.php
│ ├── Traits
│ │ ├── CallTrait.php
│ │ ├── GetLinkTrait.php
│ │ ├── MutateTagsTrait.php
│ │ └── RequestIdTrait.php
│ ├── Unsorted
│ │ ├── AcceptUnsortedModel.php
│ │ ├── BaseUnsortedModel.php
│ │ ├── ChatsMetadata.php
│ │ ├── DeclineUnsortedModel.php
│ │ ├── FormUnsortedModel.php
│ │ ├── FormsMetadata.php
│ │ ├── Interfaces
│ │ │ └── UnsortedMetadataInterface.php
│ │ ├── LinkUnsortedModel.php
│ │ ├── MailMetadata.php
│ │ ├── SipMetadata.php
│ │ ├── SipUnsortedModel.php
│ │ └── UnsortedSummaryModel.php
│ ├── UserModel.php
│ ├── WebhookModel.php
│ └── Widgets
│ │ ├── SettingTemplateModel.php
│ │ └── WidgetModel.php
│ ├── OAuth
│ ├── AmoCRMOAuth.php
│ ├── OAuthConfigInterface.php
│ └── OAuthServiceInterface.php
│ └── Support
│ └── Str.php
└── tests
└── Cases
├── AmoCRM
├── Client
│ └── AmoCRMApiClientTest.php
├── Collections
│ └── Leads
│ │ └── LeadsCollectionTest.php
├── Filters
│ ├── EventsFilterTest.php
│ └── LeadsFilterTest.php
├── Models
│ ├── CustomFieldsValues
│ │ └── ValueModel
│ │ │ └── DateCustomFieldValueModelTest.php
│ └── NoteModelTest.php
└── OAuth
│ └── AmoCRMOAuth.php
├── CustomField
└── NestedFieldTest.php
├── NoteTypes
├── CallInNoteTest.php
└── CommonNoteTest.php
└── Rights
└── CatalogRightsTest.php
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | charset = utf-8
5 | end_of_line = lf
6 | indent_size = 4
7 | indent_style = space
8 | insert_final_newline = true
9 | trim_trailing_whitespace = true
10 |
11 | [*.{yml,yaml}]
12 | indent_size = 2
13 |
14 | [*.json]
15 | indent_size = 2
16 |
17 | [*.php]
18 | ij_any_align_multiline_parameters = false
19 | ij_php_space_after_type_cast = false
20 |
--------------------------------------------------------------------------------
/.github/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amocrm/amocrm-api-php/cf4208364bfe66ec1f9e19593a15844d2ae52807/.github/logo.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | vendor/
2 | composer.phar
3 | composer.lock
4 | .idea
5 | examples/.env
6 | .phpunit.result.cache
7 | /.DS_Store
8 |
--------------------------------------------------------------------------------
/.phpcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | The coding standard for amoCRM.
4 |
5 | src
6 | examples
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: php
2 |
3 | cache:
4 | directories:
5 | - vendor
6 | - $HOME/.composer/cache
7 |
8 | env: MINIMUM_VERSIONS=false
9 |
10 | os: linux
11 | dist: bionic
12 |
13 | php:
14 | - 7.1
15 | - 7.2
16 | - 7.3
17 | - 7.4
18 | - 8.0
19 | - 8.1
20 | - 8.2
21 | - 8.3
22 | - 8.4
23 |
24 | install:
25 | - if [[ $MINIMUM_VERSIONS = false ]]; then composer install; fi
26 | - if [[ $MINIMUM_VERSIONS = true ]]; then composer update --no-interaction --prefer-lowest; fi
27 |
28 | jobs:
29 | include:
30 | - stage: style check
31 | script: composer run style:check
32 | - stage: unit tests
33 | script: composer run test
34 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2020 amoCRM.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "amocrm/amocrm-api-library",
3 | "description": "amoCRM API Client",
4 | "license": "MIT",
5 | "authors": [
6 | {
7 | "name": "Nikita Bessudnov",
8 | "email": "nbessudnov@team.amocrm.com",
9 | "homepage": "https://github.com/bessudnov"
10 | }
11 | ],
12 | "keywords": [
13 | "amocrm api",
14 | "oauth2",
15 | "api client",
16 | "client",
17 | "authorization",
18 | "authorisation",
19 | "amocrm"
20 | ],
21 | "require": {
22 | "php": ">=7.1 || >=8.0",
23 | "ext-fileinfo": "*",
24 | "ext-json": "*",
25 | "amocrm/oauth2-amocrm": "^3.0",
26 | "fig/http-message-util": "1.*",
27 | "guzzlehttp/guzzle": "6.* || 7.*",
28 | "lcobucci/clock": "1.1.0 ||^2.0.0",
29 | "lcobucci/jwt": "^3.4.6 || ^4.0.4 || ^5.0",
30 | "nesbot/carbon": "^2.72.6 || ^3.8.4",
31 | "ramsey/uuid": "^3 || ^4",
32 | "symfony/dotenv": "3.* || 4.* || 5.* || 6.* || 7.*"
33 | },
34 | "require-dev": {
35 | "phpunit/phpunit": "7.* || 8.* || 9.*",
36 | "roave/security-advisories": "dev-latest",
37 | "squizlabs/php_codesniffer": "^3.5.2"
38 | },
39 | "autoload": {
40 | "psr-4": {
41 | "AmoCRM\\": "src/AmoCRM"
42 | }
43 | },
44 | "scripts": {
45 | "test": "vendor/bin/phpunit -c phpunit.xml",
46 | "style:check": "vendor/bin/phpcs",
47 | "style:fix": "vendor/bin/phpcbf",
48 | "serve": "php -S localhost:8181",
49 | "git:prepush": [
50 | "@style:check",
51 | "@test"
52 | ]
53 | },
54 | "config": {
55 | "sort-packages": true
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/examples/.env.dist:
--------------------------------------------------------------------------------
1 | CLIENT_ID=
2 | CLIENT_SECRET=
3 | CLIENT_REDIRECT_URI=
--------------------------------------------------------------------------------
/examples/account_actions.php:
--------------------------------------------------------------------------------
1 | setAccessToken($accessToken)
12 | ->setAccountBaseDomain($accessToken->getValues()['baseDomain'])
13 | ->onAccessTokenRefresh(
14 | function (AccessTokenInterface $accessToken, string $baseDomain) {
15 | saveToken(
16 | [
17 | 'accessToken' => $accessToken->getToken(),
18 | 'refreshToken' => $accessToken->getRefreshToken(),
19 | 'expires' => $accessToken->getExpires(),
20 | 'baseDomain' => $baseDomain,
21 | ]
22 | );
23 | }
24 | );
25 |
26 |
27 | //Получим свойства аккаунта со всеми доступными свойствами
28 | try {
29 | $account = $apiClient->account()->getCurrent(AccountModel::getAvailableWith());
30 | var_dump($account->toArray());
31 | } catch (AmoCRMApiException $e) {
32 | printError($e);
33 | }
34 |
--------------------------------------------------------------------------------
/examples/bootstrap.php:
--------------------------------------------------------------------------------
1 | load(__DIR__ . '/.env.dist', __DIR__ . '/.env');
10 |
11 | $clientId = $_ENV['CLIENT_ID'];
12 | $clientSecret = $_ENV['CLIENT_SECRET'];
13 | $redirectUri = $_ENV['CLIENT_REDIRECT_URI'];
14 |
15 | $apiClient = new AmoCRMApiClient($clientId, $clientSecret, $redirectUri);
16 |
17 | include_once __DIR__ . '/token_actions.php';
18 | include_once __DIR__ . '/error_printer.php';
19 |
--------------------------------------------------------------------------------
/examples/calls.php:
--------------------------------------------------------------------------------
1 | setAccessToken($accessToken)
14 | ->setAccountBaseDomain($accessToken->getValues()['baseDomain'])
15 | ->onAccessTokenRefresh(
16 | function (AccessTokenInterface $accessToken, string $baseDomain) {
17 | saveToken(
18 | [
19 | 'accessToken' => $accessToken->getToken(),
20 | 'refreshToken' => $accessToken->getRefreshToken(),
21 | 'expires' => $accessToken->getExpires(),
22 | 'baseDomain' => $baseDomain,
23 | ]
24 | );
25 | }
26 | );
27 |
28 | //Добавим входящий звонок
29 | $call = new CallModel();
30 | $call
31 | ->setPhone('+7912312321') // кто звонил
32 | ->setCallStatus(CallInterface::CALL_STATUS_SUCCESS_CONVERSATION)
33 | ->setCallResult('Разговор состоялся')
34 | ->setDuration(148)
35 | ->setUniq(Uuid::uuid4())
36 | ->setSource('integration name')
37 | ->setDirection(CallInterface::CALL_DIRECTION_IN)
38 | ->setCallResponsible('+79161234567') // кому звонили, можно id пользователя, или строку
39 | ->setLink('https://example.test/test.mp3');
40 |
41 | try {
42 | $call = $apiClient->calls()->addOne($call);
43 | } catch (AmoCRMApiException $e) {
44 | printError($e);
45 | die;
46 | }
47 |
--------------------------------------------------------------------------------
/examples/error_printer.php:
--------------------------------------------------------------------------------
1 | getTitle();
9 | $code = $e->getCode();
10 | $debugInfo = var_export($e->getLastRequestInfo(), true);
11 |
12 | $validationErrors = null;
13 | if ($e instanceof AmoCRMApiErrorResponseException) {
14 | $validationErrors = var_export($e->getValidationErrors(), true);
15 | }
16 |
17 | $error = <<' . $error . '';
28 | }
29 |
--------------------------------------------------------------------------------
/examples/exchange_api_key.php:
--------------------------------------------------------------------------------
1 | setAccessToken($accessToken)
11 | ->setAccountBaseDomain($accessToken->getValues()['baseDomain'])
12 | ->onAccessTokenRefresh(
13 | function (AccessTokenInterface $accessToken, string $baseDomain) {
14 | saveToken(
15 | [
16 | 'accessToken' => $accessToken->getToken(),
17 | 'refreshToken' => $accessToken->getRefreshToken(),
18 | 'expires' => $accessToken->getExpires(),
19 | 'baseDomain' => $baseDomain,
20 | ]
21 | );
22 | }
23 | );
24 |
25 | //Сделаем запрос с апи ключом, чтобы получить код авторизации
26 | //Код авторизации отправляется в виде вебхука на указанный redirect_uri c GET-параметром from_exchange=1
27 | $login = 'example@example.com';
28 | $apiKey = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
29 | try {
30 | $apiClient->getOAuthClient()->exchangeApiKey($login, $apiKey);
31 | } catch (AmoCRMApiException $e) {
32 | printError($e);
33 | die;
34 | }
35 |
--------------------------------------------------------------------------------
/examples/get_account_subdomain.php:
--------------------------------------------------------------------------------
1 | getOAuthClient()
26 | ->getAccountDomainByRefreshToken($accessToken);
27 |
28 | var_dump($accountDomainModel->toArray());
29 |
30 | // Возьмём из полученной модели текущий subdomain аккаунта и засетим наш субдомен аккаунта в апи клиенте
31 | $apiClient->setAccountBaseDomain($accountDomainModel->getDomain());
32 |
33 | var_dump($apiClient->getAccountBaseDomain());
34 | } catch (AmoCRMApiException $e) {
35 | printError($e);
36 | die;
37 | }
38 |
--------------------------------------------------------------------------------
/examples/long_lived_token.php:
--------------------------------------------------------------------------------
1 | setAccessToken($longLivedAccessToken)
22 | ->setAccountBaseDomain($accountUrl);
23 |
24 | //Получим информацию об аккаунте
25 | try {
26 | $account = $apiClient->account()->getCurrent();
27 | } catch (AmoCRMApiException $e) {
28 | var_dump($e->getTraceAsString());
29 | printError($e);
30 | die;
31 | }
32 |
33 | echo $account->getName();
34 |
--------------------------------------------------------------------------------
/examples/parse_disposable_token.php:
--------------------------------------------------------------------------------
1 | getOAuthClient()
34 | ->parseDisposableToken($token);
35 |
36 | var_dump($disposableTokenModel->toArray());
37 | } catch (DisposableTokenExpiredException $e) {
38 | // Время жизни токена истекло
39 | printError($e);
40 | die;
41 | } catch (DisposableTokenInvalidDestinationException $e) {
42 | // Не прошёл проверку на адресата токена
43 | printError($e);
44 | die;
45 | } catch (DisposableTokenVerificationFailedException $e) {
46 | // Токен не прошел проверку подписи
47 | printError($e);
48 | die;
49 | }
50 |
--------------------------------------------------------------------------------
/examples/short_links_actions.php:
--------------------------------------------------------------------------------
1 | setAccessToken($accessToken)
13 | ->setAccountBaseDomain($accessToken->getValues()['baseDomain'])
14 | ->onAccessTokenRefresh(
15 | function (AccessTokenInterface $accessToken, string $baseDomain) {
16 | saveToken(
17 | [
18 | 'accessToken' => $accessToken->getToken(),
19 | 'refreshToken' => $accessToken->getRefreshToken(),
20 | 'expires' => $accessToken->getExpires(),
21 | 'baseDomain' => $baseDomain,
22 | ]
23 | );
24 | }
25 | );
26 |
27 | //Сервис коротких ссылок
28 | $shortLinksService = $apiClient->shortLinks();
29 |
30 | //Создадим ссылку
31 | $shortLink = new ShortLinkModel();
32 | $shortLink
33 | ->setUrl('https://example.com')
34 | ->setEntityType(EntityTypesInterface::CONTACTS)
35 | ->setEntityId(11070881);
36 |
37 | try {
38 | $shortLink = $shortLinksService->addOne($shortLink);
39 | } catch (AmoCRMApiException $e) {
40 | printError($e);
41 | die;
42 | }
43 |
44 | var_dump($shortLink->toArray());
45 |
--------------------------------------------------------------------------------
/examples/subscriptions_actions.php:
--------------------------------------------------------------------------------
1 | setAccessToken($accessToken)
16 | ->setAccountBaseDomain($accessToken->getValues()['baseDomain'])
17 | ->onAccessTokenRefresh(
18 | function (AccessTokenInterface $accessToken, string $baseDomain) {
19 | saveToken(
20 | [
21 | 'accessToken' => $accessToken->getToken(),
22 | 'refreshToken' => $accessToken->getRefreshToken(),
23 | 'expires' => $accessToken->getExpires(),
24 | 'baseDomain' => $baseDomain,
25 | ]
26 | );
27 | }
28 | );
29 |
30 | $subscriptionsService = $apiClient->entitySubscriptions(EntityTypesInterface::LEADS);
31 |
32 | try {
33 | $filer = (new PagesFilter())
34 | ->setLimit(3);
35 | $subscriptions = $subscriptionsService->getByParentId(667999631, $filer);
36 | } catch (AmoCRMApiException $exception) {
37 | printError($exception);
38 | die;
39 | }
40 |
41 | var_dump($subscriptions->toArray());
42 |
43 | try {
44 | $nextSubscriptions = $subscriptionsService->nextPage($subscriptions);
45 | } catch (AmoCRMApiException $exception) {
46 | printError($exception);
47 | die;
48 | }
49 |
50 | var_dump($nextSubscriptions->toArray());
51 |
--------------------------------------------------------------------------------
/examples/talks_actions.php:
--------------------------------------------------------------------------------
1 | setAccessToken($accessToken)
15 | ->setAccountBaseDomain($accessToken->getValues()['baseDomain'])
16 | ->onAccessTokenRefresh(
17 | function (AccessTokenInterface $accessToken, string $baseDomain) {
18 | saveToken(
19 | [
20 | 'accessToken' => $accessToken->getToken(),
21 | 'refreshToken' => $accessToken->getRefreshToken(),
22 | 'expires' => $accessToken->getExpires(),
23 | 'baseDomain' => $baseDomain,
24 | ]
25 | );
26 | }
27 | );
28 |
29 | $talksService = $apiClient->talks();
30 |
31 | try {
32 | $talk = $talksService->getOne('114');
33 | } catch (AmoCRMApiException $exception) {
34 | printError($exception);
35 | die;
36 | }
37 |
38 | try {
39 | $talksService->close(new TalkCloseActionModel($talk->getTalkId(), true));
40 | } catch (AmoCRMApiException $exception) {
41 | printError($exception);
42 | die;
43 | }
44 |
--------------------------------------------------------------------------------
/examples/user_context_actions.php:
--------------------------------------------------------------------------------
1 | setAccessToken($accessToken)
11 | ->setAccountBaseDomain($accessToken->getValues()['baseDomain'])
12 | ->onAccessTokenRefresh(
13 | function (AccessTokenInterface $accessToken, string $baseDomain) {
14 | saveToken(
15 | [
16 | 'accessToken' => $accessToken->getToken(),
17 | 'refreshToken' => $accessToken->getRefreshToken(),
18 | 'expires' => $accessToken->getExpires(),
19 | 'baseDomain' => $baseDomain,
20 | ]
21 | );
22 | }
23 | );
24 |
25 | $contextUserId = 123;
26 | $apiClientWithContext = $apiClient->withContextUserId($contextUserId);
27 |
28 | //Получим свойства аккаунта и сравним юезра
29 | try {
30 | $account = $apiClientWithContext->account()->getCurrent();
31 |
32 | echo 'Текущий юзер, тот кого вы передали? - ' . ($account->getCurrentUserId() === $contextUserId ? 'да' : 'нет');
33 | } catch (AmoCRMApiException $e) {
34 | printError($e);
35 | }
36 |
--------------------------------------------------------------------------------
/examples/webhooks_actions.php:
--------------------------------------------------------------------------------
1 | setAccessToken($accessToken)
12 | ->setAccountBaseDomain($accessToken->getValues()['baseDomain'])
13 | ->onAccessTokenRefresh(
14 | function (AccessTokenInterface $accessToken, string $baseDomain) {
15 | saveToken(
16 | [
17 | 'accessToken' => $accessToken->getToken(),
18 | 'refreshToken' => $accessToken->getRefreshToken(),
19 | 'expires' => $accessToken->getExpires(),
20 | 'baseDomain' => $baseDomain,
21 | ]
22 | );
23 | }
24 | );
25 |
26 | //Подпишемся на вебхук добавления сделки
27 | $webhook = new WebhookModel();
28 | $webhook->setDestination('https://example.com/')
29 | ->setSettings([
30 | 'add_lead'
31 | ]);
32 |
33 | try {
34 | $webhook = $apiClient->webhooks()->subscribe($webhook);
35 | } catch (AmoCRMApiException $e) {
36 | printError($e);
37 | die;
38 | }
39 |
40 | //Отпишемся от хука
41 | try {
42 | if ($apiClient->webhooks()->unsubscribe($webhook)) {
43 | echo "Успешно";
44 | } else {
45 | //Сюда не должны попасть никогда, так как в случае ошибки будет эксепшн
46 | echo "Не успешно";
47 | }
48 | } catch (AmoCRMApiException $e) {
49 | printError($e);
50 | die;
51 | }
52 |
--------------------------------------------------------------------------------
/examples/widgets_actions.php:
--------------------------------------------------------------------------------
1 | setAccessToken($accessToken)
11 | ->setAccountBaseDomain($accessToken->getValues()['baseDomain'])
12 | ->onAccessTokenRefresh(
13 | function (AccessTokenInterface $accessToken, string $baseDomain) {
14 | saveToken(
15 | [
16 | 'accessToken' => $accessToken->getToken(),
17 | 'refreshToken' => $accessToken->getRefreshToken(),
18 | 'expires' => $accessToken->getExpires(),
19 | 'baseDomain' => $baseDomain,
20 | ]
21 | );
22 | }
23 | );
24 |
25 | $widgetsService = $apiClient->widgets();
26 | //Получим виджет
27 | try {
28 | $widget = $widgetsService->getOne('amo_asterisk');
29 | } catch (AmoCRMApiException $e) {
30 | printError($e);
31 | die;
32 | }
33 |
34 | $widget->setSettings([
35 | 'login' => 'example',
36 | 'password' => 'SuchAnEasyPassword',
37 | 'script_path' => 'https://example.com/amocrm_asterisk/',
38 | 'phones' => [
39 | 504141 => 459 //id пользователя => добавочный номер
40 | ],
41 | ]);
42 |
43 | //Установим виджет
44 | try {
45 | $widget = $widgetsService->install($widget);
46 | } catch (AmoCRMApiException $e) {
47 | printError($e);
48 | die;
49 | }
50 |
51 | //Отключим виджет
52 | try {
53 | $widget = $widgetsService->uninstall($widget);
54 | } catch (AmoCRMApiException $e) {
55 | printError($e);
56 | die;
57 | }
58 |
--------------------------------------------------------------------------------
/phpunit.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 | tests
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/src/AmoCRM/Client/AmoCRMApiClientFactory.php:
--------------------------------------------------------------------------------
1 | oAuthConfig = $oAuthConfig;
33 | $this->oAuthService = $oAuthService;
34 | }
35 |
36 | /**
37 | * @return AmoCRMApiClient
38 | */
39 | public function make(): AmoCRMApiClient
40 | {
41 | $client = new AmoCRMApiClient(
42 | $this->oAuthConfig->getIntegrationId(),
43 | $this->oAuthConfig->getSecretKey(),
44 | $this->oAuthConfig->getRedirectDomain()
45 | );
46 |
47 | $client->onAccessTokenRefresh(
48 | function (AccessTokenInterface $accessToken, string $baseDomain) {
49 | $this->oAuthService->saveOAuthToken($accessToken, $baseDomain);
50 | }
51 | );
52 |
53 | return $client;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/AmoCRM/Client/LongLivedAccessToken.php:
--------------------------------------------------------------------------------
1 | parser()->parse($accessToken);
32 | } catch (Throwable $e) {
33 | throw new InvalidArgumentException(
34 | 'Error parsing given access token. Prev error: ' . $e->getMessage(),
35 | 0,
36 | [],
37 | 'Check access token.'
38 | );
39 | }
40 |
41 | $claims = $parsedAccessToken->claims();
42 |
43 | /** @var DateTimeImmutable $expiresAt */
44 | $expiresAt = $claims->get('exp');
45 |
46 | $options = [
47 | 'expires' => $expiresAt->getTimestamp(),
48 | 'access_token' => $accessToken,
49 | ];
50 |
51 | parent::__construct($options);
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/AmoCRM/Collections/CallsCollection.php:
--------------------------------------------------------------------------------
1 | data as $item) {
37 | $leadContact = $item->toLeadApi();
38 | if (!empty($leadContact)) {
39 | $result[] = $leadContact;
40 | }
41 | }
42 |
43 | return $result;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/AmoCRM/Collections/CurrenciesCollection.php:
--------------------------------------------------------------------------------
1 | getBy('code', $code);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/AmoCRM/Collections/CustomFieldGroupsCollection.php:
--------------------------------------------------------------------------------
1 | data as $key => $item) {
41 | if (in_array($item->getFieldType(), $this->typesToSkip, true)) {
42 | continue;
43 | }
44 | $result[$key] = $item->toApi($key);
45 | }
46 |
47 | return $result;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/AmoCRM/Collections/Customers/CustomersCollection.php:
--------------------------------------------------------------------------------
1 | data as $key => $item) {
37 | $result[$key] = $item->toDeleteApi();
38 | }
39 |
40 | return $result;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/AmoCRM/Collections/Interfaces/HasPagesInterface.php:
--------------------------------------------------------------------------------
1 | data as $key => $item) {
38 | $result[$key] = $item->toComplexApi($key);
39 | }
40 |
41 | return $result;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/AmoCRM/Collections/Leads/LossReasons/LossReasonsCollection.php:
--------------------------------------------------------------------------------
1 | getLink();
40 | }
41 |
42 | return parent::checkItem($item);
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/AmoCRM/Collections/NotesCollection.php:
--------------------------------------------------------------------------------
1 | data as $key => $item) {
19 | $result[$key] = $item->toEntityApi();
20 | }
21 |
22 | return $result;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/AmoCRM/Collections/Traits/PagesTrait.php:
--------------------------------------------------------------------------------
1 | nextPageLink = $url;
26 |
27 | return $this;
28 | }
29 |
30 | /**
31 | * @return null|string
32 | */
33 | public function getNextPageLink(): ?string
34 | {
35 | return $this->nextPageLink;
36 | }
37 |
38 | /**
39 | * @param string $url
40 | * @return PagesTrait|BaseApiCollection
41 | */
42 | public function setPrevPageLink(string $url)
43 | {
44 | $this->prevPageLink = $url;
45 |
46 | return $this;
47 | }
48 |
49 | /**
50 | * @return null|string
51 | */
52 | public function getPrevPageLink(): ?string
53 | {
54 | return $this->prevPageLink;
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/src/AmoCRM/Collections/UsersCollection.php:
--------------------------------------------------------------------------------
1 | entityId = $entityId;
38 |
39 | return $this;
40 | }
41 |
42 | /**
43 | * @return int
44 | */
45 | public function getEntityId(): int
46 | {
47 | return $this->entityId;
48 | }
49 |
50 | /**
51 | * @return string
52 | */
53 | protected function getMethod(): string
54 | {
55 | $method = parent::getMethod();
56 |
57 | return sprintf($method, $this->getEntityId());
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/src/AmoCRM/EntitiesServices/BaseEntityTypeEntity.php:
--------------------------------------------------------------------------------
1 | validateEntityType($entityType);
32 | $this->entityType = $entityType;
33 |
34 | return $this;
35 | }
36 |
37 | /**
38 | * @return string
39 | */
40 | public function getEntityType(): string
41 | {
42 | return $this->entityType;
43 | }
44 |
45 | /**
46 | * @return string
47 | */
48 | protected function getMethod(): string
49 | {
50 | $method = parent::getMethod();
51 |
52 | return sprintf($method, $this->getEntityType());
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/src/AmoCRM/EntitiesServices/BaseEntityTypeEntityIdEntity.php:
--------------------------------------------------------------------------------
1 | validateEntityType($entityType);
34 | $this->entityType = $entityType;
35 |
36 | return $this;
37 | }
38 |
39 | /**
40 | * @return string
41 | */
42 | public function getEntityType(): string
43 | {
44 | return $this->entityType;
45 | }
46 |
47 | /**
48 | * @return string
49 | */
50 | protected function getMethod(): string
51 | {
52 | return sprintf($this->method, $this->getEntityType(), $this->getEntityId());
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/src/AmoCRM/EntitiesServices/HasDeleteMethodInterface.php:
--------------------------------------------------------------------------------
1 | validationErrors = $errors;
26 |
27 | return $this;
28 | }
29 |
30 | /**
31 | * @return array
32 | */
33 | public function getValidationErrors(): array
34 | {
35 | return $this->validationErrors;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/AmoCRM/Exceptions/AmoCRMApiHttpClientException.php:
--------------------------------------------------------------------------------
1 | to;
23 | }
24 |
25 | /**
26 | * @param int $to
27 | *
28 | * @return BaseRangeFilter
29 | */
30 | public function setTo(int $to): self
31 | {
32 | if ($to >= 0) {
33 | $this->to = $to;
34 | }
35 |
36 | return $this;
37 | }
38 |
39 | /**
40 | * @return int
41 | */
42 | public function getFrom(): int
43 | {
44 | return $this->from;
45 | }
46 |
47 | /**
48 | * @param int $from
49 | *
50 | * @return BaseRangeFilter
51 | */
52 | public function setFrom(int $from): self
53 | {
54 | if ($from >= 0) {
55 | $this->from = $from;
56 | }
57 |
58 | return $this;
59 | }
60 |
61 | /**
62 | * @return array|int[]
63 | */
64 | public function toFilter()
65 | {
66 | return [
67 | 'from' => $this->getFrom(),
68 | 'to' => $this->getTo(),
69 | ];
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/src/AmoCRM/Filters/CatalogsFilter.php:
--------------------------------------------------------------------------------
1 | type = $type;
22 |
23 | return $this;
24 | }
25 |
26 | /**
27 | * @return null|string
28 | */
29 | public function getType(): ?string
30 | {
31 | return $this->type;
32 | }
33 |
34 | public function buildFilter(): array
35 | {
36 | $filter = [];
37 |
38 | if (!is_null($this->getType())) {
39 | $filter['type'] = $this->getType();
40 | }
41 |
42 | return $filter;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/AmoCRM/Filters/ChatLinksFilter.php:
--------------------------------------------------------------------------------
1 | contactId;
18 | }
19 |
20 | public function setContactId(?int $contactId): self
21 | {
22 | $this->contactId = $contactId;
23 |
24 | return $this;
25 | }
26 |
27 | public function getChatId(): ?string
28 | {
29 | return $this->chatId;
30 | }
31 |
32 | public function setChatId(?string $chatId): self
33 | {
34 | $this->chatId = $chatId;
35 |
36 | return $this;
37 | }
38 |
39 | public function buildFilter(): array
40 | {
41 | $filter = [];
42 |
43 | if (!is_null($this->getContactId())) {
44 | $filter['contact_id'] = $this->getContactId();
45 | }
46 |
47 | if (!is_null($this->getChatId())) {
48 | $filter['chat_id'] = $this->getChatId();
49 | }
50 |
51 | return $filter;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/AmoCRM/Filters/Chats/TemplatesFilter.php:
--------------------------------------------------------------------------------
1 | externalIds;
22 | }
23 |
24 | /**
25 | * @param string[]|null $externalIds
26 | *
27 | * @return TemplatesFilter
28 | */
29 | public function setExternalIds(?array $externalIds): self
30 | {
31 | $this->externalIds = $externalIds;
32 |
33 | return $this;
34 | }
35 |
36 | /**
37 | * @return array
38 | */
39 | public function buildFilter(): array
40 | {
41 | $filter = [];
42 |
43 | if (!is_null($this->getExternalIds())) {
44 | $externalIds = $this->getExternalIds();
45 |
46 | if (count($externalIds) === 1) {
47 | $externalIds = reset($externalIds);
48 | }
49 | $filter['filter']['external_id'] = $externalIds;
50 | }
51 |
52 | return $filter;
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/src/AmoCRM/Filters/CurrenciesFilter.php:
--------------------------------------------------------------------------------
1 | entityId = (array)$entityId;
16 | }
17 |
18 | /**
19 | * @return int[]
20 | */
21 | public function getEntityId(): array
22 | {
23 | return $this->entityId;
24 | }
25 |
26 | /**
27 | * @return array
28 | */
29 | public function buildFilter(): array
30 | {
31 | $filter = parent::buildFilter();
32 | $filter['filter']['entity_id'] = $this->getEntityId();
33 |
34 | return $filter;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/AmoCRM/Filters/Interfaces/HasOrderInterface.php:
--------------------------------------------------------------------------------
1 | buildPagesFilter();
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/AmoCRM/Filters/SourcesFilter.php:
--------------------------------------------------------------------------------
1 | externalIds;
18 | }
19 |
20 | /**
21 | * @param string[]|null $externalIds
22 | *
23 | * @return SourcesFilter
24 | */
25 | public function setExternalIds(?array $externalIds): self
26 | {
27 | $this->externalIds = $externalIds;
28 |
29 | return $this;
30 | }
31 |
32 | /**
33 | * @return array
34 | */
35 | public function buildFilter(): array
36 | {
37 | $filter = [];
38 |
39 | if (!is_null($this->getExternalIds())) {
40 | $externalIds = $this->getExternalIds();
41 |
42 | if (count($externalIds) === 1) {
43 | $externalIds = reset($externalIds);
44 | }
45 | $filter['filter']['external_id'] = $externalIds;
46 | }
47 |
48 | return $filter;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/AmoCRM/Filters/Traits/ArrayOrNumericFilterTrait.php:
--------------------------------------------------------------------------------
1 | = 0 ? (int)$number : null;
20 | }, $value);
21 |
22 | $value = array_filter($value, function ($number) {
23 | return !is_null($number);
24 | });
25 |
26 | if (empty($value)) {
27 | $value = null;
28 | }
29 |
30 | return $value;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/AmoCRM/Filters/Traits/ArrayOrStringFilterTrait.php:
--------------------------------------------------------------------------------
1 | 0 ? $string : null;
27 | }, $value);
28 |
29 | $value = array_filter($value, function ($string) {
30 | return !is_null($string);
31 | });
32 |
33 | if (empty($value)) {
34 | $value = null;
35 | }
36 |
37 | return $value;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/AmoCRM/Filters/Traits/IntOrIntRangeFilterTrait.php:
--------------------------------------------------------------------------------
1 | toFilter();
20 | } elseif (!is_int($value) || $value < 0) {
21 | $value = null;
22 | }
23 |
24 | return $value;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/AmoCRM/Filters/Traits/OrderTrait.php:
--------------------------------------------------------------------------------
1 | orderField = $field;
28 | $this->direction = $direction;
29 |
30 | return $this;
31 | }
32 |
33 | /**
34 | * @return null|array
35 | */
36 | public function getOrder(): ?array
37 | {
38 | return empty($this->orderField) || empty($this->direction) ? null : [$this->orderField => $this->direction];
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/AmoCRM/Filters/Traits/PagesFilterTrait.php:
--------------------------------------------------------------------------------
1 | page = $page;
25 |
26 | return $this;
27 | }
28 |
29 | /**
30 | * @return int
31 | */
32 | public function getPage(): int
33 | {
34 | return $this->page;
35 | }
36 |
37 | /**
38 | * @param int $limit
39 | * @return PagesFilterTrait
40 | */
41 | public function setLimit(int $limit): self
42 | {
43 | $this->limit = $limit;
44 |
45 | return $this;
46 | }
47 |
48 | /**
49 | * @return int
50 | */
51 | public function getLimit(): int
52 | {
53 | return $this->limit;
54 | }
55 |
56 | protected function buildPagesFilter(array $filter = []): array
57 | {
58 | if (!is_null($this->getLimit())) {
59 | $filter['limit'] = $this->getLimit();
60 | }
61 |
62 | if (!is_null($this->getPage())) {
63 | $filter['page'] = $this->getPage();
64 | }
65 |
66 | return $filter;
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/src/AmoCRM/Filters/WebhooksFilter.php:
--------------------------------------------------------------------------------
1 | destination;
18 | }
19 |
20 | /**
21 | * @param string|null $destination
22 | *
23 | * @return WebhooksFilter
24 | */
25 | public function setDestination(?string $destination): WebhooksFilter
26 | {
27 | $this->destination = $destination;
28 |
29 | return $this;
30 | }
31 |
32 | /**
33 | * @return array
34 | */
35 | public function buildFilter(): array
36 | {
37 | $filter = [];
38 |
39 | if (!is_null($this->getDestination())) {
40 | $filter['filter']['destination'] = $this->getDestination();
41 | }
42 |
43 | return $filter;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/AmoCRM/Helpers/CustomFieldHelper.php:
--------------------------------------------------------------------------------
1 | canDirect = $canDirect;
24 | $this->canCreateGroups = $canCreateGroups;
25 | }
26 |
27 | /**
28 | * @inheritDoc
29 | */
30 | public function toArray(): array
31 | {
32 | return [
33 | 'can_direct' => $this->getIsCanDirect(),
34 | 'can_create_groups' => $this->getIsCanCreateGroups(),
35 | ];
36 | }
37 |
38 | /**
39 | * @return bool
40 | */
41 | public function getIsCanDirect(): bool
42 | {
43 | return $this->canDirect;
44 | }
45 |
46 | /**
47 | * @return bool
48 | */
49 | public function getIsCanCreateGroups(): bool
50 | {
51 | return $this->canCreateGroups;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/AmoCRM/Models/AccountSettings/InvoicesSettings.php:
--------------------------------------------------------------------------------
1 | lang = $lang;
24 | $this->invoicesCatalogId = $invoicesCatalogId;
25 | }
26 |
27 | /**
28 | * @inheritDoc
29 | */
30 | public function toArray(): array
31 | {
32 | return [
33 | 'lang' => $this->getLang(),
34 | 'invoices_catalog_id' => $this->getInvoicesCatalogId(),
35 | ];
36 | }
37 |
38 | /**
39 | * @return string|null
40 | */
41 | public function getLang(): ?string
42 | {
43 | return $this->lang;
44 | }
45 |
46 | /**
47 | * @return int|null
48 | */
49 | public function getInvoicesCatalogId(): ?int
50 | {
51 | return $this->invoicesCatalogId;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/AmoCRM/Models/BaseApiModel.php:
--------------------------------------------------------------------------------
1 | $methodName();
35 | } else {
36 | return null;
37 | }
38 | }
39 |
40 | public function __set($name, $value)
41 | {
42 | $methodName = 'set' . Str::camel(Str::ucfirst($name));
43 | if (method_exists($this, $methodName) && is_callable([$this, $methodName])) {
44 | $this->$methodName($value);
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/AmoCRM/Models/Chats/Templates/Buttons/AbstractButtonModel.php:
--------------------------------------------------------------------------------
1 | setUrl($button['url']);
35 | break;
36 | case ButtonsEnums::TYPE_TEXT:
37 | $model = new TextButtonModel();
38 | break;
39 | }
40 |
41 | $model->setText($button['text']);
42 |
43 | return $model;
44 | }
45 |
46 | /**
47 | * @param string|null $requestId
48 | * @return array
49 | */
50 | public function toApi(?string $requestId = "0"): array
51 | {
52 | return $this->toArray();
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/src/AmoCRM/Models/Chats/Templates/Buttons/TextButtonModel.php:
--------------------------------------------------------------------------------
1 | ButtonsEnums::TYPE_TEXT,
28 | 'text' => $this->getText(),
29 | ];
30 | }
31 |
32 | /**
33 | * @return string
34 | */
35 | public function getText(): string
36 | {
37 | return $this->text;
38 | }
39 |
40 | /**
41 | * @param string $text
42 | *
43 | * @return TextButtonModel
44 | */
45 | public function setText(string $text): TextButtonModel
46 | {
47 | $this->text = $text;
48 |
49 | return $this;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/AmoCRM/Models/Chats/Templates/Buttons/UrlButtonModel.php:
--------------------------------------------------------------------------------
1 | ButtonsEnums::TYPE_URL,
28 | 'text' => $this->getText(),
29 | 'url' => $this->getUrl(),
30 | ];
31 | }
32 |
33 | /**
34 | * @return string
35 | */
36 | public function getUrl(): string
37 | {
38 | return $this->url;
39 | }
40 |
41 | /**
42 | * @param string $url
43 | *
44 | * @return UrlButtonModel
45 | */
46 | public function setUrl(string $url): UrlButtonModel
47 | {
48 | $this->url = $url;
49 |
50 | return $this;
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/AmoCRM/Models/CurrencyModel.php:
--------------------------------------------------------------------------------
1 | code = $code;
23 | }
24 |
25 | /**
26 | * @return string
27 | */
28 | public function getCode(): string
29 | {
30 | return $this->code;
31 | }
32 |
33 | /**
34 | * @param array $currencyArr
35 | *
36 | * @return static
37 | */
38 | public static function fromArray(array $currencyArr): self
39 | {
40 | $currency = new self();
41 | $currency->setCode($currencyArr['code']);
42 |
43 | return $currency;
44 | }
45 |
46 | /**
47 | * @return string[]
48 | */
49 | public function toArray(): array
50 | {
51 | return [
52 | 'code' => $this->getCode(),
53 | ];
54 | }
55 |
56 | /**
57 | * @param string|null $requestId
58 | *
59 | * @return string[]
60 | */
61 | public function toApi(?string $requestId = null): array
62 | {
63 | return $this->toArray();
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/src/AmoCRM/Models/CustomFields/CheckboxCustomFieldModel.php:
--------------------------------------------------------------------------------
1 | setValue($fieldValue);
30 |
31 | return $model;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/AmoCRM/Models/CustomFieldsValues/ValueModels/BaseCustomFieldValueModel.php:
--------------------------------------------------------------------------------
1 | setValue($value['value'] ?? null);
30 |
31 | return $model;
32 | }
33 |
34 | /**
35 | * @return int|string|null
36 | */
37 | public function getValue()
38 | {
39 | return $this->value;
40 | }
41 |
42 | /**
43 | * @param int|string|null|array|bool $value
44 | *
45 | * @return BaseCustomFieldValueModel
46 | */
47 | public function setValue($value): BaseCustomFieldValueModel
48 | {
49 | $this->value = $value;
50 |
51 | return $this;
52 | }
53 |
54 | public function toArray(): array
55 | {
56 | return [
57 | 'value' => $this->getValue(),
58 | ];
59 | }
60 |
61 | public function toApi(?string $requestId = null): array
62 | {
63 | return [
64 | 'value' => $this->getValue(),
65 | ];
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/src/AmoCRM/Models/CustomFieldsValues/ValueModels/BirthdayCustomFieldValueModel.php:
--------------------------------------------------------------------------------
1 | value = (bool)$value;
22 |
23 | return $this;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/AmoCRM/Models/CustomFieldsValues/ValueModels/DateTimeCustomFieldValueModel.php:
--------------------------------------------------------------------------------
1 | customerId = $customerId;
26 | $this->points = $points;
27 | }
28 |
29 | /**
30 | * @return int
31 | */
32 | public function getCustomerId(): int
33 | {
34 | return $this->customerId;
35 | }
36 |
37 | /**
38 | * @return int
39 | */
40 | public function getPoints(): int
41 | {
42 | return $this->points;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/AmoCRM/Models/Factories/UnsortedMetadataFactory.php:
--------------------------------------------------------------------------------
1 | fromArray($metadata);
32 | break;
33 | case BaseUnsortedModel::CATEGORY_CODE_FORMS:
34 | return (new FormsMetadata())->fromArray($metadata);
35 | break;
36 | case BaseUnsortedModel::CATEGORY_CODE_SIP:
37 | return (new SipMetadata())->fromArray($metadata);
38 | break;
39 | case BaseUnsortedModel::CATEGORY_CODE_MAIL:
40 | return (new MailMetadata())->fromArray($metadata);
41 | break;
42 | }
43 |
44 | throw new BadTypeException('Given category is not supported - ' . $category);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/AmoCRM/Models/Factories/UnsortedModelFactory.php:
--------------------------------------------------------------------------------
1 | fileUuid;
18 | }
19 |
20 | /**
21 | * @param null|string $fileUuid
22 | *
23 | * @return FileLinkModel
24 | */
25 | public function setFileUuid(?string $fileUuid): FileLinkModel
26 | {
27 | $this->fileUuid = $fileUuid;
28 |
29 | return $this;
30 | }
31 |
32 | /**
33 | * @param array $link
34 | *
35 | * @return self
36 | */
37 | public static function fromArray(array $link): self
38 | {
39 | $model = new self();
40 |
41 | $model
42 | ->setFileUuid($link['file_uuid'] ?? null);
43 |
44 | return $model;
45 | }
46 |
47 | /**
48 | * @inheritDoc
49 | */
50 | public function toArray(): array
51 | {
52 | return [
53 | 'file_uuid' => $this->getFileUuid(),
54 | ];
55 | }
56 |
57 | public function toApi(?string $requestId = "0"): array
58 | {
59 | return $this->toArray();
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/AmoCRM/Models/Interfaces/CallInterface.php:
--------------------------------------------------------------------------------
1 | message = $message;
15 | }
16 |
17 | public function getInvoiceWarningMessage(): ?string
18 | {
19 | return $this->message;
20 | }
21 |
22 | public static function fromArray(array $value): self
23 | {
24 | return new self($value['message']);
25 | }
26 |
27 | public function toArray(): array
28 | {
29 | return [
30 | 'message' => $this->getInvoiceWarningMessage(),
31 | ];
32 | }
33 |
34 | public function toApi(?string $requestId = null): array
35 | {
36 | return $this->toArray();
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/AmoCRM/Models/NoteType/CallInNote.php:
--------------------------------------------------------------------------------
1 | getText();
21 |
22 | return $result;
23 | }
24 |
25 | public function getNoteType(): string
26 | {
27 | return NoteFactory::NOTE_TYPE_CODE_COMMON;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/AmoCRM/Models/NoteType/ExtendedServiceMessageNote.php:
--------------------------------------------------------------------------------
1 | setText($note['params']['text']);
26 | }
27 |
28 | return $model;
29 | }
30 |
31 | /**
32 | * @inheritDoc
33 | */
34 | public function toArray(): array
35 | {
36 | $result = parent::toArray();
37 |
38 | $result['params']['text'] = $this->getText();
39 |
40 | return $result;
41 | }
42 |
43 | /**
44 | * @param string|null $requestId
45 | * @return array
46 | * @throws NotAvailableForActionException
47 | */
48 | public function toApi(?string $requestId = "0"): array
49 | {
50 | throw new NotAvailableForActionException();
51 | }
52 |
53 | /**
54 | * @return string
55 | */
56 | public function getText(): string
57 | {
58 | return $this->text;
59 | }
60 |
61 | /**
62 | * @param string $text
63 | * @return NoteModel
64 | */
65 | public function setText(string $text): NoteModel
66 | {
67 | $this->text = $text;
68 |
69 | return $this;
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/src/AmoCRM/Models/NoteType/ServiceMessageNote.php:
--------------------------------------------------------------------------------
1 | talkId = $talkId;
24 | $this->forceClose = $forceClose;
25 | }
26 |
27 | public function getTalkId(): int
28 | {
29 | return $this->talkId;
30 | }
31 |
32 | public function setTalkId(int $talkId): self
33 | {
34 | $this->talkId = $talkId;
35 |
36 | return $this;
37 | }
38 |
39 | public function isForceClose(): bool
40 | {
41 | return $this->forceClose;
42 | }
43 |
44 | public function setForceClose(bool $forceClose): self
45 | {
46 | $this->forceClose = $forceClose;
47 |
48 | return $this;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/AmoCRM/Models/Traits/GetLinkTrait.php:
--------------------------------------------------------------------------------
1 | setToEntityId($this->getId())
21 | ->setToEntityType($this->getType())
22 | ->setMetadata($this->getMetadataForLink());
23 |
24 | return $linkModel;
25 | }
26 |
27 | abstract protected function getMetadataForLink(): ?array;
28 | }
29 |
--------------------------------------------------------------------------------
/src/AmoCRM/Models/Traits/RequestIdTrait.php:
--------------------------------------------------------------------------------
1 | requestId;
23 | }
24 |
25 | /**
26 | * @param string|int|null $requestId
27 | * @return self
28 | */
29 | public function setRequestId($requestId = null): self
30 | {
31 | $this->requestId = (string)$requestId;
32 |
33 | return $this;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/AmoCRM/Models/Unsorted/FormUnsortedModel.php:
--------------------------------------------------------------------------------
1 | category = BaseUnsortedModel::CATEGORY_CODE_FORMS;
22 |
23 | return $this;
24 | }
25 |
26 | /**
27 | * @return null|UnsortedMetadataInterface
28 | */
29 | public function getMetadata(): ?UnsortedMetadataInterface
30 | {
31 | return $this->metadata;
32 | }
33 |
34 | /**
35 | * @param UnsortedMetadataInterface $metadata
36 | *
37 | * @return BaseUnsortedModel
38 | * @throws BadTypeException
39 | */
40 | public function setMetadata(UnsortedMetadataInterface $metadata): BaseUnsortedModel
41 | {
42 | if (!($metadata instanceof FormsMetadata)) {
43 | throw new BadTypeException('metadata should be instance of FormsMetadata');
44 | }
45 | $this->metadata = $metadata;
46 |
47 | return $this;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/AmoCRM/Models/Unsorted/Interfaces/UnsortedMetadataInterface.php:
--------------------------------------------------------------------------------
1 | category = BaseUnsortedModel::CATEGORY_CODE_SIP;
22 |
23 | return $this;
24 | }
25 |
26 | /**
27 | * @return UnsortedMetadataInterface|null
28 | */
29 | public function getMetadata(): ?UnsortedMetadataInterface
30 | {
31 | return $this->metadata;
32 | }
33 |
34 | /**
35 | * @param UnsortedMetadataInterface $metadata
36 | *
37 | * @return BaseUnsortedModel
38 | * @throws BadTypeException
39 | */
40 | public function setMetadata(UnsortedMetadataInterface $metadata): BaseUnsortedModel
41 | {
42 | if (!($metadata instanceof SipMetadata)) {
43 | throw new BadTypeException('metadata should be instance of SipMetadata');
44 | }
45 | $this->metadata = $metadata;
46 |
47 | return $this;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/AmoCRM/OAuth/OAuthConfigInterface.php:
--------------------------------------------------------------------------------
1 | 0,
17 | 'entity_id' => null,
18 | 'created_by' => 1,
19 | 'updated_by' => 1,
20 | 'created_at' => 1587731353,
21 | 'updated_at' => 1587731353,
22 | 'responsible_user_id' => 1,
23 | 'group_id' => 0,
24 | 'note_type' => 'call_in',
25 | 'params' => [
26 | 'text' => '123123',
27 | ],
28 | 'account_id' => 123,
29 | ];
30 |
31 | $this->expectException(TypeError::class);
32 |
33 | (new CallInNote())->fromArray($note);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------