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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2e37c66899f9c3b56713940571536a8cf3d84da9
4
- data.tar.gz: 67906118549c3fbaec86440c60e70774b4332db0
3
+ metadata.gz: 0451ff64039dd738d985b64b040969c3fb544385
4
+ data.tar.gz: 1801bea21f4c2b1f94877e36d7ec455a5309bf37
5
5
  SHA512:
6
- metadata.gz: d525ab153294ea31beea439e667476f499b11f7f874535507796e3f72a8db6a33795f97b8cfd594026c99b8a947cc4e1194bcc28ded28de9f75db681e7ee0783
7
- data.tar.gz: e4dd0c87a903c143eba2a42b81a5399c52cc901dcddd874f8617968c225dc0431979d94fd7c484033352ff9686e7974cf9934dd26893b747b533506baa5dfb97
6
+ metadata.gz: 37e7d17bd520699d9c94ad1d1818248b3a0a945ddc01a3dba29eaaf934a2783e7ddcc88b3122574450bf7dcbd2adf96740817dc666543a436642b8e95ef43215
7
+ data.tar.gz: a277f0488238e27c771f1e377699d8d6e667e37663a55043518ecd9eb9257edc934e8b73ef13ecd154ff16b419602c55b27a65b9b08b45cbeb6dc42651b8a7f3
@@ -7,6 +7,7 @@ require "outbrain/base"
7
7
  require "outbrain/request"
8
8
 
9
9
  # models
10
+ require "outbrain/api/relation"
10
11
  require "outbrain/api/marketer"
11
12
  require "outbrain/api/campaign"
12
13
  require "outbrain/api/budget"
@@ -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
@@ -5,8 +5,9 @@ module Outbrain
5
5
  RESOURCE_NAME = 'details'
6
6
 
7
7
  def self.where(options = {})
8
- report_options = options.select{|option, v| REPORT_PARAMETERS.include?(option) && !v.nil?}
9
- Request.where(options.fetch(:path), report_options, { as: self, resource_name: RESOURCE_NAME })
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
@@ -1,5 +1,5 @@
1
1
  module Outbrain
2
2
  module Api
3
- VERSION = "0.1.7"
3
+ VERSION = "0.1.8"
4
4
  end
5
5
  end
@@ -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
- json_body[resource_name].map do |obj|
15
- options[:as].new(obj)
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.7
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-04-27 00:00:00.000000000 Z
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