Skip to content

Latest commit

 

History

History
68 lines (46 loc) · 1.21 KB

README.md

File metadata and controls

68 lines (46 loc) · 1.21 KB

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