Download the PHP package oliverbj/cord without Composer
On this page you can find all versions of the php package oliverbj/cord. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package cord
Seamless integration to CargoWise One's eAdapter using the HTTP service using Laravel!
Cord offers a expressive, chainable and easy API to interact with CargoWise One's eAdapter using their HTTP Webservice.
Installation
You can install the package via composer:
You can publish the config file with:
This is the contents of the published config file:
Usage
Setting environment
In order to use Cord, you must specify the appropiate login details for your CargoWise One eAdapter service:
Modules
Cord comes with connectivity to the following modules:
- Bookings
booking()
- Shipments
shipment()
- Customs
custom()
- Organizations
organization()
- Companies
company()
Similar for all, you must call the run()
method to 'get' the actual response back from the eAdapter. The response from the eAdapter will be returned in a JSON format.
Organizations - Add Address
Cord supports the option to add an address to an organization.
Documents / eDocs
Most entities in CargoWise One have a document tab (called eDocs). It is possible to use Cord to access these documents using the withDocuments()
method.
When applying the documents method, Cord will only a DcoumentCollection
containing the documents from the specified entity.
When interacting with the eDocs of CargoWise One (getting documents), we can provide filters to the request:
The available filters are:
- DocumentType – Retrieve only documents matching the specified document type.
- IsPublished – Retrieve only published or un-published documents. The values for this filter are:
True
andFalse
. This can only be specified once. - SaveDateUTCFrom – Retrieve only documents that were added or modified on or after the specified date/time (provided in UTC time). This can only be specified once.
- SaveDateUTCTo – Retrieve only documents that were added or modified on or before the specified date/time (provided in UTC time). This can only be specified once.
- CompanyCode – Retrieve only documents related to the specified company or non-company specific. The default behavior without this Type being filtered is to return all documents regardless of company affiliation.
- BranchCode – Retrieve only documents related to the specified branch code.
- DepartmentCode – Retrieve only documents relevant to specified department code.
Upload Documents
Similar to fetching documents, it is also possible to upload documents to a file in CargoWise One using addDocument
:
Cord also supports interacting with CargoWise One's event engine, meaning we can add events to jobs:
Native Query Component
You can query all supported native query components that eAdaptor provides. Similar to all native query components is that you can run the criteriaGroup()
method, to "query" your results.
Example: When querying organizations, you can specify different criteria groups to filter the results using criteriaGroup()
:
The criteriaGroup()
method accepts a nested array of different criteria. The above will search for all organizations where the organization code starts with US
and the organization is a broker. The type
parameter can be either Partial
or Key
. The default is Key
.
The XML that is generated by the above code is:
You are free to define as many criteria groups as you want:
Info: Multiple criteria group acts as an "OR" statement.
The above with multiple criteria groups will generate the following XML:
Multiple Connections
Sometimes you may want to connect to multiple eAdapters. This can be done by using the withConfig
method:
Then you can add the connection details to your config/cord.php
file:
The URL does not neccessarily need to be directly to the eAdaptor URL. It can also point to a middleware, as long as the middleware forwards the request to the eAdaptor and returns the response.
Response as XML
If you want to return the original eAdaptor response directly as XML, call toXml()
before you call the run()
method:
Debugging
Sometimes you may want to inspect the XML request before it's sent to the eAdapter. To do this, you can simply call the inspect()
method. This will return the XML string repesentation:
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Oliver Busk
- All Contributors
License
The MIT License (MIT). Please see License File for more information.