Sha256: 4f3beeb6735fc63e5a4dcd9d7ea2b16a2ce960cb175503b40b81c1050b7c5798
Contents?: true
Size: 1.09 KB
Versions: 5
Compression:
Stored size: 1.09 KB
Contents
require 'hyperclient' # create a new client api = Hyperclient.new('https://grape-with-roar.herokuapp.com/api') # enumerate splines api.splines.each do |spline| puts "#{spline.uuid}" puts " reticulated: #{spline.reticulated ? 'yes' : 'no'}" puts " thumbnail: #{spline['images:thumbnail']}" end api._links.splines._embedded.splines.each do |_spline| # ... equivalent to the above end puts '*' * 10 # retrieve an existing spline spline = api.spline(uuid: 123) puts "Spline #{spline.uuid} is #{spline.reticulated ? 'reticulated' : 'not reticulated'}." # puts api._links.spline._expand(uuid: 'uuid')._resource._attributes.reticulated # spline.to_h # create a new spline spline = api.splines._post(reticulated: true) puts "Created a #{spline.reticulated ? 'reticulated' : 'unreticulated'} spline #{spline.uuid}." # update an existing spline spline = api.spline(uuid: 123)._put(reticulated: true) puts "Updated spline #{spline.uuid}, now #{spline.reticulated ? 'reticulated' : 'not reticulated'}." # delete an existing spline spline = api.spline(uuid: 123)._delete puts "Deleted spline #{spline.uuid}."
Version data entries
5 entries across 5 versions & 1 rubygems