assaydepot 0.0.4 → 0.0.5

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: 39ad77b2ffb93d4a0eff9df69ac02e59cffa5eb9
4
- data.tar.gz: 91ab5909a3fca9c366142566ea39415b99321019
3
+ metadata.gz: aa533354a0d547e58f3126a353a07aa5addb768a
4
+ data.tar.gz: 6b96d17cdf3d767ecff0abda1b4059c394b223e3
5
5
  SHA512:
6
- metadata.gz: 8912c78dba929eec5d318e39d0537393624ed81dbe90a18aff1f6fabd9de95cd8fa9c75492b611af0f0d688b5e7cc52cf17dd56c473810fe5a1a56051c602c3d
7
- data.tar.gz: 7dd49cf9fbae07e6eef7e1be8696c30a60b6edfb5266bd7b8cb98f458af78084085607e99d04ff0ebc805bc7c6d23e439c4c3b1435677c453aee2b1188f73afd
6
+ metadata.gz: c674589b7d71bc9ffb11cfd8a13d798502c08fe06656044fb9909d66a86f27729a4745e10a060d9c5fb14690d213035cd74bb85fc0ab5da507bfd7f96621dee5
7
+ data.tar.gz: 899c7ea6a6bbce87b2cc3c16e5ab1c89a701c5ed85d7754ba03f660ef902e197489c4213925aaca48af6ca464545a9e77eac6c55a92e7e3aa3585d40ccb1351c
data/.gitignore CHANGED
@@ -15,3 +15,5 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ .env
19
+ ./api.rb
@@ -1,5 +1,6 @@
1
- before_script:
2
- - export ASSAYDEPOT_APP_ID=6hH3KQZz9oqR5lqtckyqfAUcyfNgHQ
3
- - export ASSAYDEPOT_APP_SECRET=FDwDYchR220FSYDPtqS12e-P0pjx-7y_tbba3wyr-3VschLuVgpvOBBL
1
+ rvm:
2
+ - 2.0.0
3
+ - 2.1.0
4
+ - 2.3.0
4
5
  script:
5
6
  - bundle exec rake spec
data/Gemfile CHANGED
@@ -1,4 +1,8 @@
1
1
  source 'https://rubygems.org'
2
+ gem 'pry'
3
+ gem 'pry-byebug'
4
+ gem 'uri-query_params'
5
+ gem 'dotenv-rails', groups: [:development, :test]
2
6
 
3
7
  # Specify your gem's dependencies in assaydepot.gemspec
4
8
  gemspec
data/Rakefile CHANGED
File without changes
@@ -9,6 +9,8 @@ Gem::Specification.new do |gem|
9
9
  gem.homepage = "https://github.com/assaydepot/assaydepot-rb"
10
10
 
11
11
  gem.add_dependency('json')
12
+ gem.add_dependency('uri-query_params')
13
+
12
14
  gem.add_development_dependency('rake')
13
15
  gem.add_development_dependency('rspec')
14
16
  gem.add_development_dependency('oauth2')
@@ -18,6 +20,6 @@ Gem::Specification.new do |gem|
18
20
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
21
  gem.name = "assaydepot"
20
22
  gem.require_paths = ["lib"]
21
-
23
+
22
24
  gem.version = AssayDepot::VERSION
23
25
  end
@@ -2,6 +2,22 @@ require "assaydepot/version"
2
2
  require "assaydepot/configurable"
3
3
  require "assaydepot/client"
4
4
  require "assaydepot/model"
5
- require "assaydepot/ware"
6
- require "assaydepot/provider"
7
5
  require "assaydepot/core"
6
+ require "assaydepot/endpoints"
7
+ require "assaydepot/event"
8
+
9
+ module AssayDepot
10
+ class SignatureVerificationError < StandardError
11
+ def initialize(msg="Event not properly signed.", exception_type="custom")
12
+ @exception_type = exception_type
13
+ super(msg)
14
+ end
15
+ end
16
+
17
+ class WebhookError < StandardError
18
+ def initialize(msg="Webhook was not applied.", exception_type="custom")
19
+ @exception_type = exception_type
20
+ super(msg)
21
+ end
22
+ end
23
+ end
@@ -1,36 +1,84 @@
1
1
  require "open-uri"
