hasoffersv3 0.1.3 → 0.2.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/.ruby-version +1 -1
- data/.travis.yml +3 -0
- data/Gemfile +5 -0
- data/README.md +2 -0
- data/lib/hasoffersv3/adapter.rb +30 -0
- data/lib/hasoffersv3/advertiser.rb +1 -1
- data/lib/hasoffersv3/advertiser_user.rb +1 -1
- data/lib/hasoffersv3/affiliate.rb +1 -1
- data/lib/hasoffersv3/affiliate_offer.rb +28 -0
- data/lib/hasoffersv3/base.rb +7 -40
- data/lib/hasoffersv3/client.rb +64 -0
- data/lib/hasoffersv3/configuration.rb +35 -6
- data/lib/hasoffersv3/conversion.rb +1 -1
- data/lib/hasoffersv3/offer.rb +1 -1
- data/lib/hasoffersv3/raw_log.rb +1 -1
- data/lib/hasoffersv3/report.rb +1 -1
- data/lib/hasoffersv3/response.rb +1 -1
- data/lib/hasoffersv3/testing.rb +14 -17
- data/lib/hasoffersv3/version.rb +2 -2
- data/lib/hasoffersv3.rb +49 -3
- data/spec/lib/adapter_spec.rb +20 -0
- data/spec/lib/affiliate_offer_spec.rb +77 -0
- data/spec/lib/base_spec.rb +12 -3
- data/spec/lib/client_spec.rb +24 -0
- data/spec/lib/hasoffersv3_spec.rb +30 -0
- metadata +14 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4756bb80ad0c0810d52a7eeb37a54583f353b215
|
4
|
+
data.tar.gz: 381f65f864de2725357e2f4a7a9a5e0dd2fe25ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f8cfd576d622db0094c2e2c4b1e558a111b62e180daa69e634a49ea16630badc5f84891f0d3104ca1dc15e4a8a4155cb4dcc24d8020879e5a98d765689e3296
|
7
|
+
data.tar.gz: b49e82d36cef0696416f0d42d4426fc048ec51dd61d88995092960b6bb04ee8403e820b351850e79a6334266fb778bd76d2948540ae4081c80263e159789fcc6
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
2.1.2
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -0,0 +1,30 @@
|
|
1
|
+
class HasOffersV3
|
2
|
+
class Adapter
|
3
|
+
attr_reader :configuration
|
4
|
+
|
5
|
+
def initialize(configuration, target)
|
6
|
+
@configuration = configuration
|
7
|
+
@target = target
|
8
|
+
end
|
9
|
+
|
10
|
+
def with_configuration(&block)
|
11
|
+
previous_config = HasOffersV3.configuration
|
12
|
+
HasOffersV3.configuration = @configuration
|
13
|
+
begin
|
14
|
+
yield
|
15
|
+
ensure
|
16
|
+
HasOffersV3.configuration = previous_config
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def method_missing(meth, *args, &block)
|
21
|
+
if @target.respond_to?(meth)
|
22
|
+
with_configuration do
|
23
|
+
@target.send(meth, *args, &block)
|
24
|
+
end
|
25
|
+
else
|
26
|
+
super
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
class HasOffersV3
|
2
|
+
class AffiliateOffer < Base
|
3
|
+
|
4
|
+
def self.target
|
5
|
+
'Affiliate_Offer'
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.find_all(params = {})
|
9
|
+
post_request 'findAll', params
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.find_by_id(params = {})
|
13
|
+
requires! params, [:id]
|
14
|
+
post_request 'findById', params
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.get_categories(params = {})
|
18
|
+
requires! params, [:ids]
|
19
|
+
post_request 'getCategories', params
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.get_target_countries(params = {})
|
23
|
+
requires! params, [:ids]
|
24
|
+
post_request 'getTargetCountries', params
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
data/lib/hasoffersv3/base.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'net/http' if RUBY_VERSION < '2'
|
2
2
|
require 'active_support/core_ext/object/to_query'
|
3
3
|
|
4
|
-
|
4
|
+
class HasOffersV3
|
5
5
|
class Base
|
6
6
|
class << self
|
7
7
|
def get_request(method, params = {}, &block)
|
@@ -44,53 +44,20 @@ module HasOffersV3
|
|
44
44
|
name.split('::').last
|
45
45
|
end
|
46
46
|
|
47
|
-
|
48
|
-
|
49
|
-
def deprecation(from, to)
|
50
|
-
warn "\033[31m[DEPRECATION] `#{ name }.#{ from }` is deprecated. Please use `#{ name }.#{ to }` instead.\033[0m"
|
47
|
+
def client
|
48
|
+
HasOffersV3.client
|
51
49
|
end
|
52
50
|
|
53
|
-
|
54
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
55
|
-
http.use_ssl = true if uri.scheme == 'https'
|
56
|
-
http.read_timeout = 600
|
57
|
-
http
|
58
|
-
end
|
51
|
+
private
|
59
52
|
|
60
|
-
def
|
61
|
-
|
62
|
-
# hasoffers doesn't like, so the gsub here takes care of that.
|
63
|
-
data_hash.to_param.gsub(/\[\]\[/,'[')
|
53
|
+
def deprecation(from, to)
|
54
|
+
warn "\033[31m[DEPRECATION] `#{ name }.#{ from }` is deprecated. Please use `#{ name }.#{ to }` instead.\033[0m"
|
64
55
|
end
|
65
56
|
|
66
57
|
def make_request(http_method, method, params)
|
67
|
-
|
68
|
-
if http_method == :post
|
69
|
-
uri = URI.parse("#{HasOffersV3.configuration.base_uri}/#{target}.json")
|
70
|
-
http = new_http(uri)
|
71
|
-
raw_request = Net::HTTP::Post.new(uri.request_uri)
|
72
|
-
raw_request.body = query_string data
|
73
|
-
else # assume get
|
74
|
-
uri = URI.parse("#{HasOffersV3.configuration.base_uri}/#{target}.json?#{query_string(data)}")
|
75
|
-
http = new_http(uri)
|
76
|
-
raw_request = Net::HTTP::Get.new(uri.request_uri)
|
77
|
-
end
|
78
|
-
http_response = execute_request(http, raw_request)
|
79
|
-
|
80
|
-
Response.new(http_response)
|
58
|
+
client.request(http_method, target, method, params)
|
81
59
|
end
|
82
60
|
|
83
|
-
def execute_request(net_http, raw_request)
|
84
|
-
net_http.request raw_request
|
85
|
-
end
|
86
|
-
|
87
|
-
def build_request_params(method, params)
|
88
|
-
params['Method'] = method
|
89
|
-
{
|
90
|
-
NetworkId: HasOffersV3.configuration.network_id,
|
91
|
-
NetworkToken: HasOffersV3.configuration.api_key,
|
92
|
-
}.merge(params)
|
93
|
-
end
|
94
61
|
end
|
95
62
|
end
|
96
63
|
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'net/http' if RUBY_VERSION < '2'
|
2
|
+
require 'active_support/core_ext/object/to_query'
|
3
|
+
|
4
|
+
class HasOffersV3
|
5
|
+
class Client
|
6
|
+
|
7
|
+
attr_accessor :configuration
|
8
|
+
|
9
|
+
def initialize(configuration)
|
10
|
+
@configuration = configuration
|
11
|
+
end
|
12
|
+
|
13
|
+
def request(http_method, target, method, params)
|
14
|
+
data = build_request_params(method, params)
|
15
|
+
|
16
|
+
target_uri = "#{base_uri}/#{target}.json"
|
17
|
+
|
18
|
+
if http_method == :post
|
19
|
+
uri = URI.parse(target_uri)
|
20
|
+
http = new_http(uri)
|
21
|
+
raw_request = Net::HTTP::Post.new(uri.request_uri)
|
22
|
+
raw_request.body = query_string data
|
23
|
+
else # assume get
|
24
|
+
uri = URI.parse("#{target_uri}?#{query_string(data)}")
|
25
|
+
http = new_http(uri)
|
26
|
+
raw_request = Net::HTTP::Get.new(uri.request_uri)
|
27
|
+
end
|
28
|
+
http_response = execute_request(http, raw_request)
|
29
|
+
|
30
|
+
Response.new(http_response)
|
31
|
+
end
|
32
|
+
|
33
|
+
def execute_request(net_http, raw_request)
|
34
|
+
net_http.request raw_request
|
35
|
+
end
|
36
|
+
|
37
|
+
def build_request_params(method, params)
|
38
|
+
params['Method'] = method
|
39
|
+
{
|
40
|
+
NetworkId: configuration.network_id,
|
41
|
+
NetworkToken: configuration.api_key,
|
42
|
+
api_key: configuration.api_key
|
43
|
+
}.merge(params)
|
44
|
+
end
|
45
|
+
|
46
|
+
def query_string(data_hash)
|
47
|
+
# Rails to_params adds an extra open close brackets to multi-dimensional array parameters which
|
48
|
+
# hasoffers doesn't like, so the gsub here takes care of that.
|
49
|
+
data_hash.to_param.gsub(/\[\]\[/,'[')
|
50
|
+
end
|
51
|
+
|
52
|
+
def new_http(uri)
|
53
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
54
|
+
http.use_ssl = true if uri.scheme == 'https'
|
55
|
+
http.read_timeout = 600
|
56
|
+
http
|
57
|
+
end
|
58
|
+
|
59
|
+
def base_uri
|
60
|
+
configuration.base_uri
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
@@ -1,11 +1,40 @@
|
|
1
|
-
|
1
|
+
class HasOffersV3
|
2
2
|
class Configuration
|
3
|
-
attr_accessor :network_id, :api_key, :protocol, :host, :base_path
|
4
3
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
DEFAULTS = {
|
5
|
+
host: 'api.hasoffers.com',
|
6
|
+
protocol: 'http',
|
7
|
+
base_path: '/v3',
|
8
|
+
network_id: '',
|
9
|
+
api_key: ''
|
10
|
+
}
|
11
|
+
|
12
|
+
DEFAULTS.keys.each do |option_name|
|
13
|
+
define_method option_name do
|
14
|
+
@options[option_name]
|
15
|
+
end
|
16
|
+
|
17
|
+
define_method "#{option_name}=" do |val|
|
18
|
+
@options[option_name] = val
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
attr_reader :options
|
23
|
+
|
24
|
+
def initialize(options={})
|
25
|
+
defaults = DEFAULTS.dup
|
26
|
+
@options = options.dup
|
27
|
+
|
28
|
+
|
29
|
+
defaults.keys.each do |key|
|
30
|
+
# Symbolize only keys that are needed
|
31
|
+
@options[key] = @options[key.to_s] if @options.has_key?(key.to_s)
|
32
|
+
end
|
33
|
+
|
34
|
+
# Use default when option is not specified or nil
|
35
|
+
defaults.keys.each do |key|
|
36
|
+
@options[key] = defaults[key] if @options[key].nil?
|
37
|
+
end
|
9
38
|
end
|
10
39
|
|
11
40
|
def base_uri
|
data/lib/hasoffersv3/offer.rb
CHANGED
data/lib/hasoffersv3/raw_log.rb
CHANGED
data/lib/hasoffersv3/report.rb
CHANGED
data/lib/hasoffersv3/response.rb
CHANGED
data/lib/hasoffersv3/testing.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
class HasOffersV3
|
2
2
|
class Testing
|
3
3
|
class << self
|
4
4
|
attr_accessor :__test_mode, :__prepared_request
|
@@ -20,11 +20,12 @@ module HasOffersV3
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def stub_request(status = 200, body = '{"response":{"status":1,"data":[]}}', message = 'mock')
|
23
|
-
self.__prepared_request =
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
self.__prepared_request =
|
24
|
+
begin
|
25
|
+
response = Net::HTTPResponse.new '1.1', status, message
|
26
|
+
response.stub(:body) { body }
|
27
|
+
response
|
28
|
+
end
|
28
29
|
end
|
29
30
|
|
30
31
|
def execute_stubbed_request
|
@@ -35,18 +36,14 @@ module HasOffersV3
|
|
35
36
|
end
|
36
37
|
end
|
37
38
|
|
38
|
-
class
|
39
|
-
|
40
|
-
private
|
41
|
-
|
42
|
-
alias_method :original_execute_request, :execute_request
|
39
|
+
class Client
|
40
|
+
alias_method :original_execute_request, :execute_request
|
43
41
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
end
|
42
|
+
def execute_request(net_http, raw_request)
|
43
|
+
if HasOffersV3::Testing.enabled?
|
44
|
+
HasOffersV3::Testing.execute_stubbed_request
|
45
|
+
else
|
46
|
+
original_execute_request net_http, raw_request
|
50
47
|
end
|
51
48
|
end
|
52
49
|
end
|
data/lib/hasoffersv3/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
|
2
|
-
VERSION = '0.
|
1
|
+
class HasOffersV3
|
2
|
+
VERSION = '0.2.0'
|
3
3
|
end
|
data/lib/hasoffersv3.rb
CHANGED
@@ -1,19 +1,65 @@
|
|
1
1
|
require 'net/http'
|
2
2
|
|
3
|
+
require 'hasoffersv3/client'
|
4
|
+
|
3
5
|
%w!base affiliate response conversion raw_log report configuration advertiser advertiser_user offer!.each do |file|
|
4
6
|
require "hasoffersv3/#{file}"
|
5
7
|
end
|
6
8
|
|
7
|
-
|
9
|
+
require 'hasoffersv3/affiliate_offer'
|
10
|
+
require 'hasoffersv3/adapter'
|
11
|
+
|
12
|
+
class HasOffersV3
|
13
|
+
|
14
|
+
API_TARGETS = {
|
15
|
+
advertisers: HasOffersV3::Advertiser,
|
16
|
+
advertiser_users: HasOffersV3::AdvertiserUser,
|
17
|
+
affiliates: HasOffersV3::Affiliate,
|
18
|
+
affiliate_offers: HasOffersV3::AffiliateOffer,
|
19
|
+
conversions: HasOffersV3::Conversion,
|
20
|
+
offers: HasOffersV3::Offer,
|
21
|
+
raw_logs: HasOffersV3::RawLog,
|
22
|
+
reports: HasOffersV3::Report
|
23
|
+
}
|
24
|
+
|
8
25
|
class << self
|
26
|
+
|
27
|
+
def configuration=(config)
|
28
|
+
@configuration = config
|
29
|
+
end
|
30
|
+
|
9
31
|
def configuration
|
10
|
-
@configuration ||= Configuration.new
|
32
|
+
@configuration ||= ::HasOffersV3::Configuration.new
|
11
33
|
end
|
12
34
|
|
13
35
|
def configure &block
|
14
|
-
|
36
|
+
yield(configuration)
|
37
|
+
end
|
38
|
+
|
39
|
+
def client
|
40
|
+
::HasOffersV3::Client.new(configuration)
|
15
41
|
end
|
16
42
|
end
|
43
|
+
|
44
|
+
def configuration
|
45
|
+
@configuration ||= ::HasOffersV3.configuration
|
46
|
+
end
|
47
|
+
|
48
|
+
def configure(&block)
|
49
|
+
yield(configuration)
|
50
|
+
end
|
51
|
+
|
52
|
+
def initialize(options = {})
|
53
|
+
@options = options.dup
|
54
|
+
@configuration = ::HasOffersV3::Configuration.new options
|
55
|
+
end
|
56
|
+
|
57
|
+
API_TARGETS.each do |name, target|
|
58
|
+
define_method name do
|
59
|
+
HasOffersV3::Adapter.new(configuration, target)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
17
63
|
end
|
18
64
|
|
19
65
|
if ENV['RAILS_ENV'] == 'test' || ENV['RACK_ENV'] == 'test' || ENV['TEST']
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe HasOffersV3::Adapter do
|
4
|
+
|
5
|
+
let(:configuration) { HasOffersV3::Configuration.new(host: 'example.com') }
|
6
|
+
subject { HasOffersV3::Adapter.new(HasOffersV3::Offer, HasOffersV3::Offer) }
|
7
|
+
|
8
|
+
describe '#with_configuration' do
|
9
|
+
it 'should apply for block another config' do
|
10
|
+
default_config = HasOffersV3.configuration
|
11
|
+
expect(HasOffersV3::Offer.client.configuration).to eq(default_config)
|
12
|
+
|
13
|
+
subject.with_configuration do
|
14
|
+
expect(HasOffersV3::Offer.client.configuration).to eq(subject.configuration)
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe HasOffersV3::AffiliateOffer do
|
4
|
+
subject { HasOffersV3::AffiliateOffer }
|
5
|
+
|
6
|
+
let(:url) { api_url 'Affiliate_Offer' }
|
7
|
+
|
8
|
+
describe '.target' do
|
9
|
+
specify { expect(subject.target).to eq('Affiliate_Offer')}
|
10
|
+
end
|
11
|
+
|
12
|
+
context 'urls' do
|
13
|
+
specify { expect(url).to eq('http://api.hasoffers.com/v3/Affiliate_Offer.json') }
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '.find_all' do
|
17
|
+
it 'should make a proper request call' do
|
18
|
+
stub_call
|
19
|
+
response = subject.find_all
|
20
|
+
request = a_request(:post, url).with(body: hash_including('Method' => 'findAll'))
|
21
|
+
expect(request).to have_been_made
|
22
|
+
validate_call response
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '.find_by_id' do
|
27
|
+
it 'should make a proper request call' do
|
28
|
+
stub_call
|
29
|
+
response = subject.find_by_id id: 1
|
30
|
+
request = a_request(:post, url).with(body: hash_including('Method' => 'findById', 'id' => '1'))
|
31
|
+
expect(request).to have_been_made
|
32
|
+
|
33
|
+
validate_call response
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'when there is no id' do
|
37
|
+
it 'should raise exception' do
|
38
|
+
expect { subject.find_by_id }.to raise_error ArgumentError
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '.get_categories' do
|
44
|
+
it 'should make a proper request call' do
|
45
|
+
stub_call
|
46
|
+
response = subject.get_categories ids: [1, 2]
|
47
|
+
request = a_request(:post, url).with(body: hash_including('Method' => 'getCategories'))
|
48
|
+
expect(request).to have_been_made
|
49
|
+
|
50
|
+
validate_call response
|
51
|
+
end
|
52
|
+
|
53
|
+
context 'when there is no id' do
|
54
|
+
it 'should raise exception' do
|
55
|
+
expect { subject.get_categories }.to raise_error ArgumentError
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe '.get_target_countries' do
|
61
|
+
it 'should make a proper request call' do
|
62
|
+
stub_call
|
63
|
+
response = subject.get_target_countries ids: [1, 2]
|
64
|
+
request = a_request(:post, url).with(body: hash_including('Method' => 'getTargetCountries'))
|
65
|
+
expect(request).to have_been_made
|
66
|
+
|
67
|
+
validate_call response
|
68
|
+
end
|
69
|
+
|
70
|
+
context 'when there is no id' do
|
71
|
+
it 'should raise exception' do
|
72
|
+
expect { subject.get_target_countries }.to raise_error ArgumentError
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
data/spec/lib/base_spec.rb
CHANGED
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe HasOffersV3::Base do
|
4
4
|
subject { HasOffersV3::Base }
|
5
5
|
|
6
|
-
let(:url)
|
6
|
+
let(:url) { Regexp.new api_url('Base') }
|
7
7
|
|
8
8
|
describe :requires! do
|
9
9
|
it 'raise ArgumentError is parameters are missing' do
|
@@ -15,19 +15,28 @@ describe HasOffersV3::Base do
|
|
15
15
|
it "should make a proper request" do
|
16
16
|
stub_call :get
|
17
17
|
response = subject.get_request 'test'
|
18
|
-
a_request(:get, url).with(query: hash_including(
|
18
|
+
request = a_request(:get, url).with(query: hash_including('Method' => 'test'))
|
19
|
+
expect(request).to have_been_made
|
19
20
|
validate_call response
|
20
21
|
end
|
21
22
|
|
22
23
|
context "with HTTPS enabled" do
|
24
|
+
|
23
25
|
before(:each) do
|
26
|
+
@old_protocol = HasOffersV3.configuration.protocol
|
24
27
|
HasOffersV3.configuration.protocol = 'https'
|
25
28
|
end
|
26
29
|
|
30
|
+
after(:each) do
|
31
|
+
HasOffersV3.configuration.protocol = @old_protocol
|
32
|
+
end
|
33
|
+
|
27
34
|
it "should make a proper request" do
|
28
35
|
stub_call :get
|
29
36
|
response = subject.get_request 'test'
|
30
|
-
a_request(:get, url).
|
37
|
+
a_request(:get, url).
|
38
|
+
with(query: hash_including('Method' => 'test')).
|
39
|
+
should have_been_made
|
31
40
|
validate_call response
|
32
41
|
end
|
33
42
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe HasOffersV3::Client do
|
4
|
+
|
5
|
+
describe '#base_uri' do
|
6
|
+
|
7
|
+
let(:configuration_to_default_host) { HasOffersV3::Configuration.new }
|
8
|
+
let(:config_for_proxy) {
|
9
|
+
result = HasOffersV3::Configuration.new
|
10
|
+
result.host = 'api.applift.com'
|
11
|
+
result
|
12
|
+
}
|
13
|
+
|
14
|
+
it 'should be different configs' do
|
15
|
+
default_connection = HasOffersV3::Client.new(configuration_to_default_host)
|
16
|
+
expect(default_connection.base_uri).to eq('http://api.hasoffers.com/v3')
|
17
|
+
|
18
|
+
proxy_connection = HasOffersV3::Client.new(config_for_proxy)
|
19
|
+
expect(proxy_connection.base_uri).to eq('http://api.applift.com/v3')
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe HasOffersV3 do
|
4
|
+
|
5
|
+
context 'singleton' do
|
6
|
+
it 'should use default config' do
|
7
|
+
subject = HasOffersV3::Offer.client.configuration
|
8
|
+
expect(subject).to eq(HasOffersV3.configuration)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#configuration' do
|
13
|
+
it 'should create different connections' do
|
14
|
+
subject = HasOffersV3.new
|
15
|
+
expect(subject.configuration).to_not eq(HasOffersV3.configuration)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'api' do
|
20
|
+
subject { HasOffersV3.new }
|
21
|
+
|
22
|
+
describe '#offers' do
|
23
|
+
it 'should get offers for current connection' do
|
24
|
+
expect(HasOffersV3::Offer).to receive(:find_all)
|
25
|
+
subject.offers.find_all
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
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.2.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: 2014-
|
12
|
+
date: 2014-09-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: oj
|
@@ -115,10 +115,13 @@ files:
|
|
115
115
|
- Rakefile
|
116
116
|
- hasoffersv3.gemspec
|
117
117
|
- lib/hasoffersv3.rb
|
118
|
+
- lib/hasoffersv3/adapter.rb
|
118
119
|
- lib/hasoffersv3/advertiser.rb
|
119
120
|
- lib/hasoffersv3/advertiser_user.rb
|
120
121
|
- lib/hasoffersv3/affiliate.rb
|
122
|
+
- lib/hasoffersv3/affiliate_offer.rb
|
121
123
|
- lib/hasoffersv3/base.rb
|
124
|
+
- lib/hasoffersv3/client.rb
|
122
125
|
- lib/hasoffersv3/configuration.rb
|
123
126
|
- lib/hasoffersv3/conversion.rb
|
124
127
|
- lib/hasoffersv3/offer.rb
|
@@ -127,11 +130,15 @@ files:
|
|
127
130
|
- lib/hasoffersv3/response.rb
|
128
131
|
- lib/hasoffersv3/testing.rb
|
129
132
|
- lib/hasoffersv3/version.rb
|
133
|
+
- spec/lib/adapter_spec.rb
|
130
134
|
- spec/lib/advertiser_spec.rb
|
131
135
|
- spec/lib/advertiser_user_spec.rb
|
136
|
+
- spec/lib/affiliate_offer_spec.rb
|
132
137
|
- spec/lib/affiliate_spec.rb
|
133
138
|
- spec/lib/base_spec.rb
|
139
|
+
- spec/lib/client_spec.rb
|
134
140
|
- spec/lib/conversion_spec.rb
|
141
|
+
- spec/lib/hasoffersv3_spec.rb
|
135
142
|
- spec/lib/offer_spec.rb
|
136
143
|
- spec/lib/raw_log_spec.rb
|
137
144
|
- spec/lib/report_spec.rb
|
@@ -161,12 +168,17 @@ signing_key:
|
|
161
168
|
specification_version: 4
|
162
169
|
summary: REST Client for the HasOffers API, version 3.
|
163
170
|
test_files:
|
171
|
+
- spec/lib/adapter_spec.rb
|
164
172
|
- spec/lib/advertiser_spec.rb
|
165
173
|
- spec/lib/advertiser_user_spec.rb
|
174
|
+
- spec/lib/affiliate_offer_spec.rb
|
166
175
|
- spec/lib/affiliate_spec.rb
|
167
176
|
- spec/lib/base_spec.rb
|
177
|
+
- spec/lib/client_spec.rb
|
168
178
|
- spec/lib/conversion_spec.rb
|
179
|
+
- spec/lib/hasoffersv3_spec.rb
|
169
180
|
- spec/lib/offer_spec.rb
|
170
181
|
- spec/lib/raw_log_spec.rb
|
171
182
|
- spec/lib/report_spec.rb
|
172
183
|
- spec/spec_helper.rb
|
184
|
+
has_rdoc:
|