BeBanjo Movida API documentation and Ruby client
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



Almodovar is a client for BeBanjo's Sequence & Movida API written in Ruby (it's actually a generic client which plays nice with any RESTful API following some conventions).

Getting started

Install the gem (make sure you have in your gem source list):

$ [sudo] gem install almodovar

Now, let's play with irb:

>> require 'almodovar'
=> true

First you need an authentication token:

>> auth ="realm", "user", "password")
=> #<Almodovar::DigestAuth:0x101f846c8 ... >

Now you have to instantiate a resource given its URL. Let's try with the root of the Movida API:

>> movida = Almodovar::Resource("", auth)
=> <movida>
<link href="" rel="titles"/>
<link href="" rel="platforms"/>
<link href="" rel="title_groups"/>

Ok. Let's see what we have under platforms

>> movida.platforms
=> [<platform>
<link href="" rel="schedule"/>
</platform>, <platform>
<link href="" rel="schedule"/>

Now, show me the schedule of a title given its external id:

>> movida.titles(:external_id => "C5134350003").first.schedule(:expand => :schedulings)
=> <schedule>
<link href="" rel="schedulings"><schedulings type="array">
<id type="integer">1122</id>
<put-up type="datetime">2010-04-17T00:00:00Z</put-up>
<take-down type="datetime">2010-06-17T00:00:00Z</take-down>
<link href="" rel="title_group"/>
<link href="" rel="title"/>
<link href="" rel="title"/>

Of course, once you've got the URL of a resource, the next time you don't need to navigate from the root of the API. You can (should!) start from the resource URL:

>> schedulings = Almodovar::Resource("", auth)
=> [<scheduling>
<id type="integer">1122</id>
<put-up type="datetime">2010-04-17T00:00:00Z</put-up>
<take-down type="datetime">2010-06-17T00:00:00Z</take-down>
<link href="" rel="title_group"/>
<link href="" rel="title"/>

What if I want to access a specific node? Just do it:

=> 112
>> schedulings.first.scheduling_type
=> "archive"

Note that fields with a hyphen are accessed with an underscore instead, otherwise ruby will think you are trying to substract ('-')

Next, explore the API docs to learn about other resources.

Creating resources

Resource collections have the create method. Just call it with the attributes you want your new resource to have!

>> jobs = Almodovar::Resource("", auth)
=> [<job> ... </job>, <job> ... </job>]
>> job = jobs.create(:job => {:name => "Wadus"})
=> <job> ... </job>
=> "Wadus"

Modifying resources

You can use the update method:

>> job = Almodovar::Resource("", auth).first
=> <job> ... </job>
>> job.update(:job => {:name => "Wadus wadus"})
=> ...
=> "Wadus wadus"

Deleting resources

And exactly the same with the delete method:

>> job = Almodovar::Resource("", auth).first
=> <job> ... </job>
>> job.delete

Detailed error messages

In case an incorrect PUT/POST request fails with 422 response status, you can access list of errors using error_messages method of Almodovar::UnprocessableEntityError:

>> collection_entry = Almodovar::Resource("", auth)
=> <collection-entry> ... </collection-entry>
>> begin
    collection_entry.update(:collection_entry => {:position => 3.2})
   rescue Almodovar::UnprocessableEntityError => e
=> ["Position must be an integer"]


  • Better error management

  • Write the conventions Almodovar expects in an API

  • Other authentication methods than digest

Copyright © 2010 BeBanjo S.L., released under the MIT license