Prestashop API for Ruby
Add this line to your application's Gemfile:
gem 'prestashop', git: 'git@bitbucket.org:werein/prestashop.git'
Use branch: 'master'
for local repository in case of bundler global config
Create new client for connect to your Prestashop WebService
Prestashop::Client::Implementation.create 'api_key', 'api_url'
Now you are able to communicate with Prestashop WebService
To call API request directly you can use this class.
Call HEAD on WebService API, returns +true+ if was request successfull or raise error, when request failed.
Prestashop::Client.head :customer, 2 # => true
Prestashop::Client.check :customer, 3 # => true
Call GET on WebService API, returns parsed Prestashop response or raise error, when request failed.
Prestashop::Client.get :customer, 1 # => {id: 1 ...}
Prestashop::Client.read :customer, [1,2] # => [{id: 1}, {id: 2}]
When you are using get, you can also filter, sort or limit response. In case, when you need to get all users you need to set user id as nil
Available options:
Call POST on WebService API, returns parsed Prestashop response if was request successfull or raise error, when request failed.
Prestashop::Client.post :customer, { name: 'Steve' } # => true
Call PUT on WebService API, returns parsed Prestashop response if was request successfull or raise error, when request failed.
Prestashop::Client.put :customer, 1, {surname: 'Jobs'} # => true
Prestashop::Client.update :customer, 1, {nope: 'Jobs'} # => false
Call DELETE on WebService API, returns +true+ if was request successfull or raise error, when request failed.
Prestashop::Client.delete :customer, 1 # => true
For better handling with Prestashop is there Mapper class, that will map all Prestashop features to Ruby classes.
List of objects can be found on gem docs.
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)