outbrain-api 0.2.3 → 0.2.4

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: 611076af635dfef59515e4d7370424ae0924e924
4
- data.tar.gz: 22e7cdfdce710aa25d8aaa97f1ccefdb353c84a2
3
+ metadata.gz: f73b2228f93d82894e838c63ea515d74003987b1
4
+ data.tar.gz: f02f4d467a8de307090101f6978d43a6c0273ed7
5
5
  SHA512:
6
- metadata.gz: ab1b4431d4e0a92e15c31e1616891e1a466375317a8b3d8d6bdbe58b63255ed21f535e0d993fd9414412e437e296d9ffa25706e15a30ff3f87ca24f9b8a6d17f
7
- data.tar.gz: 6b856617eeeb6c0fb438c18a0ab053f40d98743ab45ce5d3876d28618489df352f8946425606e1272209a12ef21dca586e094f822e4cf89860b98877058d5109
6
+ metadata.gz: bda58af731788fbd4a029e4664d5e7d06678ca444c4886db9530186a633133f406f77b5d07c3d7ec268fd1a2fc8e627c062729ca30155271a28b006de067aba6
7
+ data.tar.gz: c9e3bab80cb981885a074edcab3f8297c321095f03ddbeb9cad19e3d78d702dc5d42389c94726f442a69f0f3d7e1870863a5caac836b7da7af81fd377e5df425
@@ -5,14 +5,27 @@ module Outbrain
5
5
  class PromotedLink < Base
6
6
  PATH = "promotedLinks"
7
7
  RESOURCE_NAME = PATH
8
-
8
+
9
+ def self.campaign_path(campaign_id)
10
+ "campaigns/#{campaign_id}/#{PATH}"
11
+ end
12
+
13
+ def self.create(attributes)
14
+ Request.create(campaign_path(attributes.delete(:campaign_id)),
15
+ { as: self, attributes: attributes })
16
+ end
17
+
9
18
  def self.find(id)
10
- Request.find( PATH, id, { as: self })
19
+ Request.find( PATH, id, { as: self })
11
20
  end
12
21
 
13
22
  def self.where(options)
14
- path = "campaigns/#{options.fetch(:campaign_id)}/#{PATH}"
15
- Request.where(path, options, as: self, resource_name: RESOURCE_NAME)
23
+ Request.where(campaign_path(options.fetch(:campaign_id)),
24
+ options, as: self, resource_name: RESOURCE_NAME)
25
+ end
26
+
27
+ def self.update(id, attributes)
28
+ Request.update(PATH, id, {as: self, attributes: attributes, wrap_response: false })
16
29
  end
17
30
  end
18
31
  end
@@ -1,5 +1,5 @@
1
1
  module Outbrain
2
2
  module Api
3
- VERSION = "0.2.3"
3
+ VERSION = "0.2.4"
4
4
  end
5
5
  end
@@ -54,10 +54,12 @@ module Outbrain
54
54
 
55
55
  def self.update(resource_path, id, options={})
56
56
  attributes = options.fetch(:attributes, {})
57
+ wrap_response = options.fetch(:wrap_response, true)
57
58
  response = api.put("#{resource_path}/#{id}", attributes.to_json)
59
+ success = (response.status == 200)
60
+ return success unless wrap_response
58
61
  json_body = JSON.parse(response.body)
59
-
60
- if response.status == 200
62
+ if success
61
63
  options[:as].new(json_body)
62
64
  else
63
65
  a = options[:as].new
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.3
4
+ version: 0.2.4
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-05-13 00:00:00.000000000 Z
11
+ date: 2016-05-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -150,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
150
  version: '0'
151
151
  requirements: []
152
152
  rubyforge_project:
153
- rubygems_version: 2.4.6
153
+ rubygems_version: 2.4.7
154
154
  signing_key:
155
155
  specification_version: 4
156
156
  summary: A simple wrapper for the outbrain api