tracksale 0.0.5 → 0.0.7
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 +4 -4
- data/Gemfile +1 -0
- data/lib/tracksale/answer.rb +17 -8
- data/test/test_tracksale_answer.rb +67 -1
- data/tracksale.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 68837fb1bea59e1036b75f13f0fce6a00b17a962
|
|
4
|
+
data.tar.gz: 671dadbd5bbeab55c289009ec776d5b09ac7da6b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 76e321be82a849a2d3bd457a9702781399d59ca39b6db5da3716acb678ac67dfadb9d96d619b1ab9e1468993a956be9d34f2224bccfbba27704026f460818342
|
|
7
|
+
data.tar.gz: a12f022331f70799fc7afb0535f5ae3f3a8ff21e79837b0e32e83883bd323a47d97add7f76f5d74e9aea524deed5d680b33b44f95e324e4a959ab67431112c2c
|
data/Gemfile
CHANGED
data/lib/tracksale/answer.rb
CHANGED
|
@@ -15,8 +15,8 @@ module Tracksale
|
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
class << self
|
|
18
|
-
def all
|
|
19
|
-
raw_all.map { |answer| create_from_response(answer) }
|
|
18
|
+
def all( start_time=(Time.now-86_400), end_time=(Time.now+86_400))
|
|
19
|
+
raw_all(start_time,end_time).map { |answer| create_from_response(answer) }
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
def create_from_response(raw_response)
|
|
@@ -44,8 +44,12 @@ module Tracksale
|
|
|
44
44
|
end
|
|
45
45
|
end
|
|
46
46
|
|
|
47
|
-
def raw_all
|
|
48
|
-
|
|
47
|
+
def raw_all( start_time=(Time.now-86_400), end_time=(Time.now+86_400))
|
|
48
|
+
start_date = start_time.strftime('%Y-%m-%d')
|
|
49
|
+
end_date = end_time.strftime('%Y-%m-%d')
|
|
50
|
+
all_request = "report/answer?tags=true&limit=#{LIMIT}&start=#{start_date}&end=#{end_date}"
|
|
51
|
+
|
|
52
|
+
client.get(all_request)
|
|
49
53
|
end
|
|
50
54
|
|
|
51
55
|
def client
|
|
@@ -60,10 +64,15 @@ module Tracksale
|
|
|
60
64
|
|
|
61
65
|
def convert_justif(multiple_answers)
|
|
62
66
|
multiple_answers.map do |single_answer|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
single_answer['
|
|
66
|
-
|
|
67
|
+
begin
|
|
68
|
+
{
|
|
69
|
+
JSON.parse(single_answer['name']).values.first =>
|
|
70
|
+
single_answer['children'].map { |c| JSON.parse(c).values.first }
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
rescue JSON::ParserError
|
|
74
|
+
{ single_answer['name'] => single_answer['children'] }
|
|
75
|
+
end
|
|
67
76
|
end
|
|
68
77
|
end
|
|
69
78
|
end
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
1
2
|
require 'minitest/autorun'
|
|
2
3
|
require 'webmock/minitest'
|
|
3
4
|
require 'tracksale'
|
|
@@ -15,7 +16,12 @@ class TestTracksaleAnswer < Minitest::Test
|
|
|
15
16
|
.to_return(body: body_for_campaign,
|
|
16
17
|
headers: { content_type: 'application/json' }, status: 200)
|
|
17
18
|
|
|
18
|
-
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
stub_request(:get, 'http://api.tracksale.co/v2/report/answer?tags=true&limit=' +
|
|
22
|
+
Tracksale::Answer::LIMIT.to_s +
|
|
23
|
+
'&start='+(Time.now-86_400).strftime('%Y-%m-%d') +
|
|
24
|
+
'&end='+(Time.now+86_400).strftime('%Y-%m-%d'))
|
|
19
25
|
.with(headers: { 'authorization' => 'bearer foobar' })
|
|
20
26
|
.to_return(body: '[{
|
|
21
27
|
"time": 1532611646,
|
|
@@ -62,6 +68,59 @@ class TestTracksaleAnswer < Minitest::Test
|
|
|
62
68
|
}
|
|
63
69
|
]
|
|
64
70
|
}
|
|
71
|
+
]',
|
|
72
|
+
headers: { content_type: 'application/json' }, status: 200)
|
|
73
|
+
#Second type of justifications return.
|
|
74
|
+
stub_request(:get, 'http://api.tracksale.co/v2/report/answer?tags=true&limit=' +
|
|
75
|
+
Tracksale::Answer::LIMIT.to_s +
|
|
76
|
+
'&start='+(Time.at(1000)).strftime('%Y-%m-%d') +
|
|
77
|
+
'&end='+(Time.at(1000)).strftime('%Y-%m-%d'))
|
|
78
|
+
.with(headers: { 'authorization' => 'bearer foobar' })
|
|
79
|
+
.to_return(body: '[{
|
|
80
|
+
"time": 1532611646,
|
|
81
|
+
"type": "Email",
|
|
82
|
+
"name": "Um Dois Tres Quatro",
|
|
83
|
+
"email": "emailaleatorio@gmail.com",
|
|
84
|
+
"identification": null,
|
|
85
|
+
"phone": null,
|
|
86
|
+
"alternative_email": null,
|
|
87
|
+
"alternative_phone": null,
|
|
88
|
+
"nps_answer": 10,
|
|
89
|
+
"last_nps_answer": null,
|
|
90
|
+
"nps_comment": null,
|
|
91
|
+
"campaign_name": "Campanha de Teste",
|
|
92
|
+
"campaign_code": 7,
|
|
93
|
+
"id": 11112222,
|
|
94
|
+
"deadline": null,
|
|
95
|
+
"elapsed_time": 116,
|
|
96
|
+
"dispatch_time": null,
|
|
97
|
+
"reminder_time": null,
|
|
98
|
+
"status": "Não precisa contatar",
|
|
99
|
+
"priority": "Nenhuma",
|
|
100
|
+
"assignee": "Boris",
|
|
101
|
+
"picture": null,
|
|
102
|
+
"tags": [
|
|
103
|
+
{
|
|
104
|
+
"name": "test1",
|
|
105
|
+
"value": "test2"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"name": "test3",
|
|
109
|
+
"value": "test4"
|
|
110
|
+
}
|
|
111
|
+
],
|
|
112
|
+
"categories": [],
|
|
113
|
+
"justifications": [
|
|
114
|
+
{
|
|
115
|
+
"name": "foo2",
|
|
116
|
+
"children": [
|
|
117
|
+
"bar5",
|
|
118
|
+
"bar6",
|
|
119
|
+
"bar7"
|
|
120
|
+
]
|
|
121
|
+
}
|
|
122
|
+
]
|
|
123
|
+
}
|
|
65
124
|
]',
|
|
66
125
|
headers: { content_type: 'application/json' }, status: 200)
|
|
67
126
|
end
|
|
@@ -78,6 +137,13 @@ class TestTracksaleAnswer < Minitest::Test
|
|
|
78
137
|
assert_equal expected_justifications, subject.justifications
|
|
79
138
|
end
|
|
80
139
|
|
|
140
|
+
def test_justifications_second_type
|
|
141
|
+
answer = Tracksale::Answer.all(Time.at(1000),Time.at(1000)).first
|
|
142
|
+
assert answer.respond_to? :justifications
|
|
143
|
+
expected_justifications = [{ 'foo2' => %w[bar5 bar6 bar7] }]
|
|
144
|
+
assert_equal expected_justifications, answer.justifications
|
|
145
|
+
end
|
|
146
|
+
|
|
81
147
|
def test_campaign
|
|
82
148
|
assert subject.campaign.is_a? Tracksale::Campaign
|
|
83
149
|
end
|
data/tracksale.gemspec
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: tracksale
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Estudar
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2018-
|
|
11
|
+
date: 2018-08-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: byebug
|