Build Status

MyParcel Ruby gem

MyParcel Ruby gem provides a wrapper for MyParcel API

Installation

Add this line to your application's Gemfile:

gem 'myparcel', '~> 0.1'

And then execute:

$ bundle

Or install it yourself as:

$ gem install myparcel

Usage

Client

client = Myparcel.client('your-api-key')

Shipments

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]

Delivery options

Get possible delivery options for an address:

client.delivery_options.find cc: 'NL', postal_code: '2131bc', number: 679, carrier: 'postnl'

Track and Trace

Getting Track&Trace codes by shipment IDs:

client.tracktraces.find shipment_ids: [1, 2, 3]

Webhook subscriptions

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]

Development

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.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/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.

License

The gem is available as open source under the terms of the MIT License.