zanox_publisher 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5c6bf86e78f08a2c0843e4bbd65559a199ecafd8
4
- data.tar.gz: cf5642ccc19e98e22ed773532b3e46c29dad6a70
3
+ metadata.gz: ef346f6bee84b91e9942b9a7b202a20093949dbd
4
+ data.tar.gz: dfa3e8edb4b715c2d31c79688434afaaf56a0ef1
5
5
  SHA512:
6
- metadata.gz: 735892e5eda13333689055bd9bb34566c7f24e5ea1dd9813aa051145198520686894bc8061d52646964ce3f7ffd98f5ce1c509021963bf5fe522fcdb835ac087
7
- data.tar.gz: 9086e6044aa019dd1f197b6f3fd1a012d07a10181d0ceadefe444073aeb27466105320f564b0baa8a11c00b0b28221bb6cdc494c4b14ca6df4c3dbebd824159e
6
+ metadata.gz: df2882030e67bade1de18007a69f2a909b07a7febed8f50da9eef6e2ce16bb81e907efb08ae5a28308926635e45e2d8cdff56131a2490fe3489735e173a670e0
7
+ data.tar.gz: 94ad2ec17686ffb5c08c79cf543ba5a8b5dfde5be133149fe3e722f47ecd4987fc5e67fb5a3a303a2520fbaebcdea1ba53b67ad7a2c9478d1c6903a49cec9c1a
@@ -167,7 +167,7 @@ module ZanoxPublisher
167
167
  # @param id [Integer] the ID of the adspace you want to get.
168
168
  # @param adspace [AdSpace, Integer] if you would like tracking links for only one of your publisher ad spaces, pass its ID in this parameter.
169
169
  #
170
- # @return [<AdMedium>]
170
+ # @return [<AdMedium>, nil]
171
171
  def find(id, options = {})
172
172
  params = {}
173
173
 
@@ -179,6 +179,10 @@ module ZanoxPublisher
179
179
  response = self.connection.get(RESOURCE_PATH + "/admedium/#{id}", params)
180
180
  admedium = response.fetch('admediumItem', [])
181
181
 
182
+ if admedium.empty?
183
+ return nil
184
+ end
185
+
182
186
  AdMedium.new(admedium)
183
187
  end
184
188
 
@@ -98,11 +98,15 @@ module ZanoxPublisher
98
98
  #
99
99
  # @param id [Integer] the ID of the adspace you want to get
100
100
  #
101
- # @return [<AdSpace>]
101
+ # @return [<AdSpace>, nil]
102
102
  def find(id)
103
103
  response = self.connection.signature_get(RESOURCE_PATH + "/adspace/#{id}")
104
104
  adspace = response.fetch('adspaceItem', []).first
105
105
 
106
+ if adspace.empty?
107
+ return nil
108
+ end
109
+
106
110
  AdSpace.new(adspace)
107
111
  end
108
112
 
@@ -126,9 +126,12 @@ module ZanoxPublisher
126
126
 
127
127
  programs = options[:programs]
128
128
 
129
- unless programs.nil?
130
- programs = programs.map(&:to_i).join(',') if programs.is_a? Array
131
- programs = programs.to_i if programs.is_a? Program or programs.is_a? Integer
129
+ if programs.is_a? Array
130
+ programs = programs.map(&:to_i).join(',')
131
+ elsif programs.is_a? Program or programs.is_a? Integer
132
+ programs = programs.to_i
133
+ else
134
+ programs = nil
132
135
  end
133
136
 
134
137
  has_images = options[:has_images]
@@ -192,7 +195,7 @@ module ZanoxPublisher
192
195
  # @param id [Integer] the ID of the adspace you want to get.
193
196
  # @param adspace [AdSpace, Integer] if you would like tracking links for only one of your publisher ad spaces, pass its ID in this parameter.
194
197
  #
195
- # @return [<Product>]
198
+ # @return [<Product>, nil]
196
199
  def find(id, options = {})
197
200
  params = {}
198
201
 
@@ -202,8 +205,13 @@ module ZanoxPublisher
202
205
  params = { query: { adspace: adspace } } unless adspace.nil?
203
206
 
204
207
  response = self.connection.get(RESOURCE_PATH + "/product/#{id.to_i}", params)
208
+ product = response.fetch('productItem').first
205
209
 
206
- Product.new(response.fetch('productItem').first)
210
+ if product.empty?
211
+ return nil
212
+ end
213
+
214
+ Product.new(product)
207
215
  end
208
216
 
209
217
  # A connection instance with Products' relative_path
@@ -246,9 +254,9 @@ module ZanoxPublisher
246
254
  end
247
255
 
248
256
  attr_accessor :id, :name, :modified_at, :program, :price, :currency, :tracking_links,
249
- :description, :description_long, :manufacturer, :ean, :delivery_time,
250
- :terms, :category, :image, :price_old, :shipping_costs, :shipping,
251
- :merchant_category, :merchant_product_id
257
+ :description, :description_long, :manufacturer, :ean, :delivery_time,
258
+ :terms, :category, :image, :price_old, :shipping_costs, :shipping,
259
+ :merchant_category, :merchant_product_id
252
260
 
253
261
  # make API names available
254
262
  alias modified modified_at
@@ -135,12 +135,16 @@ module ZanoxPublisher
135
135
  #
136
136
  # @param id [Program, Integer] the ID of the program you want to get.
137
137
  #
138
- # @return [<Program>]
138
+ # @return [<Program>, nil]
139
139
  def find(id)
140
140
  response = self.connection.get(RESOURCE_PATH + "/program/#{id.to_i}")
141
- progam = response.fetch('programItem', []).first
141
+ program = response.fetch('programItem', []).first
142
142
 
143
- Program.new(progam)
143
+ if program.empty?
144
+ return nil
145
+ end
146
+
147
+ Program.new(program)
144
148
  end
145
149
 
146
150
  # Get all program categories, including names and IDs, associated to the connect ID.
@@ -1,3 +1,3 @@
1
1
  module ZanoxPublisher
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zanox_publisher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oliver Prater
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-18 00:00:00.000000000 Z
11
+ date: 2015-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler