soapy_cake 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0107652f9476d98d7948231f30c2483dcc060807
4
- data.tar.gz: 26a0fc8182bb68f1178fd9a821786272132fe2ce
3
+ metadata.gz: 30ab4d58dc592b76ef9f222cd5af99dd196779e2
4
+ data.tar.gz: 150b73a83a589c38b0f993a976604940c510d09e
5
5
  SHA512:
6
- metadata.gz: aec19e1e56835808f384f4dae6e8f14dd8a1570687d19e5d5b330dd6b7293e3b2b7f0cc59d6297101ce04c20d4cdbc05842223e13367b0f8d4c570e8411ed32b
7
- data.tar.gz: eebba180198ac7a1074a9c5568da4cfdd357f689461c769f3a77bdadad4633a70f944540aa68e3344d5b9757b8528122af74685f0e09aa83514349fb40559fea
6
+ metadata.gz: 8fe7cdc3926b6eaaeb41a6ee1a3b13f542c96c814b28408aae5013bb2cb96c138e48b4dc11242c057cd8d9feb2dee47ee6813bc092485e97c31e0720636f6913
7
+ data.tar.gz: 44da349ae941c4ce26efd61abd5669c0d2abbecc8c4d73013e9b57a4cdac44242c344b83239163f0b3d8933af1e4f848bf150c03b5ada3a35832bf26e03de166
@@ -91,5 +91,9 @@ module SoapyCake
91
91
  def affiliate_signup(opts = {})
92
92
  run Request.new(:admin, :signup, :affiliate, opts)
93
93
  end
94
+
95
+ def verticals(*)
96
+ run Request.new(:admin, :get, :verticals, {})
97
+ end
94
98
  end
95
99
  end
@@ -33,7 +33,9 @@ module SoapyCake
33
33
  def update_caps(opts = {})
34
34
  require_params(opts, %i(cap_type_id cap_interval_id cap_amount send_alert_only))
35
35
 
36
- opts[:cap_amount] = -1 if opts[:cap_interval_id] == Const::CAP_INTERVAL_DISABLED
36
+ translate_values!(opts, %i(cap_type_id cap_interval_id))
37
+
38
+ opts[:cap_amount] = -1 if opts[:cap_interval_id] == const_lookup(:cap_interval_id, :disabled)
37
39
 
38
40
  run Request.new(:admin, :addedit, :caps, opts)
39
41
  end
@@ -46,11 +48,26 @@ module SoapyCake
46
48
  add_edit_option: 'add'
47
49
  )
48
50
 
51
+ opts[:status_id] = const_lookup(:offer_status_id, opts[:status_id]) if opts.key?(:status_id)
52
+ translate_values!(opts, %i(price_format_id))
53
+
49
54
  run Request.new(:admin, :addedit, :offer_tiers, opts)
50
55
  end
51
56
 
52
57
  private
53
58
 
59
+ def translate_values!(opts, params)
60
+ params.each do |type|
61
+ opts[type] = const_lookup(type, opts[type]) if opts.key?(type)
62
+ end
63
+ end
64
+
65
+ def const_lookup(type, key)
66
+ Const::CONSTS[type].fetch(key) do
67
+ fail ArgumentError, "#{key} is not a valid value for #{type}"
68
+ end
69
+ end
70
+
54
71
  def addedit_offer(opts)
