zanoxrb 0.5.7 → 0.5.8

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: 53c2d3f393205f6efefb2fac672a494cc13a9f14
4
- data.tar.gz: e339d4812334f4ee907ae9c1e92b536af666250f
3
+ metadata.gz: da2621746bb04a12d8f98c1feab9dccb75dcf30e
4
+ data.tar.gz: c9c80fda9d235b4ef30aaf19f787eaedf2f9b382
5
5
  SHA512:
6
- metadata.gz: 7bbf5eb4a76c3583c602c4956a32b1fd1df44f1ea77f876b7168308f8a090a05ae2bec9bd10e852706891e115327e50e859b6e3ded2224838573f0b771f914ac
7
- data.tar.gz: f5a4b28fedcdd1fd078e0a5bc5fbf1f69010d352834dd411c3d0789266ffe93fab5141c14a8ebf248913c2d8f67e4852246757bc14a583fe7908315fea41b83b
6
+ metadata.gz: 1ad318ec18ca872cd613b59d827b019bd2d419f925a8d0b3d915b847861d71c7726fc7a5b28bc79f1a4a29400aea59c5dc16bc81f68072f8db829ce83d14fad5
7
+ data.tar.gz: 8c479ac0b70326f7cfad2e3f71d97f05108708ccf0d7af6a94232efaeca5885e190275cd916bff010d64bab8024c77f258441501c807de05b8ff7ad8d6f7efe5
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- zanoxrb (0.5.5)
4
+ zanoxrb (0.5.8)
5
5
  httparty (~> 0.13)
6
6
  ruby-try (~> 1.1)
7
7
 
@@ -9,38 +9,38 @@ GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
11
  diff-lcs (1.2.5)
12
- httparty (0.13.5)
12
+ httparty (0.13.7)
13
13
  json (~> 1.8)
14
14
  multi_xml (>= 0.5.2)
15
15
  json (1.8.3)
16
16
  multi_xml (0.5.5)
17
- rake (10.4.2)
18
- rspec (3.3.0)
19
- rspec-core (~> 3.3.0)
20
- rspec-expectations (~> 3.3.0)
21
- rspec-mocks (~> 3.3.0)
17
+ rake (10.5.0)
18
+ rspec (3.4.0)
19
+ rspec-core (~> 3.4.0)
20
+ rspec-expectations (~> 3.4.0)
21
+ rspec-mocks (~> 3.4.0)
22
22
  rspec-collection_matchers (1.1.2)
23
23
  rspec-expectations (>= 2.99.0.beta1)
24
- rspec-core (3.3.1)
25
- rspec-support (~> 3.3.0)
26
- rspec-expectations (3.3.0)
24
+ rspec-core (3.4.2)
25
+ rspec-support (~> 3.4.0)
26
+ rspec-expectations (3.4.0)
27
27
  diff-lcs (>= 1.2.0, < 2.0)
28
- rspec-support (~> 3.3.0)
29
- rspec-mocks (3.3.1)
28
+ rspec-support (~> 3.4.0)
29
+ rspec-mocks (3.4.1)
30
30
  diff-lcs (>= 1.2.0, < 2.0)
31
- rspec-support (~> 3.3.0)
32
- rspec-support (3.3.0)
31
+ rspec-support (~> 3.4.0)
32
+ rspec-support (3.4.1)
33
33
  ruby-try (1.1.1)
34
34
 
35
35
  PLATFORMS
36
36
  ruby
37
37
 
38
38
  DEPENDENCIES
39
- bundler (~> 1.10, >= 1.10.5)
39
+ bundler (~> 1.10)
40
40
  rake (~> 10.4)
41
41
  rspec (~> 3.3)
42
42
  rspec-collection_matchers (~> 1.1)
43
43
  zanoxrb!
44
44
 
45
45
  BUNDLED WITH
