rails-pinterest 0.1.2 → 0.1.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '097b2ce4d2ec083c16dde219ab02d002612ed44147f0ea1ba7efbca852fd619f'
4
- data.tar.gz: 4997ffce4d401df22dcd418437d75d0156bafa0b89568906a62b46b348286a71
3
+ metadata.gz: 8aab3135f3b808a0275ebf74d586cd5c5d10c8adf00c742dd5774160dbd2fca7
4
+ data.tar.gz: d22b0aa38454c2bf9f3a9c2b90da90167a187b0980ee5c55241b89518c1d31a6
5
5
  SHA512:
6
- metadata.gz: '009d70127767d9823c65f25f88bb5a2c4aff755edcd3b0a750f2160efb79724053ec20d168cfe0643963b034610b07400ba1dd52c5e1e6242b052e5758fc3721'
7
- data.tar.gz: ec8e20194ed18c512c3ed412d94e571b382608cfcbe72a87f2b0e9a93233481d2a322b618f22768957fe068107de5631cd9c48a2f00c5545747f50e6ce1e8382
6
+ metadata.gz: 3f5537f6e8f1fc2730c271058b48bc8e1c9d2403a0de760f8f994b66e073c8f0ce4ceb87de7d0f60e5eedfccd418fcb07288141e517beab5a1c9e7d7c3803778
7
+ data.tar.gz: dc2870525a7a25bbb42979b86f7c999561fe0ed6bd64da4aad93af267f3838c482de0233b4a22023b9dbdf811dceb750dc7ab146ef09c979e2049d415b731dc8
data/CHANGELOG.md CHANGED
@@ -11,4 +11,10 @@
11
11
  - Re-release to rubygems
12
12
 
13
13
  ## [0.1.2] - 2023-12-2
14
- - Added oauth refresh token endpoint.
14
+ - Added oauth refresh token endpoint.
15
+
16
+ ## [0.1.3] - 2023-12-2
17
+ - Add to ReadMe how to get access token from a authorization token
18
+
19
+ ## [0.1.4] - 2024-01-17
20
+ - Add keywords and terms to API
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rails-pinterest (0.1.2)
4
+ rails-pinterest (0.1.4)
5
5
  faraday (>= 1)
6
6
  faraday-multipart (>= 1)
7
7
 
@@ -73,6 +73,7 @@ GEM
73
73
 
74
74
  PLATFORMS
75
75
  x86_64-darwin-19
76
+ x86_64-darwin-23
76
77
 
77
78
  DEPENDENCIES
78
79
  byebug (~> 11.1.3)
data/README.md CHANGED
@@ -176,6 +176,29 @@ response = client.pins.create_pin(parameters: parameters)
176
176
 
177
177
  ### Oauth
178
178
 
179
+ How to get exchange your authorization code for an access token [(step 3)](https://developers.pinterest.com/docs/getting-started/authentication/)
180
+ ```ruby
181
+ # https://developers.pinterest.com/docs/getting-started/authentication/
182
+
183
+ # POST /oauth/tokens to exchange authorization code for access token
184
+
185
+ # 1. Build the client
186
+ client = Pinterest::Client.new(access_token: "fake-token-because-you-dont-have-this-yet", client_id: "client-id" , secret_key: "secret-key")
187
+
188
+ # 2. Build parameters
189
+ parameters = {
190
+ 'grant_type' => 'authorization_code', # Required from Pinterest
191
+ 'code' => params[:code].to_s, # Replace with the actual authorization code
192
+ 'redirect_uri' => "your-redirect-uri"
193
+ }
194
+
195
+ # 3. Get the access token
196
+ response = client.oauth.retrieve_oauth_token(parameters: parameters)
197
+ puts response
198
+ # { "access_token": "{an access token string prefixed with 'pina'}", "refresh_token": "{a refresh token string prefixed with 'pinr'}", "response_type": "authorization_code", ..
199
+
200
+ ```
201
+
179
202
  How to refresh your access tokens
180
203
 
181
204
  ```ruby
@@ -31,6 +31,14 @@ module Pinterest
31
31
  @pins ||= Pinterest::Pins.new(client: self)
32
32
  end
33
33
 
34
+ def terms
35
+ @terms ||= Pinterest::Pins.new(client: self)
36
+ end
37
+
38
+ def keywords
39
+ @pins ||= Pinterest::Keywords.new(client: self)
40
+ end
41
+
34
42
  def oauth
35
43
  @oauth ||= Pinterest::Oauth.new(client: self)
36
44
  end
@@ -0,0 +1,30 @@
1
+ module Pinterest
2
+ class Keywords
3
+ def initialize(client: nil)
4
+ @client = client
5
+ end
6
+
7
+ def get_keywords(ad_account_id:, parameters: {})
8
+ @client.get(path: "/ad_accounts/#{ad_account_id}/keywords", parameters: parameters)
9
+ end
10
+
11
+ def create_keywords(ad_account_id:, parameters: {})
12
+ @client.json_post(path: "/ad_accounts/#{ad_account_id}/keywords", parameters: parameters)
13
+ end
14
+
15
+ def update_keywords(ad_account_id:, parameters: {})
16
+ @client.patch(path: "/ad_accounts/#{ad_account_id}/keywords", parameters: parameters)
17
+ end
18
+
19
+ def get_country_keyword_metrics(ad_account_id:, parameters: {})
20
+ @client.get(path: "/ad_accounts/#{ad_account_id}/keywords", parameters: parameters)
21
+ end
22
+
23
+ # Region list: "US" "CA" "DE" "FR" "ES" "IT" "DE+AT+CH" "GB+IE" "IT+ES+PT+GR+MT" "PL+RO+HU+SK+CZ" "SE+DK+FI+NO" "NL+BE+LU" "AR" "BR" "CO" "MX" "MX+AR+CO+CL" "AU+NZ"
24
+ # trend_type: "growing" "monthly" "yearly" "seasonal"
25
+ # https://developer.pinterest.com/docs/api/v5/#operation/trending_keywords/list
26
+ def list_trending_keywords(region:, trend_type:, parameters: {})
27
+ @client.get(path: "/trends/keywords/#{region}/top/#{trend_type}", parameters: parameters)
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,16 @@
1
+ module Pinterest
2
+ class Terms
3
+ def initialize(client: nil)
4
+ @client = client
5
+ end
6
+
7
+ # parameters: { terms: ["example", "of", "query"]}
8
+ def list_related_terms(parameters: {})
9
+ @client.get(path: "/terms/related", parameters: parameters)
10
+ end
11
+
12
+ def list_suggested_terms(parameters: {})
13
+ @client.get(path: "/terms/suggested", parameters: parameters)
14
+ end
15
+ end
16
+ end
@@ -1,3 +1,3 @@
1
1
  module Pinterest
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.4"
3
3
  end
data/lib/pinterest.rb CHANGED
@@ -3,8 +3,10 @@ require "faraday/multipart"
3
3
  require_relative "pinterest/http"
4
4
  require_relative "pinterest/client"
5
5
  require_relative "pinterest/boards"
6
+ require_relative "pinterest/keywords"
6
7
  require_relative "pinterest/oauth"
7
8
  require_relative "pinterest/pins"
9
+ require_relative "pinterest/terms"
8
10
  require_relative "pinterest/version"
9
11
 
10
12
  module Pinterest
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-pinterest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Donald Lee
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-12-03 00:00:00.000000000 Z
11
+ date: 2024-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -38,7 +38,7 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1'
41
- description:
41
+ description:
42
42
  email:
43
43
  - donaldlee50@gmail.com
44
44
  executables: []
@@ -60,8 +60,10 @@ files:
60
60
  - lib/pinterest/client.rb
61
61
  - lib/pinterest/compatibility.rb
62
62
  - lib/pinterest/http.rb
63
+ - lib/pinterest/keywords.rb
63
64
  - lib/pinterest/oauth.rb
64
65
  - lib/pinterest/pins.rb
66
+ - lib/pinterest/terms.rb
65
67
  - lib/pinterest/version.rb
66
68
  - lib/ruby/pinterest.rb
67
69
  - rails-pinterest.gemspec
@@ -73,7 +75,7 @@ metadata:
73
75
  homepage_uri: https://github.com/royalgiant/rails-pinterest
74
76
  source_code_uri: https://github.com/royalgiant/rails-pinterest
75
77
  changelog_uri: https://github.com/royalgiant/rails-pinterest/blob/main/CHANGELOG.md
76
- post_install_message:
78
+ post_install_message:
77
79
  rdoc_options: []
78
80
  require_paths:
79
81
  - lib
@@ -88,8 +90,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
90
  - !ruby/object:Gem::Version
89
91
  version: '0'
90
92
  requirements: []
91
- rubygems_version: 3.2.3
92
- signing_key:
93
+ rubygems_version: 3.0.3.1
94
+ signing_key:
93
95
  specification_version: 4
94
96
  summary: Pinterest API + Ruby!
95
97
  test_files: []