funky 0.2.28 → 0.2.29

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
  SHA1:
3
- metadata.gz: 0cbcbb6a6a6922632be99fc94047038799d24b94
4
- data.tar.gz: ed36268b042b5c17e200c19a35048e1088ddd1fd
3
+ metadata.gz: b52ea915d7f3e91a672141136653d9c091d0130b
4
+ data.tar.gz: b0e29324904b42bed6ec943be492f95f2a23f0df
5
5
  SHA512:
6
- metadata.gz: 84d9c87737ee60d5589a6167964496280e1656d5c5364723b6ca55374ee3b3322fc2ed38203711ab62f7861180a07eb5f78342c0f1783e6b07d10f41ac769fda
7
- data.tar.gz: 30d23371ec8b9e6a0caa32cfdcdd8d9351f7707e3795876c2b4f24dd5b54309d01b160154bce0ffb0766894de6a6d572569c09ef3ccaa472fca000ebfc29c035
6
+ metadata.gz: ca8ae886ee93939e33526c1d56632b5e2c7159e840a6ca5f251ca560f95818680aad0a51151710b486fed1fde2376a7d81c3aafb8fe3fe756c72f20be6465dff
7
+ data.tar.gz: 167a601d285f4c4cd30c18de63ce64b0c8c20f12591a6ed2fd39ea7f4f49e10aae13404a247e693d8be72b2671fc6f7466cc1745c720f88eeaa9967342b5f74e
data/CHANGELOG.md CHANGED
@@ -6,6 +6,11 @@ For more information about changelogs, check
6
6
  [Keep a Changelog](http://keepachangelog.com) and
7
7
  [Vandamme](http://tech-angels.github.io/vandamme).
8
8
 
9
+ ## 0.2.29 - 2017/10/16
10
+
11
+ * [ENHANCEMENT] Use request to get app access token. Do not use
12
+ `app_id|app_secret` string.
13
+
9
14
  ## 0.2.28 - 2017/10/05
10
15
 
11
16
  * [FEATURE] Add `since` option when it calls Page#videos and Page#posts to reduce
@@ -8,7 +8,7 @@ module Funky
8
8
  module Connection
9
9
  class API < Base
10
10
  def self.fetch_all(path_query)
11
- uri = URI "https://#{host}/v2.9/#{path_query}&limit=100&access_token=#{app_id}%7C#{app_secret}"
11
+ uri = URI "https://#{host}/v2.9/#{path_query}&limit=100&access_token=#{app_access_token}"
12
12
  fetch_data_with_paging_token(uri)
13
13
  end
14
14
 
@@ -24,7 +24,7 @@ module Funky
24
24
  end
25
25
 
26
26
  def self.fetch(path_query, is_array: false)
27
- uri = URI "https://#{host}/v2.8/#{path_query}&limit=100&access_token=#{app_id}%7C#{app_secret}"
27
+ uri = URI "https://#{host}/v2.8/#{path_query}&limit=100&access_token=#{app_access_token}"
28
28
  is_array ? fetch_multiple_pages(uri).uniq : json_for(uri)
29
29
  rescue URI::InvalidURIError
30
30
  raise Funky::ContentNotFound, "Invalid URL"
@@ -66,14 +66,14 @@ module Funky
66
66
  def self.request(id:, fields:)
67
67
  uri = URI::HTTPS.build host: host,
68
68
  path: "/v2.8/#{id}",
69
- query: "access_token=#{app_id}%7C#{app_secret}&fields=#{fields}"
69
+ query: "access_token=#{app_access_token}&fields=#{fields}"
70
70
  response_for(get_http_request(uri), uri)
71
71
  end
72
72
 
73
73
  def self.batch_request(ids:, fields:)
74
74
  uri = URI::HTTPS.build host: host,
75
75
  path: "/",
76
- query: "include_headers=false&access_token=#{app_id}%7C#{app_secret}"
76
+ query: "include_headers=false&access_token=#{app_access_token}"
77
77
  batch = create_batch_for ids, fields
78
78
  http_request = post_http_request uri
79
79
  http_request.set_form_data batch: batch.to_json
@@ -94,6 +94,14 @@ module Funky
94
94
  Funky.configuration.app_secret
95
95
  end
96
96
 
97
+ def self.app_access_token
98
+ @app_access_token ||= begin
99
+ uri = URI::HTTPS.build host: host, path: "/v2.8/oauth/access_token",
100
+ query: URI.encode_www_form({client_id: app_id, client_secret: app_secret, grant_type: 'client_credentials'})
101
+ Funky::Connection::API.json_for(uri)[:access_token]
102
+ end
103
+ end
104
+
97
105
  def self.post_http_request(uri)
98
106
  Net::HTTP::Post.new uri
99
107
  end
data/lib/funky/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Funky
2
- VERSION = "0.2.28"
2
+ VERSION = "0.2.29"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: funky
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.28
4
+ version: 0.2.29
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philip Nguyen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-10-05 00:00:00.000000000 Z
11
+ date: 2017-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler