Ruby wrapper for DHL Express Rest API.
Add this line to your application's Gemfile:
gem "dhl_express", branch: "master", github: "BloomAndWild/dhl_express"
And then execute:
$ bundle
Or install it yourself as:
$ gem install dhl_express
DHLExpress::Client.configure do |config|
config.base_url = ENV.fetch('BASE_URL')
config.username = ENV.fetch('USERNAME')
config.password = ENV.fetch('PASSWORD')
config.account = ENV.fetch('ACCOUNT')
config.logger = Logger.new(STDERR)
config.level = :debug
end
A call to ShipmentRequest service with sample payload:
DHLExpress::Operations::ShipmentRequest.new(payload: {
ClientDetail: {
# ...
},
RequestedShipment: {
# ...
}
}).execute
If successful will return parsed (from JSON) response body, for example:
{
Notification: [
{
# ...
}
],
PackagesResult: {
PackageResult: [
# ...
]
},
LabelImage: [
{
# ...
}
],
ShipmentIdentificationNumber: 123456789
}
DHLExpress::Operations::ShipmentDeleteRequest.new(payload: {}).execute
Example of payload -
{
"PickupDate": "2017-07-24",
"PickupCountry": "SG",
"DispatchConfirmationNumber": "SIN-952041",
"RequestorName": "Terry Kelly",
}
A successful call will return parsed (from JSON) response body, for example:
{
"Notification": {
"@code": "0",
"Message": "Successfully cancelled"
}
}
A call to TrackingRequest service with sample payload:
DHLExpress::Operations::TrackingRequest.new(payload: {
Request: {
ServiceHeader: {
# ...
}
},
AWBNumber: {
ArrayOfAWBNumberItem: 123456789
},
LevelOfDetails: 'ALL_CHECK_POINTS',
PiecesEnabled: 'B'
}).execute
If successful will return parsed (from JSON) response body, for example:
{
Response: {
ServiceHeader: {
# ...
}
},
AWBInfo: {
ArrayOfAWBInfoItem: {
AWBNumber: 1234567890,
Status: {
ActionStatus: 'Success'
},
ShipmentInfo: {
# ...
}
}
}
}
To run the specs, add your development credentials to your dev env:
SANDBOX_BASE_URL=https://wsbexpress.dhl.com:443/rest/sndpt
[email protected]
SANDBOX_PASSWORD=password
SANDBOX_ACCOUNT=123456789
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/dhl_express.