Skip to content

Ruby Gem to access to PrestaShop through API

Notifications You must be signed in to change notification settings

opus-codium/restashop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RestaShop

Library to use PrestaShop in Ruby using its API.

Features

  • Read any resources provided by PrestaShop
  • Only fetch resources data when needed
  • Fetch all in a row when requested
  • Provide collection and resources separatly as classes (e.g. Products and Product)

Installation

In Gemfile:

gem 'restashop', git: 'https://github.com/opus-codium/restashop'

Usage

Connect to PrestaShop

require 'restashop'

restashop = Restashop.new('http://prestashop.com/api', 'super secret token')

Fetch available resources

restashop.resources

List all IDs of a resource (e.g. products)

restashop.products.list

Fetch all entities corresponding to a resource (e.g. supplier)

suppliers = restashop.suppliers.all
suppliers.each { |s| puts s.name }

Note: it could be really slow on big shop. If you already know resource ID, prefer use find.

Fetch one entity (e.g. order)

first_order_id = restashop.orders.list.first
first_order = restashop.orders.find first_order_id
first_order.total_paid

Filter results (e.g. products from supplier)

restashop.products.where(id_supplier: 42)

Tests

bundle exec rspec

About

Ruby Gem to access to PrestaShop through API

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published