Compare commits
103 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
99d6865665 | ||
|
|
e718a3eca9 | ||
|
|
59c94e16e5 | ||
|
|
91d341b2e9 | ||
|
|
654be241e4 | ||
|
|
d6399f77e9 | ||
|
|
439e042a0d | ||
|
|
30830596b1 | ||
|
|
841cfc800d | ||
|
|
99fcd5b4ce | ||
|
|
f09825531b | ||
|
|
72440ce83d | ||
|
|
53172d00de | ||
|
|
47c041155f | ||
|
|
6e160ab567 | ||
|
|
a7be8bbc46 | ||
|
|
9aa66a8b3f | ||
|
|
3d25f43f8d | ||
|
|
9e968e71e1 | ||
|
|
a7d7436b10 | ||
|
|
664dd850a2 | ||
|
|
cbf6f8c9be | ||
|
|
04f3bc8698 | ||
|
|
dd8ff9af78 | ||
|
|
d6d9b9d54c | ||
|
|
3cd9a83dd2 | ||
|
|
1f39c519a7 | ||
|
|
1c24ce9ea5 | ||
|
|
0ce322ad94 | ||
|
|
de66204060 | ||
|
|
28596bc9e8 | ||
|
|
ee2b26e67e | ||
|
|
8b37bc50dd | ||
|
|
b0f5b6d47a | ||
|
|
2746ed89dc | ||
|
|
073725a56f | ||
|
|
03b18a083f | ||
|
|
833d024d99 | ||
|
|
b6af059d72 | ||
|
|
c531b093c8 | ||
|
|
1cb88fce19 | ||
|
|
392c3d77f2 | ||
|
|
588e74e951 | ||
|
|
b02282e8a0 | ||
|
|
7837f78bf8 | ||
|
|
d43da6d6a9 | ||
|
|
846f1b459c | ||
|
|
29a93b1f92 | ||
|
|
f9dc59ff15 | ||
|
|
f7e9ab78a2 | ||
|
|
ad5009402d | ||
|
|
d7c4018d01 | ||
|
|
99212285a4 | ||
|
|
77dd3707eb | ||
|
|
10bd5ebb85 | ||
|
|
b0eb36daed | ||
|
|
01c616ef33 | ||
|
|
a4f962c9a7 | ||
|
|
f11701ad4e | ||
|
|
6d5e433f9c | ||
|
|
8cb649bb5e | ||
|
|
72c1c4283f | ||
|
|
23d86024ef | ||
|
|
150aaeeb78 | ||
|
|
0f95357f46 | ||
|
|
d0287ff9c3 | ||
|
|
41e2fff7f7 | ||
|
|
181b320e09 | ||
|
|
70043b227c | ||
|
|
df163e7fcf | ||
|
|
b669e2010a | ||
|
|
32781fe540 | ||
|
|
f1398e1e14 | ||
|
|
4a9a2ce451 | ||
|
|
311a6c6c63 | ||
|
|
2917520aa9 | ||
|
|
df2fe5ae41 | ||
|
|
6c39a2ac3c | ||
|
|
c27c7dd1e7 | ||
|
|
36709d3668 | ||
|
|
b58a3a0817 | ||
|
|
59bee34d45 | ||
|
|
b29fb6a5bc | ||
|
|
14d966a62b | ||
|
|
9d17992545 | ||
|
|
1e4f7a6943 | ||
|
|
5c91b1d0f7 | ||
|
|
9ad2f564d5 | ||
|
|
0b2c4b4ec3 | ||
|
|
14735c4195 | ||
|
|
0c9a7e2106 | ||
|
|
c8c0808078 | ||
|
|
078201fe04 | ||
|
|
2b0be3493b | ||
|
|
407c753bc1 | ||
|
|
afa6d110b6 | ||
|
|
ff4212db93 | ||
|
|
cdf406d0a4 | ||
|
|
c9af0afe07 | ||
|
|
85680ad828 | ||
|
|
1523ca6ebf | ||
|
|
0085fb6ebb | ||
|
|
dfae053db6 |
23 changed files with 574 additions and 302 deletions
182
CHANGELOG.md
182
CHANGELOG.md
|
|
@ -2,34 +2,96 @@
|
||||||
|
|
||||||
### All notable changes to `CRM CLient V4` will be documented in this file.
|
### All notable changes to `CRM CLient V4` will be documented in this file.
|
||||||
|
|
||||||
|
# version 4.1.8
|
||||||
|
|
||||||
|
- fix: 🐛 remove sending brand id in claim call #52
|
||||||
|
|
||||||
|
# version 4.1.7
|
||||||
|
|
||||||
|
- fix: 🏷️ add Germany to the valid countries
|
||||||
|
|
||||||
|
# version 4.1.6
|
||||||
|
|
||||||
|
- Changed: move claim customer association into server side
|
||||||
|
|
||||||
|
# version 4.1.4
|
||||||
|
|
||||||
|
- Changed: update claim customer relation with hashcode
|
||||||
|
|
||||||
|
# version 4.1.4
|
||||||
|
|
||||||
|
- Changed: update claim file validation
|
||||||
|
- Changed: resolve phpcs errors
|
||||||
|
|
||||||
|
# version 4.1.3
|
||||||
|
|
||||||
|
- Added: client tests for registering a claim
|
||||||
|
|
||||||
|
# version 4.1.2
|
||||||
|
|
||||||
|
- Changed: force string cast in ctype_digit method
|
||||||
|
|
||||||
|
# version 4.1.1
|
||||||
|
|
||||||
|
- Changed: update optionnal answer id parameter when set new single optin for laravel and wordpress
|
||||||
|
|
||||||
|
# version 4.1.0
|
||||||
|
|
||||||
|
- Added: new api route for sending new claim
|
||||||
|
- Added: optionnal answer id parameter when set new single optin
|
||||||
|
|
||||||
|
# version 4.0.4
|
||||||
|
|
||||||
|
- chore: :arrow_up: bump to v4.0.4
|
||||||
|
|
||||||
|
# version 4.0.3
|
||||||
|
|
||||||
|
- chore: :arrow_up: bump to v4.0.3
|
||||||
|
|
||||||
|
# version 4.0.2
|
||||||
|
|
||||||
|
- chore: :arrow_up: bump to v4.0.2
|
||||||
|
|
||||||
|
# version 4.0.1
|
||||||
|
|
||||||
|
- chore: :arrow_up: bump to v4.0.1
|
||||||
|
- fix: 🏷️ add Netherlands to the valid countries
|
||||||
|
|
||||||
# version 4.0.0
|
# version 4.0.0
|
||||||
- Changed: CRM is now php 8.2 only
|
|
||||||
|
- Changed: CRM is now php 8.2 only
|
||||||
|
|
||||||
# version 3.0.6
|
# version 3.0.6
|
||||||
- Added: SingleOptin::unsetStatusWithHashcode to allow customers to unsubscribe using a hashcode, now single optins do have hashcodes
|
|
||||||
|
- Added: SingleOptin::unsetStatusWithHashcode to allow customers to unsubscribe using a hashcode, now single optins do have hashcodes
|
||||||
|
|
||||||
# version 3.0.5
|
# version 3.0.5
|
||||||
- Bumped to follow CRM updates
|
|
||||||
|
- Bumped to follow CRM updates
|
||||||
|
|
||||||
# version 3.0.4
|
# version 3.0.4
|
||||||
- Added CI configuration
|
|
||||||
|
- Added CI configuration
|
||||||
|
|
||||||
# version 3.0.3
|
# version 3.0.3
|
||||||
- Update Country enum
|
|
||||||
- Fixed : request merge method of data to query (Request.php)
|
- Update Country enum
|
||||||
- Fixed : validate json check should check if really false (Response.php)
|
- Fixed : request merge method of data to query (Request.php)
|
||||||
- Bumped composer deps
|
- Fixed : validate json check should check if really false (Response.php)
|
||||||
|
- Bumped composer deps
|
||||||
|
|
||||||
# version 3.0.2
|
# version 3.0.2
|
||||||
- Regen documentation with php documentor
|
|
||||||
|
- Regen documentation with php documentor
|
||||||
|
|
||||||
# version 3.0.1
|
# version 3.0.1
|
||||||
- Fixed : Customer do not call update if there are no updated fields
|
|
||||||
- Fixed : WPCrm bootSessionIfNeeded trying to access $_SESSION['wpcrm'] before session was started
|
- Fixed : Customer do not call update if there are no updated fields
|
||||||
- Fixed : WPCrm now only returns a boolean
|
- Fixed : WPCrm bootSessionIfNeeded trying to access $\_SESSION['wpcrm'] before session was started
|
||||||
- Fixed : get crm info when client used in laravel
|
- Fixed : WPCrm now only returns a boolean
|
||||||
- Changed : WpCrm::makeApiV4Call Change LogLevel on error from Emerge to Critical
|
- Fixed : get crm info when client used in laravel
|
||||||
- Changed : WPCrm readd forceLogin()
|
- Changed : WpCrm::makeApiV4Call Change LogLevel on error from Emerge to Critical
|
||||||
|
- Changed : WPCrm readd forceLogin()
|
||||||
|
|
||||||
# version 3.0.0
|
# version 3.0.0
|
||||||
|
|
||||||
|
|
@ -37,60 +99,68 @@ This removes api authentication with token in favor of signature method.
|
||||||
Refactored code and clean up. It add more unit test plus code coverage
|
Refactored code and clean up. It add more unit test plus code coverage
|
||||||
in test/coverage.
|
in test/coverage.
|
||||||
|
|
||||||
- Added : mardown documentation.
|
- Added : mardown documentation.
|
||||||
- Changed : WPCrm::login now only returns a boolean
|
- Changed : WPCrm::login now only returns a boolean
|
||||||
- Changed : model Stats::getQuestionStats to pass question as route parameter
|
- Changed : model Stats::getQuestionStats to pass question as route parameter
|
||||||
- Changed : now requests need to have a signature generated with a private key (crm password) using hmac sha256 wrapping url, method and parameters
|
- Changed : now requests need to have a signature generated with a private key (crm password) using hmac sha256 wrapping url, method and parameters
|
||||||
- Changed : now timestamp will timeout if request is slower than "timestampTimeout", this means crm will reject the request
|
- Changed : now timestamp will timeout if request is slower than "timestampTimeout", this means crm will reject the request
|
||||||
- Changed : throw ValidationException s instead of TypeErrors
|
- Changed : throw ValidationException s instead of TypeErrors
|
||||||
- Changed : timestamp has to be send in request with a DateTime format, it also has to a UTC value
|
- Changed : timestamp has to be send in request with a DateTime format, it also has to a UTC value
|
||||||
- Fixed : Change WPCRM dynamic session key, this could prevent spoofing session in some cases.
|
- Fixed : Change WPCRM dynamic session key, this could prevent spoofing session in some cases.
|
||||||
- Fixed : closure validation
|
- Fixed : closure validation
|
||||||
- Fixed : model mutator not catching reflectionException
|
- Fixed : model mutator not catching reflectionException
|
||||||
- Fixed : really send json request using Guzzle internal lib methods.
|
- Fixed : really send json request using Guzzle internal lib methods.
|
||||||
- Removed : Api AUTH system with api token
|
- Removed : Api AUTH system with api token
|
||||||
- Removed : ApiError::needAuth
|
- Removed : ApiError::needAuth
|
||||||
- Removed : composer vlucas/dotenv, .env file is not handled any more.
|
- Removed : composer vlucas/dotenv, .env file is not handled any more.
|
||||||
- Removed : LoginException
|
- Removed : LoginException
|
||||||
- Removed : memcached dependency
|
- Removed : memcached dependency
|
||||||
- Removed : need of memcached
|
- Removed : need of memcached
|
||||||
- Removed : unused service provider
|
- Removed : unused service provider
|
||||||
- Removed : WpCrm::forceLogin
|
- Removed : WpCrm::forceLogin
|
||||||
- Removed : WpCrm::sendArcadiaMailDefault
|
- Removed : WpCrm::sendArcadiaMailDefault
|
||||||
- Removed : WpCrm::sendArcadiaMailGame
|
- Removed : WpCrm::sendArcadiaMailGame
|
||||||
- Updated : PHPCS rules, phpcs fixes and refactored code
|
- Updated : PHPCS rules, phpcs fixes and refactored code
|
||||||
|
|
||||||
# version 2.3.2
|
# version 2.3.2
|
||||||
- Hotfixed arcadia order
|
|
||||||
|
- Hotfixed arcadia order
|
||||||
|
|
||||||
# version 2.3.1
|
# version 2.3.1
|
||||||
- Fixed Consider fill attributes as can be nullable
|
|
||||||
- Fixed Respect sometimes validation
|
- Fixed Consider fill attributes as can be nullable
|
||||||
|
- Fixed Respect sometimes validation
|
||||||
|
|
||||||
# version 2.3.0
|
# version 2.3.0
|
||||||
- Added Stats call by brand and by question
|
|
||||||
- Added min rule valdation for integers as well as for strings in Utils
|
- Added Stats call by brand and by question
|
||||||
|
- Added min rule valdation for integers as well as for strings in Utils
|
||||||
|
|
||||||
# version 2.2.3
|
# version 2.2.3
|
||||||
- Changed for bool casting for response parse field 'status' when is int 1 or 0
|
|
||||||
- Changed, properties are filled from CRM after a save or update action, this will allow for props to be set on model as it is on the crm, after all checks and casts (firstname capitalized, ... etc)
|
- Changed for bool casting for response parse field 'status' when is int 1 or 0
|
||||||
|
- Changed, properties are filled from CRM after a save or update action, this will allow for props to be set on model as it is on the crm, after all checks and casts (firstname capitalized, ... etc)
|
||||||
|
|
||||||
# version 2.2.2
|
# version 2.2.2
|
||||||
- Fixed Arcadia mail where sending parameters as query instead of Data
|
|
||||||
|
- Fixed Arcadia mail where sending parameters as query instead of Data
|
||||||
|
|
||||||
# version 2.2.1
|
# version 2.2.1
|
||||||
- Fixed fill methods on models to handle all enums + arrays
|
|
||||||
- Changed validation on customer, city minimum is now 2 chars,
|
- Fixed fill methods on models to handle all enums + arrays
|
||||||
firstname and lastname min are now 1 char, phone min 10 has been removed,
|
- Changed validation on customer, city minimum is now 2 chars,
|
||||||
other validations are made on backend side such as limit countries,
|
firstname and lastname min are now 1 char, phone min 10 has been removed,
|
||||||
right now limit is FR, BE, NL.
|
other validations are made on backend side such as limit countries,
|
||||||
Anyway dont forget to handle ValidationException which returns crm message.
|
right now limit is FR, BE, NL.
|
||||||
- Include Drom Com to allowed countries
|
Anyway dont forget to handle ValidationException which returns crm message.
|
||||||
- Update Country enum to remove '-' chars
|
- Include Drom Com to allowed countries
|
||||||
|
- Update Country enum to remove '-' chars
|
||||||
|
|
||||||
# version 2.2.0
|
# version 2.2.0
|
||||||
- Fixed Utils.php getResquest method
|
|
||||||
- Changed Arcadia mails, add customer parameters for these calls
|
- Fixed Utils.php getResquest method
|
||||||
|
- Changed Arcadia mails, add customer parameters for these calls
|
||||||
|
|
||||||
# version 2.1.9
|
# version 2.1.9
|
||||||
- Fixed method CrmClientModel::fill now validates data and put value to updatedValues array
|
|
||||||
|
- Fixed method CrmClientModel::fill now validates data and put value to updatedValues array
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"version": "4.0.0",
|
"version": "4.1.8",
|
||||||
"timestampTimeout": 30,
|
"timestampTimeout": 30,
|
||||||
"apiRequestRatePerMinute": 256,
|
"apiRequestRatePerMinute": 256,
|
||||||
"servicesDBCache": 10
|
"servicesDBCache": 10
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "ldc/ldccrmv4client",
|
"name": "ldc/ldccrmv4client",
|
||||||
|
"version": "4.1.8",
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"description": "LDC CRM Client V4",
|
"description": "LDC CRM Client V4",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"version": "4.0.0",
|
"support": {
|
||||||
"authors": [
|
"email": "digital@ldc.fr"
|
||||||
{
|
},
|
||||||
"name": "Jérémy Munsch",
|
|
||||||
"email": "jeremy.munsch@ldc.fr",
|
|
||||||
"homepage": "https://jeremydev.ovh"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"homepage": "https://github.com/kwaadpepper",
|
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"Laravel",
|
"Laravel",
|
||||||
"CRM",
|
"CRM",
|
||||||
|
|
@ -20,6 +15,7 @@
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^8.2",
|
"php": "^8.2",
|
||||||
|
"doctrine/inflector": "^2.0",
|
||||||
"ext-curl": "*",
|
"ext-curl": "*",
|
||||||
"guzzlehttp/guzzle": "^7.4",
|
"guzzlehttp/guzzle": "^7.4",
|
||||||
"respect/validation": "^2.2"
|
"respect/validation": "^2.2"
|
||||||
|
|
|
||||||
186
composer.lock
generated
186
composer.lock
generated
|
|
@ -4,8 +4,99 @@
|
||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "46d0f076c74afaa5b636e0b6283ad48e",
|
"content-hash": "eb380867bcf551762b352ecb8f201c22",
|
||||||
"packages": [
|
"packages": [
|
||||||
|
{
|
||||||
|
"name": "doctrine/inflector",
|
||||||
|
"version": "2.0.10",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/doctrine/inflector.git",
|
||||||
|
"reference": "5817d0659c5b50c9b950feb9af7b9668e2c436bc"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/doctrine/inflector/zipball/5817d0659c5b50c9b950feb9af7b9668e2c436bc",
|
||||||
|
"reference": "5817d0659c5b50c9b950feb9af7b9668e2c436bc",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": "^7.2 || ^8.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"doctrine/coding-standard": "^11.0",
|
||||||
|
"phpstan/phpstan": "^1.8",
|
||||||
|
"phpstan/phpstan-phpunit": "^1.1",
|
||||||
|
"phpstan/phpstan-strict-rules": "^1.3",
|
||||||
|
"phpunit/phpunit": "^8.5 || ^9.5",
|
||||||
|
"vimeo/psalm": "^4.25 || ^5.4"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Doctrine\\Inflector\\": "lib/Doctrine/Inflector"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Guilherme Blanco",
|
||||||
|
"email": "guilhermeblanco@gmail.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Roman Borschel",
|
||||||
|
"email": "roman@code-factory.org"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Benjamin Eberlei",
|
||||||
|
"email": "kontakt@beberlei.de"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Jonathan Wage",
|
||||||
|
"email": "jonwage@gmail.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Johannes Schmitt",
|
||||||
|
"email": "schmittjoh@gmail.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "PHP Doctrine Inflector is a small library that can perform string manipulations with regard to upper/lowercase and singular/plural forms of words.",
|
||||||
|
"homepage": "https://www.doctrine-project.org/projects/inflector.html",
|
||||||
|
"keywords": [
|
||||||
|
"inflection",
|
||||||
|
"inflector",
|
||||||
|
"lowercase",
|
||||||
|
"manipulation",
|
||||||
|
"php",
|
||||||
|
"plural",
|
||||||
|
"singular",
|
||||||
|
"strings",
|
||||||
|
"uppercase",
|
||||||
|
"words"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/doctrine/inflector/issues",
|
||||||
|
"source": "https://github.com/doctrine/inflector/tree/2.0.10"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://www.doctrine-project.org/sponsorship.html",
|
||||||
|
"type": "custom"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://www.patreon.com/phpdoctrine",
|
||||||
|
"type": "patreon"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://tidelift.com/funding/github/packagist/doctrine%2Finflector",
|
||||||
|
"type": "tidelift"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2024-02-18T20:23:39+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "guzzlehttp/guzzle",
|
"name": "guzzlehttp/guzzle",
|
||||||
"version": "7.8.0",
|
"version": "7.8.0",
|
||||||
|
|
@ -1097,97 +1188,6 @@
|
||||||
},
|
},
|
||||||
"time": "2022-10-27T11:44:00+00:00"
|
"time": "2022-10-27T11:44:00+00:00"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "doctrine/inflector",
|
|
||||||
"version": "2.0.8",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/doctrine/inflector.git",
|
|
||||||
"reference": "f9301a5b2fb1216b2b08f02ba04dc45423db6bff"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/doctrine/inflector/zipball/f9301a5b2fb1216b2b08f02ba04dc45423db6bff",
|
|
||||||
"reference": "f9301a5b2fb1216b2b08f02ba04dc45423db6bff",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": "^7.2 || ^8.0"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"doctrine/coding-standard": "^11.0",
|
|
||||||
"phpstan/phpstan": "^1.8",
|
|
||||||
"phpstan/phpstan-phpunit": "^1.1",
|
|
||||||
"phpstan/phpstan-strict-rules": "^1.3",
|
|
||||||
"phpunit/phpunit": "^8.5 || ^9.5",
|
|
||||||
"vimeo/psalm": "^4.25 || ^5.4"
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"Doctrine\\Inflector\\": "lib/Doctrine/Inflector"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Guilherme Blanco",
|
|
||||||
"email": "guilhermeblanco@gmail.com"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Roman Borschel",
|
|
||||||
"email": "roman@code-factory.org"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Benjamin Eberlei",
|
|
||||||
"email": "kontakt@beberlei.de"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Jonathan Wage",
|
|
||||||
"email": "jonwage@gmail.com"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Johannes Schmitt",
|
|
||||||
"email": "schmittjoh@gmail.com"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "PHP Doctrine Inflector is a small library that can perform string manipulations with regard to upper/lowercase and singular/plural forms of words.",
|
|
||||||
"homepage": "https://www.doctrine-project.org/projects/inflector.html",
|
|
||||||
"keywords": [
|
|
||||||
"inflection",
|
|
||||||
"inflector",
|
|
||||||
"lowercase",
|
|
||||||
"manipulation",
|
|
||||||
"php",
|
|
||||||
"plural",
|
|
||||||
"singular",
|
|
||||||
"strings",
|
|
||||||
"uppercase",
|
|
||||||
"words"
|
|
||||||
],
|
|
||||||
"support": {
|
|
||||||
"issues": "https://github.com/doctrine/inflector/issues",
|
|
||||||
"source": "https://github.com/doctrine/inflector/tree/2.0.8"
|
|
||||||
},
|
|
||||||
"funding": [
|
|
||||||
{
|
|
||||||
"url": "https://www.doctrine-project.org/sponsorship.html",
|
|
||||||
"type": "custom"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://www.patreon.com/phpdoctrine",
|
|
||||||
"type": "patreon"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://tidelift.com/funding/github/packagist/doctrine%2Finflector",
|
|
||||||
"type": "tidelift"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"time": "2023-06-16T13:40:37+00:00"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "doctrine/instantiator",
|
"name": "doctrine/instantiator",
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
|
|
@ -8972,7 +8972,7 @@
|
||||||
"prefer-stable": false,
|
"prefer-stable": false,
|
||||||
"prefer-lowest": false,
|
"prefer-lowest": false,
|
||||||
"platform": {
|
"platform": {
|
||||||
"php": "^8.1",
|
"php": "^8.2",
|
||||||
"ext-curl": "*"
|
"ext-curl": "*"
|
||||||
},
|
},
|
||||||
"platform-dev": [],
|
"platform-dev": [],
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,7 @@
|
||||||
<rule ref="Generic.Files.LineLength"/>
|
<rule ref="Generic.Files.LineLength"/>
|
||||||
<rule ref="Generic.Formatting.DisallowMultipleStatements"/>
|
<rule ref="Generic.Formatting.DisallowMultipleStatements"/>
|
||||||
<rule ref="Generic.Formatting.MultipleStatementAlignment"/>
|
<rule ref="Generic.Formatting.MultipleStatementAlignment"/>
|
||||||
<rule ref="Generic.Formatting.NoSpaceAfterCast"/>
|
<rule ref="Generic.Formatting.SpaceAfterCast"/>
|
||||||
<rule ref="Generic.Functions.CallTimePassByReference"/>
|
|
||||||
<rule ref="Generic.Functions.FunctionCallArgumentSpacing"/>
|
<rule ref="Generic.Functions.FunctionCallArgumentSpacing"/>
|
||||||
<rule ref="Generic.Metrics.CyclomaticComplexity"/>
|
<rule ref="Generic.Metrics.CyclomaticComplexity"/>
|
||||||
<rule ref="Generic.Metrics.NestingLevel"/>
|
<rule ref="Generic.Metrics.NestingLevel"/>
|
||||||
|
|
@ -42,9 +41,7 @@
|
||||||
<rule ref="Generic.Strings.UnnecessaryStringConcat"/>
|
<rule ref="Generic.Strings.UnnecessaryStringConcat"/>
|
||||||
<rule ref="Generic.WhiteSpace.DisallowTabIndent"/>
|
<rule ref="Generic.WhiteSpace.DisallowTabIndent"/>
|
||||||
<rule ref="Generic.WhiteSpace.ScopeIndent"/>
|
<rule ref="Generic.WhiteSpace.ScopeIndent"/>
|
||||||
<rule ref="MySource.PHP.EvalObjectFactory"/>
|
<rule ref="Generic.WhiteSpace.LanguageConstructSpacing"/>
|
||||||
<rule ref="MySource.PHP.GetRequestData"/>
|
|
||||||
<rule ref="MySource.PHP.AjaxNullComparison"/>
|
|
||||||
<rule ref="PEAR.Classes.ClassDeclaration"/>
|
<rule ref="PEAR.Classes.ClassDeclaration"/>
|
||||||
<rule ref="PEAR.Commenting.InlineComment"/>
|
<rule ref="PEAR.Commenting.InlineComment"/>
|
||||||
<rule ref="PSR1.Classes.ClassDeclaration"/>
|
<rule ref="PSR1.Classes.ClassDeclaration"/>
|
||||||
|
|
@ -77,7 +74,6 @@
|
||||||
<rule ref="Squiz.Scope.MemberVarScope"/>
|
<rule ref="Squiz.Scope.MemberVarScope"/>
|
||||||
<rule ref="Squiz.Scope.MethodScope"/>
|
<rule ref="Squiz.Scope.MethodScope"/>
|
||||||
<rule ref="Squiz.Scope.StaticThisUsage"/>
|
<rule ref="Squiz.Scope.StaticThisUsage"/>
|
||||||
<rule ref="Squiz.WhiteSpace.LanguageConstructSpacing"/>
|
|
||||||
<rule ref="Squiz.WhiteSpace.LogicalOperatorSpacing"/>
|
<rule ref="Squiz.WhiteSpace.LogicalOperatorSpacing"/>
|
||||||
<rule ref="Squiz.WhiteSpace.MemberVarSpacing">
|
<rule ref="Squiz.WhiteSpace.MemberVarSpacing">
|
||||||
<properties>
|
<properties>
|
||||||
|
|
|
||||||
|
|
@ -3,26 +3,27 @@
|
||||||
namespace LDC\LDCCRM;
|
namespace LDC\LDCCRM;
|
||||||
|
|
||||||
use LDC\LDCCRM\Enums\ApiStatus;
|
use LDC\LDCCRM\Enums\ApiStatus;
|
||||||
|
use LDC\LDCCRM\Models\Claim;
|
||||||
use LDC\LDCCRM\Models\Customer;
|
use LDC\LDCCRM\Models\Customer;
|
||||||
use LDC\LDCCRM\Models\SingleOptin;
|
use LDC\LDCCRM\Models\SingleOptin;
|
||||||
use LDC\LDCCRM\Transport\ApiInterface;
|
use LDC\LDCCRM\Transport\ApiInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the main class to interact with the CRM
|
* This is the main class to interact with the CRM.
|
||||||
*
|
*
|
||||||
* @package LDCCrmClient
|
* @package LDCCrmClient
|
||||||
*/
|
*/
|
||||||
class CrmApiV4
|
class CrmApiV4
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The Api object that will handle requests and responses
|
* The Api object that will handle requests and responses.
|
||||||
*
|
*
|
||||||
* @var \LDC\LDCCRM\Transport\ApiInterface
|
* @var \LDC\LDCCRM\Transport\ApiInterface
|
||||||
*/
|
*/
|
||||||
private static $apiInterface;
|
private static $apiInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CrmApiV4
|
* CrmApiV4.
|
||||||
*
|
*
|
||||||
* @param string|null $endpoint
|
* @param string|null $endpoint
|
||||||
* @param string|null $bearerToken
|
* @param string|null $bearerToken
|
||||||
|
|
@ -42,7 +43,7 @@ class CrmApiV4
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use this the ping the crm and know its current status
|
* Use this the ping the crm and know its current status.
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
* @throws \LDC\LDCCRM\Exceptions\CrmException If an error occurs
|
* @throws \LDC\LDCCRM\Exceptions\CrmException If an error occurs
|
||||||
|
|
@ -57,7 +58,7 @@ class CrmApiV4
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Get a customer from its hashcode or email
|
* Get a customer from its hashcode or email.
|
||||||
* If it does not exists a new instance
|
* If it does not exists a new instance
|
||||||
* will be returned. You would have
|
* will be returned. You would have
|
||||||
* to call its save method later on.
|
* to call its save method later on.
|
||||||
|
|
@ -75,7 +76,7 @@ class CrmApiV4
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a customer from its hashcode or email
|
* Get a customer from its hashcode or email.
|
||||||
* If it does not exists a new instance
|
* If it does not exists a new instance
|
||||||
* will be returned. You would have
|
* will be returned. You would have
|
||||||
* to call its save method later on.
|
* to call its save method later on.
|
||||||
|
|
@ -93,10 +94,11 @@ class CrmApiV4
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the single optin status for an email
|
* Set the single optin status for an email.
|
||||||
*
|
*
|
||||||
* @param string $email
|
* @param string $email
|
||||||
* @param boolean $opt_in
|
* @param boolean $opt_in
|
||||||
|
* @param array|null $answerId
|
||||||
* @return boolean true if succeeded
|
* @return boolean true if succeeded
|
||||||
* @throws \LDC\LDCCRM\Exceptions\ValidationException If a field email could not be validated.
|
* @throws \LDC\LDCCRM\Exceptions\ValidationException If a field email could not be validated.
|
||||||
* @throws \LDC\LDCCRM\Exceptions\CrmException If an error occurs on server side or on getting response.
|
* @throws \LDC\LDCCRM\Exceptions\CrmException If an error occurs on server side or on getting response.
|
||||||
|
|
@ -104,13 +106,13 @@ class CrmApiV4
|
||||||
* Possibles are : - singleOptinCustomerExists, If a customer exists with this email.
|
* Possibles are : - singleOptinCustomerExists, If a customer exists with this email.
|
||||||
* @phpcs:ignore Squiz.Commenting.FunctionCommentThrowTag.WrongNumber
|
* @phpcs:ignore Squiz.Commenting.FunctionCommentThrowTag.WrongNumber
|
||||||
*/
|
*/
|
||||||
public static function setStatus(#[\SensitiveParameter] string $email, bool $opt_in): bool
|
public static function setStatus(#[\SensitiveParameter] string $email, bool $opt_in, ?array $answerId = null): bool
|
||||||
{
|
{
|
||||||
return SingleOptin::setStatus($email, $opt_in);
|
return SingleOptin::setStatus($email, $opt_in, $answerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the single optin status for an email
|
* Unset the single optin status for an email.
|
||||||
*
|
*
|
||||||
* @param string $hashcode
|
* @param string $hashcode
|
||||||
* @return boolean true if succeeded
|
* @return boolean true if succeeded
|
||||||
|
|
@ -126,7 +128,50 @@ class CrmApiV4
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test a customer credentials to see if it can login
|
* Set new claim.
|
||||||
|
*
|
||||||
|
* @param string $last_name
|
||||||
|
* @param string $first_name
|
||||||
|
* @param string $email
|
||||||
|
* @param string $message
|
||||||
|
* @param integer $subject_id
|
||||||
|
* @param string|null $address
|
||||||
|
* @param string|null $city
|
||||||
|
* @param string|null $postcode
|
||||||
|
* @param string|null $file
|
||||||
|
* @return boolean true if succeeded
|
||||||
|
* @throws \LDC\LDCCRM\Exceptions\ValidationException If a field email could not be validated.
|
||||||
|
* @throws \LDC\LDCCRM\Exceptions\CrmException If an error occurs on server side or on getting response.
|
||||||
|
* @throws \LDC\LDCCRM\Exceptions\ApiErrorException If any error or \LDC\LDCCRM\Enums\ApiError occurs.
|
||||||
|
* Possibles are : - singleOptinCustomerExists, If a customer exists with this email.
|
||||||
|
* @phpcs:ignore Squiz.Commenting.FunctionCommentThrowTag.WrongNumber
|
||||||
|
*/
|
||||||
|
public static function setClaim(
|
||||||
|
#[\SensitiveParameter] string $last_name,
|
||||||
|
#[\SensitiveParameter] string $first_name,
|
||||||
|
#[\SensitiveParameter] string $email,
|
||||||
|
#[\SensitiveParameter] string $message,
|
||||||
|
#[\SensitiveParameter] int $subject_id,
|
||||||
|
#[\SensitiveParameter] ?string $address = null,
|
||||||
|
#[\SensitiveParameter] ?string $city = null,
|
||||||
|
#[\SensitiveParameter] ?string $postcode = null,
|
||||||
|
#[\SensitiveParameter] ?string $file = null,
|
||||||
|
): bool {
|
||||||
|
return Claim::setClaim(
|
||||||
|
$last_name,
|
||||||
|
$first_name,
|
||||||
|
$email,
|
||||||
|
$message,
|
||||||
|
$subject_id,
|
||||||
|
$address,
|
||||||
|
$city,
|
||||||
|
$postcode,
|
||||||
|
$file,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test a customer credentials to see if it can login.
|
||||||
*
|
*
|
||||||
* @param string $email
|
* @param string $email
|
||||||
* @param string $password
|
* @param string $password
|
||||||
|
|
|
||||||
|
|
@ -517,33 +517,30 @@ enum Country: int
|
||||||
* Get valid countries label.
|
* Get valid countries label.
|
||||||
*
|
*
|
||||||
* @return array<string>
|
* @return array<string>
|
||||||
* @codeCoverageIgnore
|
|
||||||
*/
|
*/
|
||||||
public static function getValidCountriesLabel(): array
|
public static function getValidCountriesLabel(): array
|
||||||
{
|
{
|
||||||
return collect(self::getValidCountries())->map(function (self $country) {
|
return \array_map(function (self $country) {
|
||||||
return $country->label();
|
return $country->label();
|
||||||
})->all();
|
}, self::getValidCountries());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get valid countries value.
|
* Get valid countries value.
|
||||||
*
|
*
|
||||||
* @return array<string|integer>
|
* @return array<string|integer>
|
||||||
* @codeCoverageIgnore
|
|
||||||
*/
|
*/
|
||||||
public static function getValidCountriesValues(): array
|
public static function getValidCountriesValues(): array
|
||||||
{
|
{
|
||||||
return collect(self::getValidCountries())->map(function (self $country) {
|
return \array_map(function (self $country) {
|
||||||
return $country->value();
|
return $country->value();
|
||||||
})->all();
|
}, self::getValidCountries());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Alpha 2 ISO code of valid countries
|
* Get Alpha 2 ISO code of valid countries
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
* @codeCoverageIgnore
|
|
||||||
*/
|
*/
|
||||||
public static function getValidIsoAplha2Codes(): array
|
public static function getValidIsoAplha2Codes(): array
|
||||||
{
|
{
|
||||||
|
|
@ -554,7 +551,6 @@ enum Country: int
|
||||||
* Get valid countries
|
* Get valid countries
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
* @codeCoverageIgnore
|
|
||||||
*/
|
*/
|
||||||
public static function getValidCountries(): array
|
public static function getValidCountries(): array
|
||||||
{
|
{
|
||||||
|
|
@ -572,7 +568,9 @@ enum Country: int
|
||||||
Country::saintMartinFrenchPart,
|
Country::saintMartinFrenchPart,
|
||||||
Country::wallisAndFutuna,
|
Country::wallisAndFutuna,
|
||||||
Country::frenchPolynesia,
|
Country::frenchPolynesia,
|
||||||
Country::newCaledonia
|
Country::newCaledonia,
|
||||||
|
Country::netherlands,
|
||||||
|
Country::germany,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -580,32 +578,32 @@ enum Country: int
|
||||||
* Enum classes
|
* Enum classes
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
* @codeCoverageIgnore
|
|
||||||
*/
|
*/
|
||||||
protected static function isoCodes(): array
|
protected static function isoCodes(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'france' => 'FR',
|
'france' => 'FR',
|
||||||
'belgium' => 'BE',
|
'belgium' => 'BE',
|
||||||
'luxembourg' => 'LU',
|
'luxembourg' => 'LU',
|
||||||
'guadeloupe' => 'GP',
|
'guadeloupe' => 'GP',
|
||||||
'martinique' => 'MQ',
|
'martinique' => 'MQ',
|
||||||
'frenchGuiana' => 'GF',
|
'frenchGuiana' => 'GF',
|
||||||
'reunion' => 'RE',
|
'reunion' => 'RE',
|
||||||
'saintPierreAndMiquelon' => 'PM',
|
'saintPierreAndMiquelon' => 'PM',
|
||||||
'mayotte' => 'YT',
|
'mayotte' => 'YT',
|
||||||
'saintBarthelemy' => 'BL',
|
'saintBarthelemy' => 'BL',
|
||||||
'saintMartinFrenchPart' => 'MF',
|
'saintMartinFrenchPart' => 'MF',
|
||||||
'wallisAndFutuna' => 'WF',
|
'wallisAndFutuna' => 'WF',
|
||||||
'frenchPolynesia' => 'PF',
|
'frenchPolynesia' => 'PF',
|
||||||
'newCaledonia' => 'NC',
|
'newCaledonia' => 'NC',
|
||||||
|
'netherlands' => 'NL',
|
||||||
|
'germany' => 'DE',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $attribute
|
* @param string $attribute
|
||||||
* @return integer|string|null
|
* @return integer|string|null
|
||||||
* @codeCoverageIgnore
|
|
||||||
*/
|
*/
|
||||||
public function get(string $attribute): int|string|null
|
public function get(string $attribute): int|string|null
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ namespace LDC\LDCCRM\Enums;
|
||||||
|
|
||||||
use LDC\LDCCRM\Traits\BaseEnum;
|
use LDC\LDCCRM\Traits\BaseEnum;
|
||||||
|
|
||||||
enum LogLevel: int
|
enum LogLevel: string
|
||||||
{
|
{
|
||||||
use BaseEnum;
|
use BaseEnum;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ use Illuminate\Support\Facades\Log;
|
||||||
*
|
*
|
||||||
* @package LDCCrmClient
|
* @package LDCCrmClient
|
||||||
* @subpackage exceptions
|
* @subpackage exceptions
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
class CrmException extends \RuntimeException
|
class CrmException extends \RuntimeException
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -125,6 +125,7 @@ class Answer extends ClientModel
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
|
#[\ReturnTypeWillChange]
|
||||||
public function jsonSerialize()
|
public function jsonSerialize()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
|
|
||||||
|
|
@ -327,11 +327,11 @@ class ArcadiaMailDefault extends ClientModel
|
||||||
try {
|
try {
|
||||||
$properties['state_order'] = (\is_object($properties['state_order']) and
|
$properties['state_order'] = (\is_object($properties['state_order']) and
|
||||||
get_class($properties['state_order']) === ArcadiaOrderType::class) ?
|
get_class($properties['state_order']) === ArcadiaOrderType::class) ?
|
||||||
$properties['state_order']->value() : (ctype_digit($properties['state_order']) ?
|
$properties['state_order']->value() : (ctype_digit((string) $properties['state_order']) ?
|
||||||
(int)$properties['state_order'] : $properties['state_order']);
|
(int) $properties['state_order'] : $properties['state_order']);
|
||||||
} catch (\TypeError | \BadMethodCallException) {
|
} catch (\TypeError | \BadMethodCallException) {
|
||||||
// * Cast anyway
|
// * Cast anyway
|
||||||
$properties['state_order'] = (int)$properties['state_order'];
|
$properties['state_order'] = (int) $properties['state_order'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
parent::fill($properties);
|
parent::fill($properties);
|
||||||
|
|
@ -391,6 +391,7 @@ class ArcadiaMailDefault extends ClientModel
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
|
#[\ReturnTypeWillChange]
|
||||||
public function jsonSerialize()
|
public function jsonSerialize()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
|
|
||||||
|
|
@ -296,11 +296,11 @@ class ArcadiaMailGame extends ClientModel
|
||||||
try {
|
try {
|
||||||
$properties['state_order'] = (\is_object($properties['state_order']) and
|
$properties['state_order'] = (\is_object($properties['state_order']) and
|
||||||
get_class($properties['state_order']) === ArcadiaOrderType::class) ?
|
get_class($properties['state_order']) === ArcadiaOrderType::class) ?
|
||||||
$properties['state_order']->value : (ctype_digit($properties['state_order']) ?
|
$properties['state_order']->value : (ctype_digit((string) $properties['state_order']) ?
|
||||||
(int)$properties['state_order'] : $properties['state_order']);
|
(int) $properties['state_order'] : $properties['state_order']);
|
||||||
} catch (\TypeError | \BadMethodCallException) {
|
} catch (\TypeError | \BadMethodCallException) {
|
||||||
// * Cast anyway
|
// * Cast anyway
|
||||||
$properties['state_order'] = (int)$properties['state_order'];
|
$properties['state_order'] = (int) $properties['state_order'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
parent::fill($properties);
|
parent::fill($properties);
|
||||||
|
|
@ -334,6 +334,7 @@ class ArcadiaMailGame extends ClientModel
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
|
#[\ReturnTypeWillChange]
|
||||||
public function jsonSerialize()
|
public function jsonSerialize()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
|
|
||||||
88
src/Models/Claim.php
Normal file
88
src/Models/Claim.php
Normal file
|
|
@ -0,0 +1,88 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace LDC\LDCCRM\Models;
|
||||||
|
|
||||||
|
use LDC\LDCCRM\Enums\ApiStatus;
|
||||||
|
use LDC\LDCCRM\Utils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class allows to handle claim.
|
||||||
|
*
|
||||||
|
* @category Api Models
|
||||||
|
* @package LDCCrmClient
|
||||||
|
* @subpackage models
|
||||||
|
*/
|
||||||
|
abstract class Claim extends ClientModel
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Validation rules.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected static array $validation = [
|
||||||
|
'first_name' => 'required|string|min:3|max:255',
|
||||||
|
'last_name' => 'required|string|min:3|max:255',
|
||||||
|
'email' => 'required|email:rfc,dns,spoof,filter|max:255',
|
||||||
|
'address' => 'sometimes|nullable|string|max:255',
|
||||||
|
'city' => 'sometimes|nullable|string|min:2|max:255',
|
||||||
|
'postcode' => 'sometimes|nullable|string',
|
||||||
|
'file' => 'sometimes|nullable|string',
|
||||||
|
'message' => 'required|string|min:3',
|
||||||
|
'subject_id' => 'required|int|min:1',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set new claim.
|
||||||
|
*
|
||||||
|
* @param string $last_name
|
||||||
|
* @param string $first_name
|
||||||
|
* @param string $email
|
||||||
|
* @param string $message
|
||||||
|
* @param integer $subject_id
|
||||||
|
* @param string|null $address
|
||||||
|
* @param string|null $city
|
||||||
|
* @param string|null $postcode
|
||||||
|
* @param string|null $file
|
||||||
|
* @return boolean True if succeeded.
|
||||||
|
* @throws \LDC\LDCCRM\Exceptions\ValidationException If a field could not be validated.
|
||||||
|
* @throws \LDC\LDCCRM\Exceptions\CrmException If an error occurs on server side or on getting response.
|
||||||
|
* @throws \LDC\LDCCRM\Exceptions\ApiErrorException If any error or \LDC\LDCCRM\Enums\ApiError occurs.
|
||||||
|
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassAfterLastUsed,Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed
|
||||||
|
*/
|
||||||
|
public static function setClaim(
|
||||||
|
#[\SensitiveParameter] string $last_name,
|
||||||
|
#[\SensitiveParameter] string $first_name,
|
||||||
|
#[\SensitiveParameter] string $email,
|
||||||
|
#[\SensitiveParameter] string $message,
|
||||||
|
#[\SensitiveParameter] int $subject_id,
|
||||||
|
#[\SensitiveParameter] ?string $address = null,
|
||||||
|
#[\SensitiveParameter] ?string $city = null,
|
||||||
|
#[\SensitiveParameter] ?string $postcode = null,
|
||||||
|
#[\SensitiveParameter] string|null $file = null,
|
||||||
|
): bool {
|
||||||
|
// @phpcs:enable
|
||||||
|
$params = compact(
|
||||||
|
'last_name',
|
||||||
|
'first_name',
|
||||||
|
'email',
|
||||||
|
'message',
|
||||||
|
'subject_id',
|
||||||
|
'address',
|
||||||
|
'city',
|
||||||
|
'postcode',
|
||||||
|
'file',
|
||||||
|
);
|
||||||
|
|
||||||
|
// Validate all data.
|
||||||
|
foreach ($params as $key => $value) {
|
||||||
|
self::validateValue($key, $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
static::setUpApiInterface();
|
||||||
|
$response = static::$apiInterface->call(
|
||||||
|
Utils::getResquest('apiV4.claim.store', [], $params)
|
||||||
|
);
|
||||||
|
|
||||||
|
return $response->status->equals(ApiStatus::OK);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -146,7 +146,7 @@ abstract class ClientModel implements \JsonSerializable
|
||||||
$type = $this->getPropType($field);
|
$type = $this->getPropType($field);
|
||||||
// * Force boolean
|
// * Force boolean
|
||||||
if ($type === 'bool') {
|
if ($type === 'bool') {
|
||||||
$value = (\is_int($value) and ($value === 1 or $value === 0)) ? (bool)$value : $value;
|
$value = (\is_int($value) and ($value === 1 or $value === 0)) ? (bool) $value : $value;
|
||||||
}
|
}
|
||||||
if (!is_null($value) and !$this->checkFieldType($type, $value)) {
|
if (!is_null($value) and !$this->checkFieldType($type, $value)) {
|
||||||
throw new ValidationException("Wrong type for $field");
|
throw new ValidationException("Wrong type for $field");
|
||||||
|
|
@ -270,7 +270,7 @@ abstract class ClientModel implements \JsonSerializable
|
||||||
case '\\' . ArcadiaOrderType::class:
|
case '\\' . ArcadiaOrderType::class:
|
||||||
return $checkValueIsEnum(\ltrim($type, '\\'), $value);
|
return $checkValueIsEnum(\ltrim($type, '\\'), $value);
|
||||||
case 'boolean':
|
case 'boolean':
|
||||||
return \is_bool(\is_int($value) ? (bool)$value : $value);
|
return \is_bool(\is_int($value) ? (bool) $value : $value);
|
||||||
case 'array':
|
case 'array':
|
||||||
return \is_array($value);
|
return \is_array($value);
|
||||||
case 'string':
|
case 'string':
|
||||||
|
|
|
||||||
|
|
@ -355,11 +355,11 @@ class Customer extends ClientModel
|
||||||
try {
|
try {
|
||||||
$properties['country'] = (\is_object($properties['country']) and
|
$properties['country'] = (\is_object($properties['country']) and
|
||||||
get_class($properties['country']) === Country::class) ?
|
get_class($properties['country']) === Country::class) ?
|
||||||
$properties['country']->value : (ctype_digit($properties['country']) ?
|
$properties['country']->value : (is_numeric(trim($properties['country'])) ?
|
||||||
(int)$properties['country'] : $properties['country']);
|
(int) $properties['country'] : $properties['country']);
|
||||||
} catch (TypeError | \BadMethodCallException $e) {
|
} catch (TypeError | \BadMethodCallException $e) {
|
||||||
// * Cast anyway
|
// * Cast anyway
|
||||||
$properties['country'] = (int)$properties['country'];
|
$properties['country'] = (int) $properties['country'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
parent::fill($properties);
|
parent::fill($properties);
|
||||||
|
|
@ -614,6 +614,7 @@ class Customer extends ClientModel
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
|
#[\ReturnTypeWillChange]
|
||||||
public function jsonSerialize()
|
public function jsonSerialize()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
|
|
||||||
|
|
@ -154,11 +154,11 @@ class Question extends ClientModel
|
||||||
try {
|
try {
|
||||||
$properties['type'] = (\is_object($properties['type']) and
|
$properties['type'] = (\is_object($properties['type']) and
|
||||||
get_class($properties['type']) === QuestionType::class) ?
|
get_class($properties['type']) === QuestionType::class) ?
|
||||||
$properties['type']->value : (ctype_digit($properties['type']) ?
|
$properties['type']->value : (ctype_digit((string) $properties['type']) ?
|
||||||
(int)$properties['type'] : $properties['type']);
|
(int) $properties['type'] : $properties['type']);
|
||||||
} catch (\TypeError | \BadMethodCallException) {
|
} catch (\TypeError | \BadMethodCallException) {
|
||||||
// * Cast anyway
|
// * Cast anyway
|
||||||
$properties['type'] = (int)$properties['type'];
|
$properties['type'] = (int) $properties['type'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
parent::fill($properties);
|
parent::fill($properties);
|
||||||
|
|
@ -298,6 +298,7 @@ class Question extends ClientModel
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
|
#[\ReturnTypeWillChange]
|
||||||
public function jsonSerialize()
|
public function jsonSerialize()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
|
|
||||||
|
|
@ -27,26 +27,32 @@ abstract class SingleOptin extends ClientModel
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the single opt in status for an email
|
* Set the single opt in status for an email,
|
||||||
|
* with an optionnal answer associated.
|
||||||
*
|
*
|
||||||
* @param string $email
|
* @param string $email
|
||||||
* @param boolean $opt_in
|
* @param boolean $opt_in
|
||||||
|
* @param array<int,int>|null $answerId
|
||||||
* @return boolean true if succeeded
|
* @return boolean true if succeeded
|
||||||
* @throws \LDC\LDCCRM\Exceptions\ValidationException If a field email could not be validated.
|
* @throws \LDC\LDCCRM\Exceptions\ValidationException If a field email could not be validated.
|
||||||
* @throws \LDC\LDCCRM\Exceptions\CrmException If an error occurs on server side or on getting response.
|
* @throws \LDC\LDCCRM\Exceptions\CrmException If an error occurs on server side or on getting response.
|
||||||
* @throws \LDC\LDCCRM\Exceptions\ApiErrorException If any error or \LDC\LDCCRM\Enums\ApiError occurs.
|
* @throws \LDC\LDCCRM\Exceptions\ApiErrorException If any error or \LDC\LDCCRM\Enums\ApiError occurs.
|
||||||
* Possibles are : - singleOptinCustomerExists, If a customer exists with this email.
|
* Possibles are : - singleOptinCustomerExists, If a customer exists with this email.
|
||||||
*/
|
*/
|
||||||
public static function setStatus(#[\SensitiveParameter] string $email, bool $opt_in): bool
|
public static function setStatus(#[\SensitiveParameter] string $email, bool $opt_in, ?array $answerId = null): bool
|
||||||
{
|
{
|
||||||
self::validateValue('email', $email);
|
self::validateValue('email', $email);
|
||||||
static::setUpApiInterface();
|
static::setUpApiInterface();
|
||||||
$request = Utils::getResquest('apiV4.optin', [], [
|
|
||||||
'email' => $email,
|
|
||||||
'opt_in' => $opt_in
|
|
||||||
]);
|
|
||||||
|
|
||||||
$response = static::$apiInterface->call($request);
|
$payload = [
|
||||||
|
'email' => $email,
|
||||||
|
'opt_in' => $opt_in,
|
||||||
|
'answer_id' => (!empty($answerId)) ? $answerId : null,
|
||||||
|
];
|
||||||
|
|
||||||
|
$response = static::$apiInterface->call(
|
||||||
|
Utils::getResquest('apiV4.optin', [], array_filter($payload, fn($v) => !is_null($v)))
|
||||||
|
);
|
||||||
return $response->status->equals(ApiStatus::OK);
|
return $response->status->equals(ApiStatus::OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace LDC\LDCCRM\Traits;
|
namespace LDC\LDCCRM\Traits;
|
||||||
|
|
||||||
use Illuminate\Support\Str;
|
use Doctrine\Inflector\InflectorFactory;
|
||||||
|
|
||||||
trait BaseEnum
|
trait BaseEnum
|
||||||
{
|
{
|
||||||
|
|
@ -48,15 +48,16 @@ trait BaseEnum
|
||||||
{
|
{
|
||||||
if (empty(self::getCache('labels'))) {
|
if (empty(self::getCache('labels'))) {
|
||||||
$labels = self::getLabelsConstant();
|
$labels = self::getLabelsConstant();
|
||||||
self::setCache('labels', \collect(self::cases())
|
$array = [];
|
||||||
->mapWithKeys(function ($enum) use ($labels) {
|
\array_map(function ($enum) use (&$array, $labels) {
|
||||||
if (!\is_null($labels) and !isset($labels[$enum->name])) {
|
if (!\is_null($labels) and !isset($labels[$enum->name])) {
|
||||||
throw new \Error('Missing definition label ' . self::class . " for {$enum->name}");
|
throw new \Error('Missing definition label ' . self::class . " for {$enum->name}");
|
||||||
}
|
}
|
||||||
return [$enum->name => \trans(
|
$array = array_merge($array, [$enum->name => __(
|
||||||
!\is_null($labels) ? $labels[$enum->name] : Str::ucfirst($enum->name)
|
!\is_null($labels) ? $labels[$enum->name] : ucfirst($enum->name)
|
||||||
)];
|
)]);
|
||||||
})->all());
|
}, self::cases());
|
||||||
|
self::setCache('labels', $array);
|
||||||
}
|
}
|
||||||
return self::getCache('labels');
|
return self::getCache('labels');
|
||||||
}
|
}
|
||||||
|
|
@ -69,8 +70,11 @@ trait BaseEnum
|
||||||
public static function toValues(): array
|
public static function toValues(): array
|
||||||
{
|
{
|
||||||
if (empty(self::getCache('values'))) {
|
if (empty(self::getCache('values'))) {
|
||||||
self::setCache('values', \collect(self::cases())
|
$array = [];
|
||||||
->mapWithKeys(fn ($enum) => [$enum->name => $enum->value])->all());
|
\array_map(function ($enum) use (&$array) {
|
||||||
|
$array = array_merge($array, [$enum->name => $enum->value]);
|
||||||
|
}, self::cases());
|
||||||
|
self::setCache('values', $array);
|
||||||
}
|
}
|
||||||
return self::getCache('values');
|
return self::getCache('values');
|
||||||
}
|
}
|
||||||
|
|
@ -94,23 +98,25 @@ trait BaseEnum
|
||||||
{
|
{
|
||||||
if (empty(self::getCache('enums'))) {
|
if (empty(self::getCache('enums'))) {
|
||||||
$definitions = self::getCustomDefinitions();
|
$definitions = self::getCustomDefinitions();
|
||||||
self::setCache('enums', \collect(self::cases())
|
$array = [];
|
||||||
->mapWithKeys(function ($enum) use ($definitions) {
|
$inflector = InflectorFactory::create()->build();
|
||||||
$baseArray = [
|
\array_map(function ($enum) use (&$array, $definitions, $inflector) {
|
||||||
'name' => $enum->name,
|
$baseArray = [
|
||||||
'label' => $enum->label(),
|
'name' => $enum->name,
|
||||||
'value' => $enum->value,
|
'label' => $enum->label(),
|
||||||
];
|
'value' => $enum->value,
|
||||||
foreach ($definitions as $index => $elements) {
|
];
|
||||||
$index = Str::lower(Str::singular($index));
|
foreach ($definitions as $index => $elements) {
|
||||||
if (!isset($elements[$enum->name])) {
|
$index = $inflector->singularize(strtolower($index));
|
||||||
throw new \Error("Missing definition {$index} " . self::class . " for {$enum->name}");
|
if (!isset($elements[$enum->name])) {
|
||||||
}
|
throw new \Error("Missing definition {$index} " . self::class . " for {$enum->name}");
|
||||||
$baseArray[$index] = $elements[$enum->name];
|
|
||||||
}
|
}
|
||||||
return [$enum->name => (object)$baseArray];
|
$baseArray[$index] = $elements[$enum->name];
|
||||||
})->all());
|
}
|
||||||
}
|
$array = array_merge($array, [$enum->name => (object) $baseArray]);
|
||||||
|
}, self::cases());
|
||||||
|
self::setCache('enums', $array);
|
||||||
|
} //end if
|
||||||
return self::getCache('enums');
|
return self::getCache('enums');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -123,8 +129,7 @@ trait BaseEnum
|
||||||
*/
|
*/
|
||||||
public static function make(self|int|string $value, string $field = 'value'): self|null
|
public static function make(self|int|string $value, string $field = 'value'): self|null
|
||||||
{
|
{
|
||||||
return !\is_object($value) ?
|
return !\is_object($value) ? self::cases()[array_search($value, array_column(self::cases(), $field))] : $value;
|
||||||
\collect(self::cases())->keyBy($field)->get($value) : $value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -137,7 +142,7 @@ trait BaseEnum
|
||||||
public function equals(object ...$others): bool
|
public function equals(object ...$others): bool
|
||||||
{
|
{
|
||||||
foreach ($others as $other) {
|
foreach ($others as $other) {
|
||||||
if (!\in_array(BaseEnum::class, \class_uses_recursive($other))) {
|
if (!\in_array(BaseEnum::class, $this->classUsesRecursive($other))) {
|
||||||
throw new \Error(__METHOD__ .
|
throw new \Error(__METHOD__ .
|
||||||
' requires $enum to use ' . BaseEnum::class);
|
' requires $enum to use ' . BaseEnum::class);
|
||||||
}
|
}
|
||||||
|
|
@ -204,8 +209,8 @@ trait BaseEnum
|
||||||
{
|
{
|
||||||
if (!isset($GLOBALS[self::class])) {
|
if (!isset($GLOBALS[self::class])) {
|
||||||
$GLOBALS[self::class] = [
|
$GLOBALS[self::class] = [
|
||||||
'props' => [
|
'props' => [
|
||||||
'enums' => [],
|
'enums' => [],
|
||||||
'values' => [],
|
'values' => [],
|
||||||
'labels' => []
|
'labels' => []
|
||||||
],
|
],
|
||||||
|
|
@ -241,17 +246,65 @@ trait BaseEnum
|
||||||
{
|
{
|
||||||
// ? Has custom props in cache ?
|
// ? Has custom props in cache ?
|
||||||
if (!isset($GLOBALS[self::class]) or \is_null($GLOBALS[self::class]['customProps'])) {
|
if (!isset($GLOBALS[self::class]) or \is_null($GLOBALS[self::class]['customProps'])) {
|
||||||
$names = \collect(self::cases())->keyBy('name');
|
$names = [];
|
||||||
|
\array_map(function (self $enum) use (&$names) {
|
||||||
|
$names = array_merge($names, [$enum->name => $enum]);
|
||||||
|
}, self::cases());
|
||||||
|
|
||||||
$GLOBALS[self::class]['customProps'] = \collect((new \ReflectionClass(self::class))->getConstants())
|
$GLOBALS[self::class]['customProps'] = \array_filter(
|
||||||
->filter(function (mixed $constant, string $key) use ($names) {
|
(new \ReflectionClass(self::class))->getConstants(),
|
||||||
|
function (mixed $constant, string $key) use ($names) {
|
||||||
if ($key === 'LABELS' or !\is_array($constant)) {
|
if ($key === 'LABELS' or !\is_array($constant)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return \collect($constant)->keys()
|
return count(\array_filter(
|
||||||
->filter(fn (string $name) => $names->has($name))->count();
|
array_flip($constant),
|
||||||
})->all();
|
function (string $name) use ($names) {
|
||||||
}
|
return array_key_exists($name, $names);
|
||||||
|
}
|
||||||
|
));
|
||||||
|
},
|
||||||
|
ARRAY_FILTER_USE_BOTH
|
||||||
|
);
|
||||||
|
} //end if
|
||||||
return $GLOBALS[self::class]['customProps'];
|
return $GLOBALS[self::class]['customProps'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all traits used by a class, its parent classes and trait of their traits.
|
||||||
|
*
|
||||||
|
* @param object|string $class
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private function classUsesRecursive($class)
|
||||||
|
{
|
||||||
|
if (is_object($class)) {
|
||||||
|
$class = get_class($class);
|
||||||
|
}
|
||||||
|
|
||||||
|
$results = [];
|
||||||
|
|
||||||
|
foreach (array_reverse(class_parents($class) ?: []) + [$class => $class] as $class) {
|
||||||
|
$results += $this->traitUsesRecursive($class);
|
||||||
|
}
|
||||||
|
|
||||||
|
return array_unique($results);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all traits used by a trait and its traits.
|
||||||
|
*
|
||||||
|
* @param object|string $trait
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private function traitUsesRecursive($trait)
|
||||||
|
{
|
||||||
|
$traits = class_uses($trait) ?: [];
|
||||||
|
|
||||||
|
foreach ($traits as $trait) {
|
||||||
|
$traits += $this->traitUsesRecursive($trait);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $traits;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -101,11 +101,10 @@ class Response
|
||||||
$this->message = $response->getReasonPhrase();
|
$this->message = $response->getReasonPhrase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * Body should be json data.
|
// * Body should be json data.
|
||||||
if (($decodedJson = $this->tryDecodeJson($this->body->getContents())) === false) {
|
if (($decodedJson = $this->tryDecodeJson($this->body->getContents())) === false) {
|
||||||
if (Utils::getConfig('app.env') === 'testing') {
|
if (Utils::getConfig('app.env') === 'testing') {
|
||||||
dump((string)$this->body);
|
dump((string) $this->body);
|
||||||
}
|
}
|
||||||
throw new CrmException('The Api should have returned JSON data');
|
throw new CrmException('The Api should have returned JSON data');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ use LDC\LDCCRM\Exceptions\SkipValidationException;
|
||||||
use LDC\LDCCRM\Exceptions\ValidationException;
|
use LDC\LDCCRM\Exceptions\ValidationException;
|
||||||
use LDC\LDCCRM\Transport\Request;
|
use LDC\LDCCRM\Transport\Request;
|
||||||
use Respect\Validation\Validator;
|
use Respect\Validation\Validator;
|
||||||
use Illuminate\Support\Str;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the LDCCRM utility class
|
* This is the LDCCRM utility class
|
||||||
|
|
@ -281,7 +280,7 @@ class Utils
|
||||||
),
|
),
|
||||||
'validate' => function () use ($value, $params) {
|
'validate' => function () use ($value, $params) {
|
||||||
if (\is_string($value)) {
|
if (\is_string($value)) {
|
||||||
return \strlen($value) === (int)$params[0];
|
return \strlen($value) === (int) $params[0];
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -308,10 +307,10 @@ class Utils
|
||||||
),
|
),
|
||||||
'validate' => function () use ($value, $params) {
|
'validate' => function () use ($value, $params) {
|
||||||
if (\is_string($value)) {
|
if (\is_string($value)) {
|
||||||
return \strlen($value) >= (int)$params[0];
|
return \strlen($value) >= (int) $params[0];
|
||||||
}
|
}
|
||||||
if (\is_int($value)) {
|
if (\is_int($value)) {
|
||||||
return $value >= (int)$params[0];
|
return $value >= (int) $params[0];
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -338,10 +337,10 @@ class Utils
|
||||||
),
|
),
|
||||||
'validate' => function () use ($value, $params) {
|
'validate' => function () use ($value, $params) {
|
||||||
if (\is_string($value)) {
|
if (\is_string($value)) {
|
||||||
return \strlen($value) <= (int)$params[0];
|
return \strlen($value) <= (int) $params[0];
|
||||||
}
|
}
|
||||||
if (\is_int($value)) {
|
if (\is_int($value)) {
|
||||||
return $value <= (int)$params[0];
|
return $value <= (int) $params[0];
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -570,10 +569,10 @@ class Utils
|
||||||
): Request {
|
): Request {
|
||||||
// Convert bool to integer.
|
// Convert bool to integer.
|
||||||
$query = \array_map(function ($v) {
|
$query = \array_map(function ($v) {
|
||||||
return is_bool($v) ? (int)$v : $v;
|
return is_bool($v) ? (int) $v : $v;
|
||||||
}, $query);
|
}, $query);
|
||||||
$data = \array_map(function ($v) {
|
$data = \array_map(function ($v) {
|
||||||
return is_bool($v) ? (int)$v : $v;
|
return is_bool($v) ? (int) $v : $v;
|
||||||
}, $data);
|
}, $data);
|
||||||
|
|
||||||
$routes = \json_decode(\file_get_contents(__DIR__ . '/routes.json'), true);
|
$routes = \json_decode(\file_get_contents(__DIR__ . '/routes.json'), true);
|
||||||
|
|
@ -600,7 +599,7 @@ class Utils
|
||||||
$route['uri'] = sprintf('%s?%s', $route['uri'], \http_build_query($query));
|
$route['uri'] = sprintf('%s?%s', $route['uri'], \http_build_query($query));
|
||||||
}
|
}
|
||||||
return new Request(
|
return new Request(
|
||||||
HttpMethods::make(Str::lower($route['methods'][0]), 'name'),
|
HttpMethods::make(strtolower($route['methods'][0]), 'name'),
|
||||||
$route['uri'],
|
$route['uri'],
|
||||||
[],
|
[],
|
||||||
$data
|
$data
|
||||||
|
|
@ -655,29 +654,29 @@ class Utils
|
||||||
{
|
{
|
||||||
$message = "LDC CRM: $message";
|
$message = "LDC CRM: $message";
|
||||||
if (\class_exists('\Illuminate\Support\Facades\Log')) {
|
if (\class_exists('\Illuminate\Support\Facades\Log')) {
|
||||||
switch ($level->value) {
|
switch ($level) {
|
||||||
case LogLevel::EMERG->value():
|
case LogLevel::EMERG:
|
||||||
\Illuminate\Support\Facades\Log::emergency($message);
|
\Illuminate\Support\Facades\Log::emergency($message);
|
||||||
break;
|
break;
|
||||||
case LogLevel::ALERT->value():
|
case LogLevel::ALERT:
|
||||||
\Illuminate\Support\Facades\Log::alert($message);
|
\Illuminate\Support\Facades\Log::alert($message);
|
||||||
break;
|
break;
|
||||||
case LogLevel::CRIT->value():
|
case LogLevel::CRIT:
|
||||||
\Illuminate\Support\Facades\Log::critical($message);
|
\Illuminate\Support\Facades\Log::critical($message);
|
||||||
break;
|
break;
|
||||||
case LogLevel::ERR->value():
|
case LogLevel::ERR:
|
||||||
\Illuminate\Support\Facades\Log::error($message);
|
\Illuminate\Support\Facades\Log::error($message);
|
||||||
break;
|
break;
|
||||||
case LogLevel::WARNING->value():
|
case LogLevel::WARNING:
|
||||||
\Illuminate\Support\Facades\Log::warning($message);
|
\Illuminate\Support\Facades\Log::warning($message);
|
||||||
break;
|
break;
|
||||||
case LogLevel::NOTICE->value():
|
case LogLevel::NOTICE:
|
||||||
\Illuminate\Support\Facades\Log::notice($message);
|
\Illuminate\Support\Facades\Log::notice($message);
|
||||||
break;
|
break;
|
||||||
case LogLevel::INFO->value():
|
case LogLevel::INFO:
|
||||||
\Illuminate\Support\Facades\Log::info($message);
|
\Illuminate\Support\Facades\Log::info($message);
|
||||||
break;
|
break;
|
||||||
case LogLevel::DEBUG->value():
|
case LogLevel::DEBUG:
|
||||||
\Illuminate\Support\Facades\Log::debug($message);
|
\Illuminate\Support\Facades\Log::debug($message);
|
||||||
break;
|
break;
|
||||||
} //end switch
|
} //end switch
|
||||||
|
|
|
||||||
|
|
@ -181,7 +181,7 @@ class WPCrm
|
||||||
public static function check()
|
public static function check()
|
||||||
{
|
{
|
||||||
self::bootSessionIfNeeded();
|
self::bootSessionIfNeeded();
|
||||||
return (bool)self::getUser();
|
return (bool) self::getUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -264,6 +264,7 @@ class WPCrm
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
$customer->opt_in = !$customer->opt_in;
|
||||||
if (!self::makeApiV4Call($customer, 'save')) {
|
if (!self::makeApiV4Call($customer, 'save')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -276,7 +277,6 @@ class WPCrm
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$customer->opt_in = !$customer->opt_in;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -284,8 +284,9 @@ class WPCrm
|
||||||
* Set the single optin status for an email
|
* Set the single optin status for an email
|
||||||
* on the crm
|
* on the crm
|
||||||
*
|
*
|
||||||
* @param string $email
|
* @param string $email
|
||||||
* @param boolean $opt_in
|
* @param boolean $opt_in
|
||||||
|
* @param array|null $answerId
|
||||||
*
|
*
|
||||||
* @return boolean true if the operation succeeded false otherwise
|
* @return boolean true if the operation succeeded false otherwise
|
||||||
* @throws \LDC\LDCCRM\Exceptions\ValidationException If a field email could not be validated.
|
* @throws \LDC\LDCCRM\Exceptions\ValidationException If a field email could not be validated.
|
||||||
|
|
@ -293,20 +294,19 @@ class WPCrm
|
||||||
* @throws \LDC\LDCCRM\Exceptions\ApiErrorException If any error or \LDC\LDCCRM\Enums\ApiError occurs.
|
* @throws \LDC\LDCCRM\Exceptions\ApiErrorException If any error or \LDC\LDCCRM\Enums\ApiError occurs.
|
||||||
* Possibles are : - singleOptinCustomerExists, If a customer exists with this email.
|
* Possibles are : - singleOptinCustomerExists, If a customer exists with this email.
|
||||||
*/
|
*/
|
||||||
public static function setSingleOptin(string $email, bool $opt_in): bool
|
public static function setSingleOptin(string $email, bool $opt_in, ?array $answerId = null): bool
|
||||||
{
|
{
|
||||||
return self::makeApiV4Call(SingleOptin::class, 'setStatus', [
|
return self::makeApiV4Call(
|
||||||
$email, $opt_in
|
SingleOptin::class,
|
||||||
]);
|
'setStatus',
|
||||||
|
array_filter([$email, $opt_in, $answerId], fn($v) => !is_null($v))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Toggle the current user optin value
|
* Activate the current user
|
||||||
* on the current user and the crm
|
|
||||||
*
|
*
|
||||||
* @return boolean True if the operation succeeded.
|
* @return boolean True if the operation succeeded.
|
||||||
* @throws \LDC\LDCCRM\Exceptions\ValidationException If a customer's hashcode could not be validated.
|
|
||||||
* @throws \LDC\LDCCRM\Exceptions\CrmException If an error occurs on server side or on getting response.
|
|
||||||
* @throws \LDC\LDCCRM\Exceptions\ApiErrorException If any error or \LDC\LDCCRM\Enums\ApiError occurs.
|
* @throws \LDC\LDCCRM\Exceptions\ApiErrorException If any error or \LDC\LDCCRM\Enums\ApiError occurs.
|
||||||
* Possibles are : - modelNotFound, If this customer hashcode could not be found.
|
* Possibles are : - modelNotFound, If this customer hashcode could not be found.
|
||||||
* - customerAlreadyActive, It the customer is already activated.
|
* - customerAlreadyActive, It the customer is already activated.
|
||||||
|
|
@ -319,10 +319,19 @@ class WPCrm
|
||||||
if ($customer->status) {
|
if ($customer->status) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!self::makeApiV4Call($customer, 'activate')) {
|
try {
|
||||||
return false;
|
if (!self::makeApiV4Call($customer, 'activate')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (ApiErrorException $e) {
|
||||||
|
switch ($e->getApiError()) {
|
||||||
|
case ApiError::authorizationException->value():
|
||||||
|
case ApiError::modelNotFound->value():
|
||||||
|
return false;
|
||||||
|
default:
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$customer->opt_in = !$customer->opt_in;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -442,7 +451,7 @@ class WPCrm
|
||||||
return \forward_static_call_array([$obj, $method], $arguments);
|
return \forward_static_call_array([$obj, $method], $arguments);
|
||||||
} catch (ApiErrorException $e) {
|
} catch (ApiErrorException $e) {
|
||||||
switch ($e->getApiError()) {
|
switch ($e->getApiError()) {
|
||||||
case ApiError::apiAuthFailed->value():
|
case ApiError::apiAuthFailed:
|
||||||
Utils::log($e->getMessage(), LogLevel::CRIT);
|
Utils::log($e->getMessage(), LogLevel::CRIT);
|
||||||
throw $e;
|
throw $e;
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
|
|
@ -187,6 +187,7 @@ class WPCrmUser implements JsonSerializable
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
|
#[\ReturnTypeWillChange]
|
||||||
public function jsonSerialize()
|
public function jsonSerialize()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
|
|
||||||
|
|
@ -108,5 +108,11 @@
|
||||||
"GET",
|
"GET",
|
||||||
"HEAD"
|
"HEAD"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"apiV4.claim.store": {
|
||||||
|
"uri": "api/v4/claim",
|
||||||
|
"methods": [
|
||||||
|
"POST"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Reference in a new issue