buff 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/.travis.yml +0 -1
- data/API_COVERAGE.md +19 -0
- data/README.md +29 -12
- data/Rakefile +1 -1
- data/lib/buff/client.rb +26 -0
- data/lib/buff/core.rb +40 -64
- data/lib/buff/datastructure.rb +18 -0
- data/lib/buff/encode.rb +21 -11
- data/lib/buff/error.rb +5 -2
- data/lib/buff/info.rb +10 -0
- data/lib/buff/profile.rb +10 -9
- data/lib/buff/update.rb +33 -35
- data/lib/buff/user.rb +1 -1
- data/lib/buff/version.rb +1 -1
- data/lib/buff.rb +3 -56
- data/spec/fixtures/destroy.txt +10 -0
- data/spec/fixtures/info.txt +10 -0
- data/spec/fixtures/interactions_by_update_id.txt +10 -0
- data/spec/fixtures/link.txt +12 -0
- data/spec/fixtures/profile_authenticated.txt +11 -0
- data/spec/fixtures/profile_schedules_by_id.txt +10 -0
- data/spec/fixtures/profiles_by_id.txt +10 -0
- data/spec/fixtures/update_by_id.txt +10 -0
- data/spec/fixtures/update_by_id_non_auth.txt +9 -0
- data/spec/fixtures/updates_by_profile_id.txt +10 -0
- data/spec/fixtures/updates_by_profile_id_pending.txt +10 -0
- data/spec/fixtures/user_authenticated.txt +19 -0
- data/spec/lib/buff/profile_spec.rb +87 -0
- data/spec/lib/buff/schedule_spec.rb +80 -0
- data/spec/lib/buff/update_spec.rb +107 -12
- data/spec/lib/buff/user_spec.rb +26 -0
- data/spec/lib/buff_spec.rb +0 -228
- data/spec/lib/core_spec.rb +60 -0
- data/spec/spec_helper.rb +82 -0
- metadata +36 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c720c5f920f5d215ecdd86fbbb24bce689ea3825
|
4
|
+
data.tar.gz: 71289210d6c274b805d4304e1d5dd2f355e8e1a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aaed1ab1510883a3a6f445ddc462149fabe62b127dbbc5669cf415ff4481a363dba383ecd58075a47d7cba400c3e01ddbedb7734e27d8329f005ddd57148a633
|
7
|
+
data.tar.gz: 734284b3a82d83637008294000eb7db93015af984911d7b498a7799947f9bb7d15450636a2d7daa40e5ffa215da73fb12d0005b5e6ca66a724de87f13997ecd1
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/API_COVERAGE.md
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
## Fully Implemented API Requests
|
2
|
+
GET https://api.bufferapp.com/1/user.json
|
3
|
+
GET https://api.bufferapp.com/1/profiles.json
|
4
|
+
GET https://api.bufferapp.com/1/profiles/4eb854340acb04e870000010.json
|
5
|
+
GET https://api.bufferapp.com/1/profiles/4eb854340acb04e870000010/schedules.json
|
6
|
+
GET https://api.bufferapp.com/1/updates/4eb8565e0acb04bb82000004.json
|
7
|
+
POST https://api.bufferapp.com/1/updates/4ecda256512f7ee521000001/share.json
|
8
|
+
POST https://api.bufferapp.com/1/updates/4ecda256512f7ee521000004/destroy.json
|
9
|
+
POST https://api.bufferapp.com/1/profiles/4eb854340acb04e870000010/schedules/update.json
|
10
|
+
GET https://api.bufferapp.com/1/profiles/4eb854340acb04e870000010/updates/pending.json
|
11
|
+
GET https://api.bufferapp.com/1/profiles/4eb854340acb04e870000010/updates/sent.json
|
12
|
+
GET https://api.bufferapp.com/1/updates/4ecda476542f7ee521000006/interactions.json
|
13
|
+
POST https://api.bufferapp.com/1/profiles/4eb854340acb04e870000010/updates/shuffle.json
|
14
|
+
POST https://api.bufferapp.com/1/updates/create.json
|
15
|
+
POST https://api.bufferapp.com/1/updates/4ecda256512f7ee521000004/update.json
|
16
|
+
POST https://api.bufferapp.com/1/profiles/4eb854340acb04e870000010/updates/reorder.json
|
17
|
+
|
18
|
+
## Untested Optional Params
|
19
|
+
|
data/README.md
CHANGED
@@ -7,30 +7,42 @@ Since the gem is currently in ALPHA development, the interface is prone to chang
|
|
7
7
|
|
8
8
|
## Installation
|
9
9
|
|
10
|
-
[![Coverage Status](https://coveralls.io/repos/zph/buff/badge.png?branch=master)](https://coveralls.io/r/zph/buff?branch=master)
|
10
|
+
[![Coverage Status](https://coveralls.io/repos/zph/buff/badge.png?branch=master)](https://coveralls.io/r/zph/buff?branch=master) [![Build Status](https://travis-ci.org/zph/buff.png?branch=master)](https://travis-ci.org/zph/buff) [![Code Climate](https://codeclimate.com/github/zph/buff.png)](https://codeclimate.com/github/zph/buff)
|
11
11
|
|
12
|
-
|
12
|
+
For now please `git clone git@github.com:zph/buff.git` the repo
|
13
13
|
|
14
|
-
|
14
|
+
Or
|
15
15
|
|
16
|
-
Add this line to your application's Gemfile:
|
16
|
+
Add this line to your application's Gemfile to include HEAD code:
|
17
17
|
|
18
|
-
|
18
|
+
`gem 'buff', :github => 'zph/buff'`
|
19
19
|
|
20
20
|
And then execute:
|
21
21
|
|
22
|
-
|
22
|
+
`$ bundle`
|
23
23
|
|
24
|
-
|
25
|
-
> Or install it yourself as:
|
24
|
+
Or install RubyGems version, which will receive more attention to stability:
|
26
25
|
|
27
|
-
|
26
|
+
`$ gem install buff`
|
28
27
|
|
29
28
|
## Usage
|
30
29
|
|
31
30
|
* Note that some of the optional params are not implemented!
|
32
|
-
* All methods are tested with Rspec and WebMock.
|
31
|
+
* All methods are tested with Rspec and WebMock. Most methods do not have integration tests that reach out to the live Buffer API servers. Proceed with caution until Buff reaches v0.1.0 and submit issues on Github Issues tab.
|
33
32
|
* Authentication is not included in this gem (Try OAuth-buffer) or use the single API key given when registering your own Buffer Dev credentials.
|
33
|
+
* For convenience load credentials into `~/.bufferapprc` in the following layout. This allows the `ACCESS_TOKEN` to be loaded into `Buff::ACCESS_TOKEN`:
|
34
|
+
|
35
|
+
|
36
|
+
```
|
37
|
+
CLIENT_ID
|
38
|
+
CLIENT_SECRET
|
39
|
+
ACCESS_TOKEN
|
40
|
+
|
41
|
+
# Structure:
|
42
|
+
# client ID line 1
|
43
|
+
# client secret line 2
|
44
|
+
# Access Token: line 3
|
45
|
+
```
|
34
46
|
|
35
47
|
## API Coverage
|
36
48
|
|
@@ -43,10 +55,15 @@ Once gem is pushed to RubyGems:
|
|
43
55
|
* Info
|
44
56
|
* Error Codes
|
45
57
|
|
58
|
+
Further Details [API Coverage](API_COVERAGE.md)
|
59
|
+
|
46
60
|
#### Not Implemented
|
47
61
|
|
48
62
|
* Caching
|
49
|
-
|
63
|
+
|
64
|
+
## Supported Ruby Implementations
|
65
|
+
- MRI 2.0.0
|
66
|
+
- Others likely work but are not included in CI Server
|
50
67
|
|
51
68
|
## Contributing
|
52
69
|
|
@@ -60,4 +77,4 @@ Issues, refactoring, and feedback are all welcome.
|
|
60
77
|
|
61
78
|
Also, this project is newcomer friendly!! We'd love to be your first Open Source Software contribution and would be happy to assist in that process.
|
62
79
|
|
63
|
-
Crafted with care by Zander. Reach out and say hi at [@_ZPH](http://twitter.com/_ZPH)
|
80
|
+
Crafted with care by Zander. Reach out and say hi at [@_ZPH](http://twitter.com/_ZPH) or [civet.ws](http://www.civet.ws)
|
data/Rakefile
CHANGED
@@ -15,7 +15,7 @@ desc "Generate code coverage"
|
|
15
15
|
RSpec::Core::RakeTask.new(:coverage) do |t|
|
16
16
|
t.pattern = "./spec/**/*_spec.rb" # don't need this, it's default.
|
17
17
|
t.rcov = true
|
18
|
-
t.rcov_opts = [
|
18
|
+
t.rcov_opts = %w[--exclude spec]
|
19
19
|
end
|
20
20
|
|
21
21
|
task :default => :spec
|
data/lib/buff/client.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
module Buff
|
2
|
+
class Client
|
3
|
+
include Core
|
4
|
+
include User
|
5
|
+
include Profile
|
6
|
+
include Update
|
7
|
+
include Link
|
8
|
+
include Info
|
9
|
+
|
10
|
+
attr_accessor :access_token
|
11
|
+
|
12
|
+
def initialize(access_token)
|
13
|
+
@access_token = access_token
|
14
|
+
url = "https://api.bufferapp.com/1/"
|
15
|
+
@connection = Faraday.new(url: url) do |faraday|
|
16
|
+
faraday.request :url_encoded
|
17
|
+
faraday.adapter Faraday.default_adapter
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def auth_query
|
22
|
+
{ access_token: @access_token }
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
data/lib/buff/core.rb
CHANGED
@@ -1,39 +1,52 @@
|
|
1
|
+
|
1
2
|
module Buff
|
3
|
+
begin
|
4
|
+
if File.exists?(File.expand_path("~/.bufferapprc"))
|
5
|
+
ACCESS_TOKEN = File.open(File.expand_path("~/.bufferapprc")).
|
6
|
+
readlines[2].chomp
|
7
|
+
end
|
8
|
+
rescue => x
|
9
|
+
raise x, "Bufferapprc appears to be malformed"
|
10
|
+
end
|
11
|
+
|
2
12
|
class Client
|
3
13
|
module Core
|
4
14
|
API_VERSION = "1"
|
5
15
|
|
6
|
-
|
16
|
+
private
|
7
17
|
|
8
|
-
def get(path, options={})
|
18
|
+
def get(path, options = {})
|
9
19
|
options.merge!(auth_query)
|
10
|
-
response = @
|
11
|
-
req.url path.
|
20
|
+
response = @connection.get do |req|
|
21
|
+
req.url path.remove_leading_slash
|
12
22
|
req.params = options
|
13
23
|
end
|
14
24
|
|
15
25
|
interpret_response(response)
|
16
26
|
end
|
17
27
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
req.url path.gsub(%r{^\/}, '')
|
28
|
+
def post(path, options = {})
|
29
|
+
params = merge_auth_token_and_query(options)
|
30
|
+
response = @connection.post do |req|
|
31
|
+
req.url path.remove_leading_slash
|
23
32
|
req.headers['Content-Type'] = "application/x-www-form-urlencoded"
|
24
|
-
req.body =
|
25
|
-
req.params =
|
33
|
+
req.body = options[:body]
|
34
|
+
req.params = params
|
26
35
|
end
|
36
|
+
|
37
|
+
Hashie::Mash.new(JSON.parse response.body)
|
27
38
|
end
|
28
39
|
|
29
|
-
def
|
30
|
-
|
31
|
-
|
40
|
+
def merge_auth_token_and_query(options)
|
41
|
+
if options[:query]
|
42
|
+
auth_query.merge options[:query]
|
43
|
+
else
|
44
|
+
auth_query
|
45
|
+
end
|
32
46
|
end
|
33
47
|
|
34
48
|
def interpret_response(response)
|
35
|
-
|
36
|
-
when 200
|
49
|
+
if response.status == 200
|
37
50
|
JSON.parse response.body
|
38
51
|
else
|
39
52
|
handle_response_code(response)
|
@@ -41,55 +54,18 @@ module Buff
|
|
41
54
|
end
|
42
55
|
|
43
56
|
def handle_response_code(response)
|
44
|
-
error = Hashie::Mash.new(
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
error_explanation = "Buffer API Unknown Error in Response"
|
50
|
-
end
|
51
|
-
|
52
|
-
raise Buff::APIError, error_explanation
|
57
|
+
error = Hashie::Mash.new(response.body)
|
58
|
+
raise Buff::APIError unless error.code
|
59
|
+
"Buffer API Error Code: #{error.code}\n" +
|
60
|
+
"HTTP Code: #{response.code}." +
|
61
|
+
"Description: #{error.error}"
|
53
62
|
end
|
54
|
-
|
55
|
-
def self.error_table
|
56
|
-
@error_table ||= ERROR_TABLE
|
57
|
-
end
|
58
|
-
|
59
|
-
ERROR_TABLE = {
|
60
|
-
"403"=>"Permission denied.",
|
61
|
-
"404"=>"Endpoint not found.",
|
62
|
-
"405"=>"Method not allowed.",
|
63
|
-
"1000"=>"An unknown error occurred.",
|
64
|
-
"1001"=>"Access token required.",
|
65
|
-
"1002"=>"Not within application scope.",
|
66
|
-
"1003"=>"Parameter not recognized.",
|
67
|
-
"1004"=>"Required parameter missing.",
|
68
|
-
"1005"=>"Unsupported response format.",
|
69
|
-
"1006"=>"Parameter value not within bounds.",
|
70
|
-
"1010"=>"Profile could not be found.",
|
71
|
-
"1011"=>"No authorization to access profile.",
|
72
|
-
"1012"=>"Profile did not save successfully.",
|
73
|
-
"1013"=>"Profile schedule limit reached.",
|
74
|
-
"1014"=>"Profile limit for user has been reached.",
|
75
|
-
"1015"=>"Profile could not be destroyed.",
|
76
|
-
"1020"=>"Update could not be found.",
|
77
|
-
"1021"=>"No authorization to access update.",
|
78
|
-
"1022"=>"Update did not save successfully.",
|
79
|
-
"1023"=>"Update limit for profile has been reached.",
|
80
|
-
"1024"=>"Update limit for team profile has been reached.",
|
81
|
-
"1025"=>"Update was recently posted, can't post duplicate content.",
|
82
|
-
"1026"=>"Update must be in error status to requeue.",
|
83
|
-
"1028"=>"Update soft limit for profile reached.",
|
84
|
-
"1029"=>"Event type not supported.",
|
85
|
-
"1030"=>"Media filetype not supported.",
|
86
|
-
"1031"=>"Media filesize out of acceptable range.",
|
87
|
-
"1032"=>"Unable to post image to LinkedIn group(s).",
|
88
|
-
"1042"=>"User did not save successfully.",
|
89
|
-
"1050"=>"Client could not be found.",
|
90
|
-
"1051"=>"No authorization to access client."
|
91
|
-
}
|
92
|
-
|
93
63
|
end
|
94
64
|
end
|
95
65
|
end
|
66
|
+
|
67
|
+
class String
|
68
|
+
def remove_leading_slash
|
69
|
+
gsub(/^\//, '')
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Buff
|
2
|
+
class UserInfo < Hashie::Mash; end
|
3
|
+
class Profile < Hashie::Mash; end
|
4
|
+
class Response < Hashie::Mash; end
|
5
|
+
class Update < Hashie::Mash; end
|
6
|
+
class Updates < Hashie::Mash; end
|
7
|
+
class Interaction < Hashie::Mash; end
|
8
|
+
class Interactions < Hashie::Mash; end
|
9
|
+
class Link < Hashie::Mash; end
|
10
|
+
class Info < Hashie::Mash; end
|
11
|
+
|
12
|
+
class Schedule < Hashie::Mash; end
|
13
|
+
Schedules = Class.new(Array) do
|
14
|
+
def dump
|
15
|
+
{ schedules: self }.to_json
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/buff/encode.rb
CHANGED
@@ -1,21 +1,31 @@
|
|
1
1
|
module Buff
|
2
2
|
class Encode
|
3
3
|
def self.encode(arg)
|
4
|
-
|
5
|
-
|
6
|
-
end
|
7
|
-
|
4
|
+
raise_error_for_incorrect_input(arg)
|
5
|
+
arg = arg[:schedules] if arg.respond_to?(:keys)
|
8
6
|
output = []
|
9
7
|
arg.each_with_index do |item, index|
|
10
|
-
|
11
|
-
uri.query_values = item
|
12
|
-
pairs = uri.query.split("&").map do |pair|
|
13
|
-
key , value = pair.split("=")
|
14
|
-
"schedules[#{index}][#{key}][]=#{value}"
|
15
|
-
end
|
16
|
-
output << pairs.join("&")
|
8
|
+
process_schedule(output, item, index)
|
17
9
|
end
|
18
10
|
output.join("&")
|
19
11
|
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def self.raise_error_for_incorrect_input(arg)
|
16
|
+
unless arg.kind_of?(Hash) || arg.kind_of?(Array)
|
17
|
+
raise ArgumentError, "Input must be/inherit from Hash or Array"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.process_schedule(output, item, index)
|
22
|
+
uri = Addressable::URI.new
|
23
|
+
uri.query_values = item
|
24
|
+
pairs = uri.query.split("&").map do |pair|
|
25
|
+
key , value = pair.split("=")
|
26
|
+
"schedules[#{index}][#{key}][]=#{value}"
|
27
|
+
end
|
28
|
+
output << pairs.join("&")
|
29
|
+
end
|
20
30
|
end
|
21
31
|
end
|
data/lib/buff/error.rb
CHANGED
data/lib/buff/info.rb
ADDED
data/lib/buff/profile.rb
CHANGED
@@ -1,25 +1,26 @@
|
|
1
1
|
module Buff
|
2
2
|
class Client
|
3
3
|
module Profile
|
4
|
-
def profiles
|
5
|
-
response = get("/profiles.json"
|
4
|
+
def profiles
|
5
|
+
response = get("/profiles.json")
|
6
6
|
response.map { |profile| Buff::Profile.new(profile) }
|
7
7
|
end
|
8
8
|
|
9
|
-
def profile_by_id(id
|
9
|
+
def profile_by_id(id)
|
10
10
|
response = get("/profiles/#{id}.json")
|
11
11
|
Buff::Profile.new(response)
|
12
12
|
end
|
13
13
|
|
14
|
-
def
|
14
|
+
def schedules_by_profile_id(id)
|
15
15
|
response = get("/profiles/#{id}/schedules.json")
|
16
|
-
response.map { |
|
16
|
+
response.map { |a_response| Buff::Schedule.new(a_response) }
|
17
17
|
end
|
18
18
|
|
19
|
-
def set_schedules(id, options
|
20
|
-
schedules = Buff::Encode.encode(
|
21
|
-
|
22
|
-
|
19
|
+
def set_schedules(id, options)
|
20
|
+
schedules = Buff::Encode.encode(
|
21
|
+
options.fetch(:schedules) { raise ArgumentError })
|
22
|
+
post("/profiles/#{id}/schedules/update.json",
|
23
|
+
body: { schedules: schedules })
|
23
24
|
end
|
24
25
|
end
|
25
26
|
end
|
data/lib/buff/update.rb
CHANGED
@@ -1,71 +1,69 @@
|
|
1
1
|
module Buff
|
2
2
|
class Client
|
3
3
|
module Update
|
4
|
-
def update_by_id(id, options={})
|
4
|
+
def update_by_id(id, options = {})
|
5
5
|
check_id(id)
|
6
6
|
response = get("/updates/#{id}.json")
|
7
7
|
Buff::Update.new(response)
|
8
8
|
end
|
9
9
|
|
10
|
-
def updates_by_profile_id(id, options={})
|
11
|
-
optional_params = [ :page, :count, :since, :utc ]
|
10
|
+
def updates_by_profile_id(id, options = {})
|
12
11
|
status = options.fetch(:status) do
|
13
12
|
raise Buff::MissingStatus, "Include :pending or :sent in args"
|
14
13
|
end
|
15
14
|
options.delete(:status)
|
16
|
-
response = get("/profiles/#{id}/updates/#{status.to_s}.json", options
|
15
|
+
response = get("/profiles/#{id}/updates/#{status.to_s}.json", options)
|
17
16
|
updates = response['updates'].map { |r| Buff::Update.new(r) }
|
18
17
|
Buff::Updates.new (
|
19
|
-
{ total: response['total'],
|
18
|
+
{ total: response['total'],
|
19
|
+
updates: updates }
|
20
|
+
)
|
20
21
|
end
|
21
22
|
|
22
|
-
def interactions_by_update_id(id, options={})
|
23
|
-
|
23
|
+
def interactions_by_update_id(id, options = {})
|
24
|
+
check_id(id)
|
24
25
|
response = get("/updates/#{id}/interactions.json", options)
|
25
|
-
interactions = response['interactions'].map
|
26
|
+
interactions = response['interactions'].map do |r|
|
27
|
+
Buff::Interaction.new(r)
|
28
|
+
end
|
26
29
|
Buff::Interactions.new(
|
27
30
|
{ total: response['total'], interactions: interactions }
|
28
31
|
)
|
29
32
|
end
|
30
33
|
|
31
|
-
def reorder_updates(profile_id, options={})
|
32
|
-
# order, optional: offset, utc
|
34
|
+
def reorder_updates(profile_id, options = {})
|
33
35
|
options.fetch(:order) { raise ArgumentError }
|
34
|
-
|
36
|
+
post("/profiles/#{profile_id}/updates/reorder.json", body: options)
|
35
37
|
end
|
36
38
|
|
37
|
-
def shuffle_updates(profile_id, options={})
|
38
|
-
|
39
|
-
|
39
|
+
def shuffle_updates(profile_id, options = {})
|
40
|
+
post("/profiles/#{profile_id}/updates/shuffle.json",
|
41
|
+
body: options)
|
40
42
|
end
|
41
43
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
# }
|
51
|
-
# }
|
52
|
-
response = post("/updates/create.json", options)
|
53
|
-
Hashie::Mash.new(JSON.parse response.body)
|
44
|
+
def create_update(options = {})
|
45
|
+
options[:body].fetch(:text) do
|
46
|
+
raise ArgumentError, "Must include text for update"
|
47
|
+
end
|
48
|
+
options[:body].fetch(:profile_ids) do
|
49
|
+
raise ArgumentError, "Must include array of profile_ids"
|
50
|
+
end
|
51
|
+
post("/updates/create.json", options)
|
54
52
|
end
|
55
53
|
|
56
|
-
def modify_update_text(update_id, options={})
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
54
|
+
def modify_update_text(update_id, options = {})
|
55
|
+
options[:body].fetch(:text) do
|
56
|
+
raise ArgumentError, "Must include updated text"
|
57
|
+
end
|
58
|
+
post("/updates/#{update_id}/update.json", options)
|
61
59
|
end
|
62
60
|
|
63
|
-
def share_update(update_id
|
64
|
-
|
61
|
+
def share_update(update_id)
|
62
|
+
post("/updates/#{update_id}/share.json")
|
65
63
|
end
|
66
64
|
|
67
|
-
def destroy_update(update_id
|
68
|
-
|
65
|
+
def destroy_update(update_id)
|
66
|
+
post("/updates/#{update_id}/destroy.json")
|
69
67
|
end
|
70
68
|
|
71
69
|
def check_id(id)
|
data/lib/buff/user.rb
CHANGED
data/lib/buff/version.rb
CHANGED
data/lib/buff.rb
CHANGED
@@ -12,62 +12,9 @@ require "buff/update"
|
|
12
12
|
require "buff/link"
|
13
13
|
require "buff/error"
|
14
14
|
require "buff/encode"
|
15
|
+
require "buff/datastructure"
|
16
|
+
require "buff/info"
|
17
|
+
require "buff/client"
|
15
18
|
|
16
19
|
module Buff
|
17
|
-
|
18
|
-
begin
|
19
|
-
ACCESS_TOKEN = File.open(File.expand_path("~/.bufferapprc")).readlines[2].chomp if File.exists?(File.expand_path("~/.bufferapprc"))
|
20
|
-
end
|
21
|
-
|
22
|
-
class UserInfo < Hashie::Mash; end
|
23
|
-
class Profile < Hashie::Mash; end
|
24
|
-
class Response < Hashie::Mash; end
|
25
|
-
class Update < Hashie::Mash; end
|
26
|
-
class Updates < Hashie::Mash; end
|
27
|
-
class Interaction < Hashie::Mash; end
|
28
|
-
class Interactions < Hashie::Mash; end
|
29
|
-
class Link < Hashie::Mash; end
|
30
|
-
class Info < Hashie::Mash; end
|
31
|
-
|
32
|
-
class Schedule < Hashie::Mash; end
|
33
|
-
Schedules = Class.new(Array) do
|
34
|
-
def dump
|
35
|
-
{ schedules: self }.to_json
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
InvalidIdLength = Class.new(ArgumentError)
|
40
|
-
InvalidIdContent = Class.new(ArgumentError)
|
41
|
-
MissingStatus = Class.new(ArgumentError)
|
42
|
-
APIError = Class.new(StandardError)
|
43
|
-
UnauthorizeRequest = Class.new(StandardError)
|
44
|
-
|
45
|
-
class Client
|
46
|
-
include Core
|
47
|
-
include User
|
48
|
-
include Profile
|
49
|
-
include Update
|
50
|
-
include Link
|
51
|
-
include Error
|
52
|
-
|
53
|
-
attr_accessor :access_token, :auth_query
|
54
|
-
|
55
|
-
def initialize(access_token)
|
56
|
-
@access_token = access_token
|
57
|
-
@conn = Faraday.new(:url => "https://api.bufferapp.com/1/") do |faraday|
|
58
|
-
faraday.request :url_encoded # form-encode POST params
|
59
|
-
faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def auth_query
|
64
|
-
{ :access_token => @access_token }
|
65
|
-
end
|
66
|
-
|
67
|
-
def info
|
68
|
-
response = get("/info/configuration.json")
|
69
|
-
Buff::Info.new(response)
|
70
|
-
end
|
71
|
-
end
|
72
20
|
end
|
73
|
-
|
@@ -0,0 +1,10 @@
|
|
1
|
+
HTTP/1.1 200 Awesome
|
2
|
+
Content-Type: application/json;charset=UTF-8
|
3
|
+
Date: Wed, 15 May 2013 01:43:34 GMT
|
4
|
+
Server: Apache
|
5
|
+
Vary: Accept-Encoding,User-Agent
|
6
|
+
x-frame-options: SAMEORIGIN
|
7
|
+
Content-Length: 828
|
8
|
+
Connection: keep-alive
|
9
|
+
|
10
|
+
{"success":true,"message":"Update deleted successfully"}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
HTTP/1.1 200 Awesome
|
2
|
+
Content-Type: application/json;charset=UTF-8
|
3
|
+
Date: Thu, 16 May 2013 22:05:18 GMT
|
4
|
+
Server: Apache
|
5
|
+
Vary: Accept-Encoding,User-Agent
|
6
|
+
x-frame-options: SAMEORIGIN
|
7
|
+
Content-Length: 2820
|
8
|
+
Connection: keep-alive
|
9
|
+
|
10
|
+
{"services":{"twitter":{"types":{"profile":{"name":"Twitter","character_limit":140,"schedule_limit":288,"icons":{"16":"http:\/\/static.bufferapp.com\/images\/services\/twitter-16x16.png","32":"http:\/\/static.bufferapp.com\/images\/services\/twitter-32x32.png","64":"http:\/\/static.bufferapp.com\/images\/services\/twitter-64x64.png"},"supported_interactions":["favorites","favorite","mentions","mention","retweets","retweet"]}},"urls":{"user":"https:\/\/twitter.com\/","hashtag":"https:\/\/twitter.com\/#!\/search?q=%23","cashtag":"https:\/\/twitter.com\/#!\/search?q=%24"}},"facebook":{"types":{"profile":{"name":"Facebook","character_limit":5000,"schedule_limit":5,"icons":{"16":"http:\/\/static.bufferapp.com\/images\/services\/facebook-16x16.png","32":"http:\/\/static.bufferapp.com\/images\/services\/facebook-32x32.png","64":"http:\/\/static.bufferapp.com\/images\/services\/facebook-64x64.png"},"supported_interactions":["likes","like","comments","comment"]},"page":{"name":"Facebook Page","character_limit":5000,"schedule_limit":5,"icons":{"16":"http:\/\/static.bufferapp.com\/images\/services\/facebook-16x16.png","32":"http:\/\/static.bufferapp.com\/images\/services\/facebook-32x32.png","64":"http:\/\/static.bufferapp.com\/images\/services\/facebook-64x64.png"},"supported_interactions":["likes","like","comments","comment"]}},"urls":{"user":"https:\/\/www.facebook.com\/"}},"linkedin":{"types":{"profile":{"name":"LinkedIn","character_limit":700,"schedule_limit":25,"icons":{"16":"http:\/\/static.bufferapp.com\/images\/services\/linkedin-16x16.png","32":"http:\/\/static.bufferapp.com\/images\/services\/linkedin-32x32.png","64":"http:\/\/static.bufferapp.com\/images\/services\/linkedin-64x64.png"},"supported_interactions":["comments","comment","likes","like"]},"group":{"name":"LinkedIn Group","character_limit":200,"schedule_limit":100,"icons":{"16":"http:\/\/static.bufferapp.com\/images\/services\/linkedin-16x16.png","32":"http:\/\/static.bufferapp.com\/images\/services\/linkedin-32x32.png","64":"http:\/\/static.bufferapp.com\/images\/services\/linkedin-64x64.png"},"supported_interactions":["comments","comment","likes","like"]}},"urls":{"user":"http:\/\/www.linkedin.com\/search\/fpsearch?type=people&keywords="}},"appdotnet":{"types":{"profile":{"name":"App.net","character_limit":256,"schedule_limit":288,"icons":{"16":"http:\/\/static.bufferapp.com\/images\/services\/appdotnet-alpha-16x16.png","32":"http:\/\/static.bufferapp.com\/images\/services\/appdotnet-alpha2-32x32.png","64":"http:\/\/static.bufferapp.com\/images\/services\/appdotnet-alpha-64x64.png"},"supported_interactions":[]}},"urls":{"user":"https:\/\/alpha.app.net\/","hashtag":"https:\/\/alpha.app.net\/hashtags\/"}}},"media":{"picture_size_min":0,"picture_size_max":5242880,"picture_filetypes":["jpeg","jpg","gif","png"]}}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
HTTP/1.1 200 Awesome
|
2
|
+
Content-Type: application/json;charset=UTF-8
|
3
|
+
Date: Fri, 17 May 2013 04:21:13 GMT
|
4
|
+
Server: Apache
|
5
|
+
Vary: Accept-Encoding,User-Agent
|
6
|
+
x-frame-options: SAMEORIGIN
|
7
|
+
Content-Length: 29
|
8
|
+
Connection: keep-alive
|
9
|
+
|
10
|
+
{"total":0,"interactions":[]}
|