hasoffersv3 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/hasoffersv3/advertiser_billing.rb +29 -0
- data/lib/hasoffersv3/affiliate.rb +6 -0
- data/lib/hasoffersv3/affiliate_billing.rb +30 -0
- data/lib/hasoffersv3/offer.rb +5 -0
- data/lib/hasoffersv3/version.rb +1 -1
- data/lib/hasoffersv3.rb +4 -0
- data/spec/lib/advertiser_billing_spec.rb +97 -0
- data/spec/lib/affiliate_billing_spec.rb +105 -0
- data/spec/lib/affiliate_spec.rb +22 -0
- data/spec/lib/offer_spec.rb +19 -0
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da538c54d138ea729812c0ba860ad4e207657338
|
4
|
+
data.tar.gz: eefed68384c2beda2a459d9060ef5b9b7c3b970d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a581c12f4dfd240f662b5472381d9e73d56c1b67727810ddac768e04aeb3dd836930194ec312503abdd8c3c791ca14f5bfe6a435656d2fc788ea94c5fcc9014
|
7
|
+
data.tar.gz: 1ab778d3121d3bf5b006369ce03d4b1483cf35400736bf646f0bad978bfcd62deb1f3d4a001c0085e8401b4abbf48bd8c5ac03f6ec8f16dd674b95ebc336818a
|
data/CHANGELOG.md
CHANGED
@@ -0,0 +1,29 @@
|
|
1
|
+
class HasOffersV3
|
2
|
+
class AdvertiserBilling < Base
|
3
|
+
class << self
|
4
|
+
def find_all_invoices(params = {})
|
5
|
+
post_request 'findAllInvoices', params
|
6
|
+
end
|
7
|
+
|
8
|
+
def create_invoice(params = {})
|
9
|
+
requires! params, [:data]
|
10
|
+
post_request 'createInvoice', params
|
11
|
+
end
|
12
|
+
|
13
|
+
def find_invoice_by_id(params = {})
|
14
|
+
requires! params, [:id]
|
15
|
+
post_request 'findInvoiceById', params
|
16
|
+
end
|
17
|
+
|
18
|
+
def add_invoice_item(params = {})
|
19
|
+
requires! params, [:invoice_id, :data]
|
20
|
+
post_request 'addInvoiceItem', params
|
21
|
+
end
|
22
|
+
|
23
|
+
def remove_invoice_item(params = {})
|
24
|
+
requires! params, [:id]
|
25
|
+
post_request 'removeInvoiceItem', params
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -17,6 +17,12 @@ class HasOffersV3
|
|
17
17
|
def update_payment_method_paypal(params = {})
|
18
18
|
post_request 'updatePaymentMethodPaypal', params
|
19
19
|
end
|
20
|
+
|
21
|
+
def create (params = {})
|
22
|
+
requires! params, [:data]
|
23
|
+
requires! params[:data], [:zipcode, :company]
|
24
|
+
post_request 'create', params
|
25
|
+
end
|
20
26
|
end
|
21
27
|
end
|
22
28
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
class HasOffersV3
|
2
|
+
class AffiliateBilling < Base
|
3
|
+
class << self
|
4
|
+
def find_last_invoice(params = {})
|
5
|
+
requires! params, [:affiliate_id]
|
6
|
+
post_request 'findLastInvoice', params
|
7
|
+
end
|
8
|
+
|
9
|
+
def create_invoice(params = {})
|
10
|
+
requires! params, [:data]
|
11
|
+
post_request 'createInvoice', params
|
12
|
+
end
|
13
|
+
|
14
|
+
def find_invoice_by_id(params = {})
|
15
|
+
requires! params, [:id]
|
16
|
+
post_request 'findInvoiceById', params
|
17
|
+
end
|
18
|
+
|
19
|
+
def add_invoice_item(params = {})
|
20
|
+
requires! params, [:invoice_id, :data]
|
21
|
+
post_request 'addInvoiceItem', params
|
22
|
+
end
|
23
|
+
|
24
|
+
def remove_invoice_item(params = {})
|
25
|
+
requires! params, [:id]
|
26
|
+
post_request 'removeInvoiceItem', params
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/hasoffersv3/offer.rb
CHANGED
@@ -44,6 +44,11 @@ class HasOffersV3
|
|
44
44
|
requires! params, [:id, :affiliate_id]
|
45
45
|
post_request 'removePayout', params
|
46
46
|
end
|
47
|
+
|
48
|
+
def generate_tracking_link(params = {})
|
49
|
+
requires! params, [:offer_id, :affiliate_id]
|
50
|
+
post_request 'generateTrackingLink', params
|
51
|
+
end
|
47
52
|
end
|
48
53
|
end
|
49
54
|
end
|
data/lib/hasoffersv3/version.rb
CHANGED
data/lib/hasoffersv3.rb
CHANGED
@@ -6,7 +6,9 @@ require 'hasoffersv3/client'
|
|
6
6
|
require "hasoffersv3/#{file}"
|
7
7
|
end
|
8
8
|
|
9
|
+
require 'hasoffersv3/advertiser_billing'
|
9
10
|
require 'hasoffersv3/affiliate_offer'
|
11
|
+
require 'hasoffersv3/affiliate_billing'
|
10
12
|
require 'hasoffersv3/adapter'
|
11
13
|
|
12
14
|
class HasOffersV3
|
@@ -14,8 +16,10 @@ class HasOffersV3
|
|
14
16
|
API_TARGETS = {
|
15
17
|
advertisers: HasOffersV3::Advertiser,
|
16
18
|
advertiser_users: HasOffersV3::AdvertiserUser,
|
19
|
+
advertiser_billing: HasOffersV3::AdvertiserBilling,
|
17
20
|
affiliates: HasOffersV3::Affiliate,
|
18
21
|
affiliate_offers: HasOffersV3::AffiliateOffer,
|
22
|
+
affiliate_billing: HasOffersV3::AffiliateBilling,
|
19
23
|
conversions: HasOffersV3::Conversion,
|
20
24
|
offers: HasOffersV3::Offer,
|
21
25
|
raw_logs: HasOffersV3::RawLog,
|
@@ -0,0 +1,97 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe HasOffersV3::AdvertiserBilling do
|
4
|
+
subject { HasOffersV3::AdvertiserBilling }
|
5
|
+
|
6
|
+
let(:url) { api_url 'AdvertiserBilling' }
|
7
|
+
|
8
|
+
describe '.find_all_invoices' do
|
9
|
+
it 'makes a proper request call' do
|
10
|
+
stub_call
|
11
|
+
response = subject.find_all_invoices
|
12
|
+
a_request(:post, url).with(body: hash_including({'Method' => 'findAllInvoices'})).should have_been_made
|
13
|
+
validate_call response
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '.create_invoice' do
|
18
|
+
context 'when data is specified' do
|
19
|
+
it 'makes a proper request call' do
|
20
|
+
stub_call
|
21
|
+
response = subject.create_invoice(data: {advertiser_id: 1, start_date: '2014-10-01', end_date: '2014-10-30'})
|
22
|
+
a_request(:post, url).with(body: hash_including({
|
23
|
+
'Method' => 'createInvoice',
|
24
|
+
'data' => {'advertiser_id' => '1', 'start_date' => '2014-10-01', 'end_date' => '2014-10-30'}
|
25
|
+
})).should have_been_made
|
26
|
+
validate_call response
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'when data is not specified' do
|
31
|
+
it 'raises an exception' do
|
32
|
+
expect { subject.create_invoice }.to raise_error ArgumentError
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '.find_invoice_by_id' do
|
38
|
+
context 'when ID is specified' do
|
39
|
+
it 'makes a proper request call' do
|
40
|
+
stub_call
|
41
|
+
response = subject.find_invoice_by_id(id: '1')
|
42
|
+
a_request(:post, url).with(body: hash_including({'Method' => 'findInvoiceById', 'id' => '1'})).should have_been_made
|
43
|
+
validate_call response
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context 'when ID is missing' do
|
48
|
+
it 'raises an exception' do
|
49
|
+
expect { subject.find_invoice_by_id }.to raise_error ArgumentError
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe '.add_invoice_item' do
|
55
|
+
context 'when invoice ID and data is specified' do
|
56
|
+
it 'makes a proper request call' do
|
57
|
+
stub_call
|
58
|
+
response = subject.add_invoice_item(invoice_id: 1, data: {memo: 'abc'})
|
59
|
+
a_request(:post, url).with(body: hash_including({
|
60
|
+
'Method' => 'addInvoiceItem',
|
61
|
+
'invoice_id' => '1',
|
62
|
+
'data' => {'memo' => 'abc'}
|
63
|
+
})).should have_been_made
|
64
|
+
validate_call response
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
context 'when invoice ID is not specified' do
|
69
|
+
it 'raises an exception' do
|
70
|
+
expect { subject.add_invoice_item(data: {memo: 'abc'}) }.to raise_error ArgumentError
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
context 'when data is not specified' do
|
75
|
+
it 'raises an exception' do
|
76
|
+
expect { subject.add_invoice_item(invoice_id: 1) }.to raise_error ArgumentError
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe '.remove_invoice_item' do
|
82
|
+
context 'when ID is specified' do
|
83
|
+
it 'makes a proper request call' do
|
84
|
+
stub_call
|
85
|
+
response = subject.remove_invoice_item(id: '1')
|
86
|
+
a_request(:post, url).with(body: hash_including({'Method' => 'removeInvoiceItem', 'id' => '1'})).should have_been_made
|
87
|
+
validate_call response
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
context 'when ID is missing' do
|
92
|
+
it 'raises an exception' do
|
93
|
+
expect { subject.remove_invoice_item }.to raise_error ArgumentError
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe HasOffersV3::AffiliateBilling do
|
4
|
+
subject { HasOffersV3::AffiliateBilling }
|
5
|
+
|
6
|
+
let(:url) { api_url 'AffiliateBilling' }
|
7
|
+
|
8
|
+
describe '.find_last_invoice' do
|
9
|
+
context 'when affiliate ID is specified' do
|
10
|
+
it 'makes a proper request call' do
|
11
|
+
stub_call
|
12
|
+
response = subject.find_last_invoice(affiliate_id: '1')
|
13
|
+
a_request(:post, url).with(body: hash_including({'Method' => 'findLastInvoice', 'affiliate_id' => '1'})).should have_been_made
|
14
|
+
validate_call response
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'when affiliate ID is missing' do
|
19
|
+
it 'raises an exception' do
|
20
|
+
expect { subject.find_last_invoice }.to raise_error ArgumentError
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '.create_invoice' do
|
26
|
+
context 'when data is specified' do
|
27
|
+
it 'makes a proper request call' do
|
28
|
+
stub_call
|
29
|
+
response = subject.create_invoice(data: {affiliate_id: 1, start_date: '2014-10-01', end_date: '2014-10-30'})
|
30
|
+
a_request(:post, url).with(body: hash_including({
|
31
|
+
'Method' => 'createInvoice',
|
32
|
+
'data' => {'affiliate_id' => '1', 'start_date' => '2014-10-01', 'end_date' => '2014-10-30'}
|
33
|
+
})).should have_been_made
|
34
|
+
validate_call response
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'when data is not specified' do
|
39
|
+
it 'raises an exception' do
|
40
|
+
expect { subject.create_invoice }.to raise_error ArgumentError
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe '.find_invoice_by_id' do
|
46
|
+
context 'when ID is specified' do
|
47
|
+
it 'makes a proper request call' do
|
48
|
+
stub_call
|
49
|
+
response = subject.find_invoice_by_id(id: '1')
|
50
|
+
a_request(:post, url).with(body: hash_including({'Method' => 'findInvoiceById', 'id' => '1'})).should have_been_made
|
51
|
+
validate_call response
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'when ID is missing' do
|
56
|
+
it 'raises an exception' do
|
57
|
+
expect { subject.find_invoice_by_id }.to raise_error ArgumentError
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe '.add_invoice_item' do
|
63
|
+
context 'when invoice ID and data is specified' do
|
64
|
+
it 'makes a proper request call' do
|
65
|
+
stub_call
|
66
|
+
response = subject.add_invoice_item(invoice_id: 1, data: {memo: 'abc'})
|
67
|
+
a_request(:post, url).with(body: hash_including({
|
68
|
+
'Method' => 'addInvoiceItem',
|
69
|
+
'invoice_id' => '1',
|
70
|
+
'data' => {'memo' => 'abc'}
|
71
|
+
})).should have_been_made
|
72
|
+
validate_call response
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
context 'when invoice ID is not specified' do
|
77
|
+
it 'raises an exception' do
|
78
|
+
expect { subject.add_invoice_item(data: {memo: 'abc'}) }.to raise_error ArgumentError
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
context 'when data is not specified' do
|
83
|
+
it 'raises an exception' do
|
84
|
+
expect { subject.add_invoice_item(invoice_id: 1) }.to raise_error ArgumentError
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe '.remove_invoice_item' do
|
90
|
+
context 'when ID is specified' do
|
91
|
+
it 'makes a proper request call' do
|
92
|
+
stub_call
|
93
|
+
response = subject.remove_invoice_item(id: '1')
|
94
|
+
a_request(:post, url).with(body: hash_including({'Method' => 'removeInvoiceItem', 'id' => '1'})).should have_been_made
|
95
|
+
validate_call response
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
context 'when ID is missing' do
|
100
|
+
it 'raises an exception' do
|
101
|
+
expect { subject.remove_invoice_item }.to raise_error ArgumentError
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
data/spec/lib/affiliate_spec.rb
CHANGED
@@ -47,4 +47,26 @@ describe HasOffersV3::Affiliate do
|
|
47
47
|
validate_call response
|
48
48
|
end
|
49
49
|
end
|
50
|
+
|
51
|
+
describe 'create' do
|
52
|
+
context 'when required params are missing' do
|
53
|
+
it 'should fail without data' do
|
54
|
+
expect { subject.create }.to raise_error ArgumentError
|
55
|
+
end
|
56
|
+
it 'should fail without data["company"]' do
|
57
|
+
expect { subject.create data: { zipcode: 1234567 }}.to raise_error ArgumentError
|
58
|
+
end
|
59
|
+
it 'should fail without data["zipcode"]' do
|
60
|
+
expect { subject.create data: { company: 'xyz@applift.com' }}.to raise_error ArgumentError
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'should make a successful request call' do
|
65
|
+
response = subject.create data: { company: "xyz@gmail.com", zipcode: "10178" }
|
66
|
+
expect(a_request(:post, url).with(body: hash_including({'Method' => 'create', 'data' => {'company' => 'xyz@gmail.com',
|
67
|
+
'zipcode' => '10178'}}))).to have_been_made
|
68
|
+
validate_call response
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
50
72
|
end
|
data/spec/lib/offer_spec.rb
CHANGED
@@ -126,4 +126,23 @@ describe HasOffersV3::Offer do
|
|
126
126
|
end
|
127
127
|
end
|
128
128
|
end
|
129
|
+
|
130
|
+
describe '.generate_tracking_link' do
|
131
|
+
it 'should make a proper request call' do
|
132
|
+
stub_call
|
133
|
+
response = subject.generate_tracking_link offer_id: 1, affiliate_id: 123
|
134
|
+
expect(a_request(:post, url).with(body: hash_including({'Method' => 'generateTrackingLink','offer_id' => '1',
|
135
|
+
'affiliate_id' => '123'}))).to have_been_made
|
136
|
+
validate_call response
|
137
|
+
end
|
138
|
+
|
139
|
+
context 'when required params are missing' do
|
140
|
+
it 'should fail without offer_id' do
|
141
|
+
expect { subject.generate_tracking_link affiliate_id: 1}.to raise_error ArgumentError
|
142
|
+
end
|
143
|
+
it 'should fail without affiliate_id' do
|
144
|
+
expect { subject.generate_tracking_link offer_id: 10 }.to raise_error ArgumentError
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
129
148
|
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.2.
|
4
|
+
version: 0.2.3
|
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:
|
12
|
+
date: 2015-03-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: oj
|
@@ -117,8 +117,10 @@ files:
|
|
117
117
|
- lib/hasoffersv3.rb
|
118
118
|
- lib/hasoffersv3/adapter.rb
|
119
119
|
- lib/hasoffersv3/advertiser.rb
|
120
|
+
- lib/hasoffersv3/advertiser_billing.rb
|
120
121
|
- lib/hasoffersv3/advertiser_user.rb
|
121
122
|
- lib/hasoffersv3/affiliate.rb
|
123
|
+
- lib/hasoffersv3/affiliate_billing.rb
|
122
124
|
- lib/hasoffersv3/affiliate_offer.rb
|
123
125
|
- lib/hasoffersv3/base.rb
|
124
126
|
- lib/hasoffersv3/client.rb
|
@@ -131,8 +133,10 @@ files:
|
|
131
133
|
- lib/hasoffersv3/testing.rb
|
132
134
|
- lib/hasoffersv3/version.rb
|
133
135
|
- spec/lib/adapter_spec.rb
|
136
|
+
- spec/lib/advertiser_billing_spec.rb
|
134
137
|
- spec/lib/advertiser_spec.rb
|
135
138
|
- spec/lib/advertiser_user_spec.rb
|
139
|
+
- spec/lib/affiliate_billing_spec.rb
|
136
140
|
- spec/lib/affiliate_offer_spec.rb
|
137
141
|
- spec/lib/affiliate_spec.rb
|
138
142
|
- spec/lib/base_spec.rb
|
@@ -169,8 +173,10 @@ specification_version: 4
|
|
169
173
|
summary: REST Client for the HasOffers API, version 3.
|
170
174
|
test_files:
|
171
175
|
- spec/lib/adapter_spec.rb
|
176
|
+
- spec/lib/advertiser_billing_spec.rb
|
172
177
|
- spec/lib/advertiser_spec.rb
|
173
178
|
- spec/lib/advertiser_user_spec.rb
|
179
|
+
- spec/lib/affiliate_billing_spec.rb
|
174
180
|
- spec/lib/affiliate_offer_spec.rb
|
175
181
|
- spec/lib/affiliate_spec.rb
|
176
182
|
- spec/lib/base_spec.rb
|