2
2
  require "json"
3
+ require 'uri/query_params'
4
+ require 'net/http'
3
5
 
4
6
  module AssayDepot
5
- class Client
7
+ class Client
8
+
6
9
  def initialize(options={})
7
- @search_type = options[:search_type] || "wares"
10
+ @endpoint = options[:endpoint]
11
+ end
12
+
13
+ def request(url, params={}, headers={}, auth={})
14
+ uri = URI( "#{url}" )
15
+ uri.query = URI.encode_www_form( params ) unless params.keys.length == 0
16
+ http = Net::HTTP.new(uri.host, uri.port)
17
+ request = Net::HTTP::Get.new(uri.request_uri)
18
+ request.basic_auth auth[:username], auth[:password] unless auth[:username].nil?
19
+ res = http.request(request)
20
+ JSON.parse(res.body)
21
+ end
22
+
23
+ def get(params={})
24
+ uri = get_uri( params )
25
+ http = Net::HTTP.new(uri.host, uri.port)
26
+ request = Net::HTTP::Get.new(uri.request_uri)
27
+ request["Authorization"] = "Bearer #{AssayDepot.access_token}" unless params[:access_token]
28
+ res = http.request(request)
29
+ JSON.parse(res.body)
8
30
  end
9
31
 
10
- def search_url(params={})
11
- "#{AssayDepot.url}/#{@search_type}.json"
32
+ def put(body={}, params={})
33
+ uri = get_uri( params )
34
+ http = Net::HTTP.new(uri.host, uri.port)
35
+ request = Net::HTTP::Put.new(uri.request_uri)
36
+ request["Authorization"] = "Bearer #{AssayDepot.access_token}" unless params[:access_token]
37
+ request["Content-Type"] = "application/json"
38
+ if (body.keys.length > 0)
39
+ request.body = body.to_json
40
+ end
41
+ res = http.request(request)
42
+ JSON.parse(res.body)
12
43
  end
13
44
 
14
- def get_url(id, params={})
15
- "#{AssayDepot.url}/#{@search_type}/#{id}.json"
45
+ def post(body={}, params={})
46
+ uri = get_uri( params )
47
+ http = Net::HTTP.new(uri.host, uri.port)
48
+ request = Net::HTTP::Post.new(uri.request_uri)
49
+ request["Authorization"] = "Bearer #{AssayDepot.access_token}" unless params[:access_token]
50
+ request["Accept"] = "application/json"
51
+ request["Content-Type"] = "application/json"
52
+ if (body.keys.length > 0)
53
+ request.body = body.to_json
54
+ end
55
+ res = http.request(request)
56
+ JSON.parse(res.body)
57
+ end
58
+
59
+ def delete(params={})
60
+ uri = get_uri( params )
61
+ http = Net::HTTP.new(uri.host, uri.port)
62
+ request = Net::HTTP::Delete.new(uri.request_uri)
63
+ request["Authorization"] = "Bearer #{AssayDepot.access_token}" unless params[:access_token]
64
+ res = http.request(request)
65
+ JSON.parse(res.body)
16
66
  end
17
67
 
18
68
  def search(query, facets, params={})
19
- params["access_token"] = AssayDepot.access_token
20
- params["q"] = query
69
+ params["q"] = query if query != ""
21
70
  facets.map do |name,value|
22
71
  params["facets[#{name}][]"] = value
23
72
  end
24
- execute(search_url, params)
73
+ get(params)
25
74
  end
26
75
 
27
- def get(id, params={})
28
- params["access_token"] = AssayDepot.access_token
29
- execute(get_url(id), params)
30
- end
76
+ private
31
77
 
