We use cookies (just for analytics) on this website. If you continue we will assume you are happy with it. ok

BeBanjo

Back to index

Collection

A Collection Entry resource represents the link between a collection and one title.

This is how a Collection Entry resource looks like in the API:

<?xml version="1.0" encoding="UTF-8"?>
<collection-entry>
  <id type="integer">1</id>
  <position type="integer">1</position>
  <link rel="self" href="https://movida.bebanjo.net/api/collection_entries/1"/>
  <link rel="collection" href="https://movida.bebanjo.net/api/title_groups/3"/>
  <link rel="title" href="https://movida.bebanjo.net/api/titles/1"/>
</collection-entry>

Please, refer to the title_groups and title for more information.

Collection entry attributes

  • id (required): Movida’s internal identifier for a collection entry. It must not be supplied in the creation of the collection entry, it will be set automatically.
  • position (optional): The position of this collection entry within the list of collection entries of a collection. The value, if provided, must be an integer value greater than zero. And if not provided, it will be automatically assigned to the next available position starting on 1. Trying to set a value greater than the next available position is not possible.

Get the list of collection entries of a collection

To return a (paginated) list of the collection entries for a collection, you can just follow the “collection_entries” link in a collection resource. For example, you could issue a GET request like the following:

$ curl --digest -u robot_user:password https://movida.bebanjo.net/api/title_groups/1/collection_entries
<?xml version="1.0" encoding="UTF-8"?>
<collection-entries type="array">
  <total-entries>2</total-entries>
  <collection-entry>
    <id type="integer">1</id>
    <position type="integer">1</position>
    <link rel="self" href="https://movida.bebanjo.net/api/collection_entries/1"/>
    <link rel="collection" href="https://movida.bebanjo.net/api/title_groups/1"/>
    <link rel="title" href="https://movida.bebanjo.net/api/titles/1"/>
  </collection-entry>
  <collection-entry>
    <id type="integer">3</id>
    <position type="integer">2</position>
    <link rel="self" href="https://movida.bebanjo.net/api/collection_entries/3"/>
    <link rel="collection" href="https://movida.bebanjo.net/api/title_groups/1"/>
    <link rel="title" href="https://movida.bebanjo.net/api/titles/2"/>
  </collection-entry>
</collection-entries>

Note: This is a paginated resource. By default, only 50 collection entries will be included in each page but you can override this default by using the per_page parameter described in the next section. The total-entries attribute will indicate the total number of entries and the links rel="next" and rel="prev" should be used to get the next and the previous pages.

Valid attributes

  • per_page: Number of elements returned in each page. The maximum value allowed is 200 and the default is 50.

Get a specific collection

This operation allows you to recover information about one specific collection:

$ curl --digest -u robot_user:password https://movida.bebanjo.net/api/collection_entries/1
<?xml version="1.0" encoding="UTF-8"?>
<collection-entry>
  <id type="integer">1</id>
  <position type="integer">1</position>
  <link rel="self" href="https://movida.bebanjo.net/api/collection_entries/1"/>
  <link rel="collection" href="https://movida.bebanjo.net/api/title_groups/3"/>
  <link rel="title" href="https://movida.bebanjo.net/api/titles/1"/>
</collection-entry>

Crediting a collection entry on a collection

To associate an existing title you just have to POST a payload like the following to the “collection_entries” link of any collection. Let’s suppose we want to add Forrest Gump (title with id 4 in our example):

cat new_collection_entry_existing_title.xml
<?xml version="1.0" encoding="UTF-8"?>
<collection-entry>
  <link rel="title" href="https://movida.bebanjo.net/api/titles/1"/>
</collection-entry>
$ curl --digest -u robot_user:password -H "Content-Type: application/xml" -X POST -d @new_collection_entry_existing_title.xml "https://movida.bebanjo.net/api/title_groups/4/collection_entries"

Movida will then return the full XML of our brand new collection entry, as usual:

<?xml version="1.0" encoding="UTF-8"?>
<collection-entry>
  <id type="integer">1</id>
  <position type="integer">1</position>
  <link rel="self" href="https://movida.bebanjo.net/api/collection_entries/1"/>
  <link rel="collection" href="https://movida.bebanjo.net/api/title_groups/4"/>
  <link rel="title" href="https://movida.bebanjo.net/api/titles/1"/>
</collection-entry>

Updating a collection

You can update a collection entry just by issuing a `PUT request to each collection entry URI. You only need to include those attributes that you wish to update:

cat collection_entry_update.xml
<collection-entry>
  <position>10</position>
</collection-entry>
$ curl --digest -u robot_user:password -H "Content-Type: application/xml" -X PUT -d @collection_entry_update.xml "https://movida.bebanjo.net/api/collection_entries/2"

As always, Movida will return the full XML of the resource just updated:

<?xml version="1.0" encoding="UTF-8"?>
<collection-entry>
  <id type="integer">2</id>
  <position type="integer">10</position>
  <link rel="self" href="https://movida.bebanjo.net/api/collection_entries/2"/>
  <link rel="collection" href="https://movida.bebanjo.net/api/title_groups/4"/>
  <link rel="title" href="https://movida.bebanjo.net/api/titles/1"/>
</collection-entry>

Deleting a collection entry

You can also delete a collection entry by sending a DELETE request to each collection entry URI:

$ curl --digest -u robot_user:password -X DELETE "https://movida.bebanjo.net/api/collection_entries/4"

Last updated March 31st, 2017.