hasoffersv3 0.4.1 → 0.5.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/.rspec +1 -0
- data/.travis.yml +2 -5
- data/README.md +16 -4
- data/hasoffersv3.gemspec +1 -1
- data/lib/hasoffersv3/affiliate_offer.rb +24 -0
- data/lib/hasoffersv3/client.rb +11 -0
- data/lib/hasoffersv3/configuration.rb +6 -1
- data/lib/hasoffersv3/logger.rb +45 -0
- data/lib/hasoffersv3/report.rb +4 -0
- data/lib/hasoffersv3/version.rb +1 -1
- data/lib/hasoffersv3.rb +1 -1
- data/spec/lib/advertiser_billing_spec.rb +8 -12
- data/spec/lib/advertiser_spec.rb +7 -11
- data/spec/lib/advertiser_user_spec.rb +2 -6
- data/spec/lib/affiliate_billing_spec.rb +12 -16
- data/spec/lib/affiliate_offer_spec.rb +27 -21
- data/spec/lib/affiliate_spec.rb +17 -21
- data/spec/lib/application_spec.rb +3 -6
- data/spec/lib/base_spec.rb +5 -9
- data/spec/lib/client_spec.rb +1 -3
- data/spec/lib/configuration_spec.rb +44 -0
- data/spec/lib/conversion_spec.rb +6 -23
- data/spec/lib/employee_spec.rb +8 -12
- data/spec/lib/hasoffersv3_spec.rb +4 -9
- data/spec/lib/logger_spec.rb +47 -0
- data/spec/lib/offer_pixel_spec.rb +13 -17
- data/spec/lib/offer_spec.rb +48 -52
- data/spec/lib/raw_log_spec.rb +13 -17
- data/spec/lib/report_spec.rb +9 -35
- metadata +10 -5
data/spec/lib/offer_spec.rb
CHANGED
@@ -1,149 +1,145 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
1
|
describe HasOffersV3::Offer do
|
4
|
-
subject { HasOffersV3::Offer.new }
|
5
|
-
|
6
2
|
let(:url) { api_url 'Offer' }
|
7
3
|
|
8
|
-
describe '
|
9
|
-
it '
|
4
|
+
describe '#find_all' do
|
5
|
+
it 'makes a proper request call' do
|
10
6
|
stub_call
|
11
|
-
response =
|
7
|
+
response = subject.find_all
|
12
8
|
expect(a_request(:post, url).with(body: hash_including({'Method' => 'findAll'}))).to have_been_made
|
13
9
|
validate_call response
|
14
10
|
end
|
15
11
|
end
|
16
12
|
|
17
|
-
describe '
|
18
|
-
it '
|
13
|
+
describe '#find_all_by_ids' do
|
14
|
+
it 'makes a proper request call' do
|
19
15
|
stub_call
|
20
|
-
response =
|
16
|
+
response = subject.find_all_by_ids ids: [1]
|
21
17
|
expect(a_request(:post, url).with(body: hash_including({'Method' => 'findAllByIds'}))).to have_been_made
|
22
18
|
validate_call response
|
23
19
|
end
|
24
20
|
|
25
21
|
context 'when there is no id' do
|
26
|
-
it '
|
27
|
-
expect {
|
22
|
+
it 'raises exception' do
|
23
|
+
expect { subject.find_all_by_ids }.to raise_error ArgumentError
|
28
24
|
end
|
29
25
|
end
|
30
26
|
end
|
31
27
|
|
32
|
-
describe '
|
33
|
-
it '
|
28
|
+
describe '#find_all_ids_by_advertiser_id' do
|
29
|
+
it 'makes a proper request call' do
|
34
30
|
stub_call
|
35
|
-
response =
|
31
|
+
response = subject.find_all_ids_by_advertiser_id advertiser_id: 1
|
36
32
|
expect(a_request(:post, url).with(body: hash_including({'Method' => 'findAllIdsByAdvertiserId', 'advertiser_id' => '1'}))).to have_been_made
|
37
33
|
validate_call response
|
38
34
|
end
|
39
35
|
|
40
36
|
context 'when there is no id' do
|
41
|
-
it '
|
42
|
-
expect {
|
37
|
+
it 'raises exception' do
|
38
|
+
expect { subject.find_all_ids_by_advertiser_id }.to raise_error ArgumentError
|
43
39
|
end
|
44
40
|
end
|
45
41
|
end
|
46
42
|
|
47
|
-
describe '
|
48
|
-
it '
|
43
|
+
describe '#find_all_ids_by_affiliate_id' do
|
44
|
+
it 'makes a proper request call' do
|
49
45
|
stub_call
|
50
|
-
response =
|
46
|
+
response = subject.find_all_ids_by_affiliate_id affiliate_id: 1
|
51
47
|
expect(a_request(:post, url).with(body: hash_including({'Method' => 'findAllIdsByAffiliateId', 'affiliate_id' => '1'}))).to have_been_made
|
52
48
|
end
|
53
49
|
end
|
54
50
|
|
55
|
-
describe '
|
56
|
-
it '
|
51
|
+
describe '#find_by_id' do
|
52
|
+
it 'makes a proper request call' do
|
57
53
|
stub_call
|
58
|
-
response =
|
54
|
+
response = subject.find_by_id id: 1
|
59
55
|
expect(a_request(:post, url).with(body: hash_including({'Method' => 'findById', 'id' => '1'}))).to have_been_made
|
60
56
|
validate_call response
|
61
57
|
end
|
62
58
|
|
63
59
|
context 'when there is no id' do
|
64
|
-
it '
|
65
|
-
expect {
|
60
|
+
it 'raises exception' do
|
61
|
+
expect { subject.find_by_id }.to raise_error ArgumentError
|
66
62
|
end
|
67
63
|
end
|
68
64
|
end
|
69
65
|
|
70
|
-
describe '
|
71
|
-
it '
|
66
|
+
describe '#get_groups' do
|
67
|
+
it 'makes a proper request call' do
|
72
68
|
stub_call
|
73
|
-
response =
|
69
|
+
response = subject.get_groups id: 1
|
74
70
|
expect(a_request(:post, url).with(body: hash_including({'Method' => 'getGroups'}))).to have_been_made
|
75
71
|
validate_call response
|
76
72
|
end
|
77
73
|
|
78
74
|
context 'when there is no id' do
|
79
|
-
it '
|
80
|
-
expect {
|
75
|
+
it 'raises exception' do
|
76
|
+
expect { subject.get_groups }.to raise_error ArgumentError
|
81
77
|
end
|
82
78
|
end
|
83
79
|
end
|
84
80
|
|
85
|
-
describe '
|
81
|
+
describe '#get_approved_affiliate_ids' do
|
86
82
|
it 'makes a proper API request' do
|
87
83
|
stub_call
|
88
|
-
response =
|
84
|
+
response = subject.get_approved_affiliate_ids id: 1
|
89
85
|
expect(a_request(:post, url).with(body: hash_including({'Method' => 'getApprovedAffiliateIds'}))).to have_been_made
|
90
86
|
validate_call response
|
91
87
|
end
|
92
88
|
|
93
89
|
context 'when id parameter is missed' do
|
94
90
|
it 'raises an exception' do
|
95
|
-
expect {
|
91
|
+
expect { subject.get_approved_affiliate_ids }.to raise_error ArgumentError
|
96
92
|
end
|
97
93
|
end
|
98
94
|
end
|
99
95
|
|
100
|
-
describe '
|
101
|
-
it '
|
96
|
+
describe '#set_payout' do
|
97
|
+
it 'makes a proper request call' do
|
102
98
|
stub_call
|
103
|
-
response =
|
99
|
+
response = subject.set_payout id: 1, affiliate_id: 321
|
104
100
|
expect(a_request(:post, url).with(body: hash_including({'Method' => 'setPayout'}))).to have_been_made
|
105
101
|
validate_call response
|
106
102
|
end
|
107
103
|
|
108
104
|
context 'when the id and/or affiliate id parameters are missing' do
|
109
105
|
it 'raises an exception' do
|
110
|
-
expect {
|
106
|
+
expect { subject.set_payout }.to raise_error ArgumentError
|
111
107
|
end
|
112
108
|
end
|
113
109
|
end
|
114
110
|
|
115
|
-
describe '
|
116
|
-
it '
|
111
|
+
describe '#set_tier_payout' do
|
112
|
+
it 'makes a proper request call' do
|
117
113
|
stub_call
|
118
|
-
response =
|
114
|
+
response = subject.set_tier_payout id: 1, affiliate_tier_id: 2
|
119
115
|
expect(a_request(:post, url).with(body: hash_including({'Method' => 'setTierPayout'}))).to have_been_made
|
120
116
|
validate_call response
|
121
117
|
end
|
122
118
|
|
123
119
|
context 'when the id and/or affiliate tier id parameters are missing' do
|
124
120
|
it 'raises an exception' do
|
125
|
-
expect {
|
121
|
+
expect { subject.set_tier_payout }.to raise_error ArgumentError
|
126
122
|
end
|
127
123
|
end
|
128
124
|
end
|
129
125
|
|
130
|
-
describe '
|
131
|
-
it '
|
126
|
+
describe '#remove_payout' do
|
127
|
+
it 'makes a proper request call' do
|
132
128
|
stub_call
|
133
|
-
response =
|
129
|
+
response = subject.remove_payout id: 1, affiliate_id: 321
|
134
130
|
expect(a_request(:post, url).with(body: hash_including({'Method' => 'removePayout'}))).to have_been_made
|
135
131
|
validate_call response
|
136
132
|
end
|
137
133
|
|
138
134
|
context 'when the id and/or affiliate id parameters are missing' do
|
139
135
|
it 'raises an exception' do
|
140
|
-
expect {
|
136
|
+
expect { subject.remove_payout }.to raise_error ArgumentError
|
141
137
|
end
|
142
138
|
end
|
143
139
|
end
|
144
140
|
|
145
|
-
describe '
|
146
|
-
it '
|
141
|
+
describe '#generate_tracking_link' do
|
142
|
+
it 'makes a proper request call' do
|
147
143
|
stub_call
|
148
144
|
response = subject.generate_tracking_link offer_id: 1, affiliate_id: 123
|
149
145
|
expect(a_request(:post, url).with(body: hash_including({'Method' => 'generateTrackingLink','offer_id' => '1',
|
@@ -152,24 +148,24 @@ describe HasOffersV3::Offer do
|
|
152
148
|
end
|
153
149
|
|
154
150
|
context 'when required params are missing' do
|
155
|
-
it '
|
151
|
+
it 'fails without offer_id' do
|
156
152
|
expect { subject.generate_tracking_link affiliate_id: 1}.to raise_error ArgumentError
|
157
153
|
end
|
158
|
-
it '
|
154
|
+
it 'fails without affiliate_id' do
|
159
155
|
expect { subject.generate_tracking_link offer_id: 10 }.to raise_error ArgumentError
|
160
156
|
end
|
161
157
|
end
|
162
158
|
end
|
163
159
|
|
164
|
-
describe '
|
165
|
-
it '
|
160
|
+
describe '#get_tier_payouts' do
|
161
|
+
it 'makes a proper request call' do
|
166
162
|
stub_call
|
167
163
|
response = subject.get_tier_payouts id: 1
|
168
164
|
expect(a_request(:post, url).with(body: hash_including({'Method' => 'getTierPayouts','id' => '1'}))).to have_been_made
|
169
165
|
validate_call response
|
170
166
|
end
|
171
167
|
|
172
|
-
it '
|
168
|
+
it 'fails without id' do
|
173
169
|
expect { subject.get_tier_payouts }.to raise_error ArgumentError
|
174
170
|
end
|
175
171
|
end
|
data/spec/lib/raw_log_spec.rb
CHANGED
@@ -1,71 +1,67 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
1
|
describe HasOffersV3::RawLog do
|
4
|
-
subject { HasOffersV3::RawLog.new }
|
5
|
-
|
6
2
|
let(:url) { Regexp.new api_url('RawLog') }
|
7
3
|
|
8
4
|
before :each do
|
9
5
|
stub_call :get
|
10
6
|
end
|
11
7
|
|
12
|
-
describe '
|
13
|
-
it '
|
8
|
+
describe '#get_download_link' do
|
9
|
+
it 'makes a proper request call' do
|
14
10
|
response = subject.get_download_link log_type: 'clicks', log_filename: 'xxx'
|
15
11
|
expect(a_request(:get, url).with(query: hash_including({'Method' => 'getDownloadLink'}))).to have_been_made
|
16
12
|
validate_call response
|
17
13
|
end
|
18
14
|
|
19
15
|
context 'when there is no log_type' do
|
20
|
-
it '
|
16
|
+
it 'raises an exception' do
|
21
17
|
expect { subject.get_download_link log_filename: 'xxx' }.to raise_error ArgumentError
|
22
18
|
end
|
23
19
|
end
|
24
20
|
|
25
21
|
context 'when there is no log_filename' do
|
26
|
-
it '
|
22
|
+
it 'raises an exception' do
|
27
23
|
expect { subject.get_download_link log_type: 'clicks' }.to raise_error ArgumentError
|
28
24
|
end
|
29
25
|
end
|
30
26
|
end
|
31
27
|
|
32
|
-
describe '
|
33
|
-
it '
|
28
|
+
describe '#get_log_expirations' do
|
29
|
+
it 'makes a proper request call' do
|
34
30
|
response = subject.get_log_expirations
|
35
31
|
expect(a_request(:get, url).with(query: hash_including({'Method' => 'getLogExpirations'}))).to have_been_made
|
36
32
|
validate_call response
|
37
33
|
end
|
38
34
|
end
|
39
35
|
|
40
|
-
describe '
|
41
|
-
it '
|
36
|
+
describe '#list_date_dirs' do
|
37
|
+
it 'makes a proper request call' do
|
42
38
|
response = subject.list_date_dirs log_type: 'clicks'
|
43
39
|
expect(a_request(:get, url).with(query: hash_including({'Method' => 'listDateDirs'}))).to have_been_made
|
44
40
|
validate_call response
|
45
41
|
end
|
46
42
|
|
47
43
|
context 'when there is no log_type' do
|
48
|
-
it '
|
44
|
+
it 'raises an exception' do
|
49
45
|
expect { subject.list_date_dirs }.to raise_error ArgumentError
|
50
46
|
end
|
51
47
|
end
|
52
48
|
end
|
53
49
|
|
54
|
-
describe '
|
55
|
-
it '
|
50
|
+
describe '#list_logs' do
|
51
|
+
it 'makes a proper request call' do
|
56
52
|
response = subject.list_logs log_type: 'clicks', date_dir: '20140101'
|
57
53
|
expect(a_request(:get, url).with(query: hash_including({'Method' => 'listLogs'}))).to have_been_made
|
58
54
|
validate_call response
|
59
55
|
end
|
60
56
|
|
61
57
|
context 'when there is no log_type' do
|
62
|
-
it '
|
58
|
+
it 'raises an exception' do
|
63
59
|
expect { subject.list_logs date_dir: '20140101' }.to raise_error ArgumentError
|
64
60
|
end
|
65
61
|
end
|
66
62
|
|
67
63
|
context 'when there is no date_dir' do
|
68
|
-
it '
|
64
|
+
it 'raises an exception' do
|
69
65
|
expect { subject.list_logs log_type: 'clicks' }.to raise_error ArgumentError
|
70
66
|
end
|
71
67
|
end
|
data/spec/lib/report_spec.rb
CHANGED
@@ -1,61 +1,35 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
1
|
describe HasOffersV3::Report do
|
4
|
-
subject { HasOffersV3::Report.new }
|
5
2
|
let(:url) { api_url 'Report' }
|
6
3
|
|
7
|
-
describe '
|
8
|
-
before(:each) { stub_call }
|
9
|
-
|
10
|
-
it 'should make a proper request call' do
|
11
|
-
response = subject.get_conversions
|
12
|
-
expect(a_request(:post, url).with(body: hash_including({'Method' => 'getConversions'}))).to have_been_made
|
13
|
-
validate_call response
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
describe '.getConversions' do
|
4
|
+
describe '#get_conversions' do
|
18
5
|
before(:each) { stub_call }
|
19
6
|
|
20
|
-
it '
|
7
|
+
it 'makes a proper request call' do
|
21
8
|
response = subject.get_conversions
|
22
9
|
expect(a_request(:post, url).with(body: hash_including({'Method' => 'getConversions'}))).to have_been_made
|
23
10
|
validate_call response
|
24
11
|
end
|
25
|
-
|
26
|
-
it 'should call find_all method' do
|
27
|
-
expect(subject).to receive(:get_conversions).with({test: 1})
|
28
|
-
subject.get_conversions test: 1
|
29
|
-
end
|
30
12
|
end
|
31
13
|
|
32
|
-
describe '
|
14
|
+
describe '#get_mod_summary_logs' do
|
33
15
|
let(:url) { Regexp.new api_url('Report') }
|
34
16
|
|
35
17
|
before(:each) { stub_call :get }
|
36
18
|
|
37
|
-
it '
|
19
|
+
it 'makes a proper request call' do
|
38
20
|
response = subject.get_mod_summary_logs
|
39
21
|
expect(a_request(:get, url).with(query: hash_including({'Method' => 'getModSummaryLogs'}))).to have_been_made
|
40
22
|
validate_call response
|
41
23
|
end
|
42
24
|
end
|
43
25
|
|
44
|
-
describe '
|
45
|
-
|
46
|
-
|
47
|
-
before(:each) { stub_call :get }
|
26
|
+
describe '#get_stats' do
|
27
|
+
before(:each) { stub_call }
|
48
28
|
|
49
|
-
it '
|
50
|
-
response = subject.
|
51
|
-
expect(a_request(:
|
29
|
+
it 'makes a proper request call' do
|
30
|
+
response = subject.get_stats
|
31
|
+
expect(a_request(:post, url).with(body: hash_including({'Method' => 'getStats'}))).to have_been_made
|
52
32
|
validate_call response
|
53
33
|
end
|
54
|
-
|
55
|
-
it 'should call find_all method' do
|
56
|
-
expect(subject).to receive(:get_mod_summary_logs).with({test: 1})
|
57
|
-
subject.get_mod_summary_logs test: 1
|
58
|
-
end
|
59
|
-
|
60
34
|
end
|
61
35
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hasoffersv3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maximilian Seifert
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-08-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -45,14 +45,14 @@ dependencies:
|
|
45
45
|
requirements:
|
46
46
|
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: 3.
|
48
|
+
version: 3.4.0
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
53
|
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: 3.
|
55
|
+
version: 3.4.0
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: bundler
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -112,6 +112,7 @@ files:
|
|
112
112
|
- lib/hasoffersv3/configuration.rb
|
113
113
|
- lib/hasoffersv3/conversion.rb
|
114
114
|
- lib/hasoffersv3/employee.rb
|
115
|
+
- lib/hasoffersv3/logger.rb
|
115
116
|
- lib/hasoffersv3/offer.rb
|
116
117
|
- lib/hasoffersv3/offer_pixel.rb
|
117
118
|
- lib/hasoffersv3/raw_log.rb
|
@@ -128,9 +129,11 @@ files:
|
|
128
129
|
- spec/lib/application_spec.rb
|
129
130
|
- spec/lib/base_spec.rb
|
130
131
|
- spec/lib/client_spec.rb
|
132
|
+
- spec/lib/configuration_spec.rb
|
131
133
|
- spec/lib/conversion_spec.rb
|
132
134
|
- spec/lib/employee_spec.rb
|
133
135
|
- spec/lib/hasoffersv3_spec.rb
|
136
|
+
- spec/lib/logger_spec.rb
|
134
137
|
- spec/lib/offer_pixel_spec.rb
|
135
138
|
- spec/lib/offer_spec.rb
|
136
139
|
- spec/lib/raw_log_spec.rb
|
@@ -156,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
156
159
|
version: '0'
|
157
160
|
requirements: []
|
158
161
|
rubyforge_project:
|
159
|
-
rubygems_version: 2.
|
162
|
+
rubygems_version: 2.5.1
|
160
163
|
signing_key:
|
161
164
|
specification_version: 4
|
162
165
|
summary: REST Client for the HasOffers API, version 3.
|
@@ -170,9 +173,11 @@ test_files:
|
|
170
173
|
- spec/lib/application_spec.rb
|
171
174
|
- spec/lib/base_spec.rb
|
172
175
|
- spec/lib/client_spec.rb
|
176
|
+
- spec/lib/configuration_spec.rb
|
173
177
|
- spec/lib/conversion_spec.rb
|
174
178
|
- spec/lib/employee_spec.rb
|
175
179
|
- spec/lib/hasoffersv3_spec.rb
|
180
|
+
- spec/lib/logger_spec.rb
|
176
181
|
- spec/lib/offer_pixel_spec.rb
|
177
182
|
- spec/lib/offer_spec.rb
|
178
183
|
- spec/lib/raw_log_spec.rb
|