soapy_cake 0.3.4 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +1 -0
- data/api_versions.yml +110 -110
- data/lib/soapy_cake.rb +10 -2
- data/lib/soapy_cake/admin.rb +34 -46
- data/lib/soapy_cake/affiliate.rb +5 -17
- data/lib/soapy_cake/client.rb +33 -3
- data/lib/soapy_cake/error.rb +4 -0
- data/lib/soapy_cake/helper.rb +16 -0
- data/lib/soapy_cake/request.rb +61 -0
- data/lib/soapy_cake/response.rb +48 -0
- data/lib/soapy_cake/version.rb +1 -1
- data/soapy_cake.gemspec +4 -4
- data/spec/fixtures/vcr_cassettes/Integration_test/raises_if_there_is_an_error.yml +50 -0
- data/spec/fixtures/vcr_cassettes/Integration_test/returns_an_affiliate_with_correct_data_types.yml +114 -0
- data/spec/lib/soapy_cake/admin_spec.rb +87 -199
- data/spec/lib/soapy_cake/affiliate_spec.rb +19 -39
- data/spec/lib/soapy_cake/integration_spec.rb +25 -0
- data/spec/spec_helper.rb +2 -0
- metadata +14 -55
- data/lib/soapy_cake/advertiser.rb +0 -21
- data/lib/soapy_cake/client/cake_client.rb +0 -157
- data/lib/soapy_cake/client/http_client.rb +0 -14
- data/spec/fixtures/vcr_cassettes/client_new_account_statuses.yml +0 -1200
- data/spec/fixtures/vcr_cassettes/client_new_advertisers.yml +0 -1202
- data/spec/fixtures/vcr_cassettes/client_new_affiliate_tags.yml +0 -1200
- data/spec/fixtures/vcr_cassettes/client_new_affiliate_tiers.yml +0 -1201
- data/spec/fixtures/vcr_cassettes/client_new_billing_cycles.yml +0 -1200
- data/spec/fixtures/vcr_cassettes/client_new_cap_intervals.yml +0 -1201
- data/spec/fixtures/vcr_cassettes/client_new_cap_types.yml +0 -1199
- data/spec/fixtures/vcr_cassettes/client_new_countries.yml +0 -1515
- data/spec/fixtures/vcr_cassettes/client_new_currencies.yml +0 -1199
- data/spec/fixtures/vcr_cassettes/client_new_empty_response.yml +0 -1200
- data/spec/fixtures/vcr_cassettes/client_new_empty_response_offer_summary.yml +0 -865
- data/spec/fixtures/vcr_cassettes/client_new_languages.yml +0 -1199
- data/spec/fixtures/vcr_cassettes/client_new_media_types.yml +0 -1215
- data/spec/fixtures/vcr_cassettes/client_new_offer_statuses.yml +0 -1202
- data/spec/fixtures/vcr_cassettes/client_new_offer_types.yml +0 -1201
- data/spec/fixtures/vcr_cassettes/client_new_payment_settings.yml +0 -1203
- data/spec/fixtures/vcr_cassettes/client_new_payment_types.yml +0 -1204
- data/spec/fixtures/vcr_cassettes/client_new_price_formats.yml +0 -1202
- data/spec/fixtures/vcr_cassettes/client_new_roles.yml +0 -1203
- data/spec/fixtures/vcr_cassettes/client_new_verticals.yml +0 -1197
- data/spec/fixtures/vcr_cassettes/client_new_with_username_and_password.yml +0 -1198
- data/spec/fixtures/vcr_cassettes/client_sekken_client_caches_results.yml +0 -1261
- data/spec/lib/soapy_cake/advertiser_spec.rb +0 -14
- data/spec/lib/soapy_cake/client/cake_client_spec.rb +0 -197
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b6f7d62babdfc4fc4fe15e18b73cddf9438950f6
|
4
|
+
data.tar.gz: ebb81a5b7ebc9605520231f04bc2bc84f9ba552e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 106f6be2db7835ead031a090cbce6a241451a8907af245347cb964d70d3000341d1c7447864c97ce6aee26d9e57c967c9a80a62ddb22fec468a678cfe7e05cc0
|
7
|
+
data.tar.gz: 87ecc1739c0b32da04b2c2da8b4990193f9624c013d0f234180817ab069d34f7b0eeaa383d65bf4d91e12a2f95867a6dd658113f7fd95b306e3ea72c13669e97
|
data/.rspec
CHANGED
data/api_versions.yml
CHANGED
@@ -1,111 +1,111 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
2
|
+
admin:
|
3
|
+
accounting:
|
4
|
+
mark_affiliate_bill_as_received: 1
|
5
|
+
export_advertiser_bills: 1
|
6
|
+
export_affiliate_bills: 1
|
7
|
+
mark_affiliate_bill_as_paid: 1
|
8
|
+
add:
|
9
|
+
advertiser_credit: 1
|
10
|
+
creative: 1
|
11
|
+
manual_credit: 1
|
12
|
+
addedit:
|
13
|
+
advertiser: 1
|
14
|
+
advertiser_credit_limit: 1
|
15
|
+
affiliate: 2
|
16
|
+
apply_suppression_list_to_offer: 1
|
17
|
+
campaign: 2
|
18
|
+
caps: 1
|
19
|
+
contact: 1
|
20
|
+
creative: 1
|
21
|
+
creative_files: 1
|
22
|
+
exchange_rates: 1
|
23
|
+
geo_targets: 1
|
24
|
+
offer: 4
|
25
|
+
offer_contract: 1
|
26
|
+
suppresion_list: 1
|
27
|
+
vertical: 1
|
28
|
+
auth:
|
29
|
+
login: 2
|
30
|
+
doc:
|
31
|
+
posting_doc: 1
|
32
|
+
edit:
|
33
|
+
buyer: 1
|
34
|
+
export:
|
35
|
+
advertisers: 5
|
36
|
+
affiliate_referrals: 1
|
37
|
+
affiliates: 5
|
38
|
+
buyer_contracts: 1
|
39
|
+
buyers: 1
|
40
|
+
campaigns: 6
|
41
|
+
creatives: 3
|
42
|
+
offers: 5
|
43
|
+
rules_targets: 3
|
44
|
+
schedules: 1
|
45
|
+
get:
|
46
|
+
account_statuses: 1
|
47
|
+
advertisers: 1
|
48
|
+
affiliate_tags: 1
|
49
|
+
affiliate_tiers: 1
|
50
|
+
billing_cycles: 1
|
51
|
+
cap_intervals: 1
|
52
|
+
cap_types: 1
|
53
|
+
countries: 1
|
54
|
+
currencies: 1
|
55
|
+
departments: 1
|
56
|
+
exchange_rates: 1
|
57
|
+
get_api_key: 1
|
58
|
+
inactive_reasons: 1
|
59
|
+
languages: 1
|
60
|
+
offer_statuses: 1
|
61
|
+
offer_types: 1
|
62
|
+
payment_settings: 1
|
63
|
+
payment_types: 1
|
64
|
+
price_formats: 1
|
65
|
+
roles: 1
|
66
|
+
tracking_domains: 1
|
67
|
+
verticals: 2
|
68
|
+
reports:
|
69
|
+
advertiser_summary: 2
|
70
|
+
affiliate_summary: 2
|
71
|
+
campaign_summary: 2
|
72
|
+
creative_summary: 2
|
73
|
+
caps: 4
|
74
|
+
clicks: 7
|
75
|
+
conversion_changes: 10
|
76
|
+
conversions: 11
|
77
|
+
daily_summary_export: 1
|
78
|
+
leads_by_affiliate_export: 1
|
79
|
+
leads_by_buyer: 4
|
80
|
+
login_export: 1
|
81
|
+
offer_summary: 2
|
82
|
+
traffic_export: 1
|
83
|
+
signup:
|
84
|
+
advertiser: 1
|
85
|
+
affiliate: 4
|
86
|
+
get_media_types: 1
|
87
|
+
get_price_formats: 1
|
88
|
+
get_traffic_types: 1
|
89
|
+
get_vertical_categories: 1
|
90
|
+
track:
|
91
|
+
accepted_dispositions: 1
|
92
|
+
conversion_dispositions: 2
|
93
|
+
decrypt_affiliate_link: 1
|
94
|
+
mass_conversion_adjustment: 2
|
95
|
+
mass_conversion_insert: 2
|
96
|
+
rejected_dispositions: 1
|
97
|
+
update_conversion: 2
|
98
|
+
update_conversion_disposition: 2
|
99
|
+
update_conversion_price: 2
|
100
|
+
update_conversion_revenue: 1
|
101
|
+
update_lead_price: 2
|
102
|
+
update_sale_revenue: 1
|
103
|
+
advertisers:
|
104
|
+
reports:
|
105
|
+
bills: 1
|
106
|
+
affiliates:
|
107
|
+
reports:
|
108
|
+
bills: 3
|
109
|
+
offers:
|
110
|
+
offer_feed: 4
|
111
|
+
get_campaign: 2
|
data/lib/soapy_cake.rb
CHANGED
@@ -1,9 +1,17 @@
|
|
1
|
-
require '
|
1
|
+
require 'nokogiri'
|
2
|
+
require 'saxerator'
|
3
|
+
require 'httparty'
|
2
4
|
require 'active_support/core_ext/date'
|
5
|
+
require 'active_support/core_ext/numeric/time'
|
6
|
+
require 'active_support/core_ext/time/zones'
|
7
|
+
|
3
8
|
require 'soapy_cake/version'
|
9
|
+
require 'soapy_cake/helper'
|
10
|
+
require 'soapy_cake/error'
|
11
|
+
require 'soapy_cake/request'
|
12
|
+
require 'soapy_cake/response'
|
4
13
|
require 'soapy_cake/client'
|
5
14
|
require 'soapy_cake/admin'
|
6
|
-
require 'soapy_cake/advertiser'
|
7
15
|
require 'soapy_cake/affiliate'
|
8
16
|
|
9
17
|
module SoapyCake
|
data/lib/soapy_cake/admin.rb
CHANGED
@@ -1,91 +1,79 @@
|
|
1
1
|
module SoapyCake
|
2
|
-
class Admin
|
3
|
-
def initialize(_opts = {})
|
4
|
-
end
|
5
|
-
|
2
|
+
class Admin < Client
|
6
3
|
def affiliate_bills(opts = {})
|
7
|
-
|
4
|
+
run Request.new(:admin, :accounting, :export_affiliate_bills, opts)
|
8
5
|
end
|
9
6
|
|
10
7
|
def advertiser_bills(opts = {})
|
11
|
-
|
8
|
+
run Request.new(:admin, :accounting, :export_advertiser_bills, opts)
|
9
|
+
end
|
10
|
+
|
11
|
+
def mark_affiliate_bill_as_received(opts = {})
|
12
|
+
run Request.new(:admin, :accounting, :mark_affiliate_bill_as_received, opts)
|
12
13
|
end
|
13
14
|
|
14
|
-
def
|
15
|
-
|
15
|
+
def mark_affiliate_bill_as_paid(opts = {})
|
16
|
+
run Request.new(:admin, :accounting, :mark_affiliate_bill_as_paid, opts)
|
16
17
|
end
|
17
18
|
|
18
19
|
def advertisers(opts = {})
|
19
|
-
|
20
|
+
run Request.new(:admin, :export, :advertisers, opts)
|
20
21
|
end
|
21
22
|
|
22
23
|
def affiliates(opts = {})
|
23
|
-
|
24
|
+
run Request.new(:admin, :export, :affiliates, opts)
|
24
25
|
end
|
25
26
|
|
26
27
|
def campaigns(opts = {})
|
27
|
-
|
28
|
+
run Request.new(:admin, :export, :campaigns, opts)
|
28
29
|
end
|
29
30
|
|
30
31
|
def offers(opts = {})
|
31
|
-
|
32
|
+
run Request.new(:admin, :export, :offers, opts)
|
32
33
|
end
|
33
34
|
|
34
|
-
def
|
35
|
-
|
35
|
+
def creatives(opts = {})
|
36
|
+
run Request.new(:admin, :export, :creatives, opts)
|
36
37
|
end
|
37
38
|
|
38
|
-
def
|
39
|
-
|
39
|
+
def campaign_summary(opts = {})
|
40
|
+
run Request.new(:admin, :reports, :campaign_summary, opts)
|
40
41
|
end
|
41
42
|
|
42
|
-
def
|
43
|
-
|
43
|
+
def offer_summary(opts = {})
|
44
|
+
run Request.new(:admin, :reports, :offer_summary, opts)
|
44
45
|
end
|
45
46
|
|
46
|
-
def
|
47
|
-
|
47
|
+
def affiliate_summary(opts = {})
|
48
|
+
run Request.new(:admin, :reports, :affiliate_summary, opts)
|
48
49
|
end
|
49
50
|
|
50
|
-
def
|
51
|
-
|
51
|
+
def advertiser_summary(opts = {})
|
52
|
+
run Request.new(:admin, :reports, :advertiser_summary, opts)
|
52
53
|
end
|
53
54
|
|
54
|
-
def
|
55
|
-
|
55
|
+
def clicks(opts = {})
|
56
|
+
run Request.new(:admin, :reports, :clicks, opts)
|
56
57
|
end
|
57
58
|
|
58
|
-
def
|
59
|
-
|
59
|
+
def conversions(opts = {})
|
60
|
+
run Request.new(:admin, :reports, :conversions, opts.merge(conversion_type: 'conversions'))
|
60
61
|
end
|
61
62
|
|
62
|
-
def
|
63
|
-
|
63
|
+
def events(opts = {})
|
64
|
+
run Request.new(:admin, :reports, :conversions, opts.merge(conversion_type: 'events'))
|
64
65
|
end
|
65
66
|
|
66
|
-
def
|
67
|
-
|
67
|
+
def traffic(opts = {})
|
68
|
+
run Request.new(:admin, :reports, :traffic_export, opts)
|
68
69
|
end
|
69
70
|
|
70
|
-
def
|
71
|
-
|
71
|
+
def currencies(*)
|
72
|
+
run Request.new(:admin, :get, :currencies, {})
|
72
73
|
end
|
73
74
|
|
74
75
|
def update_creative(opts = {})
|
75
|
-
|
76
|
-
end
|
77
|
-
|
78
|
-
def traffic(opts)
|
79
|
-
Client::CakeClient.reports.traffic_export(opts_with_date_range(opts))
|
80
|
-
end
|
81
|
-
|
82
|
-
private
|
83
|
-
|
84
|
-
def opts_with_date_range(opts)
|
85
|
-
start_date = opts[:start_date].to_date
|
86
|
-
end_date = opts[:end_date] || start_date + 1
|
87
|
-
|
88
|
-
opts.merge(start_date: start_date, end_date: end_date)
|
76
|
+
run Request.new(:admin, :addedit, :creative, opts)
|
89
77
|
end
|
90
78
|
end
|
91
79
|
end
|
data/lib/soapy_cake/affiliate.rb
CHANGED
@@ -1,29 +1,17 @@
|
|
1
1
|
module SoapyCake
|
2
|
-
class Affiliate
|
3
|
-
attr_reader :api_key, :affiliate_id
|
4
|
-
|
5
|
-
def initialize(opts = {})
|
6
|
-
@api_key = opts[:api_key]
|
7
|
-
@affiliate_id = opts[:affiliate_id]
|
8
|
-
end
|
9
|
-
|
2
|
+
class Affiliate < Client
|
10
3
|
def bills(opts = {})
|
11
|
-
|
4
|
+
run Request.new(:affiliate, :reports, :bills, affiliate_opts(opts))
|
12
5
|
end
|
13
6
|
|
14
7
|
def offer_feed(opts = {})
|
15
|
-
|
16
|
-
end
|
17
|
-
|
18
|
-
def campaign(opts = {})
|
19
|
-
cake_client(:offers, :get_campaign, opts)
|
8
|
+
run Request.new(:affiliate, :offers, :offer_feed, affiliate_opts(opts))
|
20
9
|
end
|
21
10
|
|
22
11
|
private
|
23
12
|
|
24
|
-
def
|
25
|
-
|
26
|
-
.send(method, opts.merge(affiliate_id: affiliate_id, api_key: api_key))
|
13
|
+
def affiliate_opts(opts)
|
14
|
+
{ affiliate_id: self.opts[:affiliate_id] }.merge(opts)
|
27
15
|
end
|
28
16
|
end
|
29
17
|
end
|
data/lib/soapy_cake/client.rb
CHANGED
@@ -1,5 +1,35 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
module SoapyCake
|
2
|
+
class Client
|
3
|
+
attr_reader :domain, :api_key, :time_offset
|
3
4
|
|
4
|
-
|
5
|
+
def initialize(opts = {})
|
6
|
+
@domain = opts.fetch(:domain, ENV['CAKE_DOMAIN']) || fail(Error, 'Cake domain missing')
|
7
|
+
@api_key = opts.fetch(:domain, ENV['CAKE_API_KEY']) || fail(Error, 'Cake API key missing')
|
8
|
+
@time_offset = opts.fetch(:time_offset, ENV['CAKE_TIME_OFFSET']) \
|
9
|
+
|| fail(Error, 'Cake time offset missing')
|
10
|
+
@opts = opts
|
11
|
+
end
|
12
|
+
|
13
|
+
protected
|
14
|
+
|
15
|
+
attr_reader :opts
|
16
|
+
|
17
|
+
def run(request)
|
18
|
+
request.api_key = api_key
|
19
|
+
request.time_offset = time_offset
|
20
|
+
|
21
|
+
url = "https://#{domain}#{request.path}"
|
22
|
+
body = HTTParty.post(url, headers: headers, body: request.xml).body
|
23
|
+
|
24
|
+
response = Response.new(body)
|
25
|
+
response.time_offset = time_offset
|
26
|
+
response.collection
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def headers
|
32
|
+
{ 'Content-Type' => 'application/soap+xml;charset=UTF-8' }
|
33
|
+
end
|
34
|
+
end
|
5
35
|
end
|