46
- 1.10.5
46
+ 1.11.2
@@ -0,0 +1,91 @@
1
+ #--
2
+ # Copyright(C) 2015 Giovanni Capuano <webmaster@giovannicapuano.net>
3
+ #
4
+ # Redistribution and use in source and binary forms, with or without modification, are
5
+ # permitted provided that the following conditions are met:
6
+ #
7
+ # 1. Redistributions of source code must retain the above copyright notice, this list of
8
+ # conditions and the following disclaimer.
9
+ #
10
+ # THIS SOFTWARE IS PROVIDED BY Giovanni Capuano ''AS IS'' AND ANY EXPRESS OR IMPLIED
11
+ # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
12
+ # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Giovanni Capuano OR
13
+ # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
14
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
15
+ # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
16
+ # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
17
+ # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
18
+ # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
19
+ #
20
+ # The views and conclusions contained in the software and documentation are those of the
21
+ # authors and should not be interpreted as representing official policies, either expressed
22
+ # or implied, of Giovanni Capuano.
23
+ #++
24
+
25
+ module Zanox
26
+ class AdMedium < Item
27
+ attr_reader :pid, :name, :adrank, :type, :program, :title, :description, :category, :tracking_links
28
+
29
+ ###################
30
+ # - pid (Integer) AdMedium ID
31
+ # - name (String) The name of the admedium
32
+ # - adrank (String) The adrank of the admedium
33
+ # - type (String) The type of the admedium (html, script, image, imagetext, text)
34
+ # - program (String) The program of the admedium
35
+ # - title (String) The title of the admedium
36
+ # - description (String) The description of the admedium
37
+ # - category (String) The category of the admedium (GET /admedia/categories/program/{id})
38
+ # - tracking_links (Hash[]) The list of the tracking links for the admedium
39
+ ###################
40
+ def initialize(data)
41
+ @pid = data['@id'].to_i
42
+ @name = data['name']
43
+ @adrank = data['adrank']
44
+ @type = data['admediumType']
45
+ @program = {
46
+ id: data['program']['@id'].to_i,
47
+ name: data['program']['$']
48
+ }
49
+ @title = data['title']
50
+ @description = data['description']
51
+ @title = data['title']
52
+ @category = parse_category(data)
53
+ @trackingLinks = parse_tracking_links(data)
54
+ end
55
+
56
+ class << self
57
+ def find(args = {})
58
+ response = API.request(:admedia, args)
59
+ if response.admedium_items.is_a?(Array)
60
+ response.admedium_items.map { |admedium| new(admedium) }
61
+ else
62
+ new(response.admedium_items)
63
+ end
64
+ end
65
+ end
66
+
67
+ private
68
+
69
+ def parse_category(data)
70
+ return nil unless data['category']
71
+
72
+ {
73
+ id: data['category']['@id'].to_i,
74
+ name: data['category']['$']
75
+ }
76
+ end
77
+
78
+ def parse_tracking_links(data)
79
+ return [] if data['trackingLinks'].empty?
80
+
81
+ data['trackingLinks'].map do |tl|
82
+ tl = tl[1][0]
83
+ tracking_link = {
84
+ adspace_id: tl.delete('@adspaceId').to_i,
85
+ }
86
+ tl.each { |type, url| tracking_link[type.to_sym] = url }
87
+ tracking_link
88
+ end
89
+ end
90
+ end
91
+ end
data/lib/zanox/version.rb CHANGED
@@ -23,5 +23,5 @@
23
23
  #++
24
24
 
25
25
  module Zanox
26
- VERSION = '0.5.7'
26
+ VERSION = '0.5.8'
27
27
  end
data/lib/zanox.rb CHANGED
@@ -39,5 +39,6 @@ require 'zanox/resources/product'
39
39
  require 'zanox/resources/program_application'
40
40
  require 'zanox/resources/tracking_category'
41
41
  require 'zanox/resources/shop'
42
+ require 'zanox/resources/admedium'
42
43
 
43
44
  require 'zanox/version'
@@ -0,0 +1,14 @@
1
+ require_relative '../spec_helper'
2
+
3
+ describe Zanox::AdMedium do
4
+ before :each do
5
+ Zanox::API::Session.connect_id = '43EEF0445509C7205827'
6
+ end
7
+
8
+ describe '#find' do
9
+ let(:admedia) { Zanox::AdMedium.find }
10
+
11
+ it { expect(admedia).to_not be_empty }
12
+ it { expect(admedia.last).to be_a(Zanox::AdMedium) }
13
+ end
14
+ end
@@ -38,14 +38,15 @@ describe Zanox::Product do
38
38
  end
39
39
 
40
40
  describe '#from_id' do
41
- let(:product) { Zanox::Product.from_id('0eca835e6c78e10c3b31a8146fc12324') }
41
+ let(:iphone) { Zanox::Product.find('iphone').first }
42
+ let(:product) { Zanox::Product.from_id(iphone.pid) }
42
43
 
43
44
  it 'returns a Product' do
44
45
  expect(product).to be_a(Zanox::Product)
45
46
  end
46
47
 
47
48
  it 'returns a Product matching given id' do
48
- expect(product.pid).to eq('0eca835e6c78e10c3b31a8146fc12324')
49
+ expect(product.pid).to eq(iphone.pid)
49
50
  end
50
51
  end
51
52
 
