<commit_before># Buffer Gem

Modelled after Octokit <3. This is a lightweight client for the Buffer API (https://buffer.com/developers/api), which is intended to return JSON as opposed to objects.

[![Code Climate](https://codeclimate.com/github/kaneda/buffer-ruby/badges/gpa.svg)](https://codeclimate.com/github/kaneda/buffer-ruby)

## Client API

### What's Imlemented?
* https://buffer.com/developers/api/oauth
* https://buffer.com/developers/api/user
* https://buffer.com/developers/api/profiles
* https://buffer.com/developers/api/updates
* https://buffer.com/developers/api/links
* https://buffer.com/developers/api/info
* https://buffer.com/developers/api/errors


### What's Missing?
* Rspecs

### Installing

Put this sucker in your Gemfile and bundle install

```ruby
gem "buffer-app", :git => "git://github.com/kaneda/buffer-ruby", :tag => "v1.1"
```

Then drop this into your config/application.rb (or wherever you want to use it)

```ruby
require 'buffer_app'
```

### Basic Usage

You can define the client up front or configure it later. The options array the BufferClient (and the API objects behind the scenes) uses takes in the following parameters:
* :user_code
* :auth_token
* :logger

```ruby
buffer_client = BufferClient.new({
  :user_code => "yourcode"
})
```

```ruby
buffer_client = BufferClient.new

buffer_client.configure({
  :user_code => "yourcode"
})
```

### Available Calls
| Client call | Input | Description | Notes
| :-----------: | :----- | :----------- | :-----
| get_auth_token | | Returns the user's long-lasting auth token | user_code must be defined in the buffer_client, as well as the ENV variables "BUFFER_KEY" and "BUFFER_SECRET" |
| get_user_id | | Returns the user's Buffer ID | |
| get_user_json | | Returns the entirety of the user JSON | |
| get_user_profiles | | Returns the entirety of the profile JSON | |
| get_user_profile | Profile ID | Get a single profile as JSON by ID | |
| get_schedule | Profile ID | Get the schedule of a profile as JSON by ID | |
| update_schedule | Profile ID, Schedule Hash | Set the schedule of a profile as JSON by ID | auth_token must be defined in the buffer client. See below for schedule representation |
| get_update | Social Media Post ID | Gets an update by post ID | |
| get_pending_updates | Profile ID, Options Hash (optional) | Gets pending updates as JSON by profile ID | Takes in hash of options, see Buffer API docs for optional parameters |
| get_sent_updates | Profile ID, Options Hash (optional) | Gets sent updates as JSON by profile ID | Takes in hash of options, see Buffer API docs for optional parameters |
| get_interactions | Social Media Post ID, Event, Options Hash (optional) | Gets interactions based on event type (see https://bufferapp.com/developers/api/info#configuration) | Takes in a hash of options, see Buffer API docs for optional parameters |
| reorder_updates | Profile ID, Updates Array, Options Hash (optional) | Updates order of updates in a profile based on updates array | |
| shuffle_updates | Profile ID, Options Hash (optional) | Randomize the order of updates to be sent | |
| create_update | Profile ID Array, Options Hash (optional) | Create a new post | Note that for the "media" option, please specify each media option in the hash separately, e.g. ```{ "media[link]" => "http%3A%2F%2Fgoogle.com", "media[description]" => "The%20google%20homepage" }``` |
| update_status | Social Media Post ID, Text, Options Hash (optional) | Update an existing status | For the "media" option see the note on create_update |
| share_update | Social Media Post ID | Share a post immediately | |
| destroy_update | Social Media Post ID| Permanently destroy an update | |
| move_to_top | Social Media Post ID| Move post to top of queue | |
| get_shares | URL (unencoded) | Gets the number of shares for a given URL through Buffer | You can pass a normal URL here, the client will encode it. This is one of the only calls to not require an auth_token |
| get_configuration | | Gets the current Buffer config | |

### Helper methods
| Method | Description |
| :---------: | :----- |
| configure | Takes in a hash (as above) and reconfigures all API objects |<commit_msg>Updated readme spacing<commit_after># Buffer Gem

Modelled after Octokit <3. This is a lightweight client for the Buffer API (https://buffer.com/developers/api), which is intended to return JSON as opposed to objects.

[![Code Climate](https://codeclimate.com/github/kaneda/buffer-ruby/badges/gpa.svg)](https://codeclimate.com/github/kaneda/buffer-ruby)

## Client API

### What's Imlemented?
* https://buffer.com/developers/api/oauth
* https://buffer.com/developers/api/user
* https://buffer.com/developers/api/profiles
* https://buffer.com/developers/api/updates
* https://buffer.com/developers/api/links
* https://buffer.com/developers/api/info
* https://buffer.com/developers/api/errors


### What's Missing?
* Rspecs

### Installing

Put this sucker in your Gemfile and bundle install

```ruby
gem "buffer-app", :git => "git://github.com/kaneda/buffer-ruby", :tag => "v1.1"
```

Then drop this into your config/application.rb (or wherever you want to use it)

```ruby
require 'buffer_app'
```

### Basic Usage

You can define the client up front or configure it later. The options array the BufferClient (and the API objects behind the scenes) uses takes in the following parameters:
* :user_code
* :auth_token
* :logger

```ruby
buffer_client = BufferClient.new({
  :user_code => "yourcode"
})
```

```ruby
buffer_client = BufferClient.new

buffer_client.configure({
  :user_code => "yourcode"
})
```

### Available Calls
| Client call | Input | Description | Notes
| :---------: | :------ | :---- | :---------
| get_auth_token | | Returns the user's long-lasting auth token | user_code must be defined in the buffer_client, as well as the ENV variables "BUFFER_KEY" and "BUFFER_SECRET" |
| get_user_id | | Returns the user's Buffer ID | |
| get_user_json | | Returns the entirety of the user JSON | |
| get_user_profiles | | Returns the entirety of the profile JSON | |
| get_user_profile | Profile ID | Get a single profile as JSON by ID | |
| get_schedule | Profile ID | Get the schedule of a profile as JSON by ID | |
| update_schedule | Profile ID, Schedule Hash | Set the schedule of a profile as JSON by ID | auth_token must be defined in the buffer client. See below for schedule representation |
| get_update | Social Media Post ID | Gets an update by post ID | |
| get_pending_updates | Profile ID, Options Hash (optional) | Gets pending updates as JSON by profile ID | Takes in hash of options, see Buffer API docs for optional parameters |
| get_sent_updates | Profile ID, Options Hash (optional) | Gets sent updates as JSON by profile ID | Takes in hash of options, see Buffer API docs for optional parameters |
| get_interactions | Social Media Post ID, Event, Options Hash (optional) | Gets interactions based on event type (see https://bufferapp.com/developers/api/info#configuration) | Takes in a hash of options, see Buffer API docs for optional parameters |
| reorder_updates | Profile ID, Updates Array, Options Hash (optional) | Updates order of updates in a profile based on updates array | |
| shuffle_updates | Profile ID, Options Hash (optional) | Randomize the order of updates to be sent | |
| create_update | Profile ID Array, Options Hash (optional) | Create a new post | Note that for the "media" option, please specify each media option in the hash separately, e.g. ```{ "media[link]" => "http%3A%2F%2Fgoogle.com", "media[description]" => "The%20google%20homepage" }``` |
| update_status | Social Media Post ID, Text, Options Hash (optional) | Update an existing status | For the "media" option see the note on create_update |
| share_update | Social Media Post ID | Share a post immediately | |
| destroy_update | Social Media Post ID| Permanently destroy an update | |
| move_to_top | Social Media Post ID| Move post to top of queue | |
| get_shares | URL (unencoded) | Gets the number of shares for a given URL through Buffer | You can pass a normal URL here, the client will encode it. This is one of the only calls to not require an auth_token |
| get_configuration | | Gets the current Buffer config | |

### Helper methods
| Method | Description |
| :---------: | :----- |
| configure | Takes in a hash (as above) and reconfigures all API objects |
{'fraction_non_alphanumeric': 0.1126626089032104, 'fraction_numerical': 0.002386919680152763, 'mean_word_length': 4.1952882827030376, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, 'https://': 22, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '279418', 'n_tokens_mistral': 2435, 'n_tokens_neox': 2359, 'n_words': 988}