admitad 0.0.11 → 0.0.12
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/admitad.gemspec +1 -1
- data/bin/console +2 -3
- data/bin/setup +0 -2
- data/lib/admitad.rb +5 -5
- data/lib/admitad/concerns/wrappers/actions.rb +19 -0
- data/lib/admitad/concerns/wrappers/ad_spaces.rb +25 -0
- data/lib/admitad/concerns/wrappers/affiliate_programs.rb +44 -0
- data/lib/admitad/concerns/wrappers/categories.rb +19 -0
- data/lib/admitad/concerns/wrappers/coupons.rb +45 -0
- data/lib/admitad/concerns/wrappers/currencies.rb +25 -0
- data/lib/admitad/concerns/wrappers/deeplinks.rb +19 -0
- data/lib/admitad/concerns/wrappers/regions.rb +19 -0
- data/lib/admitad/version.rb +1 -1
- data/lib/admitad/wrapper.rb +21 -110
- metadata +12 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 872b5319b4120dc8c929d09e0f0c769d210d57e27e220585f21f002e61ad985c
|
4
|
+
data.tar.gz: 88c7a246bcbee7e3b686d1868fb810c842b77881b1b870667199bd0d90de96a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f054603cc94547cd6fc0fc1ff3c64a0a385b6d43627da4e849fac682e5b6b8793f4dd49df81fdbc77d0f7ace0de1fbcd6f03afd1dabe511d2a12838a93e4f1f9
|
7
|
+
data.tar.gz: ba324c906d26afebcc2a119b797f62e14c52c87c927ab732b8b0ee9cd5a4759bf9c74acab48437b19227bf303a1af352b9e50e479d60b307cdb6441b322aced7
|
data/admitad.gemspec
CHANGED
@@ -6,7 +6,7 @@ Gem::Specification.new do |spec|
|
|
6
6
|
spec.name = 'admitad'
|
7
7
|
spec.version = Admitad::VERSION
|
8
8
|
spec.authors = ['alexandr-senyuk']
|
9
|
-
spec.email = ['
|
9
|
+
spec.email = ['a.senyuk.io@gmail.com']
|
10
10
|
|
11
11
|
spec.summary = 'Simple wrapper for admitad api'
|
12
12
|
spec.description = 'This interface helps you to create applications for Admitad affiliate network.
|
data/bin/console
CHANGED
data/bin/setup
CHANGED
data/lib/admitad.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
require 'virtus'
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
require_relative 'admitad/config'
|
3
|
+
require_relative 'admitad/version'
|
4
|
+
require_relative 'admitad/constants'
|
5
|
+
require_relative 'admitad/models/result'
|
6
6
|
|
7
7
|
Dir[File.join(__dir__, 'admitad', 'models', '*.rb')].map(&method(:require))
|
8
|
-
Dir[File.join(__dir__, 'admitad', '*.rb')].map(&method(:require))
|
8
|
+
Dir[File.join(__dir__, 'admitad', '**', '*.rb')].map(&method(:require))
|
9
9
|
|
10
10
|
module Admitad
|
11
11
|
def configuration
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Admitad
|
2
|
+
module Wrappers
|
3
|
+
module Actions
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
class << self
|
8
|
+
delegate :action_statistic, to: :instance
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def action_statistic(**params)
|
13
|
+
verifying_token do
|
14
|
+
client.statistics_actions(params)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Admitad
|
2
|
+
module Wrappers
|
3
|
+
module AdSpaces
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
class << self
|
8
|
+
delegate :ad_spaces_where, :find_ad_space_by_id, to: :instance
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def ad_spaces_where(**params)
|
13
|
+
verifying_token do
|
14
|
+
client.websites(params)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def find_ad_space_by_id(id, **params)
|
19
|
+
verifying_token do
|
20
|
+
client.websites(params.merge(id: id))
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Admitad
|
2
|
+
module Wrappers
|
3
|
+
module AffiliatePrograms
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
class << self
|
8
|
+
delegate :affiliate_programs_where, :affiliate_programs_for_ad_space,
|
9
|
+
:connect_affiliate_program, :disconnect_affiliate_program,
|
10
|
+
to: :instance
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def affiliate_programs_where(**params)
|
15
|
+
verifying_token do
|
16
|
+
client.advcampaigns(params)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def affiliate_programs_for_ad_space(ad_space, **params)
|
21
|
+
id = ad_space.try(:id) || ad_space
|
22
|
+
verifying_token do
|
23
|
+
client.advcampaigns_website(params.merge(w_id: id))
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def connect_affiliate_program(ad_space, affiliate_program)
|
28
|
+
w_id = ad_space.try(:id) || ad_space
|
29
|
+
c_id = affiliate_program.try(:id) || affiliate_program
|
30
|
+
verifying_token do
|
31
|
+
client.advcampaigns_attach(w_id: w_id, c_id: c_id)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def disconnect_affiliate_program(ad_space, affiliate_program)
|
36
|
+
w_id = ad_space.try(:id) || ad_space
|
37
|
+
c_id = affiliate_program.try(:id) || affiliate_program
|
38
|
+
verifying_token do
|
39
|
+
client.advcampaigns_detach(w_id: w_id, c_id: c_id)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Admitad
|
2
|
+
module Wrappers
|
3
|
+
module Categories
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
class << self
|
8
|
+
delegate :categories, to: :instance
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def categories(**params)
|
13
|
+
verifying_token do
|
14
|
+
client.categories(params)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Admitad
|
2
|
+
module Wrappers
|
3
|
+
module Coupons
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
class << self
|
8
|
+
delegate :coupon_categories, :coupons, :find_coupon,
|
9
|
+
:find_coupon_for_website, :coupons_for_website,
|
10
|
+
to: :instance
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def coupons(**params)
|
15
|
+
verifying_token do
|
16
|
+
client.coupons(params)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def find_coupon(id)
|
21
|
+
verifying_token do
|
22
|
+
client.coupons(id: id)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def coupon_categories(**params)
|
27
|
+
verifying_token do
|
28
|
+
client.coupons_categories(params)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def find_coupon_for_website(id, **params)
|
33
|
+
verifying_token do
|
34
|
+
client.coupons_website(params.merge(c_id: id))
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def coupons_for_website(**params)
|
39
|
+
verifying_token do
|
40
|
+
client.coupons_website(params)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Admitad
|
2
|
+
module Wrappers
|
3
|
+
module Currencies
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
class << self
|
8
|
+
delegate :currencies, :currencies_rate, to: :instance
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def currencies(**params)
|
13
|
+
verifying_token do
|
14
|
+
client.currencies(params)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def currencies_rate(**params)
|
19
|
+
verifying_token do
|
20
|
+
client.currencies_rate(params)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Admitad
|
2
|
+
module Wrappers
|
3
|
+
module Deeplinks
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
class << self
|
8
|
+
delegate :generate_deeplink, to: :instance
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def generate_deeplink(**params)
|
13
|
+
verifying_token do
|
14
|
+
client.deeplink(params)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Admitad
|
2
|
+
module Wrappers
|
3
|
+
module Regions
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
class << self
|
8
|
+
delegate :regions, to: :instance
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def regions(**params)
|
13
|
+
verifying_token do
|
14
|
+
client.websites_regions(params)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/admitad/version.rb
CHANGED
data/lib/admitad/wrapper.rb
CHANGED
@@ -1,130 +1,41 @@
|
|
1
1
|
module Admitad
|
2
2
|
class Wrapper
|
3
3
|
include Singleton
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
def initialize
|
14
|
-
@client = Client.new
|
15
|
-
@token = create_token
|
16
|
-
assign_token
|
17
|
-
end
|
18
|
-
|
19
|
-
def coupons(**params)
|
20
|
-
check_token
|
21
|
-
client.coupons(params)
|
22
|
-
end
|
23
|
-
|
24
|
-
def find_coupon(id)
|
25
|
-
check_token
|
26
|
-
client.coupons(id: id)
|
27
|
-
end
|
28
|
-
|
29
|
-
def coupon_categories(**params)
|
30
|
-
check_token
|
31
|
-
client.coupons_categories(params)
|
32
|
-
end
|
33
|
-
|
34
|
-
def find_coupon_for_website(id, **params)
|
35
|
-
check_token
|
36
|
-
client.coupons_website(params.merge(c_id: id))
|
37
|
-
end
|
38
|
-
|
39
|
-
def coupons_for_website(**params)
|
40
|
-
check_token
|
41
|
-
client.coupons_website(params)
|
42
|
-
end
|
43
|
-
|
44
|
-
def action_statistic(**params)
|
45
|
-
check_token
|
46
|
-
client.statistics_actions(params)
|
47
|
-
end
|
48
|
-
|
49
|
-
def generate_deeplink(**params)
|
50
|
-
check_token
|
51
|
-
client.deeplink(params)
|
52
|
-
end
|
53
|
-
|
54
|
-
def regions(**params)
|
55
|
-
check_token
|
56
|
-
client.websites_regions(params)
|
57
|
-
end
|
4
|
+
include Wrappers::Coupons
|
5
|
+
include Wrappers::Deeplinks
|
6
|
+
include Wrappers::Regions
|
7
|
+
include Wrappers::Actions
|
8
|
+
include Wrappers::Categories
|
9
|
+
include Wrappers::AdSpaces
|
10
|
+
include Wrappers::Currencies
|
11
|
+
include Wrappers::AffiliatePrograms
|
58
12
|
|
59
|
-
|
60
|
-
check_token
|
61
|
-
client.categories(params)
|
62
|
-
end
|
63
|
-
|
64
|
-
def currencies(**params)
|
65
|
-
check_token
|
66
|
-
client.currencies(params)
|
67
|
-
end
|
68
|
-
|
69
|
-
def currencies_rate(**params)
|
70
|
-
check_token
|
71
|
-
client.currencies_rate(params)
|
72
|
-
end
|
73
|
-
|
74
|
-
def ad_spaces_where(**params)
|
75
|
-
check_token
|
76
|
-
client.websites(params)
|
77
|
-
end
|
78
|
-
|
79
|
-
def find_ad_space_by_id(id, **params)
|
80
|
-
check_token
|
81
|
-
client.websites(params.merge(id: id))
|
82
|
-
end
|
83
|
-
|
84
|
-
def affiliate_programs_where(**params)
|
85
|
-
check_token
|
86
|
-
client.advcampaigns(params)
|
87
|
-
end
|
88
|
-
|
89
|
-
def affiliate_programs_for_ad_space(ad_space, **params)
|
90
|
-
check_token
|
91
|
-
id = ad_space.try(:id) || ad_space
|
92
|
-
client.advcampaigns_website(params.merge(w_id: id))
|
93
|
-
end
|
94
|
-
|
95
|
-
def connect_affiliate_program(ad_space, affiliate_program)
|
96
|
-
check_token
|
97
|
-
w_id = ad_space.try(:id) || ad_space
|
98
|
-
c_id = affiliate_program.try(:id) || affiliate_program
|
99
|
-
client.advcampaigns_attach(w_id: w_id, c_id: c_id)
|
100
|
-
end
|
13
|
+
private
|
101
14
|
|
102
|
-
def
|
103
|
-
|
104
|
-
w_id = ad_space.try(:id) || ad_space
|
105
|
-
c_id = affiliate_program.try(:id) || affiliate_program
|
106
|
-
client.advcampaigns_detach(w_id: w_id, c_id: c_id)
|
15
|
+
def initialize
|
16
|
+
create_token
|
107
17
|
end
|
108
18
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
return if token&.success? && !token.expired?
|
19
|
+
def verifying_token
|
20
|
+
return token.attributes.stringify_keys if token.error?
|
21
|
+
return yield unless token.expired?
|
113
22
|
|
114
|
-
|
115
|
-
|
23
|
+
refresh_token
|
24
|
+
verifying_token { yield }
|
116
25
|
end
|
117
26
|
|
118
|
-
def
|
27
|
+
def create_client
|
119
28
|
@client = Client.new(token.try(:access_token))
|
120
29
|
end
|
121
30
|
|
122
31
|
def create_token
|
123
|
-
Token.create(
|
32
|
+
@token = Token.create(Client.new.token(grant_type: :client_credentials))
|
33
|
+
create_client
|
124
34
|
end
|
125
35
|
|
126
36
|
def refresh_token
|
127
|
-
Token.create(client.token(grant_type: :refresh_token, refresh_token: token.refresh_token))
|
37
|
+
@token = Token.create(client.token(grant_type: :refresh_token, refresh_token: token.refresh_token))
|
38
|
+
create_client
|
128
39
|
end
|
129
40
|
|
130
41
|
attr_reader :client, :token
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: admitad
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- alexandr-senyuk
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -133,7 +133,7 @@ description: |-
|
|
133
133
|
You can build up applications to analyze your own statistics and accounting records or
|
134
134
|
to put them up for sale in the Admitad App Store.
|
135
135
|
email:
|
136
|
-
-
|
136
|
+
- a.senyuk.io@gmail.com
|
137
137
|
executables: []
|
138
138
|
extensions: []
|
139
139
|
extra_rdoc_files: []
|
@@ -152,6 +152,14 @@ files:
|
|
152
152
|
- bin/setup
|
153
153
|
- lib/admitad.rb
|
154
154
|
- lib/admitad/client.rb
|
155
|
+
- lib/admitad/concerns/wrappers/actions.rb
|
156
|
+
- lib/admitad/concerns/wrappers/ad_spaces.rb
|
157
|
+
- lib/admitad/concerns/wrappers/affiliate_programs.rb
|
158
|
+
- lib/admitad/concerns/wrappers/categories.rb
|
159
|
+
- lib/admitad/concerns/wrappers/coupons.rb
|
160
|
+
- lib/admitad/concerns/wrappers/currencies.rb
|
161
|
+
- lib/admitad/concerns/wrappers/deeplinks.rb
|
162
|
+
- lib/admitad/concerns/wrappers/regions.rb
|
155
163
|
- lib/admitad/config.rb
|
156
164
|
- lib/admitad/constants.rb
|
157
165
|
- lib/admitad/models/actions_response.rb
|
@@ -187,8 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
187
195
|
- !ruby/object:Gem::Version
|
188
196
|
version: '0'
|
189
197
|
requirements: []
|
190
|
-
|
191
|
-
rubygems_version: 2.7.6
|
198
|
+
rubygems_version: 3.0.1
|
192
199
|
signing_key:
|
193
200
|
specification_version: 4
|
194
201
|
summary: Simple wrapper for admitad api
|