material_service_client 0.1.11 → 0.1.12
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/lib/material_service_client.rb +63 -32
- data/lib/material_service_client/version.rb +1 -1
- data/material_service_client.gemspec +3 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 913d0e9c2b98a4a2142d5f8087cffdb5d97c920d
|
4
|
+
data.tar.gz: b40a24db29bfd035b3f0ccaf46c3eec905c64d0a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b61e26c437c0a5d1ce429c712dd66b8dbf195b15c5c1a28d2c929d9ce66b6b4a35c92fb5120a97e88fef56ad22f7ef744e3484ea0fdb603227d3a74ce79b965d
|
7
|
+
data.tar.gz: e34fb3413c50086eb5b78d4dbf3ee8025bde8bd5aa33bca3a9c6d2feac17e8e9f0205082d416cf9d38679493bfcc17843173ff4424df8719915b4b6f8986d2d9
|
@@ -1,51 +1,82 @@
|
|
1
1
|
require "material_service_client/version"
|
2
|
+
require 'faraday'
|
3
|
+
require 'json'
|
2
4
|
|
3
5
|
module MaterialServiceClient
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
6
|
+
module Material
|
7
|
+
def self.post(data)
|
8
|
+
conn = MaterialServiceClient::get_connection
|
9
|
+
JSON.parse(conn.post('/materials', data.to_json).body)
|
10
|
+
end
|
8
11
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
+
def self.put(data)
|
13
|
+
uuid = data[:uuid]
|
14
|
+
data_to_send = data.reject{|k,v| k.to_sym == :uuid}
|
12
15
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
+
conn = MaterialServiceClient::get_connection
|
17
|
+
JSON.parse(conn.put('/materials/'+uuid, data_to_send.to_json).body)
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.get(uuid)
|
21
|
+
return nil if uuid.nil?
|
22
|
+
conn = MaterialServiceClient::get_connection
|
23
|
+
JSON.parse(conn.get('/materials/'+uuid).body)
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.valid?(uuids)
|
27
|
+
conn = MaterialServiceClient::get_connection
|
28
|
+
data = { materials: uuids }
|
16
29
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
30
|
+
response = conn.post('/materials/validate', data.to_json)
|
31
|
+
response.body == 'ok'
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.delete(uuid)
|
35
|
+
return nil if uuid.nil?
|
36
|
+
conn = MaterialServiceClient::get_connection
|
37
|
+
JSON.parse(conn.delete('/materials/'+uuid).body)
|
38
|
+
end
|
21
39
|
end
|
22
40
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
41
|
+
module Container
|
42
|
+
def self.post(data)
|
43
|
+
conn = MaterialServiceClient::get_connection
|
44
|
+
JSON.parse(conn.post('/containers', data.to_json).body)
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.put(data)
|
48
|
+
uuid = data[:uuid]
|
49
|
+
data_to_send = data.reject{|k,v| k.to_sym == :uuid}
|
50
|
+
|
51
|
+
conn = MaterialServiceClient::get_connection
|
52
|
+
JSON.parse(conn.put('/containers/'+uuid, data_to_send.to_json).body)
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.get(uuid)
|
56
|
+
return nil if uuid.nil?
|
57
|
+
conn = MaterialServiceClient::get_connection
|
58
|
+
JSON.parse(conn.get('/containers/'+uuid).body)
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.delete(uuid)
|
62
|
+
return nil if uuid.nil?
|
63
|
+
conn = MaterialServiceClient::get_connection
|
64
|
+
conn.delete('/containers/'+uuid)
|
65
|
+
end
|
66
|
+
end
|
37
67
|
|
38
68
|
private
|
39
69
|
|
40
70
|
def self.get_connection
|
41
|
-
conn = Faraday.new(:url =>
|
71
|
+
conn = Faraday.new(:url => ENV['MATERIALS_URL']) do |faraday|
|
42
72
|
# faraday.use ZipkinTracer::FaradayHandler, 'eve'
|
43
|
-
faraday.proxy
|
73
|
+
faraday.proxy ENV['MATERIALS_URL']
|
44
74
|
faraday.request :url_encoded
|
45
75
|
faraday.response :logger
|
46
|
-
faraday.adapter Faraday.default_adapter
|
76
|
+
faraday.adapter Faraday.default_adapter
|
47
77
|
end
|
48
|
-
conn.headers = {'Content-Type' => 'application/json'}
|
78
|
+
conn.headers = {'Content-Type' => 'application/json'}
|
49
79
|
conn
|
50
80
|
end
|
81
|
+
|
51
82
|
end
|
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
|
|
16
16
|
|
17
17
|
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
18
|
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
-
|
19
|
+
|
20
20
|
# if spec.respond_to?(:metadata)
|
21
21
|
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
22
22
|
# else
|
@@ -35,4 +35,6 @@ Gem::Specification.new do |spec|
|
|
35
35
|
spec.add_development_dependency "rake", "~> 10.0"
|
36
36
|
spec.add_development_dependency "rspec", "~> 3.0"
|
37
37
|
|
38
|
+
spec.add_dependency "faraday"
|
39
|
+
|
38
40
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: material_service_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Harriet Craven
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: faraday
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
description: Gem to access the material service API.
|
56
70
|
email:
|
57
71
|
- hc6@sanger.ac.uk
|