kahuna_client 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/kahuna_client/client.rb +1 -0
- data/lib/kahuna_client/client/logs.rb +38 -0
- data/lib/kahuna_client/version.rb +1 -1
- data/spec/fixtures/logs.json +1 -0
- data/spec/kahuna_client/client/logs_spec.rb +74 -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: 852f844be1e7f03829000aac9fd1f81ca72a5ee7
|
4
|
+
data.tar.gz: 17f5b26cda633d94e4c6e686131b21391b3df747
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb2568e9d342aee5e120dcbdb5ce937fce9ff458169ac25310da5dda0d843a749c71da79e7a3c1a2340c5910b32ccb857f48856b7ffcb7759b579089a63c0f37
|
7
|
+
data.tar.gz: dbb94ece76075cc71a66f30406398a85a0391495189b6b4ab6715fa78e41053c1fc997708f25fc1c2fa18b4446730a738bb8dfb8974e860c4d71eb451d13f5e7
|
data/lib/kahuna_client/client.rb
CHANGED
@@ -0,0 +1,38 @@
|
|
1
|
+
module KahunaClient
|
2
|
+
class Client
|
3
|
+
module Logs
|
4
|
+
|
5
|
+
# Fetch push logs
|
6
|
+
#
|
7
|
+
# Params:
|
8
|
+
# timestamp: Timestamp from which to fetch logs
|
9
|
+
# cursor: Cursor string from previous response
|
10
|
+
# number_of_records: (Optional) Number of entries in log. Max 1000
|
11
|
+
#
|
12
|
+
def logs(options = {})
|
13
|
+
timestamp = options[:timestamp] || Time.now.utc
|
14
|
+
time_formatted = timestamp.strftime('%m/%d/%y %H:%M:%S %p')
|
15
|
+
cursor = options[:cursor]
|
16
|
+
number_of_records = options[:number_of_records] || 1000
|
17
|
+
params = {
|
18
|
+
:categories_to_return => [:push],
|
19
|
+
:number_of_records => number_of_records
|
20
|
+
}
|
21
|
+
# Cursor gets priority
|
22
|
+
if cursor
|
23
|
+
params.merge!({:cursor => cursor})
|
24
|
+
else
|
25
|
+
params.merge!({:timestamp => time_formatted})
|
26
|
+
end
|
27
|
+
# Do the post
|
28
|
+
post(logs_path, params)
|
29
|
+
end
|
30
|
+
|
31
|
+
protected
|
32
|
+
|
33
|
+
def logs_path
|
34
|
+
"api/kahunalogs"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
{"push": [{"ghost": true, "dev_id": "493bccb7-67e8-4745-91d9-8ca63847e19e", "user_id": 380810003, "campaign": "Saved Listing", "timestamp": "2015-03-27 08:00:47.911780", "campaign_id": 408490141, "action_category": "duplicate_ghost_push", "action": "duplicate_ghost_push", "action_detail": "Duplicate ghost push will not be sent to user 'goooyoon@gmail.com', device '493bccb7-67e8-4745-91d9-8ca63847e19e'", "push_token": "APA91bF2dCatGpeh74yrhHmD2yKOzHvrLD8zEdqZw6UPr-cOPw00AoaXQCP8W9KKmDy9rZj4zlQyicJZY5E42_9S6xkXwE_-XF_FIoGBHnopNi5eT5D6cnDBsyfmsFAqeqhiALXrELclnIbKIc5KBpy6u2Ac0w9m1vES0dJE0TyUFnnoPpMMoDU", "credentials": ["email:goooyoon@gmail.com", "username:goooyoon@gmail.com"], "message": "0", "os": "android"}, {"ghost": true, "dev_id": "7e4f55e8-43f7-4a0a-a953-b5955a3e61ab", "user_id": 378290075, "campaign": "Clear Badge", "timestamp": "2015-03-27 08:00:51.730470", "campaign_id": 396230100, "action_category": "original_push_blocked", "action": "original_push_blocked", "action_detail": "Ghost push will not be sent to user 'tarek.h.soubra@gmail.com' because the original push was not sent", "push_token": "APA91bEPvrad_TPcBJlle4f_z_CcVKk9e3OGvE7VKPKtzQZtQLROHUeAlbXd9SXG8KITc9Qx7VJ2tFoVt0lk2Y8CfSkB_IBf86MGNBVvdvK5fe2C6ACvc7phHUPELe9gUjXZ60ZH2ABWBgbCtp_c_cHrLTPS6mUPeyN7ThrHojHINgilh1qM6s4", "credentials": ["email:tarek.h.soubra@gmail.com", "username:tarek.h.soubra@gmail.com"], "message": "0", "os": "android"}, {"dev_id": "5ad2a333-e273-438e-aa5e-9432551aaa1d", "user_id": 390780004, "timestamp": "2015-03-27 08:00:57.242320", "action": "more engaged", "push_token": "APA91bEdl_hgZKTkzN0r0hIp_X_ChOmUZnro4LVkdpUqAcZBLpiWdQnN7XgjIp-XsBbzcAgsuji_Ogz3VisgtWYJOLxdS3WkxqkBGlQIf0P5pWypOkkVEWl4dVf3lPmV6MKme3NzGrdifx5pUlj9AJ41DNT7HK5g-nsywSqyV1RNrY2xVKuSMJk", "credentials": ["email:abarbot0216@gmail.com", "username:abarbot0216@gmail.com"], "os": "android"}, {"ghost": true, "dev_id": "f55096bd-4ca3-49d2-a4cb-c6b24f927325", "user_id": 46840001, "campaign": "Clear Badge", "timestamp": "2015-03-27 08:01:40.074000", "campaign_id": 396230100, "action_category": "original_push_blocked", "action": "original_push_blocked", "action_detail": "Ghost push will not be sent to user 'hondafsc600@gmail.com' because the original push was not sent", "push_token": "APA91bHPUrg9liC1Kpvm_Djkpr_HQofXTMSoXqen3MPfFsbGnWiZi705hi-7MeBq2oQjwHKv0toEoBGUrSXaIUK1L9Ms6xKj1TroyX4YnlReDDVXb30wOaTZ66NhQzZ1eaIZ5LbcZnf7PtIa56zBexisSf0myWDMohHmVoTRQn8pHhBXhDAO9jE", "credentials": ["username:hondafsc600@gmail.com", "email:hondafsc600@gmail.com"], "message": "0", "os": "android"}, {"ghost": true, "dev_id": "e9fa9770-cb05-4b0f-a0e7-085eb8cc85ac", "user_id": 46840001, "campaign": "Clear Badge", "timestamp": "2015-03-27 08:01:40.292750", "campaign_id": 396230100, "action_category": "original_push_blocked", "action": "original_push_blocked", "action_detail": "Ghost push will not be sent to user 'hondafsc600@gmail.com' because the original push was not sent", "push_token": "APA91bERaWMMhX44Fs5T6pyfdh3sk0Ixurm1WApL3fPjfhAYo12_uIAH5lSF6n_jskOKL4M9RjQu7JJR9OfXqLC0IzDIktrQXlKnKQ3XsyfFST3UhuS66fhoI3jUGN_ZJOVO4HYtGG7AODcCkGn3QhatcvyAEx-rWG5K8DItcL4vMsvh_0QA_80", "credentials": ["username:hondafsc600@gmail.com", "email:hondafsc600@gmail.com"], "message": "0", "os": "android"}], "more_records": true, "cursor": "_NJXWEX2SIZTHAUL2PJ4XSVCUN5YVQ4CMMR3FC4RXLJGHKQ2DHA______-_IJDUEWCLJVBTKSSRIFIUCQKBKNAVKSKJIJAUKQKBKVHECSKDIFDEGQKDKNBE2RSPINKT2PJ5HU6T2___"}
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require File.expand_path('../../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
describe KahunaClient::Client do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@client = KahunaClient::Client.new(app_id: 'ID', app_key: 'KEY', environment: 'p')
|
7
|
+
end
|
8
|
+
|
9
|
+
describe ".logs with timestamp" do
|
10
|
+
|
11
|
+
let!(:timestamp) { Time.now }
|
12
|
+
|
13
|
+
let(:payload) {
|
14
|
+
{
|
15
|
+
categories_to_return: ['push'],
|
16
|
+
number_of_records: 5,
|
17
|
+
timestamp: timestamp.strftime('%m/%d/%y %H:%M:%S %p')
|
18
|
+
}
|
19
|
+
}
|
20
|
+
|
21
|
+
before do
|
22
|
+
# note here the env param
|
23
|
+
stub_post("api/kahunalogs?env=p").
|
24
|
+
with(body: payload).
|
25
|
+
to_return(body: fixture("logs.json"))
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should get the correct resource" do
|
29
|
+
@client.logs({timestamp:timestamp, number_of_records:5})
|
30
|
+
expect(a_post("api/kahunalogs?env=p").with(body: payload)).to have_been_made
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should parse the response in a proper way" do
|
34
|
+
logs = @client.logs({timestamp:timestamp, number_of_records:5})
|
35
|
+
|
36
|
+
# should have the proper fields
|
37
|
+
[:cursor, :more_records, :push].each do |key|
|
38
|
+
expect(logs.has_key?(key)).to be_true
|
39
|
+
end
|
40
|
+
|
41
|
+
# push array should have the proper size
|
42
|
+
expect(logs.push).to have(5).items
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe ".logs with cursor" do
|
47
|
+
|
48
|
+
let!(:cursor) { 'TestCursor' }
|
49
|
+
|
50
|
+
let(:payload) {
|
51
|
+
{
|
52
|
+
categories_to_return: ['push'],
|
53
|
+
number_of_records: 5,
|
54
|
+
cursor: cursor
|
55
|
+
}
|
56
|
+
}
|
57
|
+
|
58
|
+
before do
|
59
|
+
# note here the env param
|
60
|
+
stub_post("api/kahunalogs?env=p").
|
61
|
+
with(body: payload).
|
62
|
+
to_return(body: fixture("logs.json"))
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should get the correct resource" do
|
66
|
+
@client.logs({cursor:cursor, number_of_records:5})
|
67
|
+
expect(a_post("api/kahunalogs?env=p").with(body: payload)).to have_been_made
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kahuna_client
|
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
|
- Edgar Gonzalez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-03-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -154,6 +154,7 @@ files:
|
|
154
154
|
- lib/kahuna_client.rb
|
155
155
|
- lib/kahuna_client/api.rb
|
156
156
|
- lib/kahuna_client/client.rb
|
157
|
+
- lib/kahuna_client/client/logs.rb
|
157
158
|
- lib/kahuna_client/client/push.rb
|
158
159
|
- lib/kahuna_client/configuration.rb
|
159
160
|
- lib/kahuna_client/connection.rb
|
@@ -162,10 +163,12 @@ files:
|
|
162
163
|
- lib/kahuna_client/version.rb
|
163
164
|
- spec/faraday/response_spec.rb
|
164
165
|
- spec/fixtures/authentication_failed.json
|
166
|
+
- spec/fixtures/logs.json
|
165
167
|
- spec/fixtures/success.json
|
166
168
|
- spec/fixtures/user_not_enabled_for_push.json
|
167
169
|
- spec/fixtures/user_not_found.json
|
168
170
|
- spec/kahuna_client/api_spec.rb
|
171
|
+
- spec/kahuna_client/client/logs_spec.rb
|
169
172
|
- spec/kahuna_client/client/push_spec.rb
|
170
173
|
- spec/kahuna_client/client_spec.rb
|
171
174
|
- spec/kahuna_client_spec.rb
|
@@ -197,10 +200,12 @@ summary: A ruby wrapper for Kahuna Push API
|
|
197
200
|
test_files:
|
198
201
|
- spec/faraday/response_spec.rb
|
199
202
|
- spec/fixtures/authentication_failed.json
|
203
|
+
- spec/fixtures/logs.json
|
200
204
|
- spec/fixtures/success.json
|
201
205
|
- spec/fixtures/user_not_enabled_for_push.json
|
202
206
|
- spec/fixtures/user_not_found.json
|
203
207
|
- spec/kahuna_client/api_spec.rb
|
208
|
+
- spec/kahuna_client/client/logs_spec.rb
|
204
209
|
- spec/kahuna_client/client/push_spec.rb
|
205
210
|
- spec/kahuna_client/client_spec.rb
|
206
211
|
- spec/kahuna_client_spec.rb
|