commission_junction 1.8.0 → 2.0.0
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/.rubocop.yml +4 -0
- data/README.md +2 -1
- data/commission_junction.gemspec +5 -4
- data/lib/commission_junction.rb +37 -57
- data/lib/commission_junction/version.rb +1 -1
- data/test/commission_junction_test.rb +12 -12
- metadata +27 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 750c227b15e7e3f9bd1e9a6db340f498851bfeaf
|
4
|
+
data.tar.gz: 49a96c42d479e7e7027d0d6039c9b531984ebf7c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0bcf73dda51f0bf74dd057493e581aaf3889b02f4c0a22abe9db769a51aff35070ab890a072183ad58d180951c8d3c56f536eb74eecafe10e89e543d605c7896
|
7
|
+
data.tar.gz: 03b7cfae4c2f13cf2e0ca180f72257521d25954e4feeaee42561df5aa3e16d49f0e09de3f14fa149e68a699759b4b204ce77b56df66adb5e72f0b1bcad73625e
|
data/.rubocop.yml
CHANGED
data/README.md
CHANGED
@@ -4,7 +4,7 @@ Ruby wrapper for the Commission Junction web services APIs (REST)
|
|
4
4
|
|
5
5
|
See https://cjcommunity.force.com/s/article/4777058.
|
6
6
|
|
7
|
-
[](https://badge.fury.io/rb/commission_junction)
|
8
8
|
|
9
9
|
## Installation
|
10
10
|
|
@@ -129,6 +129,7 @@ end
|
|
129
129
|
* [Jean-Sebastien Boulanger](https://github.com/jsboulanger)
|
130
130
|
* [luckyjazzbo](https://github.com/luckyjazzbo)
|
131
131
|
* [samsaradog](https://github.com/samsaradog)
|
132
|
+
* [Sergii Konev](https://github.com/K-S-A)
|
132
133
|
|
133
134
|
## Copyright
|
134
135
|
|
data/commission_junction.gemspec
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
1
|
lib = File.expand_path('../lib', __FILE__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
require 'commission_junction/version'
|
@@ -16,8 +15,10 @@ Gem::Specification.new do |gem|
|
|
16
15
|
gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
17
16
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
17
|
gem.require_paths = ['lib']
|
19
|
-
gem.add_dependency 'httparty', '~> 0.
|
20
|
-
gem.
|
21
|
-
gem.
|
18
|
+
gem.add_dependency 'httparty', '~> 0.15'
|
19
|
+
gem.add_dependency 'ox', '~> 2.8'
|
20
|
+
gem.add_development_dependency 'json', '~> 2.1'
|
21
|
+
gem.add_development_dependency 'minitest', '> 0'
|
22
22
|
gem.license = 'BSD-3-Clause'
|
23
|
+
gem.required_ruby_version = '~> 2.1'
|
23
24
|
end
|
data/lib/commission_junction.rb
CHANGED
@@ -33,7 +33,7 @@ class CommissionJunction
|
|
33
33
|
raise ArgumentError, "You must supply your website ID.\nSee cj.com > Account > Web site Settings > PID" if website_id.empty?
|
34
34
|
@website_id = website_id
|
35
35
|
|
36
|
-
raise ArgumentError, "timeout must be a
|
36
|
+
raise ArgumentError, "timeout must be a Integer; got #{timeout.class} instead" unless timeout.is_a?(Integer)
|
37
37
|
raise ArgumentError, "timeout must be > 0; got #{timeout} instead" unless timeout > 0
|
38
38
|
@timeout = timeout
|
39
39
|
|
@@ -57,20 +57,16 @@ class CommissionJunction
|
|
57
57
|
|
58
58
|
@cj_objects = []
|
59
59
|
|
60
|
-
|
61
|
-
|
62
|
-
advertisers = extract_contents(response, 'advertisers')
|
60
|
+
response = self.class.get(WEB_SERVICE_URIS[:advertiser_lookup], query: params)
|
61
|
+
advertisers = extract_contents(response, 'advertisers')
|
63
62
|
|
64
|
-
|
65
|
-
|
66
|
-
|
63
|
+
@total_matched = advertisers['total_matched'].to_i
|
64
|
+
@records_returned = advertisers['records_returned'].to_i
|
65
|
+
@page_number = advertisers['page_number'].to_i
|
67
66
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
rescue Timeout::Error
|
72
|
-
@total_matched = @records_returned = @page_number = 0
|
73
|
-
end
|
67
|
+
advertiser = advertisers['advertiser']
|
68
|
+
advertiser = [advertiser] if advertiser.is_a?(Hash) # If we got exactly one result, put it in an array.
|
69
|
+
advertiser.each { |item| @cj_objects << Advertiser.new(item) } if advertiser
|
74
70
|
|
75
71
|
@cj_objects
|
76
72
|
end
|
@@ -86,20 +82,16 @@ class CommissionJunction
|
|
86
82
|
|
87
83
|
@cj_objects = []
|
88
84
|
|
89
|
-
|
90
|
-
|
91
|
-
products = extract_contents(response, 'products')
|
85
|
+
response = self.class.get(WEB_SERVICE_URIS[:product_search], query: params, timeout: @timeout)
|
86
|
+
products = extract_contents(response, 'products')
|
92
87
|
|
93
|
-
|
94
|
-
|
95
|
-
|
88
|
+
@total_matched = products['total_matched'].to_i
|
89
|
+
@records_returned = products['records_returned'].to_i
|
90
|
+
@page_number = products['page_number'].to_i
|
96
91
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
rescue Timeout::Error
|
101
|
-
@total_matched = @records_returned = @page_number = 0
|
102
|
-
end
|
92
|
+
product = products['product']
|
93
|
+
product = [product] if product.is_a?(Hash) # If we got exactly one result, put it in an array.
|
94
|
+
product.each { |item| @cj_objects << Product.new(item) } if product
|
103
95
|
|
104
96
|
@cj_objects
|
105
97
|
end
|
@@ -115,20 +107,16 @@ class CommissionJunction
|
|
115
107
|
|
116
108
|
@cj_objects = []
|
117
109
|
|
118
|
-
|
119
|
-
|
120
|
-
links = extract_contents(response, 'links')
|
110
|
+
response = self.class.get(WEB_SERVICE_URIS[:link_search], query: params, timeout: @timeout)
|
111
|
+
links = extract_contents(response, 'links')
|
121
112
|
|
122
|
-
|
123
|
-
|
124
|
-
|
113
|
+
@total_matched = links['total_matched'].to_i
|
114
|
+
@records_returned = links['records_returned'].to_i
|
115
|
+
@page_number = links['page_number'].to_i
|
125
116
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
rescue Timeout::Error
|
130
|
-
@total_matched = @records_returned = @page_number = 0
|
131
|
-
end
|
117
|
+
link = links['link']
|
118
|
+
link = [link] if link.is_a?(Hash) # If we got exactly one result, put it in an array.
|
119
|
+
link.each { |item| @cj_objects << Link.new(item) } if link
|
132
120
|
|
133
121
|
@cj_objects
|
134
122
|
end
|
@@ -140,20 +128,16 @@ class CommissionJunction
|
|
140
128
|
|
141
129
|
@cj_objects = []
|
142
130
|
|
143
|
-
|
144
|
-
|
145
|
-
commissions = extract_contents(response, 'commissions')
|
131
|
+
response = self.class.get(WEB_SERVICE_URIS[:commissions], query: params)
|
132
|
+
commissions = extract_contents(response, 'commissions')
|
146
133
|
|
147
|
-
|
148
|
-
|
149
|
-
|
134
|
+
@total_matched = commissions['total_matched'].to_i
|
135
|
+
@records_returned = commissions['records_returned'].to_i
|
136
|
+
@page_number = commissions['page_number'].to_i
|
150
137
|
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
rescue Timeout::Error
|
155
|
-
@total_matched = @records_returned = @page_number = 0
|
156
|
-
end
|
138
|
+
commission = commissions['commission']
|
139
|
+
commission = [commission] if commission.is_a?(Hash) # If we got exactly one result, put it in an array.
|
140
|
+
commission.each { |item| @cj_objects << Commission.new(item) } if commission
|
157
141
|
|
158
142
|
@cj_objects
|
159
143
|
end
|
@@ -167,14 +151,10 @@ class CommissionJunction
|
|
167
151
|
|
168
152
|
@cj_objects = []
|
169
153
|
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
@cj_objects = [@cj_objects] if @cj_objects.is_a?(Hash) # If we got exactly one result, put it in an array.
|
175
|
-
rescue Timeout::Error
|
176
|
-
@total_matched = @records_returned = @page_number = 0
|
177
|
-
end
|
154
|
+
ids = original_action_ids.join(',')
|
155
|
+
response = self.class.get(WEB_SERVICE_URIS[:item_detail] + ids, query: "original-action-id=#{ids}")
|
156
|
+
@cj_objects = extract_contents(response, 'item_details')
|
157
|
+
@cj_objects = [@cj_objects] if @cj_objects.is_a?(Hash) # If we got exactly one result, put it in an array.
|
178
158
|
|
179
159
|
@cj_objects
|
180
160
|
end
|
@@ -189,9 +189,9 @@ class CommissionJunctionTest < Minitest::Test
|
|
189
189
|
end
|
190
190
|
|
191
191
|
def check_search_results(results)
|
192
|
-
assert_instance_of(
|
193
|
-
assert_instance_of(
|
194
|
-
assert_instance_of(
|
192
|
+
assert_instance_of(Integer, results.total_matched)
|
193
|
+
assert_instance_of(Integer, results.records_returned)
|
194
|
+
assert_instance_of(Integer, results.page_number)
|
195
195
|
assert_instance_of(Array, results.cj_objects)
|
196
196
|
|
197
197
|
results.cj_objects.each do |product|
|
@@ -256,9 +256,9 @@ class CommissionJunctionTest < Minitest::Test
|
|
256
256
|
end
|
257
257
|
|
258
258
|
def check_advertiser_lookup_results(results)
|
259
|
-
assert_instance_of(
|
260
|
-
assert_instance_of(
|
261
|
-
assert_instance_of(
|
259
|
+
assert_instance_of(Integer, results.total_matched)
|
260
|
+
assert_instance_of(Integer, results.records_returned)
|
261
|
+
assert_instance_of(Integer, results.page_number)
|
262
262
|
assert_instance_of(Array, results.cj_objects)
|
263
263
|
|
264
264
|
results.cj_objects.each do |advertiser|
|
@@ -308,9 +308,9 @@ class CommissionJunctionTest < Minitest::Test
|
|
308
308
|
end
|
309
309
|
|
310
310
|
def check_commission_lookup_results(results)
|
311
|
-
assert_instance_of(
|
312
|
-
assert_instance_of(
|
313
|
-
assert_instance_of(
|
311
|
+
assert_instance_of(Integer, results.total_matched)
|
312
|
+
assert_instance_of(Integer, results.records_returned)
|
313
|
+
assert_instance_of(Integer, results.page_number)
|
314
314
|
assert_instance_of(Array, results.cj_objects)
|
315
315
|
|
316
316
|
results.cj_objects.each do |commission|
|
@@ -427,9 +427,9 @@ class CommissionJunctionTest < Minitest::Test
|
|
427
427
|
end
|
428
428
|
|
429
429
|
def check_link_search_results(results)
|
430
|
-
assert_instance_of(
|
431
|
-
assert_instance_of(
|
432
|
-
assert_instance_of(
|
430
|
+
assert_instance_of(Integer, results.total_matched)
|
431
|
+
assert_instance_of(Integer, results.records_returned)
|
432
|
+
assert_instance_of(Integer, results.page_number)
|
433
433
|
assert_instance_of(Array, results.cj_objects)
|
434
434
|
|
435
435
|
results.cj_objects.each do |link|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: commission_junction
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Albert Vernon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -16,42 +16,56 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0.
|
19
|
+
version: '0.15'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0.
|
26
|
+
version: '0.15'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: ox
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
34
|
-
type: :
|
33
|
+
version: '2.8'
|
34
|
+
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '2.8'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: json
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '2.1'
|
48
|
-
type: :
|
48
|
+
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '2.1'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
description: Ruby wrapper for the Commission Junction web services APIs (REST)
|
56
70
|
email: aev@vernon.nu
|
57
71
|
executables: []
|
@@ -79,9 +93,9 @@ require_paths:
|
|
79
93
|
- lib
|
80
94
|
required_ruby_version: !ruby/object:Gem::Requirement
|
81
95
|
requirements:
|
82
|
-
- - "
|
96
|
+
- - "~>"
|
83
97
|
- !ruby/object:Gem::Version
|
84
|
-
version: '
|
98
|
+
version: '2.1'
|
85
99
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
100
|
requirements:
|
87
101
|
- - ">="
|
@@ -89,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
103
|
version: '0'
|
90
104
|
requirements: []
|
91
105
|
rubyforge_project:
|
92
|
-
rubygems_version: 2.
|
106
|
+
rubygems_version: 2.6.14
|
93
107
|
signing_key:
|
94
108
|
specification_version: 4
|
95
109
|
summary: Commission Junction web services APIs (REST)
|