outbrain-api 0.1.7 → 0.1.8
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 +4 -4
- data/lib/outbrain/api.rb +1 -0
- data/lib/outbrain/api/relation.rb +16 -0
- data/lib/outbrain/api/report.rb +3 -2
- data/lib/outbrain/api/version.rb +1 -1
- data/lib/outbrain/request.rb +4 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0451ff64039dd738d985b64b040969c3fb544385
|
4
|
+
data.tar.gz: 1801bea21f4c2b1f94877e36d7ec455a5309bf37
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37e7d17bd520699d9c94ad1d1818248b3a0a945ddc01a3dba29eaaf934a2783e7ddcc88b3122574450bf7dcbd2adf96740817dc666543a436642b8e95ef43215
|
7
|
+
data.tar.gz: a277f0488238e27c771f1e377699d8d6e667e37663a55043518ecd9eb9257edc934e8b73ef13ecd154ff16b419602c55b27a65b9b08b45cbeb6dc42651b8a7f3
|
data/lib/outbrain/api.rb
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
module Outbrain
|
2
|
+
module Api
|
3
|
+
class Relation
|
4
|
+
include Enumerable
|
5
|
+
attr_accessor :relations, :totalDataCount, :overAllMetrics, :aggregatedBy
|
6
|
+
|
7
|
+
def initialize(options = {})
|
8
|
+
@relations = []
|
9
|
+
end
|
10
|
+
|
11
|
+
def each &block
|
12
|
+
@relations.each{|relation| block.call(relation) }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/outbrain/api/report.rb
CHANGED
@@ -5,8 +5,9 @@ module Outbrain
|
|
5
5
|
RESOURCE_NAME = 'details'
|
6
6
|
|
7
7
|
def self.where(options = {})
|
8
|
-
|
9
|
-
|
8
|
+
report_query = options.select{|option, v| REPORT_PARAMETERS.include?(option) && !v.nil?}
|
9
|
+
report_options = { as: self, resource_name: RESOURCE_NAME, meta_resource_names: options.fetch(:meta_resource_names, []) }
|
10
|
+
Request.where(options.fetch(:path), report_query, report_options)
|
10
11
|
end
|
11
12
|
end
|
12
13
|
end
|
data/lib/outbrain/api/version.rb
CHANGED
data/lib/outbrain/request.rb
CHANGED
@@ -6,13 +6,15 @@ module Outbrain
|
|
6
6
|
request_path = request_path + '?' + query_string unless query_string.empty?
|
7
7
|
response = api.get(request_path)
|
8
8
|
resource_name = options.fetch(:resource_name, resource_path)
|
9
|
+
meta_requests = options.fetch(:meta_resource_names)
|
9
10
|
json_body = JSON.parse(response.body) # catch and raise proper api error
|
10
11
|
|
11
12
|
fail InvalidOption 'requires an as option' unless options[:as]
|
12
13
|
|
13
14
|
if response.status == 200
|
14
|
-
|
15
|
-
|
15
|
+
Outbrain::Api::Relation.new.tap do |r|
|
16
|
+
meta_requests.each{ |field| r.send("#{field}=", json_body[field]) }
|
17
|
+
r.relations = json_body[resource_name].map{ |obj| options[:as].new(obj) }
|
16
18
|
end
|
17
19
|
else
|
18
20
|
[json_body]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: outbrain-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Blanchet
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-05-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -120,6 +120,7 @@ files:
|
|
120
120
|
- lib/outbrain/api/marketer.rb
|
121
121
|
- lib/outbrain/api/publisher.rb
|
122
122
|
- lib/outbrain/api/publisher_report.rb
|
123
|
+
- lib/outbrain/api/relation.rb
|
123
124
|
- lib/outbrain/api/report.rb
|
124
125
|
- lib/outbrain/api/version.rb
|
125
126
|
- lib/outbrain/base.rb
|