facebook_topics 1.1.3 → 1.2.0

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: 1a6c2a64f1a7c6ce9eb3844de478a7c78b74456a
4
- data.tar.gz: d0cf696c282af83cbe059fb9d26f982f39b99f59
3
+ metadata.gz: c2278679bb8c6119a5705d3977769b63ab64a913
4
+ data.tar.gz: d5ed9e397a856701fbec7364bef414a062832efb
5
5
  SHA512:
6
- metadata.gz: c9f16e090a3fcf4101a7d97b6ce2ff47b6b93fbfc64e50a5f1a7cc585b37125a9c75dd8562a941298b941cb682b30e38a81df94587018e5ebfb5c80b0ca70b2c
7
- data.tar.gz: 3731b698ccd0fe4aecd484c92081ebe5d41faadc8c6edc87671c9df1bec05771cd4b2c2fc4f7c1aaf65283ba266e5678395a1b1035cef0e392ab2453d99ccefd
6
+ metadata.gz: 39aff8cb616a242eb55846f0704303d2b8559bb35254c36b49d4d8ebcfcc7401b55fcfaccaebe26e9f25663a016f323a8d6b24b7c8983bcd25e0b3f649a41190
7
+ data.tar.gz: 0e621935862435ebf0e9add6849167466e53990c62dc2926da49ba0135703b46b675c6123542d7272263686c9da021adfe8d3bbd769beb26ef7c830c8cbc9f05
@@ -48,16 +48,37 @@ module FacebookTopics
48
48
 
49
49
 
50
50
 
51
- def insights(contains_all, fields = [])
52
- q = {contains_all: [contains_all], fields: fields.flatten.uniq.join(',')}
53
-
54
- Insight.new self.class.get("/#{api_version}/topic_insights", {query: q}).parsed_response
51
+ def insights(contains_all, opts = {} )
52
+ from_date = opts.delete(:from_date)
53
+ until_date = opts.delete(:until_date)
54
+ region = opts.delete(:region)
55
+ city = opts.delete(:city)
56
+ country = opts.delete(:country)
57
+ continent = opts.delete(:continent)
58
+ breakdown = opts.delete(:breakdown)
59
+
60
+ fields = "mentions"
61
+ fields << ".since(#{from_date})" unless from_date.nil?
62
+ fields << ".until(#{until_date})" unless until_date.nil?
63
+ fields << ".region(#{region})" if region.present?
64
+ fields << ".city(#{city})" if city.present?
65
+ fields << ".country(#{country})" if country.present?
66
+ fields << ".continent(#{continent})" if continent.present?
67
+ fields << ".breakdown_by(#{breakdown.reject(&:blank?)})" if breakdown.present?
68
+
69
+ q = {contains_all: [contains_all], fields: fields}
70
+
71
+ data = Insight.new self.class.get("/#{api_version}/topic_insights", {query: q}).parsed_response
72
+ data.breakdown.each { |d| d["date"] = {from_date: from_date, until_date: until_date}.stringify_keys }
73
+ return data
55
74
  end
56
75
 
57
76
 
58
77
 
59
78
 
60
79
 
80
+
81
+
61
82
  def api_version
62
83
  @api_version || "v2.3"
63
84
  end
@@ -4,7 +4,7 @@ module FacebookTopics
4
4
  class Collection
5
5
  extend Forwardable
6
6
 
7
- def_delegators :@results, :<<, :length, :first, :last, :collect, :to_a, :each, :reject, :select, :count, :[], :empty?
7
+ def_delegators :@results, :<<, :length, :first, :last, :collect, :to_a, :each, :reject, :select, :count, :[], :empty?, :each_with_index
8
8
 
9
9
  def initialize(results = {})
10
10
  unless results.nil?
@@ -8,6 +8,5 @@ module FacebookTopics
8
8
  @breakdown = results["data"].first["mentions"]["data"] rescue []
9
9
  end
10
10
 
11
-
12
11
  end
13
12
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: facebook_topics
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Spencer Markowski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-29 00:00:00.000000000 Z
11
+ date: 2015-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rainbow