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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8c9a284d38f4ea7b2511f08c99a9cbf3b523bd35
4
- data.tar.gz: fafad4af4d8745213791e7106105148cd150e9a0
3
+ metadata.gz: c1f24dd0ab5dc2ecd74d97898186fe82e8707ed9
4
+ data.tar.gz: 1dd166204586a4c8a68128a63416bf103c340a15
5
5
  SHA512:
6
- metadata.gz: 64a82a247bcdb07a279a0c22b176f4a7fcb069142309e215e60b9be36d22dbaa42da16788c8fa8e6612af2b40a249c9ce94aba2f0a5c32f5c103bf875985c77a
7
- data.tar.gz: 9fcd0ada00e4ddae41be0d74b89ec3960b57f56cb3d7ca42fe48b2217fa0a0580dcaafbac085aa360b7592fd4757c10b0c1845087234540b247b33fdbd1e6a0c
6
+ metadata.gz: f0a90d7e8409ba274a6565640474560559c2dad1a3e3546b5faf7a8c87d81d13911873786b76203f1f0cbf386c456c9c9fc6fc3e961b1ac0d10e6d7cb7f7375f
7
+ data.tar.gz: 5e27257666076c2490379ca0ee1377413f90774ac96af4bab5bf9327122482600a2ed56fb319884eddb706fbd0e63dcda1c178fb924681e17a49bcfda8781632
data/.gitignore CHANGED
@@ -6,6 +6,7 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ /.idea/
9
10
 
10
11
  # rspec failure tracking
11
12
  .rspec_status
data/Gemfile.lock CHANGED
@@ -1,14 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- refocus (0.1.5)
4
+ refocus (0.1.6)
5
5
  clamp (~> 1.1)
6
6
  excon (~> 0.60)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- clamp (1.1.2)
11
+ clamp (1.2.1)
12
12
  coderay (1.1.2)
13
13
  diff-lcs (1.3)
14
14
  excon (0.60.0)
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.
@@ -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 submit(name:, aspect:, value:)
19
- c = collector
20
- c.add(name: name, aspect: aspect, value: value)
21
- c.submit
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
- require "refocus/samples/collector"
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 submit
19
+ def upsert_bulk
17
20
  result = json(http.post("upsert/bulk", body: samples, expects: 200))
18
21
  samples.clear
19
- true
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
@@ -1,3 +1,3 @@
1
1
  module Refocus
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
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.5
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-01-22 00:00:00.000000000 Z
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.2.1
154
+ rubygems_version: 2.5.1
155
155
  signing_key:
156
156
  specification_version: 4
157
157
  summary: Refocus ruby client