Correct arcadia Api V2 methods + unit tests
This commit is contained in:
parent
3f5c0d30e8
commit
2ae1d09afc
10 changed files with 452 additions and 59 deletions
|
|
@ -15,6 +15,7 @@ use DOMDocument;
|
|||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* TODO: séparer ça quand coté arcadia ils auront branché le cerveau
|
||||
|
|
@ -43,7 +44,7 @@ class ArcadiaController extends Controller
|
|||
ArcadiaMailType $type
|
||||
) {
|
||||
$request = $request->merge([
|
||||
'order_number' => str_pad(\intval($request->order_number), 9, '0', STR_PAD_LEFT)
|
||||
'order_num' => str_pad(\intval($request->order_num), 9, '0', STR_PAD_LEFT)
|
||||
]);
|
||||
$xml = 'none';
|
||||
try {
|
||||
|
|
@ -62,12 +63,18 @@ class ArcadiaController extends Controller
|
|||
|
||||
// Format xml
|
||||
$doc = new DOMDocument('1.0', 'utf-8');
|
||||
$doc->preserveWhiteSpace = true;
|
||||
$doc->xmlStandalone = true;
|
||||
$doc->preserveWhiteSpace = false;
|
||||
$doc->formatOutput = true;
|
||||
$doc->loadXML($xml);
|
||||
$xml = $doc->saveXML();
|
||||
|
||||
Storage::disk('arcadia')->put(date("Ymd_His") . ".xml", $xml);
|
||||
Storage::disk('arcadia')->put(Str::slug(sprintf(
|
||||
'v2_%s_%s%s.xml',
|
||||
$type->label,
|
||||
date('Ymd_His'),
|
||||
\microtime(true)
|
||||
)), $xml);
|
||||
return response()->json();
|
||||
} catch (\Exception $e) {
|
||||
Log::critical("ARCADIA XML CREATION FAILED : " . $e->getMessage());
|
||||
|
|
@ -102,7 +109,8 @@ class ArcadiaController extends Controller
|
|||
array $customerInfo
|
||||
): string {
|
||||
return view(
|
||||
'mail.arcadiaOrders.default',
|
||||
$type->equals(ArcadiaMailType::default()) ?
|
||||
'mail.arcadiaOrders.default' : 'mail.arcadiaOrders.game',
|
||||
[
|
||||
'request' => $request,
|
||||
'type' => $type,
|
||||
|
|
|
|||
|
|
@ -48,14 +48,14 @@ class SendArchadiaDefaultMailRequest extends BaseApiRequest
|
|||
],
|
||||
'support_code' => 'required|int',
|
||||
'deliver' => 'required|array',
|
||||
'deliver.firstname' => 'required|string|min:2',
|
||||
'deliver.lastname' => 'required|string|min:2',
|
||||
'deliver.email' => 'required|email:rfc,dns,spoof,filter',
|
||||
'deliver.address' => 'required|string|min:2',
|
||||
'deliver.address2' => 'sometimes|string|min:2',
|
||||
'deliver.city' => 'required|string|min:2',
|
||||
'deliver.postcode' => 'required|string|min:5',
|
||||
'deliver.phone' => 'required|string',
|
||||
'deliver.firstname' => 'required|string|min:1|max:255',
|
||||
'deliver.lastname' => 'required|string|min:1|max:255',
|
||||
'deliver.email' => 'required|email:rfc,dns,spoof,filter|max:255',
|
||||
'deliver.address' => 'required|string|min:2|max:255',
|
||||
'deliver.address2' => 'sometimes|string|min:2|max:255',
|
||||
'deliver.city' => 'required|string|min:2|max:255',
|
||||
'deliver.postcode' => 'required|string|min:5|max:255',
|
||||
'deliver.phone' => 'required|string|max:255',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,14 +42,14 @@ class SendArchadiaGameMailRequest extends BaseApiRequest
|
|||
'order_date' => 'required|date',
|
||||
'support_code' => 'required|int',
|
||||
'deliver' => 'required|array',
|
||||
'deliver.firstname' => 'required|string|min:2',
|
||||
'deliver.lastname' => 'required|string|min:2',
|
||||
'deliver.email' => 'required|email:rfc,dns,spoof,filter',
|
||||
'deliver.address' => 'required|string|min:2',
|
||||
'deliver.address2' => 'sometimes|string|min:2',
|
||||
'deliver.city' => 'required|string|min:2',
|
||||
'deliver.postcode' => 'required|digits:5',
|
||||
'deliver.phone' => 'required|string',
|
||||
'deliver.firstname' => 'required|string|min:1|max:255',
|
||||
'deliver.lastname' => 'required|string|min:1|max:255',
|
||||
'deliver.email' => 'required|email:rfc,dns,spoof,filter|max:255',
|
||||
'deliver.address' => 'required|string|min:2|max:255',
|
||||
'deliver.address2' => 'sometimes|string|min:2|max:255',
|
||||
'deliver.city' => 'required|string|min:2|max:255',
|
||||
'deliver.postcode' => 'required|string|min:5|max:255',
|
||||
'deliver.phone' => 'required|string|max:255',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
96
resources/documents/arcadia_default.xsd
Normal file
96
resources/documents/arcadia_default.xsd
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified"
|
||||
xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
||||
<xs:element name="export_arcadia">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="Commande">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="Num_Commande">
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:pattern value="[0-9]{9}"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:element>
|
||||
<xs:element name="Date_Commande">
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:pattern value="(0[1-9]|[12][0-9]|3[01])/(0[1-9]|1[012])/(19|20)\d\d"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:element>
|
||||
<xs:element type="xs:byte" name="Operation" />
|
||||
<xs:element name="Etat_Commande_CB">
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="1"/>
|
||||
<xs:enumeration value="Null"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:element>
|
||||
<xs:element name="Etat_Commande_Cheque">
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="1"/>
|
||||
<xs:enumeration value="Null"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:element>
|
||||
<xs:element name="Email_conso">
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:pattern value="[^@]+@[^\.]+\..+"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:element>
|
||||
<xs:element name="Civilite">
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value=""/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:element>
|
||||
<xs:element type="xs:string" name="Nom" />
|
||||
<xs:element type="xs:string" name="Prenom" />
|
||||
<xs:element type="xs:string" name="Adresse" />
|
||||
<xs:element type="xs:string" name="Adresse_Complementaire" />
|
||||
<xs:element type="xs:string" name="CP" />
|
||||
<xs:element type="xs:string" name="Ville" />
|
||||
<xs:element type="xs:string" name="Telephone" />
|
||||
<xs:element name="Ligne_de_Commande">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="Poids_Unitaire_Colis">
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="0"/>
|
||||
<xs:enumeration value="540"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:element>
|
||||
<xs:element name="Quantite">
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="1"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:element>
|
||||
<xs:element name="Code_Support">
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:unsignedInt">
|
||||
<xs:maxInclusive value="65535"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:element>
|
||||
<xs:element type="xs:string" name="Libelle_Type_Support" />
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:schema>
|
||||
95
resources/documents/arcadia_game.xsd
Normal file
95
resources/documents/arcadia_game.xsd
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified"
|
||||
xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
||||
<xs:element name="export_arcadia">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="Commande">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="Num_Commande">
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value=""/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:element>
|
||||
<xs:element name="Date_Commande">
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:pattern value="(0[1-9]|[12][0-9]|3[01])/(0[1-9]|1[012])/(19|20)\d\d"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:element>
|
||||
<xs:element type="xs:byte" name="Operation" />
|
||||
<xs:element name="Email_conso">
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:pattern value="[^@]+@[^\.]+\..+"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:element>
|
||||
<xs:element name="Civilite">
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value=""/>
|
||||
<xs:enumeration value="1"/>
|
||||
<xs:enumeration value="2"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:element>
|
||||
<xs:element type="xs:string" name="Nom" />
|
||||
<xs:element type="xs:string" name="Prenom" />
|
||||
<xs:element type="xs:string" name="Adresse" />
|
||||
<xs:element type="xs:string" name="Adresse_Complementaire" />
|
||||
<xs:element type="xs:string" name="CP" />
|
||||
<xs:element type="xs:string" name="Ville" />
|
||||
<xs:element type="xs:string" name="Telephone" />
|
||||
<xs:element name="Ligne_de_Commande">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="Quantite">
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="1"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:element>
|
||||
<xs:element name="Poids_Unitaire_Colis">
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:pattern value="[0-9]*|"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:element>
|
||||
<xs:element name="Code_Support">
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:unsignedInt">
|
||||
<xs:maxInclusive value="65535"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:element>
|
||||
<xs:element type="xs:string" name="Libelle_Type_Support" />
|
||||
<xs:element name="Code_on_Pack">
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:pattern value="\d{13}|\d{8}|\d{7}|\d{6}"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:element>
|
||||
<xs:element name="Code_Unique" minOccurs="0">
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:pattern value="[0-9A-Z]*|"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:schema>
|
||||
|
|
@ -1,41 +1,46 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<EXPORT_ARCADIA>
|
||||
<COMMANDE>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<export_arcadia>
|
||||
<Commande>
|
||||
<Num_Commande>{{ $request->order_num }}</Num_Commande>
|
||||
<Date_Commande>{{ Carbon::parse($request->order_date)->format('d/m/Y') }}</Date_Commande>
|
||||
<Operation>{{ $request->operation }}</Operation>
|
||||
@if($type->equals(ArcadiaMailType::default()))
|
||||
@if($orderType->equals(ArcadiaOrderType::cb()))
|
||||
<Etat_Commande_CB>1</Etat_Commande_CB>
|
||||
<Etat_Commande_Cheque>Null</Etat_Commande_Cheque>
|
||||
@elseif($orderType->equals(ArcadiaOrderType::check()))
|
||||
<Etat_Commande_CB>Null</Etat_Commande_CB>
|
||||
<Etat_Commande_Cheque>1</Etat_Commande_Cheque>
|
||||
@endif
|
||||
@endif
|
||||
<Email_conso><![CDATA[{{ $customerInfo['email'] }}]]></Email_conso>
|
||||
<CIVILITE></CIVILITE>
|
||||
<NOM><![CDATA[{{ $customerInfo['lastname'] }}]]></NOM>
|
||||
<Civilite/>
|
||||
<Nom><![CDATA[{{ $customerInfo['lastname'] }}]]></Nom>
|
||||
<Prenom><![CDATA[{{ $customerInfo['firstname'] }}]]></Prenom>
|
||||
<Adresse><![CDATA[{{ $customerInfo['address'] }}]]></Adresse>
|
||||
@if(strlen($customerInfo['address2']))
|
||||
<Adresse_Complementaire><![CDATA[{{ $customerInfo['address2'] }}]]></Adresse_Complementaire>
|
||||
@else
|
||||
<Adresse_Complementaire/>
|
||||
@endif
|
||||
<CP><![CDATA[{{ $customerInfo['postcode'] }}]]></CP>
|
||||
<Ville><![CDATA[{{ $customerInfo['city'] }}]]></Ville>
|
||||
<Telephone><![CDATA[{{ $customerInfo['phone'] }}]]></Telephone>
|
||||
@if($type->equals(ArcadiaMailType::default()))
|
||||
@if($orderType->equals(ArcadiaOrderType::cb()))
|
||||
<Etat_Commande_CB>1</Etat_Commande_CB>
|
||||
<Etat_Commande_Cheque>Null</Etat_Commande_Cheque>@elseif($orderType->equals(ArcadiaOrderType::check()))
|
||||
<Etat_Commande_CB>Null</Etat_Commande_CB>
|
||||
<Etat_Commande_Cheque>1</Etat_Commande_Cheque>@endif @endif
|
||||
<Ligne_de_Commande>
|
||||
<Num_Commande>{{ $request->order_num }}</Num_Commande>
|
||||
<Date_Commande>{{ Carbon::parse($request->order_date)->format('d/m/Y') }}</Date_Commande>
|
||||
<Operation>{{ $request->operation }}</Operation>
|
||||
<Code_Support>{{ $request->support_code }}</Code_Support>
|
||||
<Libelle_Type_Support>{{ $request->label_type_support }}</Libelle_Type_Support>
|
||||
<Poids_Unitaire_Colis>{{ $request->package_unit_weight }}</Poids_Unitaire_Colis>
|
||||
@if(!is_null($request->qty))
|
||||
{{-- <Quantite>{{ $request->qty }}</Quantite> --}}
|
||||
{{-- Locked by Arcadia to quantity = 1 --}}
|
||||
<Quantite>1</Quantite>
|
||||
@endif
|
||||
<Code_Support>{{ $request->support_code }}</Code_Support>
|
||||
<Libelle_Type_Support>{{ $request->label_type_support }}</Libelle_Type_Support>
|
||||
@if($type->equals(ArcadiaMailType::game()))
|
||||
@if(!is_null($request->code_on_pack))
|
||||
<Code_on_Pack><![CDATA[{{ $request->code_on_pack }}]]></Code_on_Pack>
|
||||
@endif
|
||||
@if(!is_null($request->code_unique))
|
||||
<Code_Unique><![CDATA[{{ $request->code_unique }}]]></Code_Unique>
|
||||
@endif
|
||||
@endif
|
||||
</Ligne_de_Commande>
|
||||
@if($type->equals(ArcadiaMailType::game()))
|
||||
@if(!is_null($request->code_on_pack))
|
||||
<Code_on_Pack><![CDATA[{{ $request->code_on_pack }}]]></Code_on_Pack>
|
||||
@endif
|
||||
@if(!is_null($request->code_unique))
|
||||
<Code_Unique><![CDATA[{{ $request->code_unique }}]]></Code_Unique>
|
||||
@endif
|
||||
@endif
|
||||
</COMMANDE>
|
||||
</EXPORT_ARCADIA>
|
||||
</Commande>
|
||||
</export_arcadia>
|
||||
|
|
|
|||
33
resources/views/mail/arcadiaOrders/game.blade.php
Normal file
33
resources/views/mail/arcadiaOrders/game.blade.php
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<export_arcadia>
|
||||
<Commande>
|
||||
<Num_Commande/>
|
||||
<Date_Commande>{{ Carbon::parse($request->order_date)->format('d/m/Y') }}</Date_Commande>
|
||||
<Operation>{{ $request->operation }}</Operation>
|
||||
<Email_conso><![CDATA[{{ $customerInfo['email'] }}]]></Email_conso>
|
||||
<Civilite/>
|
||||
<Nom><![CDATA[{{ $customerInfo['lastname'] }}]]></Nom>
|
||||
<Prenom><![CDATA[{{ $customerInfo['firstname'] }}]]></Prenom>
|
||||
<Adresse><![CDATA[{{ $customerInfo['address'] }}]]></Adresse>
|
||||
@if(strlen($customerInfo['address2']))
|
||||
<Adresse_Complementaire><![CDATA[{{ $customerInfo['address2'] }}]]></Adresse_Complementaire>
|
||||
@else
|
||||
<Adresse_Complementaire/>
|
||||
@endif
|
||||
<CP><![CDATA[{{ $customerInfo['postcode'] }}]]></CP>
|
||||
<Ville><![CDATA[{{ $customerInfo['city'] }}]]></Ville>
|
||||
<Telephone><![CDATA[{{ $customerInfo['phone'] }}]]></Telephone>
|
||||
<Ligne_de_Commande>
|
||||
{{-- <Quantite>{{ $request->qty }}</Quantite> --}}
|
||||
{{-- Locked by Arcadia to quantity = 1 --}}
|
||||
<Quantite>1</Quantite>
|
||||
<Poids_Unitaire_Colis/>
|
||||
<Code_Support>{{ $request->support_code }}</Code_Support>
|
||||
<Libelle_Type_Support>{{ $request->label_type_support }}</Libelle_Type_Support>
|
||||
<Code_on_Pack><![CDATA[{{ $request->code_on_pack }}]]></Code_on_Pack>
|
||||
@if(!is_null($request->code_unique))
|
||||
<Code_Unique><![CDATA[{{ $request->code_unique }}]]></Code_Unique>
|
||||
@endif
|
||||
</Ligne_de_Commande>
|
||||
</Commande>
|
||||
</export_arcadia>
|
||||
|
|
@ -34,10 +34,10 @@ class ArcadiaTest extends ApiBase
|
|||
'label_type_support' => 'Send Departaimants',
|
||||
'order_date' => \date('Y/m/d H:i:s'),
|
||||
'state_order' => ArcadiaOrderType::cb()->value,
|
||||
'support_code' => 32,
|
||||
'support_code' => 1,
|
||||
'label_type_support' => 'Fond carte Aimanté',
|
||||
'order_num' => str_pad('23', 9, '0', STR_PAD_LEFT),
|
||||
'package_unit_weight' => 200,
|
||||
'order_num' => 23,
|
||||
'package_unit_weight' => 0,
|
||||
];
|
||||
$response = $this->callApiWithToken($service, 'post', route(
|
||||
'apiV2.arcadia.outgoingMailDefault'
|
||||
|
|
@ -65,8 +65,8 @@ class ArcadiaTest extends ApiBase
|
|||
'order_date' => date('Y/m/d H:i:s'),
|
||||
'support_code' => 32,
|
||||
'label_type_support' => 'Jeux Reghalal',
|
||||
'code_unique' => Str::uuid(),
|
||||
'code_on_pack' => 'anystring'
|
||||
'code_unique' => \strtoupper(\str_replace('-', '', (string)Str::uuid())),
|
||||
'code_on_pack' => '2563547'
|
||||
];
|
||||
$response = $this->callApiWithToken($service, 'post', route(
|
||||
'apiV2.arcadia.outgoingMailGame',
|
||||
|
|
|
|||
|
|
@ -350,4 +350,100 @@ class CrmClientV1CustomerTest extends CrmClientTester
|
|||
|
||||
$this->assertEquals('OK', $reponse->status);
|
||||
}
|
||||
|
||||
public function testCreateArcadiaOutgoingMailGameWithEan()
|
||||
{
|
||||
$api = new ApiV1(config('crm.endpoint'), config('crm.token'));
|
||||
$reponse = $api->ArcadiaOutgoingMail(
|
||||
ModelsCustomer::where('email', 'v1toto.delarogerie@gmail.com')
|
||||
->firstOrFail()->id,
|
||||
[
|
||||
'root' => [
|
||||
[
|
||||
'fieldName' => 'order_date',
|
||||
'fieldValue' => date('d/m/Y')
|
||||
],
|
||||
[
|
||||
'fieldName' => 'operation',
|
||||
'fieldValue' => '32'
|
||||
]
|
||||
],
|
||||
'orderLine' => [
|
||||
[
|
||||
'fieldName' => 'code_unique',
|
||||
'fieldValue' => '2A5B416325414232'
|
||||
],
|
||||
[
|
||||
'fieldName' => 'code_on_pack',
|
||||
'fieldValue' => '2541632541423'
|
||||
],
|
||||
[
|
||||
'fieldName' => 'support_code',
|
||||
'fieldValue' => '16'
|
||||
],
|
||||
[
|
||||
'fieldName' => 'label_type_support',
|
||||
'fieldValue' => 'Gain du lot : ballon de foot en métal type "fracture"'
|
||||
]
|
||||
]
|
||||
],
|
||||
'game',
|
||||
[
|
||||
"firstname" => 'toto',
|
||||
"lastname" => 'delarogerie',
|
||||
"address" => 'rue des toto',
|
||||
"city" => 'toto ville',
|
||||
"postcode" => '72000',
|
||||
"phone" => '0673891160'
|
||||
]
|
||||
);
|
||||
|
||||
$this->assertEquals('OK', $reponse->status);
|
||||
}
|
||||
|
||||
public function testCreateArcadiaOutgoingMailGameWithoutEan()
|
||||
{
|
||||
$api = new ApiV1(config('crm.endpoint'), config('crm.token'));
|
||||
$reponse = $api->ArcadiaOutgoingMail(
|
||||
ModelsCustomer::where('email', 'v1toto.delarogerie@gmail.com')
|
||||
->firstOrFail()->id,
|
||||
[
|
||||
'root' => [
|
||||
[
|
||||
'fieldName' => 'order_date',
|
||||
'fieldValue' => date('d/m/Y')
|
||||
],
|
||||
[
|
||||
'fieldName' => 'operation',
|
||||
'fieldValue' => '32'
|
||||
]
|
||||
],
|
||||
'orderLine' => [
|
||||
[
|
||||
'fieldName' => 'code_unique',
|
||||
'fieldValue' => '25416325414232'
|
||||
],
|
||||
[
|
||||
'fieldName' => 'support_code',
|
||||
'fieldValue' => '16'
|
||||
],
|
||||
[
|
||||
'fieldName' => 'label_type_support',
|
||||
'fieldValue' => 'Gain du lot : ballon de foot en métal type "fracture"'
|
||||
]
|
||||
]
|
||||
],
|
||||
'game',
|
||||
[
|
||||
"firstname" => 'toto',
|
||||
"lastname" => 'delarogerie',
|
||||
"address" => 'rue des toto',
|
||||
"city" => 'toto ville',
|
||||
"postcode" => '72000',
|
||||
"phone" => '0673891160'
|
||||
]
|
||||
);
|
||||
|
||||
$this->assertEquals('OK', $reponse->status);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use DOMDocument;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Str;
|
||||
use LDC\LDCCRM\CrmApiV2;
|
||||
use LDC\LDCCRM\Enums\ArcadiaOrderType;
|
||||
|
|
@ -14,7 +16,7 @@ class CrmClientV2ArcadiaTest extends CrmClientTester
|
|||
{
|
||||
$api = new CrmApiV2();
|
||||
$customer = $api->getCustomerOrNew(static::$info->hashcode);
|
||||
dump(static::$info->postcode);
|
||||
|
||||
$arcadiaOrderMail = new ArcadiaMailDefault([
|
||||
'email' => static::$customer->email,
|
||||
'firstname' => static::$info->firstname,
|
||||
|
|
@ -28,10 +30,10 @@ class CrmClientV2ArcadiaTest extends CrmClientTester
|
|||
'label_type_support' => 'Send Departaimants',
|
||||
'order_date' => \date('Y/m/d H:i:s'),
|
||||
'state_order' => ArcadiaOrderType::cb()->value,
|
||||
'support_code' => 32,
|
||||
'support_code' => 1,
|
||||
'label_type_support' => 'Fond carte Aimanté',
|
||||
'order_num' => 23,
|
||||
'package_unit_weight' => 200,
|
||||
'package_unit_weight' => 0,
|
||||
]);
|
||||
$this->assertTrue($arcadiaOrderMail->send($customer));
|
||||
}
|
||||
|
|
@ -40,7 +42,6 @@ class CrmClientV2ArcadiaTest extends CrmClientTester
|
|||
{
|
||||
$api = new CrmApiV2();
|
||||
$customer = $api->getCustomerOrNew(static::$info->hashcode);
|
||||
dump(static::$info->postcode);
|
||||
$arcadiaOrderMail = new ArcadiaMailGame([
|
||||
'email' => static::$customer->email,
|
||||
'firstname' => static::$info->firstname,
|
||||
|
|
@ -54,9 +55,68 @@ class CrmClientV2ArcadiaTest extends CrmClientTester
|
|||
'order_date' => date('Y/m/d H:i:s'),
|
||||
'support_code' => 32,
|
||||
'label_type_support' => 'Jeux Reghalal',
|
||||
'code_unique' => (string)Str::uuid(),
|
||||
'code_on_pack' => 'anystring'
|
||||
'code_unique' => \strtoupper(\str_replace('-', '', (string)Str::uuid())),
|
||||
'code_on_pack' => '12365214587562'
|
||||
]);
|
||||
$this->assertTrue($arcadiaOrderMail->send($customer));
|
||||
}
|
||||
|
||||
public function testValidateGeneratedXmlGame()
|
||||
{
|
||||
$fileFound = false;
|
||||
|
||||
$files = File::allFiles(\storage_path('export/arcadia'));
|
||||
|
||||
/** @var \Symfony\Component\Finder\SplFileInfo $file */
|
||||
foreach ($files as $file) {
|
||||
if (\strpos($file->getFilename(), 'v2-game') === 0) {
|
||||
$fileFound = true;
|
||||
|
||||
// Enable user error handling
|
||||
\libxml_use_internal_errors(true);
|
||||
|
||||
$xml = new DOMDocument();
|
||||
$xml->load($file->getRealPath());
|
||||
|
||||
if (!$xml->schemaValidate(\resource_path('documents/arcadia_game.xsd'))) {
|
||||
print '<b>DOMDocument::schemaValidate() Generated Errors!</b>';
|
||||
$this->libxmlDisplayErrors();
|
||||
throw new \Exception('Could not validate xml file against xsd');
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->assertTrue($fileFound, 'Should have found a xml file to validate and pass validation');
|
||||
}
|
||||
|
||||
private function libxmlDisplayError($error)
|
||||
{
|
||||
$return = "<br/>\n";
|
||||
switch ($error->level) {
|
||||
case LIBXML_ERR_WARNING:
|
||||
$return .= "<b>Warning $error->code</b>: ";
|
||||
break;
|
||||
case LIBXML_ERR_ERROR:
|
||||
$return .= "<b>Error $error->code</b>: ";
|
||||
break;
|
||||
case LIBXML_ERR_FATAL:
|
||||
$return .= "<b>Fatal Error $error->code</b>: ";
|
||||
break;
|
||||
}
|
||||
$return .= trim($error->message);
|
||||
if ($error->file) {
|
||||
$return .= " in <b>$error->file</b>";
|
||||
}
|
||||
$return .= " on line <b>$error->line</b>\n";
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
private function libxmlDisplayErrors()
|
||||
{
|
||||
$errors = libxml_get_errors();
|
||||
foreach ($errors as $error) {
|
||||
print $this->libxmlDisplayError($error);
|
||||
}
|
||||
libxml_clear_errors();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue