pinterest-api 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 10dafb495ed5c0239162f02b1a386e1fed11435e
4
- data.tar.gz: 8f90246f07b4e19e554f2993b1fe439b2d65db59
3
+ metadata.gz: f8b746902d0ccc613ab621389e08fd801d98a7a7
4
+ data.tar.gz: 01b1b5af4d0f24b3f5ef914c9a0098b0fd6ff1af
5
5
  SHA512:
6
- metadata.gz: 4a92803a99fe6ef125067b4eb31420526fea9be1f9529d007fac5a1548bd91afa5bc61b4d3e3c5a0e839e82b57e124b3976d73a207db5586ddaacd7ce0cf2a25
7
- data.tar.gz: 04b56f42ef58953194ee71e94d333813fedcf11e349bd29a996dfc03077175c009a8621323f044e4a7c5fff05abe7384f236a192a7b475566d6dc2b8c60f38f9
6
+ metadata.gz: 8fe9a941fc906a504a11148ddcf93fb8197860e31f4744691546b3017dd92e38007876ecaa9f310d7f899316e88b60cfe1d5b4064a365948ec2c09d5f89a425b
7
+ data.tar.gz: 1268820c0bab13faa08d5fe600ba5561b205c5bf56ad04912028add150975102df8d4881b02b6cdcdba3cace4fcb0380639363620c53b22e0904e40c10516a1f
data/.gitignore CHANGED
@@ -8,3 +8,4 @@
8
8
  /spec/reports/
9
9
  /tmp/
10
10
  .env
11
+ *.gem
data/README.md CHANGED
@@ -65,11 +65,34 @@ client.get_user('<username>')
65
65
 
66
66
  ```
67
67
 
68
- The gem is currently under active development. Use at your own risk. See Known Issues below.
69
- I hope to have the gem ready for production shortly. See Contributing section below to help.
68
+ ## Authentication
69
+
70
+ You can generate access tokens through the link above, or you can use OAuth
71
+ Authentication
72
+
73
+ In your app, make sure you have the omniauth gem installed. Add the following
74
+ to your ```intializers/omniauth.rb``` file
75
+
76
+ ```ruby
77
+
78
+ Rails.application.config.middleware.use OmniAuth::Builder do
79
+ provider :pinterest, ENV['PINTEREST_APP_ID'], ENV['PINTEREST_APP_SECRET']
80
+ end
81
+
82
+ ```
83
+
84
+ Direct your users to ```/auth/pinterest```
85
+
86
+ Once they approve your app, they'll be redirect to your callback URL, which
87
+ should be something like ```auth/pinterest/callback``` with a hash of
88
+ OAuth values from Pinterest in ```request.env['omniauth.auth']```
89
+
90
+ For more details, check out "Integrating OmniAuth Into Your Application"
91
+ https://github.com/intridea/omniauth
70
92
 
71
93
  ## Known Issues
72
94
 
95
+ The gem is currently under active development.
73
96
  * PATCH requests not working, endpoint path is not being appended to base
74
97
 
75
98
  ## TODO
@@ -1,5 +1,6 @@
1
1
  require "pinterest/version"
2
2
  require "pinterest/client"
3
+ require "pinterest/omniauth"
3
4
 
4
5
  module Pinterest
5
6
 
@@ -2,8 +2,8 @@ module Pinterest
2
2
  class Client
3
3
  module Board
4
4
 
5
- def get_board(id)
6
- get("boards/#{id}")
5
+ def get_board(id, options={})
6
+ get("boards/#{id}", options)
7
7
  end
8
8
 
9
9
  def create_board(params={})
@@ -2,12 +2,12 @@ module Pinterest
2
2
  class Client
3
3
  module Pin
4
4
 
5
- def get_pin(id)
6
- get("pins/#{id}")
5
+ def get_pin(id, options={})
6
+ get("pins/#{id}", options)
7
7
  end
8
8
 
9
- def get_board_pins(board_id)
10
- get("boards/#{board_id}/pins")
9
+ def get_board_pins(board_id, options={})
10
+ get("boards/#{board_id}/pins", options)
11
11
  end
12
12
 
13
13
  def create_pin(params={})
@@ -2,28 +2,32 @@ module Pinterest
2
2
  class Client
3
3
  module User
4
4
 
5
- def me
6
- get('me')
5
+ def me(options={})
6
+ get('me', options)
7
7
  end
8
8
 
9
- def get_followers
10
- get("me/followers")
9
+ def get_followers(options={})
10
+ get("me/followers", options)
11
11
  end
12
12
 
13
- def get_likes
14
- get("me/likes")
13
+ def get_likes(options={})
14
+ get("me/likes", options)
15
15
  end
16
16
 
17
- def get_followed_boards
18
- get("me/following/boards")
17
+ def get_boards(options={})
18
+ get("me/boards", options)
19
19
  end
20
20
 
21
- def get_followed_users
22
- get("me/following/users")
21
+ def get_followed_boards(options={})
22
+ get("me/following/boards", options)
23
23
  end
24
24
 
25
- def get_followed_interests
26
- get("me/following/interests")
25
+ def get_followed_users(options={})
26
+ get("me/following/users", options)
27
+ end
28
+
29
+ def get_followed_interests(options={})
30
+ get("me/following/interests", options)
27
31
  end
28
32
 
29
33
  def follow_user(user)
@@ -50,16 +54,16 @@ module Pinterest
50
54
  delete("me/following/interests/#{interest_id}")
51
55
  end
52
56
 
53
- def search_pins(params={})
54
- get('me/search/pins', query: params[:query])
57
+ def search_pins(options={})
58
+ get('me/search/pins', options)
55
59
  end
56
60
 
57
- def search_boards(params={})
58
- get('me/search/boards', query: params[:query])
61
+ def search_boards(options={})
62
+ get('me/search/boards', options)
59
63
  end
60
64
 
61
- def get_user(user)
62
- get("users/#{user}")
65
+ def get_user(user, options={})
66
+ get("users/#{user}", options)
63
67
  end
64
68
 
65
69
  end
@@ -0,0 +1,28 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Pinterest < OmniAuth::Strategies::OAuth2
6
+ option :client_options, {
7
+ :site => 'https://api.pinterest.com/',
8
+ :authorize_url => 'https://api.pinterest.com/oauth/',
9
+ :token_url => 'https://api.pinterest.com/v1/oauth/token'
10
+ }
11
+
12
+ def request_phase
13
+ options[:scope] ||= 'read_public,write_public'
14
+ options[:response_type] ||= 'token'
15
+ #options[:state] ||= '22'
16
+ super
17
+ end
18
+
19
+ uid { raw_info['id'] }
20
+
21
+ info { raw_info }
22
+
23
+ def raw_info
24
+ @raw_info ||= access_token.get('/v1/me/').parsed['data']
25
+ end
26
+ end
27
+ end
28
+ end
@@ -1,3 +1,3 @@
1
1
  module Pinterest
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
 
12
12
  spec.summary = %q{Ruby gem to interact with the Pinterest REST API}
13
13
  spec.description = %q{This gem makes it simple to interact with the official Pinterest REST API}
14
- spec.homepage = "http://github.com/realadeel"
14
+ spec.homepage = "http://github.com/realadeel/pinterest-api"
15
15
  spec.license = "MIT"
16
16
 
17
17
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
@@ -24,8 +24,11 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency "rspec", "~> 3.3"
25
25
  spec.add_development_dependency "vcr", "~> 2.9"
26
26
  spec.add_development_dependency "dotenv", "~> 2.0"
27
+ spec.add_development_dependency "webmock", "~> 1.0"
27
28
 
28
29
  spec.add_dependency 'faraday', "~> 0.9"
29
- spec.add_dependency 'faraday_middleware', ">= 0.9.0"
30
+ spec.add_dependency 'faraday_middleware', "~> 0.9"
30
31
  spec.add_dependency 'hashie', "~> 3.0"
32
+ spec.add_dependency 'omniauth', '~> 1.0'
33
+ spec.add_dependency 'omniauth-oauth2', '~> 1.0'
31
34
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pinterest-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adeel Ahmad
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-10-02 00:00:00.000000000 Z
11
+ date: 2015-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '2.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: webmock
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: faraday
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -98,16 +112,16 @@ dependencies:
98
112
  name: faraday_middleware
99
113
  requirement: !ruby/object:Gem::Requirement
100
114
  requirements:
101
- - - ">="
115
+ - - "~>"
102
116
  - !ruby/object:Gem::Version
103
- version: 0.9.0
117
+ version: '0.9'
104
118
  type: :runtime
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
107
121
  requirements:
108
- - - ">="
122
+ - - "~>"
109
123
  - !ruby/object:Gem::Version
110
- version: 0.9.0
124
+ version: '0.9'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: hashie
113
127
  requirement: !ruby/object:Gem::Requirement
@@ -122,6 +136,34 @@ dependencies:
122
136
  - - "~>"
123
137
  - !ruby/object:Gem::Version
124
138
  version: '3.0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: omniauth
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '1.0'
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '1.0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: omniauth-oauth2
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '1.0'
160
+ type: :runtime
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '1.0'
125
167
  description: This gem makes it simple to interact with the official Pinterest REST
126
168
  API
127
169
  email:
@@ -144,10 +186,10 @@ files:
144
186
  - lib/pinterest/client/board.rb
145
187
  - lib/pinterest/client/pin.rb
146
188
  - lib/pinterest/client/user.rb
189
+ - lib/pinterest/omniauth.rb
147
190
  - lib/pinterest/version.rb
148
- - pinterest-api-0.1.0.gem
149
191
  - pinterest.gemspec
150
- homepage: http://github.com/realadeel
192
+ homepage: http://github.com/realadeel/pinterest-api
151
193
  licenses:
152
194
  - MIT
153
195
  metadata: {}
Binary file