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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6d4931962a54c3bf75cc4169d8655914a15545c
|
4
|
+
data.tar.gz: f780dbccf7809ffa58f85c71a86b48c9061d185f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c65325e39ed7c68f52e94b657f0626723921c7927be29a4da35e0d208d1f8cb56f3cb0212c32ef16baddbb9947d21b4f7dfd672fd96b464a39ebd817d65e00b4
|
7
|
+
data.tar.gz: cdd6b8143f3c9b0895a93c7042a65f4cbf0aea5240413a9b5a69ef22c3a161254e567436d55be75695622891d1473bc39449b2d32961682d3cd9c5c17804190b
|
data/.rspec
CHANGED
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
### Overview
|
1
|
+
### Overview
|
2
2
|
|
3
3
|
[](http://travis-ci.org/applift/hasoffersv3)
|
4
4
|
|
@@ -10,10 +10,8 @@ This gem provides a wrapper around HasOffers API in version 3, [HasOffers APIv3
|
|
10
10
|
|
11
11
|
Supported ruby versions:
|
12
12
|
|
13
|
-
* 1.9.3
|
14
|
-
* 2.0
|
15
|
-
* 2.1
|
16
13
|
* 2.2
|
14
|
+
* 2.3
|
17
15
|
|
18
16
|
## Installation
|
19
17
|
|
@@ -70,6 +68,20 @@ HasOffersV3::Advertiser.signup({
|
|
70
68
|
})
|
71
69
|
```
|
72
70
|
|
71
|
+
### Logging
|
72
|
+
|
73
|
+
To enable log you can set a logger in configuration. All HTTP requests and responses will be logged.
|
74
|
+
|
75
|
+
To disable it, just set the logger configuration to `nil` value. Default is disabled.
|
76
|
+
|
77
|
+
An example setting Rails logger:
|
78
|
+
|
79
|
+
```ruby
|
80
|
+
HasOffersV3.configure do |config|
|
81
|
+
config.logger = Rails.logger
|
82
|
+
end
|
83
|
+
```
|
84
|
+
|
73
85
|
## Testing
|
74
86
|
|
75
87
|
If `RAILS_ENV` or `RACK_ENV` is set to `test`, or there's a `TEST`
|
data/hasoffersv3.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
|
|
20
20
|
|
21
21
|
s.add_dependency 'activesupport' # for to_param method
|
22
22
|
s.add_development_dependency 'webmock'
|
23
|
-
s.add_development_dependency 'rspec', '~> 3.
|
23
|
+
s.add_development_dependency 'rspec', '~> 3.4.0'
|
24
24
|
s.add_development_dependency 'bundler', '~> 1.3'
|
25
25
|
s.add_development_dependency 'rake'
|
26
26
|
end
|
@@ -17,21 +17,45 @@ class HasOffersV3
|
|
17
17
|
post_request 'findById', params
|
18
18
|
end
|
19
19
|
|
20
|
+
def get_approval_questions(params = {})
|
21
|
+
requires! params, [:offer_id]
|
22
|
+
get_request 'getApprovalQuestions', params
|
23
|
+
end
|
24
|
+
|
20
25
|
def get_categories(params = {})
|
21
26
|
requires! params, [:ids]
|
22
27
|
post_request 'getCategories', params
|
23
28
|
end
|
24
29
|
|
30
|
+
def get_payout_details(params = {})
|
31
|
+
requires! params, [:offer_id]
|
32
|
+
get_request 'getPayoutDetails', params
|
33
|
+
end
|
34
|
+
|
35
|
+
def get_pixels(params = {})
|
36
|
+
requires! params, [:id]
|
37
|
+
get_request 'getPixels', params
|
38
|
+
end
|
39
|
+
|
25
40
|
def get_target_countries(params = {})
|
26
41
|
requires! params, [:ids]
|
27
42
|
post_request 'getTargetCountries', params
|
28
43
|
end
|
29
44
|
|
45
|
+
def get_thumbnail(params = {})
|
46
|
+
requires! params, [:ids]
|
47
|
+
get_request 'getThumbnail', params
|
48
|
+
end
|
49
|
+
|
30
50
|
def generate_tracking_link(params = {})
|
31
51
|
requires! params, [:offer_id]
|
32
52
|
post_request 'generateTrackingLink', params
|
33
53
|
end
|
34
54
|
|
55
|
+
def find_my_approved_offers(params = {})
|
56
|
+
get_request 'findMyApprovedOffers', params
|
57
|
+
end
|
58
|
+
|
35
59
|
def find_my_offers(params = {})
|
36
60
|
post_request 'findMyOffers', params
|
37
61
|
end
|
data/lib/hasoffersv3/client.rb
CHANGED
@@ -25,8 +25,13 @@ class HasOffersV3
|
|
25
25
|
http = new_http(uri)
|
26
26
|
raw_request = Net::HTTP::Get.new(uri.request_uri)
|
27
27
|
end
|
28
|
+
|
29
|
+
logger.log_request(raw_request, uri)
|
30
|
+
|
28
31
|
http_response = execute_request(http, raw_request)
|
29
32
|
|
33
|
+
logger.log_response(http_response)
|
34
|
+
|
30
35
|
Response.new(http_response, @configuration.json_driver)
|
31
36
|
end
|
32
37
|
|
@@ -60,5 +65,11 @@ class HasOffersV3
|
|
60
65
|
configuration.base_uri
|
61
66
|
end
|
62
67
|
|
68
|
+
private
|
69
|
+
|
70
|
+
def logger
|
71
|
+
configuration.http_logger
|
72
|
+
end
|
73
|
+
|
63
74
|
end
|
64
75
|
end
|
@@ -19,7 +19,8 @@ class HasOffersV3
|
|
19
19
|
base_path: '/v3',
|
20
20
|
network_id: '',
|
21
21
|
api_key: '',
|
22
|
-
json_driver: self.default_json_driver
|
22
|
+
json_driver: self.default_json_driver,
|
23
|
+
logger: nil
|
23
24
|
}.freeze
|
24
25
|
|
25
26
|
DEFAULTS.keys.each do |option_name|
|
@@ -49,6 +50,10 @@ class HasOffersV3
|
|
49
50
|
end
|
50
51
|
end
|
51
52
|
|
53
|
+
def http_logger
|
54
|
+
@http_logger ||= HasOffersV3::Logger.new(logger)
|
55
|
+
end
|
56
|
+
|
52
57
|
def base_uri
|
53
58
|
"#{protocol}://#{host}#{base_path}"
|
54
59
|
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
class HasOffersV3
|
2
|
+
class Logger
|
3
|
+
LABEL = '[HasOffersV3]'.freeze
|
4
|
+
|
5
|
+
attr_reader :log
|
6
|
+
|
7
|
+
def initialize(log = nil)
|
8
|
+
@log = log
|
9
|
+
end
|
10
|
+
|
11
|
+
def log_request(request, uri)
|
12
|
+
log_http(request, "Request: #{request.method} #{uri}")
|
13
|
+
end
|
14
|
+
|
15
|
+
def log_response(response)
|
16
|
+
log_http(response, "Response: HTTP/#{response.http_version} #{response.code} #{response.message}")
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def log_http(http, first_line)
|
22
|
+
return unless log
|
23
|
+
|
24
|
+
message = format_message(http, first_line)
|
25
|
+
log.info(message)
|
26
|
+
end
|
27
|
+
|
28
|
+
def format_message(http, first_line)
|
29
|
+
StringIO.open do |s|
|
30
|
+
s.puts("#{LABEL} #{first_line}")
|
31
|
+
append_headers(s, http.each_capitalized)
|
32
|
+
s.puts(http.body) unless http.body.to_s.empty?
|
33
|
+
s.string
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def append_headers(message, headers)
|
38
|
+
headers.each do |name, value|
|
39
|
+
message.puts("#{name}: #{value}")
|
40
|
+
end
|
41
|
+
|
42
|
+
message.puts
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/lib/hasoffersv3/report.rb
CHANGED
data/lib/hasoffersv3/version.rb
CHANGED
data/lib/hasoffersv3.rb
CHANGED
@@ -3,7 +3,7 @@ require 'json'
|
|
3
3
|
|
4
4
|
require 'hasoffersv3/client'
|
5
5
|
|
6
|
-
%w!base affiliate response conversion raw_log report configuration advertiser advertiser_user offer offer_pixel employee application!.each do |file|
|
6
|
+
%w!base affiliate response conversion raw_log report configuration advertiser advertiser_user offer offer_pixel employee application logger!.each do |file|
|
7
7
|
require "hasoffersv3/#{file}"
|
8
8
|
end
|
9
9
|
|
@@ -1,11 +1,7 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
1
|
describe HasOffersV3::AdvertiserBilling do
|
4
|
-
subject { HasOffersV3::AdvertiserBilling }
|
5
|
-
|
6
2
|
let(:url) { api_url 'AdvertiserBilling' }
|
7
3
|
|
8
|
-
describe '
|
4
|
+
describe '#find_all_invoices' do
|
9
5
|
it 'makes a proper request call' do
|
10
6
|
stub_call
|
11
7
|
response = subject.find_all_invoices
|
@@ -14,7 +10,7 @@ describe HasOffersV3::AdvertiserBilling do
|
|
14
10
|
end
|
15
11
|
end
|
16
12
|
|
17
|
-
describe '
|
13
|
+
describe '#create_invoice' do
|
18
14
|
context 'when data is specified' do
|
19
15
|
it 'makes a proper request call' do
|
20
16
|
stub_call
|
@@ -35,7 +31,7 @@ describe HasOffersV3::AdvertiserBilling do
|
|
35
31
|
end
|
36
32
|
end
|
37
33
|
|
38
|
-
describe '
|
34
|
+
describe '#find_invoice_by_id' do
|
39
35
|
context 'when ID is specified' do
|
40
36
|
it 'makes a proper request call' do
|
41
37
|
stub_call
|
@@ -52,16 +48,16 @@ describe HasOffersV3::AdvertiserBilling do
|
|
52
48
|
end
|
53
49
|
end
|
54
50
|
|
55
|
-
describe '
|
51
|
+
describe '#add_invoice_item' do
|
56
52
|
context 'when invoice ID and data is specified' do
|
57
53
|
it 'makes a proper request call' do
|
58
54
|
stub_call
|
59
55
|
response = subject.add_invoice_item(invoice_id: 1, data: {memo: 'abc'})
|
60
|
-
a_request(:post, url).with(body: hash_including({
|
56
|
+
expect(a_request(:post, url).with(body: hash_including({
|
61
57
|
'Method' => 'addInvoiceItem',
|
62
58
|
'invoice_id' => '1',
|
63
59
|
'data' => {'memo' => 'abc'}
|
64
|
-
})).
|
60
|
+
}))).to have_been_made
|
65
61
|
validate_call response
|
66
62
|
end
|
67
63
|
end
|
@@ -79,12 +75,12 @@ describe HasOffersV3::AdvertiserBilling do
|
|
79
75
|
end
|
80
76
|
end
|
81
77
|
|
82
|
-
describe '
|
78
|
+
describe '#remove_invoice_item' do
|
83
79
|
context 'when ID is specified' do
|
84
80
|
it 'makes a proper request call' do
|
85
81
|
stub_call
|
86
82
|
response = subject.remove_invoice_item(id: '1')
|
87
|
-
a_request(:post, url).with(body: hash_including({'Method' => 'removeInvoiceItem', 'id' => '1'})).
|
83
|
+
expect(a_request(:post, url).with(body: hash_including({'Method' => 'removeInvoiceItem', 'id' => '1'}))).to have_been_made
|
88
84
|
validate_call response
|
89
85
|
end
|
90
86
|
end
|
data/spec/lib/advertiser_spec.rb
CHANGED
@@ -1,12 +1,8 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
1
|
describe HasOffersV3::Advertiser do
|
4
|
-
subject { HasOffersV3::Advertiser.new }
|
5
|
-
|
6
2
|
let(:url) { api_url 'Advertiser' }
|
7
3
|
|
8
|
-
describe '
|
9
|
-
it '
|
4
|
+
describe '#find_all' do
|
5
|
+
it 'makes a proper request call' do
|
10
6
|
stub_call
|
11
7
|
response = subject.find_all
|
12
8
|
expect(a_request(:post, url).with(body: hash_including({'Method' => 'findAll'}))).to have_been_made
|
@@ -14,8 +10,8 @@ describe HasOffersV3::Advertiser do
|
|
14
10
|
end
|
15
11
|
end
|
16
12
|
|
17
|
-
describe '
|
18
|
-
it '
|
13
|
+
describe '#find_all_ids' do
|
14
|
+
it 'makes a proper request call' do
|
19
15
|
stub_call
|
20
16
|
response = subject.find_all_ids
|
21
17
|
expect(a_request(:post, url).with(body: hash_including({'Method' => 'findAllIds'}))).to have_been_made
|
@@ -23,8 +19,8 @@ describe HasOffersV3::Advertiser do
|
|
23
19
|
end
|
24
20
|
end
|
25
21
|
|
26
|
-
describe '
|
27
|
-
it '
|
22
|
+
describe '#find_by_id' do
|
23
|
+
it 'makes a proper request call' do
|
28
24
|
stub_call
|
29
25
|
response = subject.find_by_id id: 1
|
30
26
|
expect(a_request(:post, url).with(body: hash_including({'Method' => 'findById', 'id' => '1'}))).to have_been_made
|
@@ -32,7 +28,7 @@ describe HasOffersV3::Advertiser do
|
|
32
28
|
end
|
33
29
|
|
34
30
|
context 'when there is no id' do
|
35
|
-
it '
|
31
|
+
it 'raises exception' do
|
36
32
|
expect { subject.find_by_id failed_id: 1 }.to raise_error ArgumentError
|
37
33
|
end
|
38
34
|
end
|
@@ -1,12 +1,8 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
1
|
describe HasOffersV3::AdvertiserUser do
|
4
|
-
subject { HasOffersV3::AdvertiserUser.new }
|
5
|
-
|
6
2
|
let(:url) { api_url 'AdvertiserUser' }
|
7
3
|
|
8
|
-
describe '
|
9
|
-
it '
|
4
|
+
describe '#find_all' do
|
5
|
+
it 'makes a proper request call' do
|
10
6
|
stub_call
|
11
7
|
response = subject.find_all
|
12
8
|
expect(a_request(:post, url).with(body: hash_including({'Method' => 'findAll'}))).to have_been_made
|
@@ -1,16 +1,12 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
1
|
describe HasOffersV3::AffiliateBilling do
|
4
|
-
subject { HasOffersV3::AffiliateBilling.new }
|
5
|
-
|
6
2
|
let(:url) { api_url 'AffiliateBilling' }
|
7
3
|
|
8
|
-
describe '
|
4
|
+
describe '#find_last_invoice' do
|
9
5
|
context 'when affiliate ID is specified' do
|
10
6
|
it 'makes a proper request call' do
|
11
7
|
stub_call
|
12
8
|
response = subject.find_last_invoice(affiliate_id: '1')
|
13
|
-
a_request(:post, url).with(body: hash_including({'Method' => 'findLastInvoice', 'affiliate_id' => '1'})).
|
9
|
+
expect(a_request(:post, url).with(body: hash_including({'Method' => 'findLastInvoice', 'affiliate_id' => '1'}))).to have_been_made
|
14
10
|
validate_call response
|
15
11
|
end
|
16
12
|
end
|
@@ -22,15 +18,15 @@ describe HasOffersV3::AffiliateBilling do
|
|
22
18
|
end
|
23
19
|
end
|
24
20
|
|
25
|
-
describe '
|
21
|
+
describe '#create_invoice' do
|
26
22
|
context 'when data is specified' do
|
27
23
|
it 'makes a proper request call' do
|
28
24
|
stub_call
|
29
25
|
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({
|
26
|
+
expect(a_request(:post, url).with(body: hash_including({
|
31
27
|
'Method' => 'createInvoice',
|
32
28
|
'data' => {'affiliate_id' => '1', 'start_date' => '2014-10-01', 'end_date' => '2014-10-30'}
|
33
|
-
})).
|
29
|
+
}))).to have_been_made
|
34
30
|
validate_call response
|
35
31
|
end
|
36
32
|
end
|
@@ -42,12 +38,12 @@ describe HasOffersV3::AffiliateBilling do
|
|
42
38
|
end
|
43
39
|
end
|
44
40
|
|
45
|
-
describe '
|
41
|
+
describe '#find_invoice_by_id' do
|
46
42
|
context 'when ID is specified' do
|
47
43
|
it 'makes a proper request call' do
|
48
44
|
stub_call
|
49
45
|
response = subject.find_invoice_by_id(id: '1')
|
50
|
-
a_request(:post, url).with(body: hash_including({'Method' => 'findInvoiceById', 'id' => '1'})).
|
46
|
+
expect(a_request(:post, url).with(body: hash_including({'Method' => 'findInvoiceById', 'id' => '1'}))).to have_been_made
|
51
47
|
validate_call response
|
52
48
|
end
|
53
49
|
end
|
@@ -59,16 +55,16 @@ describe HasOffersV3::AffiliateBilling do
|
|
59
55
|
end
|
60
56
|
end
|
61
57
|
|
62
|
-
describe '
|
58
|
+
describe '#add_invoice_item' do
|
63
59
|
context 'when invoice ID and data is specified' do
|
64
60
|
it 'makes a proper request call' do
|
65
61
|
stub_call
|
66
62
|
response = subject.add_invoice_item(invoice_id: 1, data: {memo: 'abc'})
|
67
|
-
a_request(:post, url).with(body: hash_including({
|
63
|
+
expect(a_request(:post, url).with(body: hash_including({
|
68
64
|
'Method' => 'addInvoiceItem',
|
69
65
|
'invoice_id' => '1',
|
70
66
|
'data' => {'memo' => 'abc'}
|
71
|
-
})).
|
67
|
+
}))).to have_been_made
|
72
68
|
validate_call response
|
73
69
|
end
|
74
70
|
end
|
@@ -86,12 +82,12 @@ describe HasOffersV3::AffiliateBilling do
|
|
86
82
|
end
|
87
83
|
end
|
88
84
|
|
89
|
-
describe '
|
85
|
+
describe '#remove_invoice_item' do
|
90
86
|
context 'when ID is specified' do
|
91
87
|
it 'makes a proper request call' do
|
92
88
|
stub_call
|
93
89
|
response = subject.remove_invoice_item(id: '1')
|
94
|
-
a_request(:post, url).with(body: hash_including({'Method' => 'removeInvoiceItem', 'id' => '1'})).
|
90
|
+
expect(a_request(:post, url).with(body: hash_including({'Method' => 'removeInvoiceItem', 'id' => '1'}))).to have_been_made
|
95
91
|
validate_call response
|
96
92
|
end
|
97
93
|
end
|
@@ -1,11 +1,7 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
1
|
describe HasOffersV3::AffiliateOffer do
|
4
|
-
subject { HasOffersV3::AffiliateOffer.new }
|
5
|
-
|
6
2
|
let(:url) { api_url 'Affiliate_Offer' }
|
7
3
|
|
8
|
-
describe '
|
4
|
+
describe '#target' do
|
9
5
|
specify { expect(subject.target).to eq('Affiliate_Offer')}
|
10
6
|
end
|
11
7
|
|
@@ -13,8 +9,8 @@ describe HasOffersV3::AffiliateOffer do
|
|
13
9
|
specify { expect(url).to eq('https://api.hasoffers.com/v3/Affiliate_Offer.json') }
|
14
10
|
end
|
15
11
|
|
16
|
-
describe '
|
17
|
-
it '
|
12
|
+
describe '#find_all' do
|
13
|
+
it 'makes a proper request call' do
|
18
14
|
stub_call
|
19
15
|
response = subject.find_all
|
20
16
|
request = a_request(:post, url).with(body: hash_including('Method' => 'findAll'))
|
@@ -23,8 +19,8 @@ describe HasOffersV3::AffiliateOffer do
|
|
23
19
|
end
|
24
20
|
end
|
25
21
|
|
26
|
-
describe '
|
27
|
-
it '
|
22
|
+
describe '#find_by_id' do
|
23
|
+
it 'makes a proper request call' do
|
28
24
|
stub_call
|
29
25
|
response = subject.find_by_id id: 1
|
30
26
|
request = a_request(:post, url).with(body: hash_including('Method' => 'findById', 'id' => '1'))
|
@@ -34,14 +30,14 @@ describe HasOffersV3::AffiliateOffer do
|
|
34
30
|
end
|
35
31
|
|
36
32
|
context 'when there is no id' do
|
37
|
-
it '
|
33
|
+
it 'raises exception' do
|
38
34
|
expect { subject.find_by_id }.to raise_error ArgumentError
|
39
35
|
end
|
40
36
|
end
|
41
37
|
end
|
42
38
|
|
43
|
-
describe '
|
44
|
-
it '
|
39
|
+
describe '#get_categories' do
|
40
|
+
it 'makes a proper request call' do
|
45
41
|
stub_call
|
46
42
|
response = subject.get_categories ids: [1, 2]
|
47
43
|
request = a_request(:post, url).with(body: hash_including('Method' => 'getCategories'))
|
@@ -51,14 +47,14 @@ describe HasOffersV3::AffiliateOffer do
|
|
51
47
|
end
|
52
48
|
|
53
49
|
context 'when there is no id' do
|
54
|
-
it '
|
50
|
+
it 'raises exception' do
|
55
51
|
expect { subject.get_categories }.to raise_error ArgumentError
|
56
52
|
end
|
57
53
|
end
|
58
54
|
end
|
59
55
|
|
60
|
-
describe '
|
61
|
-
it '
|
56
|
+
describe '#get_target_countries' do
|
57
|
+
it 'makes a proper request call' do
|
62
58
|
stub_call
|
63
59
|
response = subject.get_target_countries ids: [1, 2]
|
64
60
|
request = a_request(:post, url).with(body: hash_including('Method' => 'getTargetCountries'))
|
@@ -68,14 +64,14 @@ describe HasOffersV3::AffiliateOffer do
|
|
68
64
|
end
|
69
65
|
|
70
66
|
context 'when there is no id' do
|
71
|
-
it '
|
67
|
+
it 'raises exception' do
|
72
68
|
expect { subject.get_target_countries }.to raise_error ArgumentError
|
73
69
|
end
|
74
70
|
end
|
75
71
|
end
|
76
72
|
|
77
|
-
describe '
|
78
|
-
it '
|
73
|
+
describe '#generate_tracking_link' do
|
74
|
+
it 'makes a proper request call' do
|
79
75
|
stub_call
|
80
76
|
response = subject.generate_tracking_link offer_id: 1
|
81
77
|
request = a_request(:post, url).with(body: hash_including('Method' => 'generateTrackingLink'))
|
@@ -85,14 +81,14 @@ describe HasOffersV3::AffiliateOffer do
|
|
85
81
|
end
|
86
82
|
|
87
83
|
context 'when there is no offer_id' do
|
88
|
-
it '
|
84
|
+
it 'raises exception' do
|
89
85
|
expect { subject.generate_tracking_link }.to raise_error ArgumentError
|
90
86
|
end
|
91
87
|
end
|
92
88
|
end
|
93
89
|
|
94
|
-
describe '
|
95
|
-
it '
|
90
|
+
describe '#find_my_offers' do
|
91
|
+
it 'makes a proper request call' do
|
96
92
|
stub_call
|
97
93
|
response = subject.find_my_offers
|
98
94
|
request = a_request(:post, url).with(body: hash_including('Method' => 'findMyOffers'))
|
@@ -102,4 +98,14 @@ describe HasOffersV3::AffiliateOffer do
|
|
102
98
|
end
|
103
99
|
end
|
104
100
|
|
101
|
+
describe '#find_my_approved_ffers' do
|
102
|
+
it 'makes a proper request call' do
|
103
|
+
stub_call :get, nil, Regexp.new(url)
|
104
|
+
response = subject.find_my_approved_offers
|
105
|
+
expect(a_request(:get, url).with(query: hash_including({'Method' => 'findMyApprovedOffers'}))).to have_been_made
|
106
|
+
|
107
|
+
validate_call response
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
105
111
|
end
|