refocus 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +2 -2
- data/README.md +28 -3
- data/lib/refocus/samples.rb +16 -7
- data/lib/refocus/samples/collector.rb +9 -8
- data/lib/refocus/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1f24dd0ab5dc2ecd74d97898186fe82e8707ed9
|
4
|
+
data.tar.gz: 1dd166204586a4c8a68128a63416bf103c340a15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0a90d7e8409ba274a6565640474560559c2dad1a3e3546b5faf7a8c87d81d13911873786b76203f1f0cbf386c456c9c9fc6fc3e961b1ac0d10e6d7cb7f7375f
|
7
|
+
data.tar.gz: 5e27257666076c2490379ca0ee1377413f90774ac96af4bab5bf9327122482600a2ed56fb319884eddb706fbd0e63dcda1c178fb924681e17a49bcfda8781632
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -2,9 +2,6 @@
|
|
2
2
|
|
3
3
|
A ruby client library and CLI for [Refocus](https://github.com/salesforce/refocus).
|
4
4
|
|
5
|
-
This client is not complete. If you notice any missing functionality, please feel free to submit a pull request!
|
6
|
-
|
7
|
-
|
8
5
|
## Installation
|
9
6
|
|
10
7
|
Add this line to your application's Gemfile:
|
@@ -86,6 +83,34 @@ refocus.aspects.get(name: "my-aspect")
|
|
86
83
|
refocus.aspects.delete(name: "my-aspect")
|
87
84
|
```
|
88
85
|
|
86
|
+
#### Samples
|
87
|
+
|
88
|
+
You can manage samples like this:
|
89
|
+
|
90
|
+
```ruby
|
91
|
+
# Instantiate the samples client
|
92
|
+
samples_client = refocus.samples
|
93
|
+
|
94
|
+
# Create or update a sample:
|
95
|
+
samples_client.upsert(name: "my-subject.child-subject", aspect: "my-aspect", value: '100')
|
96
|
+
|
97
|
+
# Create or update a sample with a custom request body
|
98
|
+
request_body = {name: "my-subject.child-subject|my-aspect", value: '100', messageCode: '100%', messageBody: "Great Results!", relatedLinks: [{name:'example_1', url:'https://www.example_1.com'}]}
|
99
|
+
samples_client.upsert_custom_body(request_body)
|
100
|
+
|
101
|
+
# Describe a sample:
|
102
|
+
samples_client.get(subject: "my-subject", aspect: "my-aspect")
|
103
|
+
|
104
|
+
# List samples:
|
105
|
+
samples_client.list(limit: 50)
|
106
|
+
|
107
|
+
# Create or update samples in bulk:
|
108
|
+
samples_collector = samples_client.collector
|
109
|
+
samples_collector.add(name: "my-subject.child-subject", aspect: "my-aspect-1", value: '100')
|
110
|
+
samples_collector.add(name: "my-subject.child-subject", aspect: "my-aspect-2", messageCode: '100%')
|
111
|
+
samples_collector.upsert_bulk
|
112
|
+
```
|
113
|
+
|
89
114
|
#### Lenses
|
90
115
|
|
91
116
|
Lenses are not supported at this time.
|
data/lib/refocus/samples.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "refocus/http"
|
2
2
|
require "refocus/json_helper"
|
3
|
+
require "refocus/samples/collector"
|
3
4
|
|
4
5
|
module Refocus
|
5
6
|
class Samples
|
@@ -15,10 +16,15 @@ module Refocus
|
|
15
16
|
Collector.new(http: http)
|
16
17
|
end
|
17
18
|
|
18
|
-
def
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
def upsert(name:, aspect:, value:"", messageBody:"", messageCode:"", relatedLinks:[])
|
20
|
+
sample = format_sample(name:name, aspect: aspect, value: value, messageBody: messageBody, messageCode: messageCode, relatedLinks: relatedLinks)
|
21
|
+
json(http.post("upsert", body: sample, expects: 200))
|
22
|
+
end
|
23
|
+
alias_method :submit, :upsert
|
24
|
+
|
25
|
+
def upsert_custom_body(custom_body)
|
26
|
+
endpoint = (custom_body.is_a? Array) ? "upsert/bulk" : "upsert"
|
27
|
+
json(http.post(endpoint, body: custom_body, expects: 200))
|
22
28
|
end
|
23
29
|
|
24
30
|
def list(limit: nil)
|
@@ -30,8 +36,11 @@ module Refocus
|
|
30
36
|
def get(subject:, aspect:)
|
31
37
|
json(http.get(URI.escape("#{subject}\|#{aspect}")))
|
32
38
|
end
|
33
|
-
end
|
34
|
-
end
|
35
39
|
|
36
|
-
|
40
|
+
private
|
41
|
+
def format_sample(name:, aspect:, value:"", messageBody:"", messageCode:"", relatedLinks:[])
|
42
|
+
{name: "#{name}|#{aspect}", value: value.to_s, messageBody: messageBody, messageCode: messageCode, relatedLinks: relatedLinks}
|
43
|
+
end
|
37
44
|
|
45
|
+
end
|
46
|
+
end
|
@@ -1,6 +1,9 @@
|
|
1
|
+
require "refocus/json_helper"
|
2
|
+
|
1
3
|
module Refocus
|
2
4
|
class Samples
|
3
5
|
class Collector
|
6
|
+
include JsonHelper
|
4
7
|
|
5
8
|
attr_reader :http, :samples
|
6
9
|
|
@@ -9,19 +12,17 @@ module Refocus
|
|
9
12
|
@samples = []
|
10
13
|
end
|
11
14
|
|
12
|
-
def add(name:, aspect:, value:)
|
13
|
-
samples << {name: "#{name}|#{aspect}", value: value.to_s}
|
15
|
+
def add(name:, aspect:, value:"", messageBody:"", messageCode:"", relatedLinks:[])
|
16
|
+
samples << {name: "#{name}|#{aspect}", value: value.to_s, messageBody: messageBody, messageCode: messageCode, relatedLinks: relatedLinks}
|
14
17
|
end
|
15
18
|
|
16
|
-
def
|
19
|
+
def upsert_bulk
|
17
20
|
result = json(http.post("upsert/bulk", body: samples, expects: 200))
|
18
21
|
samples.clear
|
19
|
-
|
22
|
+
result
|
20
23
|
end
|
24
|
+
alias_method :submit, :upsert_bulk
|
21
25
|
|
22
|
-
def json(response)
|
23
|
-
JSON.parse(response.body)
|
24
|
-
end
|
25
26
|
end
|
26
27
|
end
|
27
|
-
end
|
28
|
+
end
|
data/lib/refocus/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: refocus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Shea
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -151,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
151
151
|
version: '0'
|
152
152
|
requirements: []
|
153
153
|
rubyforge_project:
|
154
|
-
rubygems_version: 2.5.
|
154
|
+
rubygems_version: 2.5.1
|
155
155
|
signing_key:
|
156
156
|
specification_version: 4
|
157
157
|
summary: Refocus ruby client
|