Skip to content

Instantly share code, notes, and snippets.

@ismasan
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ismasan/50a8a0b64fcc5bb90a43 to your computer and use it in GitHub Desktop.
Save ismasan/50a8a0b64fcc5bb90a43 to your computer and use it in GitHub Desktop.
# Configura el cliente al inicializar
BooticClient.configure do |c|
c.client_id = 'xxx'
c.client_secret = 'zzz'
end
# Instancia la estrategia :client_credentials
api = BooticClient.client(:client_credentials, scope: 'admin')
# La raiz
root = api.root
# Mi tienda
shop = root.shops.first
# Las órndenes exitosas (cerradas o despachadas)
orders = shop.orders(status: 'closed,shipped')
puts orders.total_items
# Itera órdenes
# https://developers.bootic.net/rels/orders/
orders.each do |order|
puts order.price
puts order.code
# productos en la orden
order.line_items.each do |li|
puts li.product_title
end
end
# Hay más órdenes en la lista?
if orders.has?(:next)
orders.next.each do |order|
# etc. La paginación puede ser recursiva.
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment