soapy_cake 0.2.1 → 0.2.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/Gemfile +4 -0
- data/README.md +6 -1
- data/api_versions.yml +8 -0
- data/lib/soapy_cake/client.rb +13 -5
- data/lib/soapy_cake/version.rb +1 -1
- data/soapy_cake.gemspec +1 -1
- data/spec/lib/soapy_cake/client_spec.rb +35 -0
- data/spec/spec_helper.rb +5 -0
- metadata +25 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b53508bd3216bab78655097a29155c363dcd40c
|
4
|
+
data.tar.gz: 307e42a79a8dfe66a984ad27eef27548befa0bf4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: edb5178d36653d29c321fa3b28b1abc5637942aa63d9f0159b6e4f7abc768a946ec736437d8ccc8a8464530a99f55731f0e806970ac3745f94aa7880ffb8e470
|
7
|
+
data.tar.gz: 8ba791b73e73e10b8da57bad9d3e87e3407248a1103006104dfbb717a10ea7fdcc7004cce6ea3359f8aae7be6458656cdb5d7cf0c3d8b7cc8c0dd7697cc4c81e
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.1.2
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,9 @@
|
|
1
1
|
# SoapyCake
|
2
|
+
[![Code Climate](https://codeclimate.com/github/ad2games/soapy_cake.png)](https://codeclimate.com/github/ad2games/soapy_cake)
|
3
|
+
[![Test Coverage](https://codeclimate.com/github/ad2games/soapy_cake/coverage.png)](https://codeclimate.com/github/ad2games/soapy_cake)
|
4
|
+
[![Gem Version](http://img.shields.io/gem/v/soapy_cake.svg)](http://rubygems.org/gems/soapy_cake)
|
5
|
+
[![Dependency Status](http://img.shields.io/gemnasium/ad2games/soapy_cake.svg)](https://gemnasium.com/ad2games/soapy_cake)
|
6
|
+
[![Build Status](https://circleci.com/gh/ad2games/soapy_cake.png?circle-token=aac691804f58acd8e96db632f8133e3c6155f123)](https://circleci.com/gh/ad2games/soapy_cake)
|
2
7
|
|
3
8
|
Simple client library for [cake](http://getcake.com).
|
4
9
|
|
@@ -37,7 +42,7 @@ SoapyCake::Client.reports.affiliate_summary(
|
|
37
42
|
```
|
38
43
|
|
39
44
|
If you are interested in how we map methods to api endpoints take a look
|
40
|
-
at [api_versions.yml](
|
45
|
+
at [api_versions.yml](api_versions.yml).
|
41
46
|
|
42
47
|
## Contributing
|
43
48
|
|
data/api_versions.yml
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
---
|
2
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
|
3
8
|
:add:
|
4
9
|
:advertiser_credit: 1
|
5
10
|
:creative: 1
|
@@ -101,3 +106,6 @@
|
|
101
106
|
:affiliates:
|
102
107
|
:reports:
|
103
108
|
:bills: 3
|
109
|
+
:offers:
|
110
|
+
:offer_feed: 4
|
111
|
+
:get_campaign: 2
|
data/lib/soapy_cake/client.rb
CHANGED
@@ -84,22 +84,28 @@ module SoapyCake
|
|
84
84
|
|
85
85
|
def process_response(method, response)
|
86
86
|
Time.use_zone('UTC') do
|
87
|
-
raise response[:fault][:reason][:text] if response[:fault]
|
87
|
+
raise RequestUnsuccessful, response[:fault][:reason][:text] if response[:fault]
|
88
88
|
node_name = {
|
89
89
|
'affiliate_summary' => 'affiliates',
|
90
|
+
'advertiser_summary' => 'advertisers',
|
90
91
|
'affiliate_tags' => 'tags',
|
91
92
|
'offer_summary' => 'offers',
|
93
|
+
'campaign_summary' => 'campaigns',
|
94
|
+
'offer_feed' => 'offers',
|
95
|
+
'export_affiliate_bills' => 'affiliate_bills',
|
96
|
+
'export_advertiser_bills' => 'advertiser_bills',
|
92
97
|
}.fetch(method, method)
|
98
|
+
|
93
99
|
result = response[:"#{method}_response"][:"#{method}_result"]
|
94
|
-
raise result[:message] if result[:success] == false
|
95
|
-
return result unless result_has_collection?(result)
|
100
|
+
raise RequestUnsuccessful, result[:message] if result[:success] == false
|
101
|
+
return result unless result_has_collection?(result, method)
|
96
102
|
extract_collection(node_name, result).
|
97
103
|
map { |hash| remove_prefix(node_name, hash) }
|
98
104
|
end
|
99
105
|
end
|
100
106
|
|
101
|
-
def result_has_collection?(result)
|
102
|
-
!result.key?(:message)
|
107
|
+
def result_has_collection?(result, method)
|
108
|
+
!result.key?(:message) && !method.to_s.starts_with?('get_')
|
103
109
|
end
|
104
110
|
|
105
111
|
def extract_collection(node_name, response)
|
@@ -141,5 +147,7 @@ module SoapyCake
|
|
141
147
|
def supported?(method)
|
142
148
|
API_VERSIONS[role][service].keys.include?(method)
|
143
149
|
end
|
150
|
+
|
151
|
+
class RequestUnsuccessful < RuntimeError; end
|
144
152
|
end
|
145
153
|
end
|
data/lib/soapy_cake/version.rb
CHANGED
data/soapy_cake.gemspec
CHANGED
@@ -149,10 +149,45 @@ describe SoapyCake::Client do
|
|
149
149
|
}
|
150
150
|
end
|
151
151
|
|
152
|
+
let(:get_response) do
|
153
|
+
{
|
154
|
+
get_campaign_response: {
|
155
|
+
get_campaign_result: {
|
156
|
+
success: true,
|
157
|
+
campaign: {
|
158
|
+
offer_id: '5129'
|
159
|
+
}
|
160
|
+
}
|
161
|
+
}
|
162
|
+
}
|
163
|
+
end
|
164
|
+
|
152
165
|
it 'handles responses with a message field as not having a collection' do
|
153
166
|
expect(client.send(:process_response, :affiliate, response)).to eq(
|
154
167
|
response[:affiliate_response][:affiliate_result])
|
155
168
|
end
|
169
|
+
|
170
|
+
it 'handles get API responses as having no collection' do
|
171
|
+
expect(client.send(:process_response, :get_campaign, get_response)).to eq(
|
172
|
+
get_response[:get_campaign_response][:get_campaign_result])
|
173
|
+
end
|
174
|
+
|
175
|
+
it 'raises RequestUnsuccessful if response contains success: false' do
|
176
|
+
expect {
|
177
|
+
client.send(:process_response, :affiliate, {
|
178
|
+
affiliate_response: {
|
179
|
+
affiliate_result: { message: 'FAIL!', success: false }
|
180
|
+
}
|
181
|
+
})
|
182
|
+
}.to raise_error(SoapyCake::Client::RequestUnsuccessful, 'FAIL!')
|
183
|
+
end
|
184
|
+
|
185
|
+
it 'raises RequestUnsuccessful if response contains `:fault` key' do
|
186
|
+
expect {
|
187
|
+
client.send(:process_response, :affiliate,
|
188
|
+
{ fault: { reason: { text: 'FAIL!' }}})
|
189
|
+
}.to raise_error(SoapyCake::Client::RequestUnsuccessful, 'FAIL!')
|
190
|
+
end
|
156
191
|
end
|
157
192
|
|
158
193
|
describe 'instantiating through class method' do
|
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require "codeclimate-test-reporter"
|
2
|
+
CodeClimate::TestReporter.start
|
1
3
|
require 'bundler/setup'
|
2
4
|
Bundler.require(:default, :development)
|
3
5
|
require 'soapy_cake'
|
@@ -33,4 +35,7 @@ VCR.configure do |c|
|
|
33
35
|
c.filter_sensitive_data('cake-api-key') { ENV['CAKE_API_KEY'] }
|
34
36
|
c.filter_sensitive_data('cake-partner-domain.com') { ENV['CAKE_DOMAIN'] }
|
35
37
|
c.default_cassette_options = { match_requests_on: [:method, :uri, :body] }
|
38
|
+
|
39
|
+
# allow codeclimate-test-reporter to phone home
|
40
|
+
c.ignore_hosts 'codeclimate.com'
|
36
41
|
end
|
metadata
CHANGED
@@ -1,125 +1,125 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: soapy_cake
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ad2games GmbH
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: sekken
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: 3.0.0
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 3.0.0
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: vcr
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: webmock
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
112
|
+
name: pry
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- -
|
115
|
+
- - ">="
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '0'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- -
|
122
|
+
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
description: Simple client for the CAKE API (http://getcake.com)
|
@@ -129,9 +129,9 @@ executables: []
|
|
129
129
|
extensions: []
|
130
130
|
extra_rdoc_files: []
|
131
131
|
files:
|
132
|
-
- .gitignore
|
133
|
-
- .rspec
|
134
|
-
- .ruby-version
|
132
|
+
- ".gitignore"
|
133
|
+
- ".rspec"
|
134
|
+
- ".ruby-version"
|
135
135
|
- Gemfile
|
136
136
|
- LICENSE.txt
|
137
137
|
- README.md
|
@@ -177,17 +177,17 @@ require_paths:
|
|
177
177
|
- lib
|
178
178
|
required_ruby_version: !ruby/object:Gem::Requirement
|
179
179
|
requirements:
|
180
|
-
- -
|
180
|
+
- - ">="
|
181
181
|
- !ruby/object:Gem::Version
|
182
182
|
version: '0'
|
183
183
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
184
184
|
requirements:
|
185
|
-
- -
|
185
|
+
- - ">="
|
186
186
|
- !ruby/object:Gem::Version
|
187
187
|
version: '0'
|
188
188
|
requirements: []
|
189
189
|
rubyforge_project:
|
190
|
-
rubygems_version: 2.
|
190
|
+
rubygems_version: 2.2.2
|
191
191
|
signing_key:
|
192
192
|
specification_version: 4
|
193
193
|
summary: Simple client for the CAKE API
|
@@ -216,4 +216,3 @@ test_files:
|
|
216
216
|
- spec/fixtures/vcr_cassettes/client_sekken_client_caches_results.yml
|
217
217
|
- spec/lib/soapy_cake/client_spec.rb
|
218
218
|
- spec/spec_helper.rb
|
219
|
-
has_rdoc:
|