adjust 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/adjust.rb +2 -1
- data/lib/adjust/transport.rb +2 -0
- data/lib/adjust/transport/fail_hard.rb +23 -0
- data/lib/adjust/transport/faraday.rb +1 -2
- data/lib/adjust/version.rb +1 -1
- data/spec/fixtures/responses/event_unknown_device.yml +35 -0
- data/spec/fixtures/responses/revenue_unknown_device.yml +35 -0
- data/spec/integration/sending_a_revenue_spec.rb +17 -1
- data/spec/integration/sending_an_event_spec.rb +15 -1
- data/spec/support/vcr.rb +4 -0
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b6006d97a274628f7f36570ac0a1c7471a7810d1
|
4
|
+
data.tar.gz: b0cc4a2260d946f0eb12839ae3979f6c7a5d6058
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d9ac213976e887ae202856a9857f53310640cec97c82a55783113d068acebc9507a8d46a8b1b99da3dce6d9aaee93112c82dd4ff363affb0edc848012b8573f
|
7
|
+
data.tar.gz: d83860afe9461d421db46380110cc76abc0daf50d13207564959d6665aae21b76671540073990505844e308fdb0e89fc07eaba9d401e10d6d2f0926ab62802fe
|
data/lib/adjust.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
|
+
require 'faraday'
|
1
2
|
require 'adjust/version'
|
2
|
-
require 'adjust/transport/faraday'
|
3
3
|
|
4
4
|
module Adjust
|
5
5
|
autoload :Core, 'adjust/core'
|
6
6
|
autoload :Clients, 'adjust/clients'
|
7
7
|
autoload :Representers, 'adjust/representers'
|
8
|
+
autoload :Transport, 'adjust/transport'
|
8
9
|
|
9
10
|
class << self
|
10
11
|
include Core::Configurable
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Adjust
|
2
|
+
module Transport
|
3
|
+
class Error < StandardError; end
|
4
|
+
|
5
|
+
class FailHard < ::Faraday::Response::Middleware
|
6
|
+
SUCCESS_STATUSES = 200...300
|
7
|
+
|
8
|
+
def on_complete(env)
|
9
|
+
fail Error, error_from_json(env[:body]) if failed?(env)
|
10
|
+
end
|
11
|
+
|
12
|
+
def failed?(env)
|
13
|
+
!SUCCESS_STATUSES.include?(env[:status])
|
14
|
+
end
|
15
|
+
|
16
|
+
def error_from_json(body)
|
17
|
+
MultiJson.load(body)['error']
|
18
|
+
end
|
19
|
+
|
20
|
+
Faraday::Response.register_middleware fail_hard: FailHard
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'roar/http_verbs'
|
2
1
|
require 'roar/transport/faraday'
|
3
2
|
|
4
3
|
module Adjust
|
@@ -9,7 +8,7 @@ module Adjust
|
|
9
8
|
def build_connection(uri, _)
|
10
9
|
::Faraday.new(url: uri) do |connection|
|
11
10
|
connection.request :url_encoded
|
12
|
-
connection.
|
11
|
+
connection.response :fail_hard
|
13
12
|
connection.adapter ::Faraday.default_adapter
|
14
13
|
end
|
15
14
|
end
|
data/lib/adjust/version.rb
CHANGED
@@ -0,0 +1,35 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://s2s.adjust.com/event
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: app_token=<ADJUST_APP_TOKEN>&created_at=2015-05-13T15%3A34%3A02Z&environment=sandbox&event_token=tawmb9&idfa=D2CADB5F-410F-4963-AC0C-2A78534BDF1E&s2s=1
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v0.9.1
|
12
|
+
Content-Type:
|
13
|
+
- application/x-www-form-urlencoded
|
14
|
+
Accept-Encoding:
|
15
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
16
|
+
Accept:
|
17
|
+
- "*/*"
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 500
|
21
|
+
message: Internal Server Error
|
22
|
+
headers:
|
23
|
+
Content-Type:
|
24
|
+
- text/plain; charset=utf-8
|
25
|
+
Date:
|
26
|
+
- Wed, 13 May 2015 15:34:02 GMT
|
27
|
+
Content-Length:
|
28
|
+
- '138'
|
29
|
+
body:
|
30
|
+
encoding: UTF-8
|
31
|
+
string: |
|
32
|
+
{"error":"Event failed (Device not found, contact support@adjust.com) (app_token: <ADJUST_APP_TOKEN>, adid: dc4920c26bcc478fbdd2e5bfd0dbe551)"}
|
33
|
+
http_version:
|
34
|
+
recorded_at: Wed, 13 May 2015 15:34:02 GMT
|
35
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,35 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://s2s.adjust.com/revenue
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: app_token=<ADJUST_APP_TOKEN>&created_at=2015-05-13T14%3A28%3A41Z¤cy=CAD&environment=sandbox&event_token=fbv8to&idfa=D2CADB5F-410F-4963-AC0C-2A78534BDF1E&revenue=2.0&s2s=1
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v0.9.1
|
12
|
+
Content-Type:
|
13
|
+
- application/x-www-form-urlencoded
|
14
|
+
Accept-Encoding:
|
15
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
16
|
+
Accept:
|
17
|
+
- "*/*"
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 500
|
21
|
+
message: Internal Server Error
|
22
|
+
headers:
|
23
|
+
Content-Type:
|
24
|
+
- text/plain; charset=utf-8
|
25
|
+
Date:
|
26
|
+
- Wed, 13 May 2015 14:28:42 GMT
|
27
|
+
Content-Length:
|
28
|
+
- '138'
|
29
|
+
body:
|
30
|
+
encoding: UTF-8
|
31
|
+
string: |
|
32
|
+
{"error":"Event failed (Device not found, contact support@adjust.com) (app_token: <ADJUST_APP_TOKEN>, adid: dc4920c26bcc478fbdd2e5bfd0dbe551)"}
|
33
|
+
http_version:
|
34
|
+
recorded_at: Wed, 13 May 2015 14:28:41 GMT
|
35
|
+
recorded_with: VCR 2.9.3
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'Sending a revenue' do
|
4
|
-
context 'with success', vcr:
|
4
|
+
context 'with success', vcr: named(:revenue_success) do
|
5
5
|
subject do
|
6
6
|
Adjust.revenue \
|
7
7
|
app: :test_app,
|
@@ -15,4 +15,20 @@ describe 'Sending a revenue' do
|
|
15
15
|
expect(subject.track!).to be_success
|
16
16
|
end
|
17
17
|
end
|
18
|
+
|
19
|
+
context 'with unknown device', vcr: named(:revenue_unknown_device) do
|
20
|
+
subject do
|
21
|
+
Adjust.revenue \
|
22
|
+
app: :test_app,
|
23
|
+
event: :event2,
|
24
|
+
revenue: 2.0,
|
25
|
+
currency: 'CAD',
|
26
|
+
idfa: 'D2CADB5F-410F-4963-AC0C-2A78534BDF1E'
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'raises an error' do
|
30
|
+
expect { subject.track! }.to raise_error \
|
31
|
+
Adjust::Transport::Error, /Device not found/
|
32
|
+
end
|
33
|
+
end
|
18
34
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'Sending an event' do
|
4
|
-
context 'with success', vcr:
|
4
|
+
context 'with success', vcr: named(:event_success) do
|
5
5
|
subject do
|
6
6
|
Adjust.event \
|
7
7
|
app: :test_app,
|
@@ -13,4 +13,18 @@ describe 'Sending an event' do
|
|
13
13
|
expect(subject.track!).to be_success
|
14
14
|
end
|
15
15
|
end
|
16
|
+
|
17
|
+
context 'with unknown device', vcr: named(:event_unknown_device) do
|
18
|
+
subject do
|
19
|
+
Adjust.event \
|
20
|
+
app: :test_app,
|
21
|
+
event: :event1,
|
22
|
+
idfa: 'D2CADB5F-410F-4963-AC0C-2A78534BDF1E'
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'raises an error' do
|
26
|
+
expect { subject.track! }.to raise_error \
|
27
|
+
Adjust::Transport::Error, /Device not found/
|
28
|
+
end
|
29
|
+
end
|
16
30
|
end
|
data/spec/support/vcr.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: adjust
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hugo Bastien
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -192,6 +192,8 @@ files:
|
|
192
192
|
- lib/adjust/core/tokens.rb
|
193
193
|
- lib/adjust/representers.rb
|
194
194
|
- lib/adjust/representers/event_representer.rb
|
195
|
+
- lib/adjust/transport.rb
|
196
|
+
- lib/adjust/transport/fail_hard.rb
|
195
197
|
- lib/adjust/transport/faraday.rb
|
196
198
|
- lib/adjust/version.rb
|
197
199
|
- spec/clients/event_spec.rb
|
@@ -199,7 +201,9 @@ files:
|
|
199
201
|
- spec/core/configuration_spec.rb
|
200
202
|
- spec/fixtures/config/adjust.yml
|
201
203
|
- spec/fixtures/responses/event_success.yml
|
204
|
+
- spec/fixtures/responses/event_unknown_device.yml
|
202
205
|
- spec/fixtures/responses/revenue_success.yml
|
206
|
+
- spec/fixtures/responses/revenue_unknown_device.yml
|
203
207
|
- spec/integration/sending_a_revenue_spec.rb
|
204
208
|
- spec/integration/sending_an_event_spec.rb
|
205
209
|
- spec/spec_helper.rb
|
@@ -234,7 +238,9 @@ test_files:
|
|
234
238
|
- spec/core/configuration_spec.rb
|
235
239
|
- spec/fixtures/config/adjust.yml
|
236
240
|
- spec/fixtures/responses/event_success.yml
|
241
|
+
- spec/fixtures/responses/event_unknown_device.yml
|
237
242
|
- spec/fixtures/responses/revenue_success.yml
|
243
|
+
- spec/fixtures/responses/revenue_unknown_device.yml
|
238
244
|
- spec/integration/sending_a_revenue_spec.rb
|
239
245
|
- spec/integration/sending_an_event_spec.rb
|
240
246
|
- spec/spec_helper.rb
|