pocket-ruby-andyw8 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.yardopts +9 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +3 -0
- data/LICENSE.md +21 -0
- data/README.md +31 -0
- data/Rakefile +27 -0
- data/demo-server.rb +72 -0
- data/lib/faraday/pocket_oauth.rb +24 -0
- data/lib/faraday/raise_pocket_error.rb +32 -0
- data/lib/pocket-ruby.rb +26 -0
- data/lib/pocket/api.rb +21 -0
- data/lib/pocket/client.rb +13 -0
- data/lib/pocket/client/add.rb +12 -0
- data/lib/pocket/client/modify.rb +12 -0
- data/lib/pocket/client/retrieve.rb +12 -0
- data/lib/pocket/configuration.rb +87 -0
- data/lib/pocket/connection.rb +29 -0
- data/lib/pocket/error.rb +19 -0
- data/lib/pocket/oauth.rb +45 -0
- data/lib/pocket/version.rb +3 -0
- data/pocket-ruby.gemspec +25 -0
- metadata +156 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 184559f436d9a7270366507934bbf439a9f99a9eb7b4f567def2c557f0e7200f
|
4
|
+
data.tar.gz: a46cd3667e1fcf6626a8abb0aca9cc4739a6ad1a5866c5639cf8bed2e6f45630
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ee26f47f82484ab5f1ccccb91fef3ac282b0d515d2d8da0208b9cbc7b1f337807b02ab669c64a6610c385dffd9d7cb0681412b0396ec3cbf4e28732988825c9b
|
7
|
+
data.tar.gz: 6310e11534eb9ecf4df690ec093b9a0c7fb4a8f88874b27661b3ff1b4fe45e1df392e5b76ff7d234a0efb8e58afc5450164e5dab508a5b3aee06a91ce76a645b
|
data/.gitignore
ADDED
data/.yardopts
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/LICENSE.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
Copyright (c) 2012 Geknowm, Inc.
|
2
|
+
Portions Copyright (c) 2011 Instagram (Burbn, Inc.)
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
a copy of this software and associated documentation files (the
|
6
|
+
"Software"), to deal in the Software without restriction, including
|
7
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
pocket-ruby
|
2
|
+
===========
|
3
|
+
|
4
|
+
[](https://codeclimate.com/github/turadg/pocket-ruby) [](http://badge.fury.io/rb/pocket-ruby)
|
5
|
+
|
6
|
+
Ruby API for v3 of the [Pocket API](http://getpocket.com/developer/docs/overview) (formerly Read It Later)
|
7
|
+
|
8
|
+
# Usage
|
9
|
+
|
10
|
+
Just clone the repo here and refer to the demo-server.rb file for examples on how to interact with the Pocket API.
|
11
|
+
|
12
|
+
```sh
|
13
|
+
git clone
|
14
|
+
cd pocket-ruby
|
15
|
+
bundle install
|
16
|
+
ruby demo-server.rb
|
17
|
+
```
|
18
|
+
|
19
|
+
Pocket-Ruby can be installed via the gem, ```gem install pocket-ruby```
|
20
|
+
|
21
|
+
Or via bundler, ```gem 'pocket-ruby'```
|
22
|
+
|
23
|
+
# For v0.0.5 and earlier
|
24
|
+
|
25
|
+
Using v0.0.5 and earlier may result in a ```require``` error. To fix this you may either update to a newer version of the gem or uninstall with ```gem uninstall pocket-ruby``` and try again using the method below:
|
26
|
+
|
27
|
+
Install via the gem, ```gem install pocket-ruby -v 0.0.5```
|
28
|
+
|
29
|
+
Or via bundler, ```gem 'pocket-ruby', '0.0.5', :require => 'pocket'```
|
30
|
+
|
31
|
+
Be sure to require the gem in your code with ```require 'pocket'``` not ```require 'pocket-ruby'```
|
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
Bundler::GemHelper.install_tasks
|
3
|
+
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
RSpec::Core::RakeTask.new(:spec)
|
6
|
+
|
7
|
+
task :default => :spec
|
8
|
+
|
9
|
+
namespace :doc do
|
10
|
+
begin
|
11
|
+
require 'yard'
|
12
|
+
rescue LoadError
|
13
|
+
# ignore
|
14
|
+
else
|
15
|
+
YARD::Rake::YardocTask.new do |task|
|
16
|
+
task.files = ['HISTORY.mkd', 'LICENSE.mkd', 'lib/**/*.rb']
|
17
|
+
task.options = [
|
18
|
+
'--protected',
|
19
|
+
'--output-dir', 'doc/yard',
|
20
|
+
'--tag', 'format:Supported formats',
|
21
|
+
'--tag', 'authenticated:Requires Authentication',
|
22
|
+
'--tag', 'rate_limited:Rate Limited',
|
23
|
+
'--markup', 'markdown',
|
24
|
+
]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/demo-server.rb
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
require "sinatra"
|
2
|
+
|
3
|
+
require "./lib/pocket-ruby.rb"
|
4
|
+
|
5
|
+
enable :sessions
|
6
|
+
|
7
|
+
CALLBACK_URL = "http://localhost:4567/oauth/callback"
|
8
|
+
|
9
|
+
Pocket.configure do |config|
|
10
|
+
config.consumer_key = '10188-3565cd04d1464e6d0e64b67f'
|
11
|
+
end
|
12
|
+
|
13
|
+
get '/reset' do
|
14
|
+
puts "GET /reset"
|
15
|
+
session.clear
|
16
|
+
end
|
17
|
+
|
18
|
+
get "/" do
|
19
|
+
puts "GET /"
|
20
|
+
puts "session: #{session}"
|
21
|
+
|
22
|
+
if session[:access_token]
|
23
|
+
'
|
24
|
+
<a href="/add?url=http://getpocket.com">Add Pocket Homepage</a>
|
25
|
+
<a href="/retrieve">Retrieve single item</a>
|
26
|
+
'
|
27
|
+
else
|
28
|
+
'<a href="/oauth/connect">Connect with Pocket</a>'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
get "/oauth/connect" do
|
33
|
+
puts "OAUTH CONNECT"
|
34
|
+
session[:code] = Pocket.get_code(:redirect_uri => CALLBACK_URL)
|
35
|
+
new_url = Pocket.authorize_url(:code => session[:code], :redirect_uri => CALLBACK_URL)
|
36
|
+
puts "new_url: #{new_url}"
|
37
|
+
puts "session: #{session}"
|
38
|
+
redirect new_url
|
39
|
+
end
|
40
|
+
|
41
|
+
get "/oauth/callback" do
|
42
|
+
puts "OAUTH CALLBACK"
|
43
|
+
puts "request.url: #{request.url}"
|
44
|
+
puts "request.body: #{request.body.read}"
|
45
|
+
result = Pocket.get_result(session[:code], :redirect_uri => CALLBACK_URL)
|
46
|
+
session[:access_token] = result['access_token']
|
47
|
+
puts result['access_token']
|
48
|
+
puts result['username']
|
49
|
+
# Alternative method to get the access token directly
|
50
|
+
#session[:access_token] = Pocket.get_access_token(session[:code])
|
51
|
+
puts session[:access_token]
|
52
|
+
puts "session: #{session}"
|
53
|
+
redirect "/"
|
54
|
+
end
|
55
|
+
|
56
|
+
get '/add' do
|
57
|
+
client = Pocket.client(:access_token => session[:access_token])
|
58
|
+
info = client.add :url => 'http://getpocket.com'
|
59
|
+
"<pre>#{info}</pre>"
|
60
|
+
end
|
61
|
+
|
62
|
+
get "/retrieve" do
|
63
|
+
client = Pocket.client(:access_token => session[:access_token])
|
64
|
+
info = client.retrieve(:detailType => :complete, :count => 1)
|
65
|
+
|
66
|
+
# html = "<h1>#{user.username}'s recent photos</h1>"
|
67
|
+
# for media_item in client.user_recent_media
|
68
|
+
# html << "<img src='#{media_item.images.thumbnail.url}'>"
|
69
|
+
# end
|
70
|
+
# html
|
71
|
+
"<pre>#{info}</pre>"
|
72
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
|
3
|
+
# @private
|
4
|
+
module FaradayMiddleware
|
5
|
+
# @private
|
6
|
+
class PocketOAuth < Faraday::Middleware
|
7
|
+
def call(env)
|
8
|
+
env[:body] = {} if env[:body].nil?
|
9
|
+
env[:body] = env[:body].merge(:consumer_key => @consumer_key)
|
10
|
+
|
11
|
+
if @access_token
|
12
|
+
env[:body] = env[:body].merge(:access_token => @access_token)
|
13
|
+
end
|
14
|
+
|
15
|
+
@app.call env
|
16
|
+
end
|
17
|
+
|
18
|
+
def initialize(app, consumer_key, access_token=nil)
|
19
|
+
@app = app
|
20
|
+
@consumer_key = consumer_key
|
21
|
+
@access_token = access_token
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Faraday
|
2
|
+
|
3
|
+
# HTTP Status X-Error-Code X-Error
|
4
|
+
# 400 138 Missing consumer key.
|
5
|
+
# 403 152 Invalid consumer key.
|
6
|
+
# 400 181 Invalid redirect uri.
|
7
|
+
# 400 182 Missing code.
|
8
|
+
# 400 185 Code not found.
|
9
|
+
# 403 158 User rejected code.
|
10
|
+
# 403 159 Already used code.
|
11
|
+
# 50X 199 Pocket server issue.
|
12
|
+
#
|
13
|
+
# @see http://getpocket.com/developer/docs/authentication
|
14
|
+
class Response::RaisePocketError < Response::Middleware
|
15
|
+
ClientErrorStatuses = 400...600
|
16
|
+
|
17
|
+
def on_complete(env)
|
18
|
+
case env[:status]
|
19
|
+
when 404
|
20
|
+
raise Faraday::Error::ResourceNotFound, response_values(env)
|
21
|
+
when 400...403
|
22
|
+
raise Pocket::Error, env[:response_headers]['X-Error']
|
23
|
+
when ClientErrorStatuses
|
24
|
+
raise Faraday::Error::ClientError, response_values(env)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def response_values(env)
|
29
|
+
{:status => env[:status], :headers => env[:response_headers], :body => env[:body]}
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/pocket-ruby.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require File.expand_path('../pocket/error', __FILE__)
|
2
|
+
require File.expand_path('../pocket/configuration', __FILE__)
|
3
|
+
require File.expand_path('../pocket/api', __FILE__)
|
4
|
+
require File.expand_path('../pocket/client', __FILE__)
|
5
|
+
|
6
|
+
module Pocket
|
7
|
+
extend Configuration
|
8
|
+
|
9
|
+
# Alias for Pocket::Client.new
|
10
|
+
#
|
11
|
+
# @return [Pocket::Client]
|
12
|
+
def self.client(options={})
|
13
|
+
Pocket::Client.new(options)
|
14
|
+
end
|
15
|
+
|
16
|
+
# Delegate to Pocket::Client
|
17
|
+
def self.method_missing(method, *args, &block)
|
18
|
+
return super unless client.respond_to?(method)
|
19
|
+
client.send(method, *args, &block)
|
20
|
+
end
|
21
|
+
|
22
|
+
# Delegate to Pocket::Client
|
23
|
+
def self.respond_to?(method)
|
24
|
+
return client.respond_to?(method) || super
|
25
|
+
end
|
26
|
+
end
|
data/lib/pocket/api.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require File.expand_path('../connection', __FILE__)
|
2
|
+
require File.expand_path('../oauth', __FILE__)
|
3
|
+
|
4
|
+
module Pocket
|
5
|
+
# @private
|
6
|
+
class API
|
7
|
+
# @private
|
8
|
+
attr_accessor *Configuration::VALID_OPTIONS_KEYS
|
9
|
+
|
10
|
+
# Creates a new API
|
11
|
+
def initialize(options={})
|
12
|
+
options = Pocket.options.merge(options)
|
13
|
+
Configuration::VALID_OPTIONS_KEYS.each do |key|
|
14
|
+
send("#{key}=", options[key])
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
include Connection
|
19
|
+
include OAuth
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Pocket
|
2
|
+
# Wrapper for the Pocket REST API
|
3
|
+
#
|
4
|
+
# @note All methods have been separated into modules and follow the same grouping used in {TODO:doc_URL the Pocket API Documentation}.
|
5
|
+
# @see TODO:doc_url
|
6
|
+
class Client < API
|
7
|
+
Dir[File.expand_path('../client/*.rb', __FILE__)].each{|f| require f}
|
8
|
+
|
9
|
+
include Pocket::Client::Add
|
10
|
+
include Pocket::Client::Modify
|
11
|
+
include Pocket::Client::Retrieve
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Pocket
|
2
|
+
class Client
|
3
|
+
# http://getpocket.com/developer/docs/v3/modify
|
4
|
+
module Modify
|
5
|
+
# required params: actions, consumer_key, access_token
|
6
|
+
def modify actions
|
7
|
+
response = connection.post("/v3/send", {actions: actions})
|
8
|
+
response.body
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Pocket
|
2
|
+
class Client
|
3
|
+
# http://getpocket.com/developer/docs/v3/retrieve
|
4
|
+
module Retrieve
|
5
|
+
# required params: consumer_key, access_token
|
6
|
+
def retrieve params=[]
|
7
|
+
response = connection.post("/v3/get", params)
|
8
|
+
response.body
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
require File.expand_path('../version', __FILE__)
|
3
|
+
|
4
|
+
module Pocket
|
5
|
+
# Defines constants and methods related to configuration
|
6
|
+
module Configuration
|
7
|
+
# An array of valid keys in the options hash when configuring a {Pocket::API}
|
8
|
+
VALID_OPTIONS_KEYS = [
|
9
|
+
:adapter,
|
10
|
+
:consumer_key,
|
11
|
+
:access_token,
|
12
|
+
:endpoint,
|
13
|
+
:redirect_uri,
|
14
|
+
:format,
|
15
|
+
:user_agent,
|
16
|
+
:proxy
|
17
|
+
].freeze
|
18
|
+
|
19
|
+
# An array of valid request/response formats
|
20
|
+
#
|
21
|
+
# @note Not all methods support the XML format.
|
22
|
+
VALID_FORMATS = [
|
23
|
+
:json].freeze
|
24
|
+
|
25
|
+
# The adapter that will be used to connect if none is set
|
26
|
+
#
|
27
|
+
# @note The default faraday adapter is Net::HTTP.
|
28
|
+
DEFAULT_ADAPTER = Faraday.default_adapter
|
29
|
+
|
30
|
+
# By default, don't set an application ID
|
31
|
+
DEFAULT_CONSUMER_KEY = nil
|
32
|
+
|
33
|
+
# By default, don't set an application redirect uri
|
34
|
+
DEFAULT_REDIRECT_URI = nil
|
35
|
+
|
36
|
+
# By default, don't set a user access token
|
37
|
+
DEFAULT_ACCESS_TOKEN = nil
|
38
|
+
|
39
|
+
# The endpoint that will be used to connect if none is set
|
40
|
+
#
|
41
|
+
# @note There is no reason to use any other endpoint at this time
|
42
|
+
DEFAULT_ENDPOINT = 'https://getpocket.com/v3/'.freeze
|
43
|
+
|
44
|
+
# The response format appended to the path and sent in the 'Accept' header if none is set
|
45
|
+
#
|
46
|
+
# @note JSON is the only available format at this time
|
47
|
+
DEFAULT_FORMAT = :json
|
48
|
+
|
49
|
+
# By default, don't use a proxy server
|
50
|
+
DEFAULT_PROXY = nil
|
51
|
+
|
52
|
+
# The user agent that will be sent to the API endpoint if none is set
|
53
|
+
DEFAULT_USER_AGENT = "Pocket Ruby Gem #{Pocket::VERSION}".freeze
|
54
|
+
|
55
|
+
# @private
|
56
|
+
attr_accessor *VALID_OPTIONS_KEYS
|
57
|
+
|
58
|
+
# When this module is extended, set all configuration options to their default values
|
59
|
+
def self.extended(base)
|
60
|
+
base.reset
|
61
|
+
end
|
62
|
+
|
63
|
+
# Convenience method to allow configuration options to be set in a block
|
64
|
+
def configure
|
65
|
+
yield self
|
66
|
+
end
|
67
|
+
|
68
|
+
# Create a hash of options and their values
|
69
|
+
def options
|
70
|
+
VALID_OPTIONS_KEYS.inject({}) do |option, key|
|
71
|
+
option.merge!(key => send(key))
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
# Reset all configuration options to defaults
|
76
|
+
def reset
|
77
|
+
self.adapter = DEFAULT_ADAPTER
|
78
|
+
self.consumer_key = DEFAULT_CONSUMER_KEY
|
79
|
+
self.access_token = DEFAULT_ACCESS_TOKEN
|
80
|
+
self.endpoint = DEFAULT_ENDPOINT
|
81
|
+
self.redirect_uri = DEFAULT_REDIRECT_URI
|
82
|
+
self.format = DEFAULT_FORMAT
|
83
|
+
self.user_agent = DEFAULT_USER_AGENT
|
84
|
+
self.proxy = DEFAULT_PROXY
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'faraday_middleware'
|
2
|
+
Dir[File.expand_path('../../faraday/*.rb', __FILE__)].each{|f| require f}
|
3
|
+
|
4
|
+
module Pocket
|
5
|
+
# @private
|
6
|
+
module Connection
|
7
|
+
private
|
8
|
+
|
9
|
+
def connection(raw=false)
|
10
|
+
options = {
|
11
|
+
:headers => {'User-Agent' => user_agent},
|
12
|
+
:proxy => proxy,
|
13
|
+
:ssl => {:verify => false},
|
14
|
+
:url => endpoint,
|
15
|
+
}
|
16
|
+
|
17
|
+
Faraday::Connection.new(options) do |conn|
|
18
|
+
conn.use FaradayMiddleware::PocketOAuth, consumer_key, access_token
|
19
|
+
conn.use Faraday::Response::RaisePocketError
|
20
|
+
|
21
|
+
conn.request :json
|
22
|
+
|
23
|
+
conn.response :json, :content_type => /\bjson$/
|
24
|
+
|
25
|
+
conn.adapter Faraday.default_adapter
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/pocket/error.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
module Pocket
|
2
|
+
# Custom error class for rescuing from all Pocket errors
|
3
|
+
class Error < StandardError; end
|
4
|
+
|
5
|
+
# Raised when Pocket returns the HTTP status code 400
|
6
|
+
class BadRequest < Error; end
|
7
|
+
|
8
|
+
# Raised when Pocket returns the HTTP status code 404
|
9
|
+
class NotFound < Error; end
|
10
|
+
|
11
|
+
# Raised when Pocket returns the HTTP status code 500
|
12
|
+
class InternalServerError < Error; end
|
13
|
+
|
14
|
+
# Raised when Pocket returns the HTTP status code 503
|
15
|
+
class ServiceUnavailable < Error; end
|
16
|
+
|
17
|
+
# Raised when a subscription payload hash is invalid
|
18
|
+
class InvalidSignature < Error; end
|
19
|
+
end
|
data/lib/pocket/oauth.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
module Pocket
|
2
|
+
# Defines HTTP request methods
|
3
|
+
module OAuth
|
4
|
+
# Return URL for OAuth authorization
|
5
|
+
def authorize_url(options={})
|
6
|
+
params = access_token_params.merge(options)
|
7
|
+
params.delete(:consumer_key) # shouldn't be exposed publically
|
8
|
+
# Pocket renames `code` to `request_token` for some reason in this call
|
9
|
+
params[:request_token] ||= params.delete(:code)
|
10
|
+
connection.build_url("/auth/authorize", params).to_s
|
11
|
+
end
|
12
|
+
|
13
|
+
# Return a Pocket code
|
14
|
+
def get_code(options={})
|
15
|
+
params = access_token_params.merge(options)
|
16
|
+
response = connection.post 'oauth/request', params
|
17
|
+
results = Hash[URI.decode_www_form(response.body)]
|
18
|
+
code = results['code']
|
19
|
+
end
|
20
|
+
|
21
|
+
# Return an access token from authorization
|
22
|
+
def get_access_token(code, options={})
|
23
|
+
params = access_token_params.merge(:code => code).merge(options)
|
24
|
+
response = connection.post 'oauth/authorize', params
|
25
|
+
results = Hash[URI.decode_www_form(response.body)]
|
26
|
+
access_token = results['access_token']
|
27
|
+
end
|
28
|
+
|
29
|
+
# Return result from authorization
|
30
|
+
def get_result(code, options={})
|
31
|
+
params = access_token_params.merge(:code => code).merge(options)
|
32
|
+
response = connection.post 'oauth/authorize', params
|
33
|
+
results = Hash[URI.decode_www_form(response.body)]
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def access_token_params
|
39
|
+
{
|
40
|
+
:consumer_key => consumer_key,
|
41
|
+
:redirect_uri => redirect_uri
|
42
|
+
}
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/pocket-ruby.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/pocket/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.add_development_dependency('sinatra', '~> 1.3.3')
|
6
|
+
s.add_development_dependency('multi_xml')
|
7
|
+
s.add_runtime_dependency('faraday', ['>= 0.7'])
|
8
|
+
s.add_runtime_dependency('faraday_middleware')
|
9
|
+
s.add_runtime_dependency('multi_json', '>= 1.0.3', '~> 1.0')
|
10
|
+
s.add_runtime_dependency('hashie', '>= 0.4.0')
|
11
|
+
s.authors = ["Turadg Aleahmad","Jason Ng PT"]
|
12
|
+
s.description = %q{A Ruby wrapper for the Pocket API v3 (Add, Modify and Retrieve)}
|
13
|
+
s.email = ['turadg@aleahmad.net',"me@jasonngpt.com"]
|
14
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
15
|
+
s.files = `git ls-files`.split("\n")
|
16
|
+
s.homepage = 'https://github.com/turadg/pocket-ruby'
|
17
|
+
s.name = 'pocket-ruby-andyw8'
|
18
|
+
s.platform = Gem::Platform::RUBY
|
19
|
+
s.require_paths = ['lib']
|
20
|
+
s.required_rubygems_version = Gem::Requirement.new('>= 1.3.6') if s.respond_to? :required_rubygems_version=
|
21
|
+
s.rubyforge_project = s.name
|
22
|
+
s.summary = %q{Ruby wrapper for the Pocket API v3}
|
23
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
24
|
+
s.version = Pocket::VERSION
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,156 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pocket-ruby-andyw8
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.7
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Turadg Aleahmad
|
8
|
+
- Jason Ng PT
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2021-03-28 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: sinatra
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 1.3.3
|
21
|
+
type: :development
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: 1.3.3
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: multi_xml
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: faraday
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0.7'
|
49
|
+
type: :runtime
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0.7'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: faraday_middleware
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: multi_json
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '1.0'
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: 1.0.3
|
80
|
+
type: :runtime
|
81
|
+
prerelease: false
|
82
|
+
version_requirements: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - "~>"
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '1.0'
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 1.0.3
|
90
|
+
- !ruby/object:Gem::Dependency
|
91
|
+
name: hashie
|
92
|
+
requirement: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.4.0
|
97
|
+
type: :runtime
|
98
|
+
prerelease: false
|
99
|
+
version_requirements: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 0.4.0
|
104
|
+
description: A Ruby wrapper for the Pocket API v3 (Add, Modify and Retrieve)
|
105
|
+
email:
|
106
|
+
- turadg@aleahmad.net
|
107
|
+
- me@jasonngpt.com
|
108
|
+
executables: []
|
109
|
+
extensions: []
|
110
|
+
extra_rdoc_files: []
|
111
|
+
files:
|
112
|
+
- ".gitignore"
|
113
|
+
- ".yardopts"
|
114
|
+
- CHANGELOG.md
|
115
|
+
- Gemfile
|
116
|
+
- LICENSE.md
|
117
|
+
- README.md
|
118
|
+
- Rakefile
|
119
|
+
- demo-server.rb
|
120
|
+
- lib/faraday/pocket_oauth.rb
|
121
|
+
- lib/faraday/raise_pocket_error.rb
|
122
|
+
- lib/pocket-ruby.rb
|
123
|
+
- lib/pocket/api.rb
|
124
|
+
- lib/pocket/client.rb
|
125
|
+
- lib/pocket/client/add.rb
|
126
|
+
- lib/pocket/client/modify.rb
|
127
|
+
- lib/pocket/client/retrieve.rb
|
128
|
+
- lib/pocket/configuration.rb
|
129
|
+
- lib/pocket/connection.rb
|
130
|
+
- lib/pocket/error.rb
|
131
|
+
- lib/pocket/oauth.rb
|
132
|
+
- lib/pocket/version.rb
|
133
|
+
- pocket-ruby.gemspec
|
134
|
+
homepage: https://github.com/turadg/pocket-ruby
|
135
|
+
licenses: []
|
136
|
+
metadata: {}
|
137
|
+
post_install_message:
|
138
|
+
rdoc_options: []
|
139
|
+
require_paths:
|
140
|
+
- lib
|
141
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
|
+
requirements:
|
148
|
+
- - ">="
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: 1.3.6
|
151
|
+
requirements: []
|
152
|
+
rubygems_version: 3.0.3
|
153
|
+
signing_key:
|
154
|
+
specification_version: 4
|
155
|
+
summary: Ruby wrapper for the Pocket API v3
|
156
|
+
test_files: []
|