data/zanoxrb.gemspec CHANGED
@@ -19,5 +19,5 @@ Gem::Specification.new { |s|
19
19
  s.add_development_dependency 'rake', '~> 10.4'
20
20
  s.add_development_dependency 'rspec', '~> 3.3'
21
21
  s.add_development_dependency 'rspec-collection_matchers', '~> 1.1'
22
- s.add_development_dependency 'bundler', '~> 1.10', '>= 1.10.5'
22
+ s.add_development_dependency 'bundler', '~> 1.10'
23
23
  }
metadata CHANGED
@@ -1,24 +1,24 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zanoxrb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.7
4
+ version: 0.5.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Giovanni Capuano
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-31 00:00:00.000000000 Z
11
+ date: 2016-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
15
- prerelease: false
16
15
  requirement: !ruby/object:Gem::Requirement
17
16
  requirements:
18
17
  - - "~>"
19
18
  - !ruby/object:Gem::Version
20
19
  version: '0.13'
21
20
  type: :runtime
21
+ prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
@@ -26,13 +26,13 @@ dependencies:
26
26
  version: '0.13'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: ruby-try
29
- prerelease: false
30
29
  requirement: !ruby/object:Gem::Requirement
31
30
  requirements:
32
31
  - - "~>"
33
32
  - !ruby/object:Gem::Version
34
33
  version: '1.1'
35
34
  type: :runtime
35
+ prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
@@ -40,13 +40,13 @@ dependencies:
40
40
  version: '1.1'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
- prerelease: false
44
43
  requirement: !ruby/object:Gem::Requirement
45
44
  requirements:
46
45
  - - "~>"
47
46
  - !ruby/object:Gem::Version
48
47
  version: '10.4'
49
48
  type: :development
49
+ prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
@@ -54,13 +54,13 @@ dependencies:
54
54
  version: '10.4'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
- prerelease: false
58
57
  requirement: !ruby/object:Gem::Requirement
59
58
  requirements:
60
59
  - - "~>"
61
60
  - !ruby/object:Gem::Version
62
61
  version: '3.3'
63
62
  type: :development
63
+ prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
@@ -68,13 +68,13 @@ dependencies:
68
68
  version: '3.3'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec-collection_matchers
71
- prerelease: false
72
71
  requirement: !ruby/object:Gem::Requirement
73
72
  requirements:
74
73
  - - "~>"
75
74
  - !ruby/object:Gem::Version
76
75
  version: '1.1'
77
76
  type: :development
77
+ prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
@@ -82,24 +82,18 @@ dependencies:
82
82
  version: '1.1'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: bundler
85
- prerelease: false
86
85
  requirement: !ruby/object:Gem::Requirement
87
86
  requirements:
88
87
  - - "~>"
89
88
  - !ruby/object:Gem::Version
90
89
  version: '1.10'
91
- - - ">="
92
- - !ruby/object:Gem::Version
93
- version: 1.10.5
94
90
  type: :development
91
+ prerelease: false
95
92
  version_requirements: !ruby/object:Gem::Requirement
96
93
  requirements:
97
94
  - - "~>"
98
95
  - !ruby/object:Gem::Version
99
96
  version: '1.10'
100
- - - ">="
101
- - !ruby/object:Gem::Version
102
- version: 1.10.5
103
97
  description: A Ruby wrapper for Zanox's RESTful APIs because all the current alternatives
104
98
  outta here are shit.
105
99
  email: webmaster@giovannicapuano.net
@@ -120,6 +114,7 @@ files:
120
114
  - lib/zanox/exceptions/invalid_request.rb
121
115
  - lib/zanox/hashable.rb
122
116
  - lib/zanox/logger.rb
117
+ - lib/zanox/resources/admedium.rb
123
118
  - lib/zanox/resources/adspace.rb
124
119
  - lib/zanox/resources/item.rb
125
120
  - lib/zanox/resources/product.rb
@@ -133,6 +128,7 @@ files:
133
128
  - specs/profiles_spec.rb
134
129
  - specs/program_application_spec.rb
135
130
  - specs/programs_spec.rb
131
+ - specs/resources/admedium_spec.rb
136
132
  - specs/resources/product_spec.rb
137
133
  - specs/resources/shop_spec.rb
138
134
  - specs/response_spec.rb
@@ -158,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
158
154
  version: '0'
159
155
  requirements: []
160
156
  rubyforge_project:
161
- rubygems_version: 2.4.8
157
+ rubygems_version: 2.5.1
162
158
  signing_key:
163
159
  specification_version: 4
164
160
  summary: A Ruby wrapper for Zanox's RESTful APIs.