32
- def execute(url, params)
33
- JSON.parse(open("#{url}?#{params.collect { |k,v| "#{k}=#{v.to_s.gsub(" ","+")}"}.join("&")}").read)
78
+ def get_uri( params )
79
+ uri = URI( "#{AssayDepot.url}/#{@endpoint}" )
80
+ uri.query = URI.encode_www_form( params ) unless params.keys.length == 0
81
+ uri
34
82
  end
35
83
  end
36
84
  end
@@ -0,0 +1,171 @@
1
+ module AssayDepot
2
+
3
+ class Category
4
+ include ::AssayDepot::Model
5
+
6
+ def self.endpoint(id=nil)
7
+ get_endpoint(id, "categories")
8
+ end
9
+
10
+ def self.ref_name
11
+ "category_refs"
12
+ end
13
+ end
14
+
15
+ class DynamicForm
16
+ include ::AssayDepot::Model
17
+
18
+ def self.endpoint(id=nil)
19
+ get_endpoint(id, "dynamic_forms")
20
+ end
21
+ end
22
+
23
+ class Info
24
+ include ::AssayDepot::Model
25
+
26
+ def self.endpoint(id=nil)
27
+ get_endpoint(nil, "info")
28
+ end
29
+ end
30
+
31
+ class Organization
32
+ include ::AssayDepot::Model
33
+
34
+ def self.endpoint(id=nil)
35
+ get_endpoint(id, "organizations")
36
+ end
37
+ end
38
+
39
+ class QuoteGroup
40
+ include ::AssayDepot::Model
41
+
42
+ def self.endpoint(id=nil)
43
+ get_endpoint(id, "quote_groups")
44
+ end
45
+
46
+ def self.ref_name
47
+ "quote_group_refs"
48
+ end
49
+ end
50
+
51
+ class AddNote
52
+ include ::AssayDepot::Model
53
+
54
+ def self.endpoint(id)
55
+ "/quote_groups/#{id}/add_note"
56
+ end
57
+
58
+ def self.ref_name
59
+ "quote_group_refs"
60
+ end
61
+ end
62
+
63
+ class QuotedWare
64
+ include ::AssayDepot::Model
65
+
66
+ def self.endpoint(id=nil)
67
+ get_endpoint(id, "quoted_wares")
68
+ end
69
+
70
+ def self.ref_name
71
+ "quoted_ware_refs"
72
+ end
73
+ end
74
+
75
+ class Provider
76
+ include ::AssayDepot::Model
77
+
78
+ def self.endpoint(id=nil)
79
+ get_endpoint( id, "providers" )
80
+ end
81
+
82
+ def self.search_type
83
+ "providers"
84
+ end
85
+
86
+ def self.ref_name
87
+ "provider_refs"
88
+ end
89
+ end
90
+
91
+ class ProviderWare
92
+ include ::AssayDepot::Model
93
+
94
+ def self.endpoint(id)
95
+ "/providers/#{id.is_a?(Array) ? id[0] : id}/wares.json"
96
+ end
97
+
98
+ def self.ref_name
99
+ "ware_refs"
100
+ end
101
+ end
102
+
103
+ class User
104
+ include ::AssayDepot::Model
105
+
106
+ def self.endpoint(id=nil)
107
+ get_endpoint(id == nil || id[0] == nil ? nil : 'profile', "users")
108
+ end
109
+
110
+ def self.ref_name
111
+ "user_refs"
112
+ end
113
+ end
114
+
115
+ class Ware
116
+ include ::AssayDepot::Model
117
+
118
+ def self.endpoint(id=nil)
119
+ get_endpoint( id, "wares" )
120
+ end
121
+
122
+ def self.search_type
123
+ "wares"
124
+ end
125
+
126
+ def self.ref_name
127
+ "ware_refs"
128
+ end
129
+ end
130
+
131
+ class WareProvider
132
+ include ::AssayDepot::Model
133
+
134
+ def self.endpoint(id)
135
+ if (id.is_a?(Array) && id.length > 1)
136
+ url = "/wares/#{id[0]}/providers/#{id[1]}.json"
137
+ else
138
+ url = "/wares/#{id.is_a?(Array) ? id[0] : id}/providers.json"
139
+ end
140
+ url
141
+ end
142
+
143
+ def self.ref_name
144
+ "provider_refs"
145
+ end
146
+ end
147
+
148
+ class Webhook
149
+ include ::AssayDepot::Model
150
+
151
+ def self.endpoint(id=nil)
152
+ get_endpoint(id, "webhook_config")
153
+ end
154
+
155
+ def self.ref_name
156
+ "results"
157
+ end
158
+ end
159
+
160
+ class TokenAuth
161
+ include ::AssayDepot::Model
162
+
163
+ def self.endpoint(site="")
164
+ "#{site}/oauth/token?grant_type=client_credentials"
165
+ end
166
+
167
+ def self.ref_name
168
+ "access_token"
169
+ end
170
+ end
171
+ end
@@ -0,0 +1,21 @@
1
+ require "openssl"
2
+
3
+ module AssayDepot
4
+ class Webhook
5
+
6
+ def self.construct_event(payload, signature_header, endpoint_secret)
7
+ sig_hash = {}
8
+
9
+ # get t=, v0=, v1= components of the signature
10
+ signature_header.split(',').each do |str|
11
+ sig_hash[str.split('=')[0]] = str.split('=')[1]
12
+ end
13
+
14
+ mac = OpenSSL::HMAC.hexdigest("SHA256", "#{sig_hash["t"]}0123456789abcdefghijklmnopqrstuvwxyz", payload)
15
+ raise AssayDepot::SignatureVerificationError.new "Event (#{Rails.env}) not properly signed." if Rails.env == 'test' || Rails.env == 'development' && mac != sig_hash["v0"]
16
+ mac = OpenSSL::HMAC.hexdigest("SHA256", "#{sig_hash["t"]}#{endpoint_secret}", payload)
17
+ raise AssayDepot::SignatureVerificationError.new if Rails.env != 'test' && Rails.env != 'development' && mac != sig_hash["v1"]
18
+ raise AssayDepot::SignatureVerificationError.new "Invalid timestamp." if sig_hash["t"].to_i < 5.minutes.ago.to_i
19
+ end
20
+ end
21
+ end
@@ -2,14 +2,74 @@ require 'forwardable'
2
2
  module AssayDepot
3
3
  module Model
4
4
  module ClassMethods
5
+
6
+ def get_token(client_id, client_secret, site)
7
+ response = Client.new.request(AssayDepot::TokenAuth.endpoint(site), {}, {}, {:username => client_id, :password => client_secret})
8
+ response[AssayDepot::TokenAuth.ref_name]
9
+ end
10
+
11
+ def get_endpoint( id, endpoint )
12
+ id = id[0] if id && id.kind_of?(Array)
13
+ id ? "#{endpoint}/#{id}.json" : "#{endpoint}.json"
14
+ end
15
+
16
+ # find and where to modify params
5
17
  def find(query)
6
18
  self.new.find(query)
7
19
  end
20
+
8
21
  def where(conditions={})
9
22
  self.new.where(conditions)
10
23
  end
11
- def get(id)
12
- Client.new(:search_type => search_type).get(id)
24
+
25
+ # HTTP request verbs
26
+ # optional "id" followed by optional hash
27
+ def get(*id, **params)
28
+ Client.new(:endpoint => endpoint(id)).get(params)
29
+ end
30
+
31
+ def put(*id, **params)
32
+
33
+ id, body, params = get_variable_args(id, params)
34
+ # puts "id #{id}, body #{body.to_s}, params #{params}"
35
+ Client.new(:endpoint => endpoint(id)).put( body, params )
36
+ end
37
+
38
+ def patch(*id, **params)
39
+ id, body, params = get_variable_args(id, params)
40
+ Client.new(:endpoint => endpoint(id)).put( body, params )
41
+ end
42
+
43
+ def post(*id, **params)
44
+ id, body, params = get_variable_args(id, params)
45
+ Client.new(:endpoint => endpoint(id)).post( body, params )
46
+ end
47
+
48
+ def delete(*id, **params)
49
+ Client.new(:endpoint => endpoint(id)).delete(params)
50
+ end
51
+
52
+ def get_variable_args(id, params)
53
+
54
+ if (id && id.length > 1 && (id[1].is_a?(Integer) || id[1].is_a?(String)))
55
+ body = params
56
+ params = {}
57
+ elsif (id && id.length > 1)
58
+ body = id[1]
59
+ id = id[0]
60
+ elsif (id && id[0].is_a?(Hash))
61
+ body = id.last
62
+ id = nil
63
+ elsif (id && id.length == 1 && id[0].is_a?(Hash) == false)
64
+ body = params
65
+ id = id[0]
66
+ params = {}
67
+ else
68
+ body = params
69
+ params = {}
70
+ id = nil
71
+ end
72
+ [id, body, params]
13
73
  end
14
74
  end
15
75
 
@@ -101,7 +161,7 @@ module AssayDepot
101
161
  end
102
162
  def search_results
103
163
  unless @search_results
104
- @search_results = Client.new(:search_type => self.class.search_type).search(search_query, search_facets, search_options)
164
+ @search_results = Client.new(:endpoint => self.class.endpoint(nil)).search(search_query, search_facets, search_options)
105
165
  end
106
166
  @search_results
107
167
  end
@@ -1,3 +1,3 @@
1
1
  module AssayDepot
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -1,17 +1,14 @@
1
- require 'oauth2'
2
1
  require 'assaydepot'
2
+ require 'dotenv'
3
+ Dotenv.load
3
4
 
4
5
  describe AssayDepot do
5
- context "when accessing the api via oauth2 client credentials" do
6
+ context "when accessing the api via token client credentials" do
6
7
  before(:all) do
7
- site = "https://staging.assaydepot.com"
8
- client = OAuth2::Client.new( ENV["ASSAYDEPOT_APP_ID"],
9
- ENV["ASSAYDEPOT_APP_SECRET"],
10
- site: site)
11
- access_token = client.client_credentials.get_token(:redirect_uri => 'http://localhost:4567/oauth2/callback')
8
+ site = "http://dev.scientist.com:3000"
12
9
  AssayDepot.configure do |config|
13
- config.access_token = access_token.token
14
- config.url = "#{site}/api"
10
+ config.access_token = ENV['ACCESS_TOKEN']
11
+ config.url = "#{site}/api/v2"
15
12
  end
16
13
  end
17
14
 
@@ -41,6 +38,7 @@ describe AssayDepot do
41
38
 
42
39
  context "when searching for wares of type CustomService" do
43
40
  let(:wares) { AssayDepot::Ware.where(:ware_type => "CustomService") }
41
+
44
42
  it "should return facets" do
45
43
  wares.facets.should_not be_empty
46
44
  end
@@ -53,8 +51,9 @@ describe AssayDepot do
53
51
  wares.facets.should include("ware_type")
54
52
  end
55
53
 
56
- it "should include the available_provider_names facet" do
57
- wares.facets.should include("available_provider_names")
54
+ # RR: replaced "available_provider_names"
55
+ it "should include the technology facet" do
56
+ wares.facets.should include("technology")
58
57
  end
59
58
 
60
59
  it "should include the certifications facet" do
@@ -87,7 +86,7 @@ describe AssayDepot do
87
86
  end
88
87
 
89
88
  context "when searching for wares using a chained query" do
90
- let(:wares) { AssayDepot::Ware.where(:ware_type => "CustomService").where(:available_provider_names => "Blue Sky Biotech") }
89
+ let(:wares) { AssayDepot::Ware.where(:ware_type => "CustomService").where(:source => "central-staging") }
91
90
 
92
91
  it "should return wares" do
93
92
  wares.total.should > 0
@@ -99,14 +98,15 @@ describe AssayDepot do
99
98
  end
100
99
 
101
100
  context "and searching for providers that start with the letter a" do
102
- let(:providers) { AssayDepot::Provider.where(:starts_with => "a").per_page(50) }
103
-
101
+ let(:starts_with) {AssayDepot::Provider.get()["facets"]["starts_with"]["buckets"].first}
102
+ let(:providers) { AssayDepot::Provider.where(:starts_with => starts_with["key"]).per_page(50) }
103
+
104
104
  it "should return a Provider object" do
105
105
  providers.class.should == AssayDepot::Provider
106
106
  end
107
107
 
108
108
  it "should return some providers" do
109
- providers.total.should > 1
109
+ providers.total.should == starts_with["doc_count"]
110
110
  end
111
111
 
112
112
  context "and getting the details for the first provider" do
@@ -0,0 +1,231 @@
1
+ require 'assaydepot'
2
+ require 'dotenv'
3
+ Dotenv.load
4
+
5
+ describe AssayDepot do
6
+ context "scientist_api tests" do
7
+ before(:all) do
8
+ site = "http://dev.scientist.com:3000"
9
+ AssayDepot.configure do |config|
10
+ config.access_token = ENV['ACCESS_TOKEN']
11
+ config.url = "#{site}/api/v2"
12
+ end
13
+ end
14
+
15
+ context "info" do
16
+ let(:info) { AssayDepot::Info.get() }
17
+
18
+ it "info version V2" do
19
+ info["api_version"].should == "V2"
20
+ end
21
+ end
22
+
23
+ context "categories" do
24
+ let(:categories) { AssayDepot::Category.get() }
25
+ it "get all categories" do
26
+ categories[AssayDepot::Category.ref_name].is_a?(Array).should == true
27
+ end
28
+
29
+ it "get specific category" do
30
+ category = AssayDepot::Category.get(categories[AssayDepot::Category.ref_name].first[:id])
31
+ categories[AssayDepot::Category.ref_name][0][:id].should == category[:id]
32
+ end
33
+ end
34
+
35
+ context "organizations" do
36
+ let(:organizations) { AssayDepot::Organization.get() }
37
+
38
+ it "get all organizations" do
39
+ organizations.is_a?(Array).should == true
40
+ end
41
+
42
+ it "get specific organization" do
43
+ organization = AssayDepot::Organization.get(organizations.first["id"])
44
+ organizations.first["id"].should == organization["id"]
45
+ end
46
+ end
47
+
48
+ context "providers" do
49
+ let(:providers) { AssayDepot::Provider.get() }
50
+
51
+ it "get all providers" do
52
+ providers[AssayDepot::Provider.ref_name].is_a?(Array).should == true
53
+ end
54
+
55
+ it "get specific provider" do
56
+ id = providers[AssayDepot::Provider.ref_name].first["id"]
57
+ provider = AssayDepot::Provider.get(id)
58
+ id.is_a?(Integer).should == true
59
+ id.should == provider["provider"]["id"]
60
+ end
61
+
62
+ it "get wares for a specific provider" do
63
+ id = providers[AssayDepot::Provider.ref_name].first["id"]
64
+ ware = AssayDepot::ProviderWare.get(id)
65
+ ware[AssayDepot::ProviderWare.ref_name].is_a?(Array).should == true
66
+ end
67
+
68
+ it "update specific provider attribute" do
69
+ id = providers[AssayDepot::Provider.ref_name].first["id"]
70
+ num_employees = rand(1000)
71
+ response = AssayDepot::Provider.put(id, {number_of_employees: num_employees});
72
+ response["code"].should == "forbidden"
73
+ end
74
+
75
+ end
76
+
77
+ context "quote groups" do
78
+ let(:qg) { AssayDepot::QuoteGroup.get('mine')}
79
+
80
+ it "quote groups mine" do
81
+ qg[AssayDepot::QuoteGroup.ref_name].is_a?(Array).should == true
82
+ end
83
+
84
+ it "quote groups specific id" do
85
+ id = qg[AssayDepot::QuoteGroup.ref_name].first["id"]
86
+ response = AssayDepot::QuoteGroup.get( id )
87
+ response["id"].should == id
88
+ end
89
+
90
+ it "quote group add note" do
91
+ id = qg[AssayDepot::QuoteGroup.ref_name].first["id"]
92
+ title_text = "This is some #{rand(1000)} text."
93
+ body_text = "This is some #{rand(1000)} body text."
94
+ response = AssayDepot::AddNote.post(id, {
95
+ note: {
96
+ title: title_text,
97
+ body: body_text
98
+ }
99
+ })
100
+ response["code"].should == "unprocessable_entity"
101
+ end
102
+ end
103
+
104
+ context "quoted wares" do
105
+ let(:qw) { AssayDepot::QuotedWare.get() }
106
+
107
+ it "get all quoted wares" do
108
+ qw.is_a?(Array).should == true
109
+ end
110
+ end
111
+
112
+ context "users" do
113
+ let(:users) { AssayDepot::User.get() }
114
+ let(:profile) { AssayDepot::User.get('profile') }
115
+
116
+ it "get all users" do
117
+ users[AssayDepot::User.ref_name].is_a?(Array).should == true
118
+ end
119
+
120
+ it "get my user profile" do
121
+ profile["user"]["first_name"].is_a?(String).should == true
122
+ end
123
+ end
124
+
125
+ context "wares" do
126
+ let(:wares) { AssayDepot::Ware.get() }
127
+
128
+ it "get all wares" do
129
+ wares[AssayDepot::Ware.ref_name].is_a?(Array).should == true
130
+ end
131
+
132
+ it "get specific ware" do
133
+ ware = AssayDepot::Ware.get( wares[AssayDepot::Ware.ref_name].first["id"] )
134
+ wares[AssayDepot::Ware.ref_name].first["id"].should == ware["ware"]["id"]
135
+ end
136
+
137
+ it "get providers for a ware id" do
138
+ response = AssayDepot::WareProvider.get( wares[AssayDepot::Ware.ref_name].first["id"] )
139
+ response[AssayDepot::WareProvider.ref_name].is_a?(Array).should == true
140
+ end
141
+ end
142
+
143
+ context "wares providers" do
144
+
145
+ before(:all) do
146
+ wares = AssayDepot::Ware.get()
147
+ providers = AssayDepot::Provider.get()
148
+ @ware_id = wares[AssayDepot::Ware.ref_name].first["id"]
149
+ @provider_id = providers[AssayDepot::Provider.ref_name].first["id"]
150
+ @provider_name = providers[AssayDepot::Provider.ref_name].first["name"]
151
+ sleep(1)
152
+ @delete = AssayDepot::WareProvider.delete( @ware_id, @provider_id )
153
+ @ware_provider_response = AssayDepot::WareProvider.post( @ware_id, @provider_id )
154
+ # TODO: this should not be needed
155
+ sleep(2)
156
+ @ware_provider = AssayDepot::WareProvider.get( @ware_id )
157
+ @provider_ware = AssayDepot::ProviderWare.get( @provider_id )
158
+ @clean_up = AssayDepot::WareProvider.delete( @ware_id, @provider_id )
159
+ @provider_clean_up = AssayDepot::WareProvider.get( @ware_id )
160
+ @ware_clean_up = AssayDepot::ProviderWare.get( @provider_id )
161
+ end
162
+
163
+ it "make sure provider is not published" do
164
+ (@delete["status"] != nil || @delete["message"] != nil).should == true
165
+ end
166
+
167
+ it "publish provider with ware" do
168
+ @ware_provider_response["result"].should == "OK"
169
+ end
170
+
171
+ it "get posted provider for ware" do
172
+ @ware_provider[AssayDepot::WareProvider.ref_name].select { |el|
173
+ el["name"] == @provider_name
174
+ }.length.should == 1
175
+ end
176
+
177
+ it "get posted ware for provider" do
178
+ @provider_ware[AssayDepot::ProviderWare.ref_name].select { |el|
179
+ el["id"] == @ware_id
180
+ }.length.should == 1
181
+ end
182
+
183
+ it "delete ware provider association" do
184
+ @clean_up["result"].should == "OK"
185
+ end
186
+
187
+ it "verify provider is removed from ware" do
188
+ @provider_clean_up[AssayDepot::WareProvider.ref_name].select { |el|
189
+ el["reference_of_id"] == @ware_id
190
+ }.length.should == 0
191
+ end
192
+
193
+ it "verify ware is removed from provider" do
194
+ @ware_clean_up[AssayDepot::ProviderWare.ref_name].select { |el|
195
+ el["name"] == @provider_name
196
+ }.length.should == 0
197
+ end
198
+ end
199
+
200
+ context "webhooks" do
201
+ it "create a web hook for this user" do
202
+ response = AssayDepot::Webhook.put({
203
+ name: "This is another new 'name'.",
204
+ bogus_key: "ignore_me"
205
+ })
206
+
207
+ response[AssayDepot::Webhook.ref_name]["name"].should == "Applied"
208
+ response[AssayDepot::Webhook.ref_name]["bogus_key"].should == "Ignored"
209
+ end
210
+
211
+ it "create a web hook for this user (patch) and verify (get)" do
212
+ response = AssayDepot::Webhook.patch({
213
+ name: "And another new 'name'.",
214
+ bogus_key: "ignore_me"
215
+ })
216
+
217
+ response[AssayDepot::Webhook.ref_name]["name"].should == "Applied"
218
+ response[AssayDepot::Webhook.ref_name]["bogus_key"].should == "Ignored"
219
+ playback = AssayDepot::Webhook.get();
220
+ playback["name"].should == "And another new 'name'."
221
+ end
222
+
223
+ it "delete a web hook for this user (delete)" do
224
+ response = AssayDepot::Webhook.delete();
225
+ response["status"].should == "ok"
226
+ response = AssayDepot::Webhook.get();
227
+ response["code"].should == "not_found"
228
+ end
229
+ end
230
+ end
231
+ end
metadata CHANGED
@@ -1,69 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: assaydepot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christopher Petersen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-30 00:00:00.000000000 Z
11
+ date: 2020-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: uri-query_params
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
25
39
  - !ruby/object:Gem::Version
26
40
  version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rake
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
- - - '>='
45
+ - - ">="
32
46
  - !ruby/object:Gem::Version
33
47
  version: '0'
34
48
  type: :development
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
- - - '>='
52
+ - - ">="
39
53
  - !ruby/object:Gem::Version
40
54
  version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rspec
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
- - - '>='
59
+ - - ">="
46
60
  - !ruby/object:Gem::Version
47
61
  version: '0'
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
- - - '>='
66
+ - - ">="
53
67
  - !ruby/object:Gem::Version
54
68
  version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: oauth2
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
- - - '>='
73
+ - - ">="
60
74
  - !ruby/object:Gem::Version
61
75
  version: '0'
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
- - - '>='
80
+ - - ">="
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0'
69
83
  description: This is the first version of Assay Depot's Ruby SDK. It provides read
@@ -74,8 +88,8 @@ executables: []
74
88
  extensions: []
75
89
  extra_rdoc_files: []
76
90
  files:
77
- - .gitignore
78
- - .travis.yml
91
+ - ".gitignore"
92
+ - ".travis.yml"
79
93
  - Gemfile
80
94
  - LICENSE.md
81
95
  - README.md
@@ -85,11 +99,12 @@ files:
85
99
  - lib/assaydepot/client.rb
86
100
  - lib/assaydepot/configurable.rb
87
101
  - lib/assaydepot/core.rb
102
+ - lib/assaydepot/endpoints.rb
103
+ - lib/assaydepot/event.rb
88
104
  - lib/assaydepot/model.rb
89
- - lib/assaydepot/provider.rb
90
105
  - lib/assaydepot/version.rb
91
- - lib/assaydepot/ware.rb
92
106
  - spec/assaydepot_spec.rb
107
+ - spec/assaydepot_wrapper_spec.rb
93
108
  homepage: https://github.com/assaydepot/assaydepot-rb
94
109
  licenses: []
95
110
  metadata: {}
@@ -99,19 +114,20 @@ require_paths:
99
114
  - lib
100
115
  required_ruby_version: !ruby/object:Gem::Requirement
101
116
  requirements:
102
- - - '>='
117
+ - - ">="
103
118
  - !ruby/object:Gem::Version
104
119
  version: '0'
105
120
  required_rubygems_version: !ruby/object:Gem::Requirement
106
121
  requirements:
107
- - - '>='
122
+ - - ">="
108
123
  - !ruby/object:Gem::Version
109
124
  version: '0'
110
125
  requirements: []
111
126
  rubyforge_project:
112
- rubygems_version: 2.0.14.1
127
+ rubygems_version: 2.5.1
113
128
  signing_key:
114
129
  specification_version: 4
115
130
  summary: Provides read access to Assay Depot's Services and Vendors.
116
131
  test_files:
117
132
  - spec/assaydepot_spec.rb
133
+ - spec/assaydepot_wrapper_spec.rb
@@ -1,12 +0,0 @@
1
- module AssayDepot
2
- class Provider
3
- include ::AssayDepot::Model
4
-
5
- def self.search_type
6
- "providers"
7
- end
8
- def self.ref_name
9
- "provider_refs"
10
- end
11
- end
12
- end
@@ -1,12 +0,0 @@
1
- module AssayDepot
2
- class Ware
3
- include ::AssayDepot::Model
4
-
5
- def self.search_type
6
- "wares"
7
- end
8
- def self.ref_name
9
- "ware_refs"
10
- end
11
- end
12
- end