55
72
  require_params(opts, %i(
56
73
  advertiser_id vertical_id postback_url_ms_delay offer_contract_hidden
@@ -61,6 +78,8 @@ module SoapyCake
61
78
  opts[k] = 'off' if v == false
62
79
  end
63
80
 
81
+ translate_values!(opts, %i(currency_id offer_status_id offer_type_id price_format_id))
82
+
64
83
  opts.reverse_merge!(
65
84
  offer_name: '',
66
85
  third_party_name: '',
@@ -81,8 +100,8 @@ module SoapyCake
81
100
  postback_url: '',
82
101
  fire_global_pixel: 'no_change',
83
102
  fire_pixel_on_nonpaid_conversions: 'no_change',
84
- conversion_cap_behavior: Const::CONVERSION_BEHAVIOR_SYSTEM,
85
- conversion_behavior_on_redirect: Const::CONVERSION_BEHAVIOR_SYSTEM,
103
+ conversion_cap_behavior: const_lookup(:conversion_behaviour_id, :system),
104
+ conversion_behavior_on_redirect: const_lookup(:conversion_behaviour_id, :system),
86
105
  expiration_date: Date.today + (365 * 100),
87
106
  expiration_date_modification_type: 'do_not_change',
88
107
  offer_contract_name: '',
@@ -109,6 +128,8 @@ module SoapyCake
109
128
  received_percentage offer_link thankyou_link offer_contract_hidden
110
129
  offer_contract_is_default use_fallback_targeting))
111
130
 
131
+ translate_values!(opts, %i(price_format_id))
132
+
112
133
  run Request.new(:admin, :addedit, :offer_contract, opts)
113
134
  end
114
135
  end
@@ -1,39 +1,49 @@
1
1
  module SoapyCake
2
2
  module Const
3
- OFFER_STATUS_PUBLIC = 1
4
- OFFER_STATUS_PRIVATE = 2
5
- OFFER_STATUS_APPLY_TO_RUN = 3
6
- OFFER_STATUS_INACTIVE = 4
7
-
8
- OFFER_TYPE_HOSTED = 1
9
- OFFER_TYPE_HOST_N_POST = 2
10
- OFFER_TYPE_3RD_PARTY = 3
11
-
12
- CURRENCY_USD = 1
13
- CURRENCY_EUR = 2
14
- CURRENCY_GBD = 3
15
- CURRENCY_AUD = 4
16
- CURRENCY_CAD = 5
17
-
18
- PRICE_FORMAT_CPA = 1
19
- PRICE_FORMAT_CPC = 2
20
- PRICE_FORMAT_CPM = 3
21
- PRICE_FORMAT_FIXED = 4
22
- PRICE_FORMAT_REVSHARE = 5
23
-
24
- CONVERSION_BEHAVIOR_SYSTEM = 0
25
- CONVERSION_BEHAVIOR_ADV_AFF = 1
26
- CONVERSION_BEHAVIOR_ADV_NO_AFF = 2
27
- CONVERSION_BEHAVIOR_IGNORE = 3
28
- CONVERSION_BEHAVIOR_NO_ADV_AFF = 4
29
- CONVERSION_BEHAVIOR_NO_ADV_NO_AFF = 5
30
-
31
- CAP_TYPE_CLICK = 1
32
- CAP_TYPE_CONVERSION = 2
33
-
34
- CAP_INTERVAL_DISABLED = 0
35
- CAP_INTERVAL_DAILY = 1
36
- CAP_INTERVAL_WEEKLY = 2
37
- CAP_INTERVAL_MONTHLY = 3
3
+ CONSTS = {
4
+ offer_status_id: {
5
+ public: 1,
6
+ private: 2,
7
+ apply_to_run: 3,
8
+ inactive: 4,
9
+ },
10
+ offer_type_id: {
11
+ hosted: 1,
12
+ host_n_post: 2,
13
+ third_party: 3,
14
+ },
15
+ currency_id: {
16
+ usd: 1,
17
+ eur: 2,
18
+ gbd: 3,
19
+ aud: 4,
20
+ cad: 5,
21
+ },
22
+ price_format_id: {
23
+ cpa: 1,
24
+ cpc: 2,
25
+ cpm: 3,
26
+ fixed: 4,
27
+ revshare: 5,
28
+ },
29
+ conversion_behaviour_id: {
30
+ system: 0,
31
+ adv_off: 1,
32
+ adv_no_aff: 2,
33
+ ignore: 3,
34
+ no_adv_aff: 4,
35
+ no_adv_no_aff: 5,
36
+ },
37
+ cap_type_id: {
38
+ click: 1,
39
+ conversion: 2,
40
+ },
41
+ cap_interval_id: {
42
+ disabled: 0,
43
+ daily: 1,
44
+ weekly: 2,
45
+ monthly: 3,
46
+ }
47
+ }
38
48
  end
39
49
  end
@@ -1,3 +1,3 @@
1
1
  module SoapyCake
2
- VERSION = '1.2.0'
2
+ VERSION = '1.3.0'
3
3
  end
@@ -13,9 +13,9 @@ RSpec.describe 'ADDEDIT integration test' do
13
13
  it 'creates an offer', :vcr do
14
14
  result = subject.add_offer(
15
15
  hidden: false,
16
- offer_status_id: SoapyCake::Const::OFFER_STATUS_PUBLIC,
17
- offer_type_id: SoapyCake::Const::OFFER_TYPE_3RD_PARTY,
18
- currency_id: SoapyCake::Const::CURRENCY_EUR,
16
+ offer_status_id: :public,
17
+ offer_type_id: :third_party,
18
+ currency_id: :eur,
19
19
  ssl: false,
20
20
  click_cookie_days: 30,
21
21
  impression_cookie_days: 30,
@@ -37,7 +37,7 @@ RSpec.describe 'ADDEDIT integration test' do
37
37
  vertical_id: vertical_id,
38
38
  postback_url_ms_delay: 60,
39
39
  offer_contract_hidden: false,
40
- price_format_id: SoapyCake::Const::PRICE_FORMAT_CPA,
40
+ price_format_id: :cpa,
41
41
  received: 2.0,
42
42
  received_percentage: false,
43
43
  payout: 1.5,
@@ -65,7 +65,7 @@ RSpec.describe 'ADDEDIT integration test' do
65
65
  vertical_id: vertical_id,
66
66
  postback_url_ms_delay: 50,
67
67
  offer_contract_hidden: false,
68
- price_format_id: SoapyCake::Const::PRICE_FORMAT_CPA,
68
+ price_format_id: :cpa,
69
69
  received: 2.0,
70
70
  received_percentage: false,
71
71
  payout: 1.5,
@@ -95,7 +95,7 @@ RSpec.describe 'ADDEDIT integration test' do
95
95
  result = subject.add_offer_contract(
96
96
  offer_id: offer_id,
97
97
  offer_contract_name: 'Test Contract',
98
- price_format_id: SoapyCake::Const::PRICE_FORMAT_CPA,
98
+ price_format_id: :cpa,
99
99
  received: 3.2,
100
100
  received_percentage: false,
101
101
  payout: 2.5,
@@ -114,7 +114,7 @@ RSpec.describe 'ADDEDIT integration test' do
114
114
  offer_id: offer_id,
115
115
  offer_contract_id: offer_contract_id,
116
116
  offer_contract_name: 'Test Contract',
117
- price_format_id: SoapyCake::Const::PRICE_FORMAT_CPA,
117
+ price_format_id: :cpa,
118
118
  received: 3.2,
119
119
  received_percentage: false,
120
120
  payout: 2.5,
@@ -147,8 +147,8 @@ RSpec.describe 'ADDEDIT integration test' do
147
147
  it 'updates a cap for an offer contract', :vcr do
148
148
  result = subject.update_caps(
149
149
  offer_contract_id: offer_contract_id,
150
- cap_type_id: SoapyCake::Const::CAP_TYPE_CONVERSION,
151
- cap_interval_id: SoapyCake::Const::CAP_INTERVAL_DAILY,
150
+ cap_type_id: :conversion,
151
+ cap_interval_id: :daily,
152
152
  cap_amount: 42,
153
153
  send_alert_only: false
154
154
  )
@@ -159,8 +159,8 @@ RSpec.describe 'ADDEDIT integration test' do
159
159
  it 'removes a cap for an offer contract', :vcr do
160
160
  result = subject.update_caps(
161
161
  offer_contract_id: offer_contract_id,
162
- cap_type_id: SoapyCake::Const::CAP_TYPE_CONVERSION,
163
- cap_interval_id: SoapyCake::Const::CAP_INTERVAL_DISABLED,
162
+ cap_type_id: :conversion,
163
+ cap_interval_id: :disabled,
164
164
  cap_amount: 42,
165
165
  send_alert_only: false
166
166
  )
@@ -175,8 +175,8 @@ RSpec.describe 'ADDEDIT integration test' do
175
175
  offer_id: offer_id,
176
176
  offer_contract_id: offer_contract_id,
177
177
  tier_id: tier_id,
178
- price_format_id: SoapyCake::Const::PRICE_FORMAT_CPA,
179
- status_id: SoapyCake::Const::OFFER_STATUS_PUBLIC
178
+ price_format_id: :cpa,
179
+ status_id: :public
180
180
  )
181
181
 
182
182
  expect(result[:message]).to eq('Offer Tier Added')
@@ -125,6 +125,12 @@ RSpec.describe SoapyCake::Admin do
125
125
  describe 'get service' do
126
126
  let(:service) { :get }
127
127
 
128
+ describe '#verticals' do
129
+ let(:method) { :verticals }
130
+ let(:cake_opts) { {} }
131
+ it_behaves_like 'a cake admin method'
132
+ end
133
+
128
134
  describe '#currencies' do
129
135
  let(:method) { :currencies }
130
136
  let(:cake_opts) { {} }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: soapy_cake
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ad2games GmbH
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-18 00:00:00.000000000 Z
11
+ date: 2015-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport