MyParcel Ruby gem provides a wrapper for MyParcel API
This repository is a fork of paypronl/myparcel. The original repository is no longer maintained.
Note: the myparcel
gem is owned by the original authors and is not updated
from changes in this repository.
Add this line to your application's Gemfile:
gem 'myparcel', git: 'https://github.com/bjpbakker/myparcel.git', branch: 'next'
And then execute:
$ bundle
client = Myparcel.client('your-api-key')
Getting shipments by id:
client.shipments.find shipment_ids: [1, 2, 3]
Getting all shipments:
client.shipments.all
# or
client.shipments.find
Creating shipments:
shipment = {
recipient: {
cc: 'NL',
postal_code: '9999XX',
city: 'Amsterdam',
street: 'Hoofdstraat',
number: '1',
person: 'John Doe'
},
carrier: 1,
options: {
package_type: 1
},
status: 1
}
client.shipments.create shipments: [shipment]
Deleting shipments (at least one ID is required):
client.shipments.delete shipment_ids: [1, 2, 3]
Get possible delivery options for an address:
client.delivery_options.find cc: 'NL', postal_code: '2131bc', number: 679, carrier: 'postnl'
Getting Track&Trace codes by shipment IDs:
client.tracktraces.find shipment_ids: [1, 2, 3]
Creating a webhook:
webhook = {
hook: "shipment_status_change",
url: "https://seoshop.nl/myparcel/notifications"
}
client.webhooks.create subscriptions: [webhook]
Getting webhook subscriptions (at least one subscription ID is required):
client.webhooks.find subscription_ids: [1, 2, 3]
After checking out the repo, run bin/setup
to install dependencies. Then, run rake spec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
Bug reports and pull requests are welcome on GitHub at https://github.com/bjpbakker/myparcel. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
The gem is available as open source under the terms of the MIT License.