soapy_cake 1.7.0 → 1.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/soapy_cake.rb +1 -0
- data/lib/soapy_cake/response.rb +1 -15
- data/lib/soapy_cake/response_value.rb +62 -0
- data/lib/soapy_cake/version.rb +1 -1
- data/spec/fixtures/vcr_cassettes/SoapyCake_Admin/does_not_parse_a_transaction_id_as_an_integer.yml +162 -0
- data/spec/integration/soapy_cake/admin_spec.rb +11 -0
- data/spec/lib/soapy_cake/response_value_spec.rb +59 -0
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 00d5799aaeb8efca06f9ab1c1f9cbd90c4159f64
|
4
|
+
data.tar.gz: 96e577c979fec1ae24018e09598bc07763ffdb00
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39d2eadbaf1878b02ce401aa50d16cb96f710ca7d5f6a2a55f55f060d28d34def74fd95668854e8c579ff2a970709a0c70efaa9d9561fe80363f767394df70b8
|
7
|
+
data.tar.gz: 2f224424014bfc7d70c2f19e31d68b057e5b5c06b27753485dfe1a3fd34770be94cf3bf36e61d224d4cad639f02103e75ffd55ce9565ca3b02c3a512666e5d08
|
data/lib/soapy_cake.rb
CHANGED
data/lib/soapy_cake/response.rb
CHANGED
@@ -24,24 +24,10 @@ module SoapyCake
|
|
24
24
|
|
25
25
|
def typed_element(element)
|
26
26
|
walk_tree(element) do |value, key|
|
27
|
-
|
27
|
+
ResponseValue.new(key, value, time_offset: time_offset).parse
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
def parse_element(key, value)
|
32
|
-
return value.to_i if key.to_s.end_with?('_id') && !key.to_s.end_with?('tax_id')
|
33
|
-
return false if value == 'false'
|
34
|
-
return true if value == 'true'
|
35
|
-
return parse_date(value) if /\A\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.?\d*\z/.match(value)
|
36
|
-
|
37
|
-
# cast to primitive string to get rid of Saxerator string class
|
38
|
-
value.to_s
|
39
|
-
end
|
40
|
-
|
41
|
-
def parse_date(value)
|
42
|
-
DateTime.parse(value + format('%+03d:00', time_offset.to_i))
|
43
|
-
end
|
44
|
-
|
45
31
|
def sax
|
46
32
|
@sax ||= Saxerator.parser(StringIO.new(body)) do |config|
|
47
33
|
config.symbolize_keys!
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module SoapyCake
|
2
|
+
class ResponseValue
|
3
|
+
attr_reader :value
|
4
|
+
attr_reader :key
|
5
|
+
|
6
|
+
# Known string ids that should not be parsed as integers
|
7
|
+
STRING_IDS = %w(tax_id transaction_id)
|
8
|
+
|
9
|
+
def initialize(key, value, opts = {})
|
10
|
+
@key = key.to_s
|
11
|
+
@value = value
|
12
|
+
@opts = opts
|
13
|
+
end
|
14
|
+
|
15
|
+
def parse
|
16
|
+
return parse_int if id? && !string_id?
|
17
|
+
return false if false?
|
18
|
+
return true if true?
|
19
|
+
return parse_date if date?
|
20
|
+
|
21
|
+
# cast to primitive string to get rid of Saxerator string class
|
22
|
+
value.to_s
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def false?
|
28
|
+
value == 'false'
|
29
|
+
end
|
30
|
+
|
31
|
+
def true?
|
32
|
+
value == 'true'
|
33
|
+
end
|
34
|
+
|
35
|
+
def date?
|
36
|
+
value =~ /\A\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.?\d*\z/
|
37
|
+
end
|
38
|
+
|
39
|
+
def id?
|
40
|
+
key.to_s.end_with?('_id')
|
41
|
+
end
|
42
|
+
|
43
|
+
def string_id?
|
44
|
+
STRING_IDS.any? { |id| key.end_with?(id) }
|
45
|
+
end
|
46
|
+
|
47
|
+
def numeric?
|
48
|
+
value =~ /\A-?\d*\z/
|
49
|
+
end
|
50
|
+
|
51
|
+
def parse_int
|
52
|
+
unless value.nil? || numeric?
|
53
|
+
fail Error, "'#{key}' contains non-digit chars but was to be parsed as an integer id"
|
54
|
+
end
|
55
|
+
value.to_i
|
56
|
+
end
|
57
|
+
|
58
|
+
def parse_date
|
59
|
+
DateTime.parse(value + format('%+03d:00', @opts[:time_offset].to_i))
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
data/lib/soapy_cake/version.rb
CHANGED
data/spec/fixtures/vcr_cassettes/SoapyCake_Admin/does_not_parse_a_transaction_id_as_an_integer.yml
ADDED
@@ -0,0 +1,162 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://cake-partner-domain.com/api/11/reports.asmx
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: |
|
9
|
+
<?xml version="1.0"?>
|
10
|
+
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:cake="http://cakemarketing.com/api/11/">
|
11
|
+
<env:Header/>
|
12
|
+
<env:Body>
|
13
|
+
<cake:Conversions>
|
14
|
+
<cake:api_key>cake-api-key</cake:api_key>
|
15
|
+
<cake:start_date>2015-04-11T01:00:00</cake:start_date>
|
16
|
+
<cake:end_date>2015-04-12T01:00:00</cake:end_date>
|
17
|
+
<cake:row_limit>1</cake:row_limit>
|
18
|
+
<cake:conversion_type>conversions</cake:conversion_type>
|
19
|
+
</cake:Conversions>
|
20
|
+
</env:Body>
|
21
|
+
</env:Envelope>
|
22
|
+
headers:
|
23
|
+
Content-Type:
|
24
|
+
- application/soap+xml;charset=UTF-8
|
25
|
+
response:
|
26
|
+
status:
|
27
|
+
code: 200
|
28
|
+
message: OK
|
29
|
+
headers:
|
30
|
+
Cache-Control:
|
31
|
+
- private, max-age=0
|
32
|
+
Content-Type:
|
33
|
+
- application/soap+xml; charset=utf-8
|
34
|
+
Server:
|
35
|
+
- Microsoft-IIS/8.0
|
36
|
+
X-Aspnet-Version:
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yb3dz
|
150
|
+
ZXJfaWQ+PGJyb3dzZXJfbmFtZT5DaHJvbWU8L2Jyb3dzZXJfbmFtZT48YnJv
|
151
|
+
d3Nlcl92ZXJzaW9uPjx2ZXJzaW9uX2lkIHhtbG5zPSJBUEk6aWRfbmFtZV9z
|
152
|
+
dG9yZSI+MjQ8L3ZlcnNpb25faWQ+PHZlcnNpb25fbmFtZSB4bWxucz0iQVBJ
|
153
|
+
OmlkX25hbWVfc3RvcmUiPk90aGVyPC92ZXJzaW9uX25hbWU+PC9icm93c2Vy
|
154
|
+
X3ZlcnNpb24+PGJyb3dzZXJfdmVyc2lvbl9taW5vcj48dmVyc2lvbl9pZCB4
|
155
|
+
bWxucz0iQVBJOmlkX25hbWVfc3RvcmUiPjI0PC92ZXJzaW9uX2lkPjx2ZXJz
|
156
|
+
aW9uX25hbWUgeG1sbnM9IkFQSTppZF9uYW1lX3N0b3JlIiAvPjwvYnJvd3Nl
|
157
|
+
cl92ZXJzaW9uX21pbm9yPjwvYnJvd3Nlcj48bm90ZSAvPjwvY29udmVyc2lv
|
158
|
+
bj48L2NvbnZlcnNpb25zPjwvQ29udmVyc2lvbnNSZXN1bHQ+PC9Db252ZXJz
|
159
|
+
aW9uc1Jlc3BvbnNlPjwvc29hcDpCb2R5Pjwvc29hcDpFbnZlbG9wZT4=
|
160
|
+
http_version:
|
161
|
+
recorded_at: Thu, 07 May 2015 09:37:00 GMT
|
162
|
+
recorded_with: VCR 2.9.3
|
@@ -38,6 +38,17 @@ RSpec.describe SoapyCake::Admin do
|
|
38
38
|
)
|
39
39
|
end
|
40
40
|
|
41
|
+
it 'does not parse a transaction_id as an integer', :vcr do
|
42
|
+
result = subject.conversions(
|
43
|
+
start_date: Date.new(2015, 4, 11),
|
44
|
+
end_date: Date.new(2015, 4, 12),
|
45
|
+
row_limit: 1
|
46
|
+
)
|
47
|
+
|
48
|
+
expect(result.count).to eq(1)
|
49
|
+
expect(result.first[:transaction_id]).to eq('TRANSACTION_ID')
|
50
|
+
end
|
51
|
+
|
41
52
|
it 'raises if there is an error', :vcr do
|
42
53
|
expect do
|
43
54
|
subject.affiliates(affiliate_id: 'bloops')
|
@@ -0,0 +1,59 @@
|
|
1
|
+
RSpec.describe SoapyCake::ResponseValue do
|
2
|
+
def subject(*args)
|
3
|
+
described_class.new(*args)
|
4
|
+
end
|
5
|
+
|
6
|
+
describe '#parse' do
|
7
|
+
context 'booleans' do
|
8
|
+
it 'converts the string "true" to the true value' do
|
9
|
+
expect(subject(:foo, 'true').parse).to eq(true)
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'converts the string "false" to the false value' do
|
13
|
+
expect(subject(:foo, 'false').parse).to eq(false)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'dates' do
|
18
|
+
it 'parses an ISO-formatted date' do
|
19
|
+
expect(subject(:foo, '2014-06-30T01:00:00').parse).to eq(DateTime.new(2014, 6, 30, 1))
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'properly applies the provided time offset' do
|
23
|
+
expect(subject(:foo, '2014-01-01T00:00:00', time_offset: 5).parse)
|
24
|
+
.to eq(DateTime.new(2014, 1, 1, 0).change(offset: '+0500'))
|
25
|
+
|
26
|
+
expect(subject(:foo, '2014-12-31T01:00:00', time_offset: -2).parse)
|
27
|
+
.to eq(DateTime.new(2014, 12, 31, 1).change(offset: '-0200'))
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'strings' do
|
32
|
+
it 'parses a string' do
|
33
|
+
expect(subject(:foo, 'abc').parse).to eq('abc')
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'IDs' do
|
38
|
+
it 'converts keys ending in "_id" to integers' do
|
39
|
+
expect(subject(:conversion_id, '42').parse).to eq(42)
|
40
|
+
end
|
41
|
+
|
42
|
+
it "doesn't convert ids in the blacklist to integers" do
|
43
|
+
expect(subject(:tax_id, '123abc').parse).to eq('123abc')
|
44
|
+
expect(subject(:other_tax_id, '123abc').parse).to eq('123abc')
|
45
|
+
expect(subject(:transaction_id, '123abc').parse).to eq('123abc')
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'raises an error if not in the blacklist and non-digit characters are detected' do
|
49
|
+
expect { subject(:foo_id, '123abc').parse }.to raise_error(SoapyCake::Error)
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'does not raise an error if the value is absent' do
|
53
|
+
expect(subject(:foo_id, '-1').parse).to eq(-1)
|
54
|
+
expect(subject(:foo_id, '').parse).to eq(0)
|
55
|
+
expect(subject(:foo_id, nil).parse).to eq(0)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: soapy_cake
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ad2games GmbH
|
@@ -191,8 +191,10 @@ files:
|
|
191
191
|
- lib/soapy_cake/helper.rb
|
192
192
|
- lib/soapy_cake/request.rb
|
193
193
|
- lib/soapy_cake/response.rb
|
194
|
+
- lib/soapy_cake/response_value.rb
|
194
195
|
- lib/soapy_cake/version.rb
|
195
196
|
- soapy_cake.gemspec
|
197
|
+
- spec/fixtures/vcr_cassettes/SoapyCake_Admin/does_not_parse_a_transaction_id_as_an_integer.yml
|
196
198
|
- spec/fixtures/vcr_cassettes/SoapyCake_Admin/raises_if_there_is_an_error.yml
|
197
199
|
- spec/fixtures/vcr_cassettes/SoapyCake_Admin/returns_a_clicks_report_with_a_defined_time_range.yml
|
198
200
|
- spec/fixtures/vcr_cassettes/SoapyCake_Admin/returns_an_affiliate_with_correct_data_types.yml
|
@@ -213,6 +215,7 @@ files:
|
|
213
215
|
- spec/lib/soapy_cake/admin_track_spec.rb
|
214
216
|
- spec/lib/soapy_cake/affiliate_spec.rb
|
215
217
|
- spec/lib/soapy_cake/request_spec.rb
|
218
|
+
- spec/lib/soapy_cake/response_value_spec.rb
|
216
219
|
- spec/spec_helper.rb
|
217
220
|
- spec/support/admin_method_example.rb
|
218
221
|
homepage: http://ad2games.com
|
@@ -235,11 +238,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
235
238
|
version: '0'
|
236
239
|
requirements: []
|
237
240
|
rubyforge_project:
|
238
|
-
rubygems_version: 2.4.
|
241
|
+
rubygems_version: 2.4.5
|
239
242
|
signing_key:
|
240
243
|
specification_version: 4
|
241
244
|
summary: Simple client for the CAKE API
|
242
245
|
test_files:
|
246
|
+
- spec/fixtures/vcr_cassettes/SoapyCake_Admin/does_not_parse_a_transaction_id_as_an_integer.yml
|
243
247
|
- spec/fixtures/vcr_cassettes/SoapyCake_Admin/raises_if_there_is_an_error.yml
|
244
248
|
- spec/fixtures/vcr_cassettes/SoapyCake_Admin/returns_a_clicks_report_with_a_defined_time_range.yml
|
245
249
|
- spec/fixtures/vcr_cassettes/SoapyCake_Admin/returns_an_affiliate_with_correct_data_types.yml
|
@@ -260,5 +264,6 @@ test_files:
|
|
260
264
|
- spec/lib/soapy_cake/admin_track_spec.rb
|
261
265
|
- spec/lib/soapy_cake/affiliate_spec.rb
|
262
266
|
- spec/lib/soapy_cake/request_spec.rb
|
267
|
+
- spec/lib/soapy_cake/response_value_spec.rb
|
263
268
|
- spec/spec_helper.rb
|
264
269
|
- spec/support/admin_method_example.rb
|