action_tracker_client 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/Gemfile.lock +9 -11
- data/README.md +19 -0
- data/lib/action_tracker/models/transition_record.rb +30 -3
- data/lib/action_tracker/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b49e126178e1c41aeac5bca208cf545dfd9d221cee9ff843506b889ec56620cc
|
4
|
+
data.tar.gz: a572ecb730e7fafc315d31905b0ad8a5fbfb1c1d178f1ebe924050cce8657104
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: baf06c442cf8bc2a726af177be71084618d364173282869fdebf20e8dbd0a0679f9aa163639f038f43bc1e10f595ce367765a05b2629643ac68f644035dd438c
|
7
|
+
data.tar.gz: 6b94ce8fa2ce2904841d8429eb273f78e901ad7cb33871d7f1b0885c6e392aed5ca0f407daa135b6f2b49e1caa48390ee03b78e35ea3040bee5e06cac0cf5b11
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
action_tracker_client (0.1.
|
4
|
+
action_tracker_client (0.1.1)
|
5
5
|
activemodel (>= 4.0)
|
6
6
|
activesupport (>= 4.0)
|
7
7
|
api_signature (~> 0.1.5)
|
@@ -12,14 +12,13 @@ PATH
|
|
12
12
|
GEM
|
13
13
|
remote: https://rubygems.org/
|
14
14
|
specs:
|
15
|
-
activemodel (
|
16
|
-
activesupport (=
|
17
|
-
activesupport (
|
15
|
+
activemodel (5.2.3)
|
16
|
+
activesupport (= 5.2.3)
|
17
|
+
activesupport (5.2.3)
|
18
18
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
19
19
|
i18n (>= 0.7, < 2)
|
20
20
|
minitest (~> 5.1)
|
21
21
|
tzinfo (~> 1.1)
|
22
|
-
zeitwerk (~> 2.1, >= 2.1.8)
|
23
22
|
addressable (2.6.0)
|
24
23
|
public_suffix (>= 2.0.2, < 4.0)
|
25
24
|
api_signature (0.1.5)
|
@@ -57,7 +56,7 @@ GEM
|
|
57
56
|
guard-compat (~> 1.1)
|
58
57
|
rspec (>= 2.99.0, < 4.0)
|
59
58
|
hashdiff (0.3.9)
|
60
|
-
httparty (0.17.
|
59
|
+
httparty (0.17.0)
|
61
60
|
mime-types (~> 3.0)
|
62
61
|
multi_xml (>= 0.5.2)
|
63
62
|
i18n (1.6.0)
|
@@ -69,10 +68,10 @@ GEM
|
|
69
68
|
ruby_dep (~> 1.2)
|
70
69
|
lumberjack (1.0.13)
|
71
70
|
method_source (0.9.2)
|
72
|
-
mime-types (3.
|
71
|
+
mime-types (3.2.2)
|
73
72
|
mime-types-data (~> 3.2015)
|
74
|
-
mime-types-data (3.2019.
|
75
|
-
minitest (5.
|
73
|
+
mime-types-data (3.2019.0331)
|
74
|
+
minitest (5.11.3)
|
76
75
|
model_auditor (0.0.2)
|
77
76
|
multi_xml (0.6.0)
|
78
77
|
nenv (0.3.0)
|
@@ -120,7 +119,6 @@ GEM
|
|
120
119
|
addressable (>= 2.3.6)
|
121
120
|
crack (>= 0.3.2)
|
122
121
|
hashdiff
|
123
|
-
zeitwerk (2.1.10)
|
124
122
|
|
125
123
|
PLATFORMS
|
126
124
|
ruby
|
@@ -135,4 +133,4 @@ DEPENDENCIES
|
|
135
133
|
webmock (~> 3.5, >= 3.5.1)
|
136
134
|
|
137
135
|
BUNDLED WITH
|
138
|
-
1.
|
136
|
+
1.16.2
|
data/README.md
CHANGED
@@ -62,6 +62,25 @@ end
|
|
62
62
|
#<ActionTracker::Models::TransitionRecord:0x00007f9584d3dfd0 @id="810b900d-d24b-4206-85e3-b7a53e55a060"...
|
63
63
|
```
|
64
64
|
|
65
|
+
### Records filtered by user
|
66
|
+
```ruby
|
67
|
+
api = ActionTracker::Models::TransitionRecord.new
|
68
|
+
data = api.filtered_by_users(user_id: user.id, target_id: order.id, target_type: 'Order', per_page: 25, cursor: 'Y3VycmVudF9wYWdl')
|
69
|
+
|
70
|
+
#<ActionTracker::CollectionProxy:0x00007f958b6970a8
|
71
|
+
# ...
|
72
|
+
|
73
|
+
data.each do |record|
|
74
|
+
puts record.inspect
|
75
|
+
end
|
76
|
+
|
77
|
+
#<ActionTracker::Models::TransitionRecord:0x00007f9584d44470 @id="a51b2fe2-fa92-4e91-bdcd-5beee9081903"...
|
78
|
+
#<ActionTracker::Models::TransitionRecord:0x00007f9584d3dfd0 @id="810b900d-d24b-4206-85e3-b7a53e55a060"...
|
79
|
+
|
80
|
+
# data = api.filtered_by_users_count(user_id: user.id, target_id: order.id, target_type: 'Order')
|
81
|
+
# this will return count of actions
|
82
|
+
```
|
83
|
+
|
65
84
|
### Writing records
|
66
85
|
|
67
86
|
Call ActionTracker::Recorder after creating or updating your model:
|
@@ -31,16 +31,31 @@ module ActionTracker
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def index(params = {})
|
34
|
-
path =
|
35
|
-
@response ||= Connection.new.get(path)
|
34
|
+
@path = processed_path(collection_path, params)
|
36
35
|
|
37
|
-
|
36
|
+
parse_response
|
37
|
+
end
|
38
|
+
|
39
|
+
def filtered_by_users(params = {})
|
40
|
+
@path = processed_path(users(params[:user_id]), params.except(:user_id))
|
41
|
+
|
42
|
+
parse_response
|
43
|
+
end
|
44
|
+
|
45
|
+
def filtered_by_users_count(params = {})
|
46
|
+
@path = processed_path(users(params[:user_id]) + '/count', params.except(:user_id))
|
47
|
+
|
48
|
+
response
|
38
49
|
end
|
39
50
|
|
40
51
|
def collection_path
|
41
52
|
'transitions'
|
42
53
|
end
|
43
54
|
|
55
|
+
def users(user_id)
|
56
|
+
"users/#{user_id}"
|
57
|
+
end
|
58
|
+
|
44
59
|
def payload
|
45
60
|
super.presence || @payload = ActionTracker::Models::Payload.new
|
46
61
|
end
|
@@ -55,11 +70,23 @@ module ActionTracker
|
|
55
70
|
|
56
71
|
private
|
57
72
|
|
73
|
+
def parse_response
|
74
|
+
ActionTracker::CollectionProxy.new response, self.class.model_name
|
75
|
+
end
|
76
|
+
|
77
|
+
def response
|
78
|
+
@response ||= Connection.new.get(@path)
|
79
|
+
end
|
80
|
+
|
58
81
|
def check_payload
|
59
82
|
return if payload.valid?
|
60
83
|
|
61
84
|
errors.add(:payload, :invalid)
|
62
85
|
end
|
86
|
+
|
87
|
+
def processed_path(collection_name, params)
|
88
|
+
[collection_name, params.to_query].reject(&:blank?).compact.join('?')
|
89
|
+
end
|
63
90
|
end
|
64
91
|
end
|
65
92
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: action_tracker_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Malinovskiy
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -257,7 +257,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
257
257
|
- !ruby/object:Gem::Version
|
258
258
|
version: '0'
|
259
259
|
requirements: []
|
260
|
-
|
260
|
+
rubyforge_project:
|
261
|
+
rubygems_version: 2.7.6.2
|
261
262
|
signing_key:
|
262
263
|
specification_version: 4
|
263
264
|
summary: ActionTracking service client gem
|