PlentyClient

Code Climate Issue Count Test Coverage Build Status

This Client is a ruby wrapper around the PlentyMarkets REST API.
The complete documentation can be found here.

Installation

Add this line to your application's Gemfile:

gem 'plenty_client'

And then execute:

bundle install

Or install it yourself as:

gem install plenty_client

Getting Started

Configuration

PlentyClient is a simple Ruby library. It works with Rails, as well as in a simple irb. Make sure you configure the PlentyClient with the following options:

PlentyClient::Config.site_url     = 'http://plenty7.plentymarkets.de/rest'
PlentyClient::Config.api_user     = 'myusername'
PlentyClient::Config.api_password = 'mypassword'
PlentyClient::Config.log          = true || false

Calls

Once you are set up you can use the client with the following methods:

Note:

  • required parameters need to be passed in, otherwise you will get an error
  • This Client handles no validation, it is only a gateway to the API
PlentyClient::Item.find(103)
PlentyClient::Item::Variation.find(103, 105)

PlentyClient::Item.list
PlentyClient::Item::Variation.list

PlentyClient::Item.create(parameters)

PlentyClient::Item::Variation.update(103, update_parameters)

PlentyClient::Item::Variation.delete(103, 105)

Blocks

# Use blocks to iterate in batches
PlentyClient::Item.list do |item|
  puts item
end

# You can set optional headers after the required parameters of each request
PlentyClient::Item::Variation.list(103, {'itemsPerPage' => 1, 'page' => 4}) do |item|
  puts item
end

HTTP-Methods

If there is no resource available you can still make the request like so:

PlentyClient::Request.patch(path, body = {})
PlentyClient::Request.put(path, body = {})
PlentyClient::Request.post(path, body = {})
PlentyClient::Request.delete(path, params = {})
PlentyClient::Request.get(path, params = {})
PlentyClient::Request.get(path, params = {}) do |body|
end

Warnings

There is a difference in the get method with and without a block. This returns the raw body with all parameters

PlentyClient::Request.get(path, params = {})

The get-call with the block only returns the entries

PlentyClient::Request.get(path, params = {}) do |body|
  puts entries
end

Debugging

If you are not sure which required parameters to pass in simply call

PlentyClient::Item::Variation.routes

Todo:

Contributing

Bug reports and pull requests are welcome. 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.