outbrain-api 0.2.7 → 0.2.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/geo_location.rb +12 -0
- data/lib/outbrain/api/version.rb +1 -1
- data/lib/outbrain/request.rb +21 -8
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73358d80c9df67f274bf36ced5845d152831ee54
|
4
|
+
data.tar.gz: 017a89b9c8942dcdc5ed84c0e2356466f6e917d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4a37eca12bacfdd3dca625347513464392e9821c77bb433f6b51e947fec6a1d99e7ef749a12b3473e38818e22015859bc7b845a1fae7a4b33290018ffec9ebc
|
7
|
+
data.tar.gz: 3d97d99a371039ea30ec26d3b3d1326bd5d9018bde81b699da97a2a932c1157939b7d1c0e22b51b6d74bd7cc61d284c0682e0a007be00bc54e7b115550b3804b
|
data/lib/outbrain/api.rb
CHANGED
@@ -16,6 +16,7 @@ require "outbrain/api/publisher_report"
|
|
16
16
|
require "outbrain/api/campaign_by_day_report"
|
17
17
|
require "outbrain/api/promoted_link_performance_report"
|
18
18
|
require "outbrain/api/promoted_link"
|
19
|
+
require "outbrain/api/geo_location"
|
19
20
|
|
20
21
|
module Outbrain
|
21
22
|
HEADER_AUTH_KEY = 'OB-TOKEN-V1'
|
data/lib/outbrain/api/version.rb
CHANGED
data/lib/outbrain/request.rb
CHANGED
@@ -1,16 +1,11 @@
|
|
1
1
|
module Outbrain
|
2
2
|
class Request < Config
|
3
3
|
def self.where(resource_path, query={}, options={})
|
4
|
-
request_path = resource_path
|
5
|
-
query_string = query.map{|k,v| "#{k}=#{v}"}.join("&")
|
6
|
-
request_path = request_path + '?' + query_string unless query_string.empty?
|
7
|
-
response = api.get(request_path)
|
8
|
-
resource_name = options.fetch(:resource_name, resource_path)
|
9
|
-
json_body = JSON.parse(response.body) # catch and raise proper api error
|
10
|
-
|
11
4
|
fail InvalidOption 'requires an as option' unless options[:as]
|
5
|
+
json_body, status = get_json(resource_path, query)
|
12
6
|
|
13
|
-
if
|
7
|
+
if status == 200
|
8
|
+
resource_name = options.fetch(:resource_name, resource_path)
|
14
9
|
Outbrain::Api::Relation
|
15
10
|
.new(json_body.merge(relation_class: options[:as], relation_name: resource_name))
|
16
11
|
else
|
@@ -37,6 +32,17 @@ module Outbrain
|
|
37
32
|
end
|
38
33
|
end
|
39
34
|
|
35
|
+
## For api methods that return arrays without a root element or meta info
|
36
|
+
def self.search(path, query={}, options={})
|
37
|
+
json_body, status = get_json(path, query)
|
38
|
+
resource_class = options.fetch(:as)
|
39
|
+
if status == 200
|
40
|
+
json_body.map{|e| resource_class.new(e)}
|
41
|
+
else
|
42
|
+
Outbrain::Api::Relation.new(errors: json_body)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
40
46
|
def self.create(resource, options={})
|
41
47
|
attributes = options.fetch(:attributes, {})
|
42
48
|
|
@@ -67,5 +73,12 @@ module Outbrain
|
|
67
73
|
a
|
68
74
|
end
|
69
75
|
end
|
76
|
+
|
77
|
+
def self.get_json(root_path, query)
|
78
|
+
query_string = query.map{|k,v| "#{k}=#{v}"}.join("&")
|
79
|
+
path = query_string.empty? ? root_path : "#{root_path}?#{query_string}"
|
80
|
+
response = api.get(path)
|
81
|
+
[JSON.parse(response.body), response.status] # catch and raise proper api error
|
82
|
+
end
|
70
83
|
end
|
71
84
|
end
|
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.2.
|
4
|
+
version: 0.2.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-06-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -117,6 +117,7 @@ files:
|
|
117
117
|
- lib/outbrain/api/campaign_report.rb
|
118
118
|
- lib/outbrain/api/config.rb
|
119
119
|
- lib/outbrain/api/errors.rb
|
120
|
+
- lib/outbrain/api/geo_location.rb
|
120
121
|
- lib/outbrain/api/marketer.rb
|
121
122
|
- lib/outbrain/api/promoted_link.rb
|
122
123
|
- lib/outbrain/api/promoted_link_performance_report.rb
|
@@ -150,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
150
151
|
version: '0'
|
151
152
|
requirements: []
|
152
153
|
rubyforge_project:
|
153
|
-
rubygems_version: 2.4.
|
154
|
+
rubygems_version: 2.4.7
|
154
155
|
signing_key:
|
155
156
|
specification_version: 4
|
156
157
|
summary: A simple wrapper for the outbrain api
|