Project

phono

0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
Simple Ruby client for the Phono API
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

About

Simple Ruby client for the Phono API.

Usage

  phono = Phono::Client.new('424242424242424242424242')

Getting all instances of an entity

  phono.all('products')

Results are paginated. You can play with page and per_page parameters.

Sorting

  phono.all('products', {
  	'sort' => 'price.asc'
  })

Filtering

  phono.all('products', {
  	'filters' => {
  	  'price' => {
  	  	'$lt' => 10.0
  	  },

  	  'category' => '1234567890ezrzerzrzer'
  	}
  })

Getting a given instance of an entity

  phono.find('products', '2323...')

Creating an instance of an entity

  phono.create('products', {
  	'name'  => 'San Pellegrino',
  	'price' => 42.5
  })

Updating an instance of an entity

  phono.update('products', '2323...', {
  	'name'  => 'San Pellegrino',
  	'price' => 42.5
  })

Destroying an instance of an entity

  phono.destroy('products', '2323...')

Displaying pictures

Get the original's URL :

  instance['picture']

Get a resized version :

  "#{instance['picture']}?size=300x200"

Get a resized and cropped version :

  "#{instance['picture']}?size=300x200&crop=true"

You can also force the resize (with deformation) :

  "#{instance['picture']}?size=300x200&force=true"

Cache control

All JSON responses are cached (5 minutes by default) for performance. You can override this timeout by passing the value you want as a 2nd parameter to the client's constructor :

  Phono::Client.new('424242424242424242424242', 3600) # responses will be cached for 1 hour