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 [
'base' => [
'eadapter_connection' => [
'url' => env('CORD_URL', ''),
'username' => env('CORD_USERNAME', ''),
'password' => env('CORD_PASSWORD', ''),
],
],
];
use Oliverbj\Cord\Facades\Cord;
$schema = Cord::schema('one_off_quote.create');
$response = Cord::fromStructured('one_off_quote.create', [
'company' => 'CPH',
'branch' => 'A01',
'department' => 'FES',
'org_role' => 'LOC',
'event_branch' => 'QTE',
'event_department' => 'PRC',
'data_provider' => 'PORTAL',
'transport_mode' => 'SEA',
'packing_mode' => 'LCL',
'port_of_origin' => 'AUSYD',
'port_of_destination' => 'NZAKL',
'client_address' => 'ABSDEOSLP',
])->run();
use Oliverbj\Cord\Facades\Cord;
Cord::shipment('SMIA12345678')->run();
Cord::withCompany('CPH')
->oneOffQuote('QCPH00001004')
->get()
->run();
Cord::withCompany('CPH')
->oneOffQuote()
->create()
->branch('A01')
->department('FES')
->transportMode('SEA')
->portOfOrigin('AUSYD')
->portOfDestination('NZAKL')
->run();
Cord::custom('BATL12345678')->run();
Cord::withCompany('QHE')
->docManager('QU1', 'QHEL00011452')
->run();
Cord::organization('SAGFURHEL')->get()->run();
Cord::company('CPH')->run();
Cord::shipment('SMIA12345678')
->withCompany('CPH')
->run();
Cord::shipment('SMIA12345678')
->withSenderId('PartnerA')
->withRecipientId('PartnerB')
->run();
Cord::shipment('SMIA12345678')
->withDocuments()
->run();
Cord::shipment('SMIA92838292')
->withDocuments()
->filter('DocumentType', 'ARN')
->filter('IsPublished', true)
->run();
Cord::shipment('SJFK21060014')
->addDocument(
file_contents: base64_encode(file_get_contents('myfile.pdf')),
name: 'myfile.pdf',
type: 'MSC',
description: 'Optional description',
isPublished: true,
)
->run();
Cord::shipment('SJFK21060014')
->addEvent(
date: now()->toIso8601String(),
type: 'DIM',
reference: 'My Reference',
isEstimate: true,
)
->addEventContext('MBLNumber', 'HBL85161TRN')
->addEventContext('BOLNumber', '423908')
->run();
Cord::fromStructured('shipment.event.add', [
'key' => 'SJFK21060014',
'event' => [
'date' => now()->toIso8601String(),
'type' => 'DIM',
'reference' => 'My Reference',
'is_estimate' => true,
],
'event_contexts' => [
['type' => 'MBLNumber', 'value' => 'HBL85161TRN'],
['type' => 'BOLNumber', 'value' => '423908'],
],
])->run();
Cord::withCompany('QHE')
->docManager('QU1', 'QHEL00011452')
->run();
$xml = Cord::fromStructured('doc_manager.get', [
'company' => 'QHE',
'module' => 'QU1',
'key' => 'QHEL00011452',
])->inspect();
Cord::withCompany('QHE')
->docManager('QU1', 'QHEL00011452')
->filter('DocumentType', 'QUO')
->filter('IsPublished', true)
->run();
Cord::withCompany('QHE')
->docManager('QU1', 'QHEL00011452')
->filterCollection([
['type' => 'DocumentType', 'value' => 'QUO'],
['type' => 'BranchCode', 'value' => 'QTE'],
])
->filterCollection([
['type' => 'DocumentType', 'value' => 'INV'],
])
->run();
$xml = Cord::fromStructured('doc_manager.get', [
'company' => 'QHE',
'module' => 'QU1',
'key' => 'QHEL00011452',
'filter_collections' => [
[
'filters' => [
['type' => 'DocumentType', 'value' => 'QUO'],
['type' => 'BranchCode', 'value' => 'QTE'],
],
],
[
'filters' => [
['type' => 'DocumentType', 'value' => 'INV'],
],
],
],
])->inspect();
$schema = Cord::schema('doc_manager.get');
$active = Cord::withCompany('QHE')
->docManager('QU1', 'QHEL00011452')
->describe();
Cord::organization()
->criteriaGroup([
[
'Entity' => 'OrgHeader',
'FieldName' => 'Code',
'Value' => 'US%',
],
[
'Entity' => 'OrgHeader',
'FieldName' => 'IsBroker',
'Value' => 'True',
],
], type: 'Partial')
->get()
->run();
$json = Cord::organization()
->criteriaGroup([
[
'Entity' => 'OrgHeader',
'FieldName' => 'Code',
'Value' => 'SAGFURHEL',
],
], type: 'Key')
->get()
->toJson()
->run();
Cord::organization()
->criteriaGroup([
[
'Entity' => 'OrgHeader',
'FieldName' => 'Code',
'Value' => 'US%',
],
], type: 'Partial')
->criteriaGroup([
[
'Entity' => 'OrgHeader',
'FieldName' => 'IsBroker',
'Value' => 'True',
],
], type: 'Partial')
->get()
->run();
Cord::organization()
->criteriaGroup([
[
'Entity' => 'OrgHeader',
'FieldName' => 'Code',
'Value' => 'ABCDEF',
],
], type: 'Key')
->get()
->run();
Cord::withCompany('CPH')
->organization('NEWORG')
->create()
->fullName('New Organization Ltd')
->isActive(true)
->isForwarder(true)
->isConsignee(true)
->isConsignor(false)
->isAirLine(false)
->closestPort('AUSYD')
->addAddress(fn ($a) => $a
->code('MAIN ST')
->addressOne('1 Main Street')
->country('AU')
->city('Sydney')
->capability('OFC', isMainAddress: true)
)
->addContact(fn ($c) => $c
->name('Operations')
->email('[email protected] ')
)
->run();
Cord::withCompany('CPH')
->organization('SAGFURHEL')
->update()
->addAddress(fn ($a) => $a
->code('MAIN STREET NO. 1')
->addressOne('Main Street')
->addressTwo('Number One')
->country('US')
->city('Anytown')
->state('NY')
->postcode('12345')
->relatedPort('USNYC')
->capability('OFC', isMainAddress: false)
)
->run();
Cord::withCompany('CPH')
->organization('SAGFURHEL')
->update()
->addContact(fn ($c) => $c
->name('Jane Doe')
->email('[email protected] ')
->phone('+1 555 123 4567')
->language('EN')
)
->run();
Cord::withCompany('CPH')
->organization('SAGFURHEL')
->update()
->addEDICommunication(fn ($e) => $e
->module('IMP')
->purpose('CUS')
->direction('OUT')
->transport('EML')
->destination('[email protected] ')
->format('XML')
)
->run();
$source = Cord::organization('SOURCE')->get()->run();
Cord::withCompany('CPH')
->organization('TARGET')
->update()
->transferContact($source['OrgContactCollection']['OrgContact'][0])
->run();
// Introspect a specific operation
$schema = Cord::schema('organization.address.add');
// Execute via structured payload
$response = Cord::fromStructured('organization.contact.add', [
'company' => 'CPH',
'code' => 'SAGFURHEL',
'contact' => [
'name' => 'Jane Doe',
'email' => '[email protected] ',
],
])->run();
Cord::company()
->criteriaGroup([
[
'Entity' => 'GlbCompany',
'FieldName' => 'Code',
'Value' => 'CPH',
],
])
->run();
Cord::container()
->criteriaGroup([
[
'Entity' => 'GlbContainerType',
'FieldName' => 'Code',
'Value' => '20GP',
],
])
->get()
->run();
$xml = Cord::fromStructured('container.query', [
'criteria_groups' => [
[
'type' => 'Key',
'criteria' => [
['entity' => 'GlbContainerType', 'field_name' => 'Code', 'value' => '20GP'],
],
],
],
])->inspect();
Cord::staff()
->criteriaGroup([
[
'Entity' => 'GlbStaff',
'FieldName' => 'Code',
'Value' => 'BVO',
],
], type: 'Key')
->get()
->run();
$schema = Cord::schema('staff.query');
$active = Cord::staff('BVO')->get()->describe();
Cord::withCompany('CPH')
->staff()
->create()
->code('BVO')
->loginName('user.test')
->password('1234')
->fullName('User Test')
->email('[email protected] ')
->branch('TLS')
->department('FES')
->phone('+111')
->isActive(true)
->country('FR')
->replaceGroups(['ORGALL', 'OPSALL'])
->withPayload([
'FriendlyName' => 'User Test',
'Title' => 'Operations Specialist',
'GlbWorkTime' => [
'_attributes' => ['Action' => 'Insert'],
'MondayWorkingHours' => '*******************',
'TuesdayWorkingHours' => '*******************',
],
])
->run();
$schema = Cord::schema('staff.create');
$operations = Cord::staff()->describe();
Cord::withCompany('CPH')
->staff('BVO')
->update()
->fullName('Updated User')
->canLogin(false)
->email('[email protected] ')
->branch('CPH')
->department('OPS')
->removeGroup('OLDOPS')
->addGroup('NEWOPS')
->phone('+4511223344')
->country('DK')
->withPayload([
'FriendlyName' => 'Updated',
'Title' => 'Branch Manager',
'GlbWorkTime' => [
'_attributes' => ['Action' => 'Update'],
'MondayWorkingHours' => '********',
],
])
->run();
$response = Cord::withCompany('CPH')
->oneOffQuote('QCPH00001004')
->get()
->run();
$schema = Cord::schema('one_off_quote.get');
$active = Cord::oneOffQuote('QCPH00001004')->get()->describe();
Cord::withCompany('CPH')
->oneOffQuote()
->create()
->branch('A01')
->department('FES')
->orgRole('LOC')
->eventBranch('QTE')
->eventDepartment('PRC')
->transportMode('SEA')
->packingMode('LCL')
->commodity('GEN')
->portOfOrigin('AUSYD')
->portOfDestination('NZAKL')
->serviceLevel('STD')
->incoterm('DAP')
->totalWeight(5000, 'KG')
->totalVolume(19.2, 'M3')
->goodsValue(15000, 'AUD')
->additionalTerms('Export Only')
->isDomesticFreight(false)
->clientAddress('ABSDEOSLP')
->pickupAddress(fn ($a) => $a
->addressLine1('3 TENTH AVENUE')
->city('OYSTER BAY')
->country('AU')
)
->deliveryAddress('NZAKLDL1')
->carrierAddress('DHLAIR_WW')
->overseasAgentAddress('MAIATLSAV')
->addPotentialCarrier('KLMAIR_WW')
->addPotentialCarrier('LUFAIR_WW')
->addNote(fn ($n) => $n
->key('One Off Quote Notes')
->text('Handle as fragile. Deliver before noon if possible.')
)
->addChargeLine(fn ($c) => $c
->chargeCode('FRT')
->description('International Freight')
->costAmount('500.0000', 'AUD')
->sellAmount('1500.0000', 'AUD')
)
->addPackLine(fn ($p) => $p
->packageType('BOX')
->quantity(10)
->weight(500, 'KG')
->volume(2.5, 'M3')
)
->addAttachedDocument(fn ($d) => $d
->fileName('Quote.pdf')
->imageData(base64_encode(file_get_contents('Quote.pdf')))
->type('QTE')
->isPublished(true)
)
->withPayload([
'CustomizedFieldCollection' => [
'CustomizedField' => [
'DataType' => 'String',
'Key' => 'Test User',
'Value' => 'Janice Testing',
],
],
])
->run();
$xml = Cord::fromStructured('one_off_quote.create', [
'company' => 'CPH',
'branch' => 'A01',
'department' => 'FES',
'org_role' => 'LOC',
'event_branch' => 'QTE',
'event_department' => 'PRC',
'data_provider' => 'PORTAL',
'transport_mode' => 'SEA',
'packing_mode' => 'LCL',
'commodity' => 'GEN',
'port_of_origin' => 'AUSYD',
'port_of_destination' => 'NZAKL',
'client_address' => 'ABSDEOSLP',
'pickup_address' => [
'address_line_1' => '3 TENTH AVENUE',
'city' => 'OYSTER BAY',
'country' => 'AU',
],
'delivery_address' => 'NZAKLDL1',
'carrier_address' => 'DHLAIR_WW',
'overseas_agent_address' => 'MAIATLSAV',
'potential_carriers' => ['KLMAIR_WW', 'LUFAIR_WW'],
'notes' => [
[
'key' => 'One Off Quote Notes',
'text' => 'Handle as fragile. Deliver before noon if possible.',
],
],
'pack_lines' => [
[
'pack_type' => 'BOX',
'quantity' => 10,
'weight' => ['value' => 500, 'unit_code' => 'KG'],
'volume' => ['value' => 2.5, 'unit_code' => 'M3'],
],
],
])->inspect();
$querySchema = Cord::schema('one_off_quote.get');
$query = Cord::oneOffQuote('QCPH00001004')->get()->describe();
$schema = Cord::schema('one_off_quote.create');
$active = Cord::oneOffQuote()->create()->describe();
$docSchema = Cord::schema('one_off_quote.document.add');
$eventSchema = Cord::schema('one_off_quote.event.add');
Cord::withCompany('CPH')
->oneOffQuote('QCPH00001004')
->addDocument(
file_contents: base64_encode(file_get_contents('quote.pdf')),
name: 'quote.pdf',
type: 'QUO',
description: 'Signed quote',
isPublished: true,
)
->run();
Cord::fromStructured('one_off_quote.document.add', [
'company' => 'CPH',
'key' => 'QCPH00001004',
'document' => [
'file_contents' => base64_encode(file_get_contents('quote.pdf')),
'name' => 'quote.pdf',
'type' => 'QUO',
'description' => 'Signed quote',
'is_published' => true,
],
])->run();
Cord::withCompany('CPH')
->oneOffQuote('QCPH00001004')
->addEvent(
date: now()->toIso8601String(),
type: 'DIM',
reference: 'Quote milestone',
isEstimate: true,
)
->addEventContext('MBLNumber', 'HBL85161TRN')
->addEventContext('BOLNumber', '423908')
->run();
Cord::fromStructured('one_off_quote.event.add', [
'company' => 'CPH',
'key' => 'QCPH00001004',
'event' => [
'date' => now()->toIso8601String(),
'type' => 'DIM',
'reference' => 'Quote milestone',
'is_estimate' => true,
],
'event_contexts' => [
['type' => 'MBLNumber', 'value' => 'HBL85161TRN'],
['type' => 'BOLNumber', 'value' => '423908'],
],
])->run();
Cord::shipment('SJFK21060014')
->withConfig('archive')
->run();
return [
'base' => [
'eadapter_connection' => [
'url' => env('CORD_URL', ''),
'username' => env('CORD_USERNAME', ''),
'password' => env('CORD_PASSWORD', ''),
],
],
'archive' => [
'eadapter_connection' => [
'url' => env('CORD_ARCHIVE_URL', ''),
'username' => env('CORD_ARCHIVE_USERNAME', ''),
'password' => env('CORD_ARCHIVE_PASSWORD', ''),
],
],
];
$response = Cord::withConfig('NTG_TRN')
->rawXml($xml)
->run();
$status = $response['Status'];
$message = $response['ProcessingLog'] ?? null;
$xml = Cord::rawXml($xml)->inspect();
$json = Cord::shipment('SJFK21041242')
->toJson()
->run();
$json = Cord::rawXml($xml)
->toJson()
->run();
Cord::shipment('SJFK21041242')
->toXml()
->run();
$response = Cord::rawXml($xml)
->toXml()
->run();
// Varargs — top-level fields
$result = Cord::container()
->criteriaGroup([
[
'Entity' => 'GlbContainerType',
'FieldName' => 'ShippingMode',
'Value' => 'SEA',
],
], type: 'Partial')
->get()
->select('Code', 'ShippingMode')
->run();
// Single array argument
->select(['Code', 'ShippingMode', 'Description'])
// Dot-notation for nested fields
->select('Code', 'Owner.Code')
$json = Cord::organization()
->criteriaGroup([...])
->get()
->select('Code', 'FullName')
->toJson()
->run();
$xml = Cord::custom('BJFK21041242')
->withDocuments()
->filter('DocumentType', 'ARN')
->inspect();
return response($xml, 200, ['Content-Type' => 'application/xml']);
bash
php artisan vendor:publish --tag="cord-config"
bash
php artisan boost:install
bash
php artisan boost:update
bash
composer manual-staff-test -- --connection=NTG_TRN --payload=resources/manual/staff-payload.local.php --update
composer manual-staff-test -- --connection=NTG_TRN --payload=resources/manual/staff-payload.local.php --update --send