[][src]Crate mm_client

mm_client

The mm_client crate is a very small library for communicating with the PBS Media Manager API easier. It provides a Client for querying against either the production API or the staging API.

The main goals of the crate are to:

  • Provide authentication handling
  • Manage API url construction
  • Handle API error responses
  • Make few assumptions about how responses will be used

Currently all requests made by a Client are synchronous.

Creating a Client

Client provides two constructors, one for the accessing the production API and one for the staging API. Both constructors take an API key and secret as arguments. It is recommended to create a single Client that is then passed around for making requests.

Note that constructing a client may fail.

use mm_client::Client;

let client = Client::new("API_KEY", "API_SECRET").unwrap();

Fetching a single object

Requesting a single object can be performed by using the get method

use mm_client::Client;
use mm_client::Endpoints;

let client = Client::new("API_KEY", "API_SECRET").unwrap();
let response = client.get(Endpoints::Asset, "asset-id", None);

The response string can then be handed off a JSON parser for further use.

Fetching a list of objects

Requesting a list of objects can be performed by using the list method

use mm_client::Client;
use mm_client::Endpoints;

let client = Client::new("API_KEY", "API_SECRET").unwrap();
let params = vec![("since", "2017-02-12T00:00:00Z")];
let response = client.list(Endpoints::Show, params);

Here a request is made for all of the show objects that have been updated since the supplied date. Similar to the get method, the response string is available to pass to a JSON parser

Structs

Client

A client for communicating with the Media Manager API

Enums

Endpoints

The Media Manager endpoints that are supported by Client

MMCError

Error type that represents failures from Client

Type Definitions

MMCResult

Result type that represents the result of calls to the Media Manager API via Client