PHP code example of oliverbj / cord
1. Go to this page and download the library: Download oliverbj/cord library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
oliverbj / cord example snippets
return [
'eadapter_connection' => [
'url' => env('CORD_URL', ''),
'username' => env('CORD_USERNAME', ''),
'password' => env('CORD_PASSWORD', ''),
],
];
//Get a shipment
Cord::shipment('SMIA12345678')
->run();
//Get a brokerage job
Cord::custom('BATL12345678')
->run();
//Get an organization
Cord::organization('SAGFURHEL')
->run();
//Get a company
Cord::company('CPH')
->run();
Cord::organization('SAGFURHEL')
->addAddress([
'code' => 'MAIN STREET NO. 1',
'addressOne' => 'Main Street',
'addressTwo' => 'Number One',
'country' => 'US',
'city' => 'Anytown',
'state' => 'NY',
'postcode' => '12345',
'relatedPort' => 'USNYC',
'capabilities' => [
'AddressType' => 'OFC',
'IsMainAddress' => 'false',
]
]);
//Get all the available documents from a shipment file
Cord::shipment('SMIA12345678')
->withDocuments()
->run();
//Get only documents from a shipment file that is the type "ARN"
Cord::shipment('SMIA92838292')
->withDocuments()
->filter('DocumentType', 'ARN')
->filter('IsPublished', True)
->run();
Cord::shipment('SJFK21060014')
->addDocument(
file_contents: base64_decode(file_get_contents("myfile.pdf")),
name: 'myfile.pdf',
type: 'MSC'
description: '(Optional)',
isPublished: true //default is *false*
)
->run();
Cord::shipment('SJFK21060014')
->addEvent(
date: date('c'),
type: 'DIM',
reference: 'My Reference',
isEstimate: true //default is *false*
)
->run();
Cord::organization()
->criteriaGroup([
[
'Entity' => 'OrgHeader',
'FieldName' => 'Code',
'Value' => 'US%'
],
[
'Entity' => 'OrgHeader',
'FieldName' => 'IsBroker',
'Value' => 'True'
],
], type: "Partial")
->run();
Cord::organization()
->criteriaGroup([
[
'Entity' => 'OrgHeader',
'FieldName' => 'Code',
'Value' => 'US%'
],
], type: "Partial")
->criteriaGroup([
[
'Entity' => 'OrgHeader',
'FieldName' => 'IsBroker',
'Value' => 'True'
],
], type: "Partial")
->run();
$config = "my_custom_connection";
Cord::shipment('SJFK21060014')
->withConfig($config)
->run();
return [
'base' => [
'eadapter_connection' => [
'url' => env('CORD_URL', ''),
'username' => env('CORD_USERNAME', ''),
'password' => env('CORD_PASSWORD', ''),
],
],
'my_custom_connection' => [
'eadapter_connection' => [
'url' => env('CORD_URL', ''),
'username' => env('CORD_USERNAME', ''),
'password' => env('CORD_PASSWORD', ''),
],
],
];
Cord::shipment('SJFK21041242')->toXml()->run();
$xml = Cord::custom('BJFK21041242')
->documents()
->filter('DocumentType', 'ARN')
->inspect();
return response($xml, 200, ['Content-Type' => 'application/xml']);
bash
php artisan vendor:publish --tag="cord-config"
xml
<Native xmlns="http://www.cargowise.com/Schemas/Native">
<Body>
<Organization>
<CriteriaGroup Type="Partial">
<Criteria Entity="OrgHeader" FieldName="Code">US%</Criteria>
<Criteria Entity="OrgHeader" FieldName="IsBroker">True</Criteria>
</CriteriaGroup>
</Organization>
</Body>
</Native>
xml
<Native xmlns="http://www.cargowise.com/Schemas/Native">
<Body>
<Organization>
<CriteriaGroup Type="Partial">
<Criteria Entity="OrgHeader" FieldName="Code">US%</Criteria>
</CriteriaGroup>
<CriteriaGroup Type="Partial">
<Criteria Entity="OrgHeader" FieldName="IsBroker">True</Criteria>
</CriteriaGroup>
</Organization>
</Body>
</Native>