Sha256: 9e7e1a3df8d7c34a6fb3b047a9d70009c39e7efa6caef4a0098ba56ac104836d

Contents?: true

Size: 1.16 KB

Versions: 1

Compression:

Stored size: 1.16 KB

Contents

require 'hyperclient'

puts "Using Hyperclient #{Hyperclient::VERSION} ..."

# 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(spline: { reticulated: true })
puts "Created a #{spline.reticulated ? 'reticulated' : 'unreticulated'} spline #{spline.uuid}."

# update an existing spline
spline = api.spline(uuid: 123)._put(spline: { 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

1 entries across 1 versions & 1 rubygems

Version Path
hyperclient-0.8.1 examples/splines_api.rb