Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Magento2 Ruby SDK

The Magento's Ruby SDK is a small and no dependency gem that allows you to do any kind of request to the Magento 2's API

Before start

Add it to your Gemfile:

gem 'magento2', github: 'centrycl/magento2'

And then install

bundle install

How do I use it?

Create an instance of Magento2 class

sdk = Magento2.new('host', 'username', 'password')
# Refhresh the access token
sdk.admin_token

GET

# List products
resp = sdk.get('/rest/V1/products', searchCriteria: 10)
if resp.code == 200
  products = JSON.parse(resp.body)
end

# One product
product = JSON.parse(sdk.get('/rest/V1/products/1', searchCriteria: nil).body)

POST

product = {
  # Your product info
}
resp = sdk.post('/rest/V1/products', nil, product)
if resp.code == 200
  # All right
end

PUT

product = {
  # Your product info
}
resp = sdk.put('/rest/V1/products/', searchCriteria: nil, product)
if resp.code == 200
  # All right
end

DELETE

resp = sdk.delete('/rest/V1/products/1')
if resp.code == 200
  # Product deleted
end

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages