Skip to content

blue-pebble/myparcel

 
 

Repository files navigation

MyParcel Ruby gem

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.

Installation

Add this line to your application's Gemfile:

gem 'myparcel', git: 'https://github.com/bjpbakker/myparcel.git', branch: 'next'

And then execute:

$ bundle

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.

Contributing

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.

License

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

About

MyParcel API wrapper for Ruby

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 99.7%
  • Shell 0.3%