soapy_cake 2.2.3 → 2.2.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: db53a85a24c32bedc5424cb71fa94299d1b2b656
4
- data.tar.gz: 6ff419a8734b6c665d239c9f277abfce3a6e7d3a
3
+ metadata.gz: 70c84bead32dad291a2969cf47b93f30e7ca08ea
4
+ data.tar.gz: 71bf3ac75e66d776971df47f70e6d955f3034407
5
5
  SHA512:
6
- metadata.gz: e7ef921b6577c7e37f9fc448199f1b832ff556cd9ad63dfc2db1377a66160185eda2669f1067c48a7266155d2190f6f45699fa8c0f42b266981faaf8ff949d91
7
- data.tar.gz: 7be351d763c9cafebd1f500e6a3cf6b3c879e26e821d96e7e701f09ec103a6e798037dca7d87aa5e8157a2a217ff345f7fc8e86693945551a3e157e73c14052a
6
+ metadata.gz: a4ef76954d20b9576ceb510fbcbb015fa750f772ca3719b39bfb41df118b360c0929a8ba1cdf220d89ad6c9685350e23ef0189c35c40f2cfc4513df0d150749b
7
+ data.tar.gz: 79dc72b5b081674155311aaa690e56e567dda81024eb86dadcc3dd786ebed07d43f8955404018e3feae36140fa095eef710448ceb5024c69f3ebf750b1377a56
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.4.1
1
+ 2.4.3
@@ -164,4 +164,5 @@ module SoapyCake
164
164
  Request.new(:admin, :reports, :event_conversions, opts.merge(event_type: event_type))
165
165
  end
166
166
  end
167
+ # rubocop:enable Metrics/ClassLength
167
168
  end
@@ -282,4 +282,5 @@ module SoapyCake
282
282
  run Request.new(:admin, :addedit, :offer_contract, opts)
283
283
  end
284
284
  end
285
+ # rubocop:enable Metrics/ClassLength
285
286
  end
@@ -29,8 +29,17 @@ module SoapyCake
29
29
  request.time_converter = time_converter
30
30
 
31
31
  with_retries do
32
- response = Response.new(response_body(request), request.short_response?, time_converter)
33
- xml_response? ? response.to_xml : response.to_enum
32
+ begin
33
+ response = Response.new(response_body(request), request.short_response?, time_converter)
34
+ xml_response? ? response.to_xml : response.to_enum
35
+ rescue RequestFailed => e
36
+ raise RequestFailed.new(
37
+ e.message,
38
+ request_path: request.path,
39
+ request_body: request.xml,
40
+ response_body: e.response_body || response.body
41
+ )
42
+ end
34
43
  end
35
44
  end
36
45
 
@@ -84,8 +93,6 @@ module SoapyCake
84
93
  unless response.is_a?(Net::HTTPSuccess)
85
94
  raise RequestFailed.new(
86
95
  "Request failed with HTTP #{response.code}",
87
- request_path: request.path,
88
- request_body: http_request.body,
89
96
  response_body: response.body
90
97
  )
91
98
  end
@@ -94,8 +101,12 @@ module SoapyCake
94
101
  end
95
102
 
96
103
  def perform_http_request(http_request)
97
- Net::HTTP.start(domain,
98
- use_ssl: true, open_timeout: NET_TIMEOUT, read_timeout: NET_TIMEOUT) do |http|
104
+ Net::HTTP.start(
105
+ domain,
106
+ use_ssl: true,
107
+ open_timeout: NET_TIMEOUT,
108
+ read_timeout: NET_TIMEOUT
109
+ ) do |http|
99
110
  http.request(http_request)
100
111
  end
101
112
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SoapyCake
4
- VERSION = '2.2.3'
4
+ VERSION = '2.2.4'
5
5
  end
@@ -89,10 +89,8 @@ RSpec.describe SoapyCake::AdminAddedit do
89
89
  thankyou_link: 'http://www.example.com/',
90
90
  from_lines: 'from',
91
91
  subject_lines: 'subject',
92
-
93
92
  conversion_cap_behavior: :ignore,
94
93
  conversion_behavior_on_redirect: :ignore,
95
-
96
94
  advertiser_id: advertiser_id,
97
95
  vertical_id: vertical_id,
98
96
  postback_url_ms_delay: 60,
@@ -101,7 +99,6 @@ RSpec.describe SoapyCake::AdminAddedit do
101
99
  received: 2.0,
102
100
  received_percentage: false,
103
101
  payout: 1.5,
104
-
105
102
  tags: %w[some tags],
106
103
  offer_name: 'Test Offer',
107
104
  offer_description: 'TEST1',
@@ -6,6 +6,7 @@ RSpec.describe SoapyCake::AdminAddedit do
6
6
  before do
7
7
  # rubocop:disable RSpec/SubjectStub
8
8
  allow(admin_addedit).to receive(:run).and_return({})
9
+ # rubocop:enable RSpec/SubjectStub
9
10
  end
10
11
 
11
12
  describe '#edit_offer' do
@@ -148,28 +149,43 @@ RSpec.describe SoapyCake::AdminAddedit do
148
149
 
149
150
  context 'when creative id was passed' do
150
151
  it 'raises an error' do
151
- expect { admin_addedit.create_creative(offer_id: 10, creative_id: 11) }.to raise_error(
152
- 'cannot pass creative_id when creating creative'
153
- )
152
+ expect do
153
+ admin_addedit.create_creative(offer_id: 10, creative_id: 11)
154
+ end.to raise_error('cannot pass creative_id when creating creative')
154
155
  end
155
156
  end
