Add the gem to your ‘Gemfile’:
gem 'lucid-shopify'
gem 'lucid-shopify-resource'
class OrderRepository
include Lucid::Shopify::Resource::Create
resource :orders
end
order_repo = OrderRepository.new
order_repo.create(credentials, new_order)
class OrderRepository
include Lucid::Shopify::Resource::Delete
resource :orders
end
order_repo = OrderRepository.new
order_repo.delete(credentials, id)
Include and configure Read
:
class OrderRepository
include Lucid::Shopify::Resource::Read
resource :orders
default_params fields: %w[id tags], limit: 250
end
order_repo = OrderRepository.new
order_repo.find(credentials, id)
The OrderRepository
class is enumerable. Each page is fetched from the API as
needed, rather than all at once:
order_repo = OrderRepository.new
order_repo.each(credentials) |order|
# ...
end
class OrderRepository
include Lucid::Shopify::Resource::Update
resource :orders
end
order_repo = OrderRepository.new
order_repo.create(credentials, id, order)