Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/gobengo/livefyre-subscriptions

A isomorphic JavaScript library for managing Subscriptions in Livefyre's Personalized News Stream service.
https://github.com/gobengo/livefyre-subscriptions

Last synced: 25 days ago
JSON representation

A isomorphic JavaScript library for managing Subscriptions in Livefyre's Personalized News Stream service.

Awesome Lists containing this project

README

        

# livefyre-subscriptions

A JavaScript library for [managing Subscriptions](http://docs.livefyre.com/beta-docs/personalizedstream/personalized-streams/subscription-apis/) in Livefyre's Personalized News Stream service.

## Usage

This module is intended to work in both node.js and the browser (via browserify). Run `make dist` to put the browser bundle in dist/.

Use as a CLI (e.g. if you `npm install -g livefyre-subscriptions`):

### CLI

```sh
livefyre-subscriptions --auth=$LFTOKEN
```

[
{
"to": "urn:livefyre:demo.fyre.co:site=362588:topic=mlb",
"type": "personalStream",
"by": "urn:livefyre:demo.fyre.co:user=system",
"createdAt": 1406886370
}
]

You can even pipe to something like [jq](http://stedolan.github.io/jq/):

```sh
livefyre-subscriptions --auth=$LFTOKEN | jq .[]
```

### JavaScript

```javascript
var subscriptions = require('livefyre-subscriptions');
```

## API

The main export is an object.

### `.forUser(user)`

Manage a user's subscriptions.

```javascript
var subscriptions = require('livefyre-subscriptions');
var benSubscriptions = subscriptions.forUser({
userId: 'ben',
network: 'go.fyre.co',
lftoken: 'optional. will use LFTOKEN env variable by default'
});
// or...
var benSubscriptions = subscriptions.forUser('[email protected]');
```

When you have a user's subscriptions, there are a few methods you can call that
will perform operations using Livefyre's HTTP APIs. Each of these methods returns a promise.

#### Get subscriptions

```javascript
benSubscriptions.get().then(function (data) {
console.log(data.subscriptions);
})
```

#### Create a new subscription

```javascript
var newSubscription = {
to: 'urn:livefyre:demo.fyre.co:site=362588:topic=mlb',
type: 'personalStream'
};
benSubscriptions.create(newSubscription).then(
function (data) {
console.log('success');
},
function (e) {
console.error(e);
}
);
```

## `make` commands

* `make build` - will `npm install` and `bower install`
* `make dist` - will use r.js optimizer to compile the source, UMD wrap, and place that and source maps in dist/
* `make clean`
* `make server` - serve the repo over http
* `make deploy [env={*prod,uat,qa}]` - Deploy to lfcdn, optionally specifying a bucket env