156
157
 
157
158
  context 'when given the right parameters' do
158
159
  it 'creates a creative and adds a file to it' do
159
- expect(admin_addedit).to receive(:addedit_creative).with(
160
- offer_id: 10, creative_name: 'creative_name'
161
- ).and_return(
162
- success: true, message: 'Creative 12163 Created', creative_id: 12163
163
- )
164
- expect(admin_addedit).to receive(:addedit_creative_files).with(
165
- creative_id: 12163, creative_file_import_url: 'http://www.example.org/image.png'
166
- ).and_return(
167
- success: true, message: 'Creative Files 8013 Created.', creative_files: {
168
- creative_file: {
169
- creative_file_id: 8013, creative_file_name: 'image.jpg', updated: false
170
- }
171
- }
172
- )
160
+ expect(SoapyCake::Request)
161
+ .to receive(:new)
162
+ .with(
163
+ :admin,
164
+ :addedit,
165
+ :creative,
166
+ creative_name: 'creative_name',
167
+ creative_status_id: 1,
168
+ creative_type_id: 3,
169
+ height: 0,
170
+ notes: '',
171
+ offer_link: '',
172
+ third_party_name: '',
173
+ width: 0,
174
+ offer_id: 10
175
+ )
176
+ .and_call_original
177
+
178
+ expect(SoapyCake::Request)
179
+ .to receive(:new)
180
+ .with(
181
+ :admin,
182
+ :addedit,
183
+ :creative_files,
184
+ creative_file_import_url: 'http://www.example.org/image.png',
185
+ creative_id: nil
186
+ )
187
+ .and_call_original
188
+
173
189
  admin_addedit.create_creative(
174
190
  offer_id: 10,
175
191
  creative_name: 'creative_name',
@@ -14,6 +14,7 @@ RSpec.describe SoapyCake::Affiliate do
14
14
  .with(:affiliate, service, method, cake_opts).and_return(request)
15
15
  # rubocop:disable RSpec/SubjectStub
16
16
  expect(affiliate).to receive(:run).with(request)
17
+ # rubocop:enable RSpec/SubjectStub
17
18
 
18
19
  affiliate.public_send(method, opts)
19
20
  end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.describe SoapyCake::Client do
4
+ subject(:client) { described_class.new }
5
+
6
+ let(:http) do
7
+ instance_double(Net::HTTP)
8
+ end
9
+
10
+ let(:request) do
11
+ SoapyCake::Request.new(:admin, :addedit, :advertiser, {})
12
+ end
13
+
14
+ describe '#run' do
15
+ context 'receives non-200 HTTP status code' do
16
+ before do
17
+ stub_request(:post, "https://#{ENV.fetch('CAKE_DOMAIN')}/api/1/addedit.asmx")
18
+ .to_return(status: 500, body: '🔥')
19
+ end
20
+
21
+ it 'raises an exception with request information' do
22
+ expect do
23
+ client.run(request)
24
+ end.to raise_error(SoapyCake::RequestFailed, 'Request failed with HTTP 500') do |e|
25
+ expect(e.request_path).to eq('/api/1/addedit.asmx')
26
+ expect(e.request_body).to include('<cake:api_key>[redacted]</cake:api_key>')
27
+ expect(e.response_body).to eq('🔥')
28
+ end
29
+ end
30
+ end
31
+
32
+ context 'receives 200 HTTP status code with errors' do
33
+ before do
34
+ stub_request(:post, "https://#{ENV.fetch('CAKE_DOMAIN')}/api/1/addedit.asmx")
35
+ .to_return(status: 200, body: '🔥')
36
+ end
37
+
38
+ it 'raises an exception with request information' do
39
+ expect do
40
+ client.run(request)
41
+ end.to raise_error(SoapyCake::RequestFailed, 'Unknown error') do |e|
42
+ expect(e.request_path).to eq('/api/1/addedit.asmx')
43
+ expect(e.request_body).to include('<cake:api_key>[redacted]</cake:api_key>')
44
+ expect(e.response_body).to eq('🔥')
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
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: 2.2.3
4
+ version: 2.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - ad2games GmbH
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-15 00:00:00.000000000 Z
11
+ date: 2018-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -260,6 +260,7 @@ files:
260
260
  - spec/lib/soapy_cake/admin_track_spec.rb
261
261
  - spec/lib/soapy_cake/affiliate_spec.rb
262
262
  - spec/lib/soapy_cake/campaigns_spec.rb
263
+ - spec/lib/soapy_cake/client_spec.rb
263
264
  - spec/lib/soapy_cake/modification_type_spec.rb
264
265
  - spec/lib/soapy_cake/request_failed_spec.rb
265
266
  - spec/lib/soapy_cake/request_spec.rb
@@ -288,7 +289,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
288
289
  version: '0'
289
290
  requirements: []
290
291
  rubyforge_project:
291
- rubygems_version: 2.6.11
292
+ rubygems_version: 2.6.14
292
293
  signing_key:
293
294
  specification_version: 4
294
295
  summary: Simple client for the CAKE API
@@ -339,6 +340,7 @@ test_files:
339
340
  - spec/lib/soapy_cake/admin_track_spec.rb
340
341
  - spec/lib/soapy_cake/affiliate_spec.rb
341
342
  - spec/lib/soapy_cake/campaigns_spec.rb
343
+ - spec/lib/soapy_cake/client_spec.rb
342
344
  - spec/lib/soapy_cake/modification_type_spec.rb
343
345
  - spec/lib/soapy_cake/request_failed_spec.rb
344
346
  - spec/lib/soapy_cake/request_spec.rb