pinterest-api 0.2.2 → 0.4.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: 23947737fa04298dcb3b66c9ce5859e072ce6c05
4
- data.tar.gz: 58e70ea1325e5a89b08655f5816623c04ae27584
3
+ metadata.gz: b0d81e04ec50f94410f1d1bc014bc6ee1343f3e2
4
+ data.tar.gz: 57d301ff4fd4b41ad507b2e892d8d1c45b6956d5
5
5
  SHA512:
6
- metadata.gz: c59be570e75c7621ddf28fc114a6f41379b183bdbdc06ee7785a400da7ef88377fba90a2e7fb3bcddefdde2c27971743e36fa6db9b0dddc21ba7a1b7a0defc7d
7
- data.tar.gz: 292bd49abfedb82e14112704c861d54b9b08ee92e9d7370f64c41619b0e51e8cb04220fdb020eddfb1c89ee71932368fdd4d893dbfc8b2827fcc88cea883bc11
6
+ metadata.gz: a259c40135f8d701451825b2b914c481c3a0bd60ab2fbd9c66ffdab7047d199e05ac84c4f262ba0f87f29f3ffe7a9abb5b43d9781e2c8687852962c7f8416de1
7
+ data.tar.gz: f43ddf762cbef6077258940e5efca3f1acff9c47eae2b5bc176bf80fc1f330451246fe5694bed46d6b920615c453cab8a2d89ef968f65685010ffca24a15e3e4
data/.gitignore CHANGED
@@ -9,3 +9,5 @@
9
9
  /tmp/
10
10
  .env
11
11
  *.gem
12
+ *.swp
13
+ *.swo
data/README.md CHANGED
@@ -2,12 +2,13 @@
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/pinterest-api.svg)](https://badge.fury.io/rb/pinterest-api)
4
4
  [![Code Climate](https://codeclimate.com/github/realadeel/pinterest-api/badges/gpa.svg)](https://codeclimate.com/github/realadeel/pinterest-api)
5
- [![Build Status](https://semaphoreci.com/api/v1/projects/17e4870c-9339-42e9-b2a1-8a7ca1d02bc2/558393/badge.svg)](https://semaphoreci.com/realdeal/pinterest-api)
6
5
 
7
6
  This is the Ruby gem for interacting with the official [Pinterest REST API](https://developers.pinterest.com/docs/getting-started/introduction/).
8
7
 
9
8
  This gem uses Faraday and Hashie to make requests and parse the responses.
10
9
 
10
+ Battle-tested at [Shopseen](https://www.shopseen.com) to help merchants sell more.
11
+
11
12
  ## Usage
12
13
 
13
14
  Obtain an access token from Pinterest. You can generate one [here](https://developers.pinterest.com/tools/access_token/).
@@ -50,11 +51,19 @@ client.follow_board(<board_id>)
50
51
  client.unfollow_board(<board_id>)
51
52
 
52
53
  # Follow an interest
54
+ > This endpoint is no longer part of the Pinterest documentation, and has always returned an error
53
55
  client.follow_interest(<interest_id>)
54
56
 
55
57
  # Unfollow an interest
58
+ > This endpoint is no longer part of the Pinterest documentation, and has always returned an error
56
59
  client.unfollow_interest(<interest_id>)
57
60
 
61
+ # Get all of authenticated users's pins
62
+ client.get_pins
63
+
64
+ # Get all of authenticated users's boards
65
+ client.get_boards
66
+
58
67
  # Search for authenticated users's pins related to shoes
59
68
  client.get_pins(query: 'shoes')
60
69
 
@@ -64,6 +73,29 @@ client.get_boards(query: 'shoes')
64
73
  # Get the account info for a Pinterest user
65
74
  client.get_user('<username>')
66
75
 
76
+ ```
77
+ ## Creating pins
78
+
79
+ You can create pins as follows
80
+
81
+ ```
82
+ @client.create_pin({
83
+ board: '<username>/<board_name>' OR '<board_id>',
84
+ note: 'My note'
85
+ link: 'https://www.google.com',
86
+ image_url: 'http://marketingland.com/wp-content/ml-loads/2014/07/pinterest-logo-white-1920.png'
87
+ })
88
+ ```
89
+
90
+ You can also upload your own image file like so
91
+
92
+ ```
93
+ @client.create_pin({
94
+ board: '1154178055932271277',
95
+ note: 'Test from ruby gem',
96
+ link: 'https://www.shopseen.com',
97
+ image: Faraday::UploadIO.new(your_file_path, "image/<image_type>")
98
+ })
67
99
  ```
68
100
 
69
101
  ## Authentication
@@ -91,6 +123,23 @@ OAuth values from Pinterest in ```request.env['omniauth.auth']```
91
123
  For more details, check out "Integrating OmniAuth Into Your Application"
92
124
  https://github.com/intridea/omniauth
93
125
 
126
+ ## Request options
127
+
128
+ You can set any request options that are valid in `Faraday::Connection` by adding them as a has to the Pinterest Client initializer.
129
+
130
+ Example:
131
+
132
+ ```
133
+ client = Pinterest::Client.new(ACCESS_TOKEN, {
134
+ request: {
135
+ timeout: 1.5,
136
+ open_timeout: 1,
137
+ }
138
+ })
139
+
140
+ counts = client.get_user('<username>', {fields: "counts"})
141
+ ```
142
+
94
143
  ## Known Issues
95
144
 
96
145
  The gem is currently under active development. The following issues cause the test specs to fail, though it's not clear to me that these issues are not with the Pinterest API itself.
@@ -14,8 +14,9 @@ module Pinterest
14
14
  DEFAULT_USER_AGENT = "Pinterest Ruby Gem #{Pinterest::VERSION}".freeze
15
15
  DEFAULT_ADAPTER = Faraday.default_adapter
16
16
 
17
- def initialize(access_token = nil)
17
+ def initialize(access_token = nil, connection_options={})
18
18
  @access_token = access_token
19
+ @connection_options = connection_options
19
20
  end
20
21
 
21
22
  attr_reader :access_token
@@ -51,6 +52,10 @@ module Pinterest
51
52
  when :get
52
53
  path = path + "?access_token=" + @access_token
53
54
  request.url(URI.encode(path), options)
55
+ when :patch
56
+ request.path = path + "?access_token=" + @access_token
57
+ request.body = options unless options.empty?
58
+ request.headers['Authorization'] = "BEARER #{@access_token}"
54
59
  when :post, :put, :delete
55
60
  request.path = URI.encode(path)
56
61
  request.body = options unless options.empty?
@@ -61,15 +66,16 @@ module Pinterest
61
66
  end
62
67
 
63
68
  def connection(raw = false, log = false)
64
- options = {
69
+ options = @connection_options.merge({
65
70
  :headers => {'Accept' => "application/json; charset=utf-8", 'User-Agent' => user_agent},
66
71
  :url => endpoint,
67
- }
72
+ })
68
73
 
69
74
  Faraday::Connection.new(options) do |connection|
70
75
  unless raw
71
76
  connection.use FaradayMiddleware::Mashify
72
77
  end
78
+ connection.use Faraday::Request::Multipart
73
79
  connection.use Faraday::Response::ParseJson
74
80
  connection.use Faraday::Request::UrlEncoded
75
81
  connection.response :logger if log
@@ -14,8 +14,8 @@ module Pinterest
14
14
  post('pins', params)
15
15
  end
16
16
 
17
- def update_pin(params={})
18
- patch('pins', params)
17
+ def update_pin(id, params={})
18
+ patch("pins/#{id}", params)
19
19
  end
20
20
 
21
21
  def delete_pin(id)
@@ -1,3 +1,3 @@
1
1
  module Pinterest
2
- VERSION = "0.2.2"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -24,7 +24,7 @@ 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
+ spec.add_development_dependency "webmock", "~> 3.0.1"
28
28
 
29
29
  spec.add_dependency 'faraday', "~> 0.9"
30
30
  spec.add_dependency 'faraday_middleware', "~> 0.9"
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.2.2
4
+ version: 0.4.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-12 00:00:00.000000000 Z
11
+ date: 2017-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '1.0'
89
+ version: 3.0.1
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '1.0'
96
+ version: 3.0.1
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: faraday
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -209,7 +209,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
209
209
  version: '0'
210
210
  requirements: []
211
211
  rubyforge_project:
212
- rubygems_version: 2.4.5.1
212
+ rubygems_version: 2.6.10
213
213
  signing_key:
214
214
  specification_version: 4
215
215
  summary: Ruby gem to interact with the Pinterest REST API