hasoffersv3 0.2.6 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/.travis.yml +1 -1
- data/CHANGELOG.md +13 -0
- data/README.md +36 -3
- data/hasoffersv3.gemspec +4 -4
- data/lib/hasoffersv3/advertiser.rb +9 -11
- data/lib/hasoffersv3/advertiser_billing.rb +18 -20
- data/lib/hasoffersv3/advertiser_user.rb +2 -4
- data/lib/hasoffersv3/affiliate.rb +21 -23
- data/lib/hasoffersv3/affiliate_billing.rb +19 -21
- data/lib/hasoffersv3/affiliate_offer.rb +27 -27
- data/lib/hasoffersv3/application.rb +2 -4
- data/lib/hasoffersv3/base.rb +53 -38
- data/lib/hasoffersv3/client.rb +1 -1
- data/lib/hasoffersv3/configuration.rb +1 -0
- data/lib/hasoffersv3/conversion.rb +8 -15
- data/lib/hasoffersv3/employee.rb +17 -0
- data/lib/hasoffersv3/offer.rb +52 -54
- data/lib/hasoffersv3/offer_pixel.rb +22 -0
- data/lib/hasoffersv3/raw_log.rb +14 -16
- data/lib/hasoffersv3/report.rb +7 -21
- data/lib/hasoffersv3/version.rb +1 -1
- data/lib/hasoffersv3.rb +8 -3
- data/spec/lib/advertiser_billing_spec.rb +5 -4
- data/spec/lib/advertiser_spec.rb +1 -1
- data/spec/lib/advertiser_user_spec.rb +1 -1
- data/spec/lib/affiliate_billing_spec.rb +1 -1
- data/spec/lib/affiliate_offer_spec.rb +1 -1
- data/spec/lib/affiliate_spec.rb +1 -1
- data/spec/lib/conversion_spec.rb +3 -8
- data/spec/lib/employee_spec.rb +47 -0
- data/spec/lib/hasoffersv3_spec.rb +9 -1
- data/spec/lib/offer_pixel_spec.rb +76 -0
- data/spec/lib/offer_spec.rb +1 -1
- data/spec/lib/raw_log_spec.rb +1 -1
- data/spec/lib/report_spec.rb +5 -15
- metadata +8 -7
- data/.ruby-gemset +0 -1
- data/lib/hasoffersv3/adapter.rb +0 -30
- data/spec/lib/adapter_spec.rb +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 488904130364dca63aaebe483eb85f170bc768ec
|
4
|
+
data.tar.gz: d8e5195ff89cee5f418bf1a806a5b7018a0487ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3851200de016fdbe5e357e93847e333db04cfe8284849b60bc9dfd64d636eb52154b76ba80286431268b53e937680d25f33b47a2c21259847d26caf63ca856be
|
7
|
+
data.tar.gz: 35a1c685c0b32a8db00102bfbbb6bc8326e56724f4e2a5271e9ac381bf3734101b7fb305a19c0c90bf54e02720e80b80d371f5c14b041fc823b4acf209268696
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.2.2
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
# 0.4.0
|
2
|
+
- [#42] Support "Employee": findAll, find_all_by_ids and find_by_id
|
3
|
+
- [#41] Added config option `read_timeout` to changed default timeout to 60
|
4
|
+
|
5
|
+
# 0.3.0
|
6
|
+
- [#39] Removed depreacted methods. Updated structure to use separated client configs.
|
7
|
+
|
8
|
+
# 0.2.7
|
9
|
+
- [#37][#38] Support "OfferPixel": findAll, find_all_by_ids, find_by_id, get_allowed_types
|
10
|
+
|
11
|
+
# 0.2.6
|
12
|
+
- Use `https` by default
|
13
|
+
|
1
14
|
# 0.2.5
|
2
15
|
- Support "Application/findAllAffiliateTiers" method
|
3
16
|
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
### Overview
|
2
2
|
|
3
|
-
[![Build status](https://api.travis-ci.org/applift/hasoffersv3.png?branch=master)](http://travis-ci.org/
|
3
|
+
[![Build status](https://api.travis-ci.org/applift/hasoffersv3.png?branch=master)](http://travis-ci.org/applift/hasoffersv3)
|
4
4
|
|
5
5
|
### Synopsis
|
6
6
|
|
@@ -21,7 +21,20 @@ Supported ruby versions:
|
|
21
21
|
|
22
22
|
## Usage
|
23
23
|
|
24
|
-
|
24
|
+
First, check if the method you want to call is already defined in `hasoffersv3/lib/hasoffersv3/*`. If not, you will need to add the method yourself (either just use your fork or submit a PR with your changes).
|
25
|
+
|
26
|
+
Next, create an initializer in your project in `config/intializers` and configure your API credentials like so:
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
HasOffersV3.configure do |config|
|
30
|
+
config.api_key = ENV['YOUR_HAS_OFFERS_API_KEY']
|
31
|
+
config.network_id = ENV['YOUR_HAS_OFFERS_NETWORK_ID']
|
32
|
+
config.read_timeout = 10
|
33
|
+
end
|
34
|
+
```
|
35
|
+
|
36
|
+
You can now use the defined methods, following this pattern:
|
37
|
+
|
25
38
|
|
26
39
|
```ruby
|
27
40
|
HasOffersV3::ControllerName.snake_case_method_name
|
@@ -34,7 +47,27 @@ Naming is the same as in HasOffers documentation, also if it requires attributes
|
|
34
47
|
Examples:
|
35
48
|
|
36
49
|
```ruby
|
37
|
-
HasOffersV3::Affiliate.update_payment_method_wire affiliate_id: '877', data:
|
50
|
+
HasOffersV3::Affiliate.update_payment_method_wire({ affiliate_id: '877', data: {} })
|
51
|
+
```
|
52
|
+
|
53
|
+
or when working with forms:
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
HasOffersV3::Advertiser.signup({
|
57
|
+
account: {
|
58
|
+
company: params[:company_name],
|
59
|
+
country: params[:company_country],
|
60
|
+
address1: 'Change me 123',
|
61
|
+
zipcode: '123123'
|
62
|
+
},
|
63
|
+
user: {
|
64
|
+
first_name: params[:user_name],
|
65
|
+
email: params[:user_email],
|
66
|
+
password: params[:user_password],
|
67
|
+
password_confirmation: params[:user_password_confirmation]
|
68
|
+
},
|
69
|
+
return_object: 1
|
70
|
+
})
|
38
71
|
```
|
39
72
|
|
40
73
|
## Testing
|
data/hasoffersv3.gemspec
CHANGED
@@ -4,11 +4,11 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'hasoffersv3/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
|
-
s.name =
|
7
|
+
s.name = 'hasoffersv3'
|
8
8
|
s.version = HasOffersV3::VERSION
|
9
9
|
s.platform = Gem::Platform::RUBY
|
10
|
-
s.authors = [
|
11
|
-
s.email = [
|
10
|
+
s.authors = ['Maximilian Seifert', 'Timo Rößner']
|
11
|
+
s.email = ['ms@hitfox.com', 'tr@hitfox.com']
|
12
12
|
s.summary = %q{REST Client for the HasOffers API, version 3.}
|
13
13
|
s.description = %q{REST Client for the HasOffers API, version 3.}
|
14
14
|
s.license = "MIT"
|
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.files = `git ls-files`.split($/)
|
17
17
|
s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
18
18
|
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
19
|
-
s.require_paths = [
|
19
|
+
s.require_paths = ['lib']
|
20
20
|
|
21
21
|
s.add_dependency 'activesupport' # for to_param method
|
22
22
|
s.add_development_dependency 'webmock'
|
@@ -1,18 +1,16 @@
|
|
1
1
|
class HasOffersV3
|
2
2
|
class Advertiser < Base
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
end
|
3
|
+
def find_all_ids
|
4
|
+
post_request 'findAllIds', {}
|
5
|
+
end
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
def find_all(params = {})
|
8
|
+
post_request 'findAll', params
|
9
|
+
end
|
11
10
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
end
|
11
|
+
def find_by_id(params = {})
|
12
|
+
requires! params, [:id]
|
13
|
+
post_request 'findById', params
|
16
14
|
end
|
17
15
|
end
|
18
16
|
end
|
@@ -1,29 +1,27 @@
|
|
1
1
|
class HasOffersV3
|
2
2
|
class AdvertiserBilling < Base
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
end
|
3
|
+
def find_all_invoices(params = {})
|
4
|
+
post_request 'findAllInvoices', params
|
5
|
+
end
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
def create_invoice(params = {})
|
8
|
+
requires! params, [:data]
|
9
|
+
post_request 'createInvoice', params
|
10
|
+
end
|
12
11
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
def find_invoice_by_id(params = {})
|
13
|
+
requires! params, [:id]
|
14
|
+
post_request 'findInvoiceById', params
|
15
|
+
end
|
17
16
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
17
|
+
def add_invoice_item(params = {})
|
18
|
+
requires! params, [:invoice_id, :data]
|
19
|
+
post_request 'addInvoiceItem', params
|
20
|
+
end
|
22
21
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
22
|
+
def remove_invoice_item(params = {})
|
23
|
+
requires! params, [:id]
|
24
|
+
post_request 'removeInvoiceItem', params
|
27
25
|
end
|
28
26
|
end
|
29
27
|
end
|
@@ -1,33 +1,31 @@
|
|
1
1
|
class HasOffersV3
|
2
2
|
class Affiliate < Base
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
end
|
3
|
+
def find_all(params = {})
|
4
|
+
post_request 'findAll', params
|
5
|
+
end
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
def find_by_id(params = {})
|
8
|
+
requires! params, [:id]
|
9
|
+
get_request 'findById', params
|
10
|
+
end
|
12
11
|
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
def update_payment_method_wire(params = {})
|
13
|
+
post_request 'updatePaymentMethodWire', params
|
14
|
+
end
|
16
15
|
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
def update_payment_method_paypal(params = {})
|
17
|
+
post_request 'updatePaymentMethodPaypal', params
|
18
|
+
end
|
20
19
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
20
|
+
def create (params = {})
|
21
|
+
requires! params, [:data]
|
22
|
+
requires! params[:data], [:zipcode, :company]
|
23
|
+
post_request 'create', params
|
24
|
+
end
|
26
25
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
end
|
26
|
+
def get_tier(params = {})
|
27
|
+
requires! params, [:id]
|
28
|
+
post_request 'getAffiliateTier', params
|
31
29
|
end
|
32
30
|
end
|
33
31
|
end
|
@@ -1,30 +1,28 @@
|
|
1
1
|
class HasOffersV3
|
2
2
|
class AffiliateBilling < Base
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
end
|
3
|
+
def find_last_invoice(params = {})
|
4
|
+
requires! params, [:affiliate_id]
|
5
|
+
post_request 'findLastInvoice', params
|
6
|
+
end
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
def create_invoice(params = {})
|
9
|
+
requires! params, [:data]
|
10
|
+
post_request 'createInvoice', params
|
11
|
+
end
|
13
12
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
def find_invoice_by_id(params = {})
|
14
|
+
requires! params, [:id]
|
15
|
+
post_request 'findInvoiceById', params
|
16
|
+
end
|
18
17
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
def add_invoice_item(params = {})
|
19
|
+
requires! params, [:invoice_id, :data]
|
20
|
+
post_request 'addInvoiceItem', params
|
21
|
+
end
|
23
22
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
end
|
23
|
+
def remove_invoice_item(params = {})
|
24
|
+
requires! params, [:id]
|
25
|
+
post_request 'removeInvoiceItem', params
|
28
26
|
end
|
29
27
|
end
|
30
28
|
end
|
@@ -1,39 +1,39 @@
|
|
1
1
|
class HasOffersV3
|
2
2
|
class AffiliateOffer < Base
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
'Affiliate_Offer'
|
7
|
-
end
|
3
|
+
def self.target
|
4
|
+
'Affiliate_Offer'
|
5
|
+
end
|
8
6
|
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
def target
|
8
|
+
'Affiliate_Offer'
|
9
|
+
end
|
12
10
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
end
|
11
|
+
def find_all(params = {})
|
12
|
+
post_request 'findAll', params
|
13
|
+
end
|
17
14
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
15
|
+
def find_by_id(params = {})
|
16
|
+
requires! params, [:id]
|
17
|
+
post_request 'findById', params
|
18
|
+
end
|
22
19
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
20
|
+
def get_categories(params = {})
|
21
|
+
requires! params, [:ids]
|
22
|
+
post_request 'getCategories', params
|
23
|
+
end
|
27
24
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
25
|
+
def get_target_countries(params = {})
|
26
|
+
requires! params, [:ids]
|
27
|
+
post_request 'getTargetCountries', params
|
28
|
+
end
|
32
29
|
|
33
|
-
|
34
|
-
|
35
|
-
|
30
|
+
def generate_tracking_link(params = {})
|
31
|
+
requires! params, [:offer_id]
|
32
|
+
post_request 'generateTrackingLink', params
|
33
|
+
end
|
36
34
|
|
35
|
+
def find_my_offers(params = {})
|
36
|
+
post_request 'findMyOffers', params
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
data/lib/hasoffersv3/base.rb
CHANGED
@@ -3,43 +3,11 @@ require 'active_support/core_ext/object/to_query'
|
|
3
3
|
|
4
4
|
class HasOffersV3
|
5
5
|
class Base
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
make_request(:get, method, params)
|
10
|
-
else
|
11
|
-
page = 1
|
12
|
-
begin
|
13
|
-
response = make_request(:get, method, params.merge(page: page))
|
14
|
-
block.call response
|
15
|
-
page += 1
|
16
|
-
end until page > (response.page_info['page_count'] || 1)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def post_request(method, params = {}, &block)
|
21
|
-
if block.nil?
|
22
|
-
make_request(:post, method, params)
|
23
|
-
else
|
24
|
-
page = 1
|
25
|
-
begin
|
26
|
-
response = make_request(:post, method, params.merge(page: page))
|
27
|
-
block.call response
|
28
|
-
page += 1
|
29
|
-
end until page > (response.page_info['page_count'] || 1)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def requires!(hash, required_params)
|
34
|
-
missing_params = []
|
35
|
-
required_params.each do |param|
|
36
|
-
missing_params.push param unless hash.has_key?(param)
|
37
|
-
end
|
38
|
-
unless missing_params.empty?
|
39
|
-
raise ArgumentError.new("Missing required parameter(s): #{missing_params.join(', ')}")
|
40
|
-
end
|
41
|
-
end
|
6
|
+
def initialize(client = HasOffersV3.client)
|
7
|
+
@client = client
|
8
|
+
end
|
42
9
|
|
10
|
+
class << self
|
43
11
|
def target
|
44
12
|
name.split('::').last
|
45
13
|
end
|
@@ -48,16 +16,63 @@ class HasOffersV3
|
|
48
16
|
HasOffersV3.client
|
49
17
|
end
|
50
18
|
|
19
|
+
def method_missing(meth, *args, &block)
|
20
|
+
new(client).send(meth, *args, &block)
|
21
|
+
end
|
22
|
+
|
51
23
|
private
|
52
24
|
|
53
25
|
def deprecation(from, to)
|
54
26
|
warn "\033[31m[DEPRECATION] `#{ name }.#{ from }` is deprecated. Please use `#{ name }.#{ to }` instead.\033[0m"
|
55
27
|
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def get_request(method, params = {}, &block)
|
31
|
+
if block.nil?
|
32
|
+
make_request(:get, method, params)
|
33
|
+
else
|
34
|
+
page = 1
|
35
|
+
begin
|
36
|
+
response = make_request(:get, method, params.merge(page: page))
|
37
|
+
block.call response
|
38
|
+
page += 1
|
39
|
+
end until page > (response.page_info['page_count'] || 1)
|
40
|
+
end
|
41
|
+
end
|
56
42
|
|
57
|
-
|
58
|
-
|
43
|
+
def post_request(method, params = {}, &block)
|
44
|
+
if block.nil?
|
45
|
+
make_request(:post, method, params)
|
46
|
+
else
|
47
|
+
page = 1
|
48
|
+
begin
|
49
|
+
response = make_request(:post, method, params.merge(page: page))
|
50
|
+
block.call response
|
51
|
+
page += 1
|
52
|
+
end until page > (response.page_info['page_count'] || 1)
|
59
53
|
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def requires!(hash, required_params)
|
57
|
+
missing_params = []
|
58
|
+
required_params.each do |param|
|
59
|
+
missing_params.push param unless hash.has_key?(param)
|
60
|
+
end
|
61
|
+
unless missing_params.empty?
|
62
|
+
raise ArgumentError.new("Missing required parameter(s): #{missing_params.join(', ')}")
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def target
|
67
|
+
self.class.target
|
68
|
+
end
|
69
|
+
|
70
|
+
def client
|
71
|
+
@client
|
72
|
+
end
|
60
73
|
|
74
|
+
def make_request(http_method, method, params)
|
75
|
+
@client.request(http_method, target, method, params)
|
61
76
|
end
|
62
77
|
end
|
63
78
|
end
|
data/lib/hasoffersv3/client.rb
CHANGED
@@ -1,22 +1,15 @@
|
|
1
1
|
class HasOffersV3
|
2
2
|
class Conversion < Base
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
find_all params
|
7
|
-
end
|
8
|
-
|
9
|
-
def find_all(params = {})
|
10
|
-
get_request 'findAll', params
|
11
|
-
end
|
3
|
+
def find_all(params = {})
|
4
|
+
get_request 'findAll', params
|
5
|
+
end
|
12
6
|
|
13
|
-
|
14
|
-
|
15
|
-
|
7
|
+
def find_added_conversions(params = {})
|
8
|
+
get_request 'findAddedConversions', params
|
9
|
+
end
|
16
10
|
|
17
|
-
|
18
|
-
|
19
|
-
end
|
11
|
+
def find_updated_conversions(params = {})
|
12
|
+
get_request 'findUpdatedConversions', params
|
20
13
|
end
|
21
14
|
end
|
22
15
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class HasOffersV3
|
2
|
+
class Employee < Base
|
3
|
+
def find_all(params = {})
|
4
|
+
post_request 'findAll', params
|
5
|
+
end
|
6
|
+
|
7
|
+
def find_all_by_ids(params = {})
|
8
|
+
requires! params, [:ids]
|
9
|
+
post_request 'findAllByIds', params
|
10
|
+
end
|
11
|
+
|
12
|
+
def find_by_id(params = {})
|
13
|
+
requires! params, [:id]
|
14
|
+
post_request 'findById', params
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|