Class: HealthDataStandards::Util::VSApi
- Inherits:
-
Object
- Object
- HealthDataStandards::Util::VSApi
- Defined in:
- lib/health-data-standards/util/vs_api.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#api_url ⇒ Object
Returns the value of attribute api_url.
-
#password ⇒ Object
Returns the value of attribute password.
-
#ticket_url ⇒ Object
Returns the value of attribute ticket_url.
-
#username ⇒ Object
Returns the value of attribute username.
Class Method Summary collapse
Instance Method Summary collapse
- #get_proxy_ticket ⇒ Object
- #get_ticket ⇒ Object
- #get_valueset(oid, effective_date = nil, include_draft = false) {|oid, vs| ... } ⇒ Object
-
#initialize(ticket_url, api_url, username, password, ticket_granting_ticket = nil) ⇒ VSApi
constructor
A new instance of VSApi.
- #process_valuesets(oids, effective_date = nil, &block) ⇒ Object
- #proxy_ticket ⇒ Object
Constructor Details
#initialize(ticket_url, api_url, username, password, ticket_granting_ticket = nil) ⇒ VSApi
Returns a new instance of VSApi.
11 12 13 14 15 16 17 |
# File 'lib/health-data-standards/util/vs_api.rb', line 11 def initialize(ticket_url, api_url, username, password, ticket_granting_ticket = nil) @api_url = api_url @ticket_url = ticket_url @username = username @password = password @proxy_ticket = ticket_granting_ticket end |
Instance Attribute Details
#api_url ⇒ Object
Returns the value of attribute api_url.
9 10 11 |
# File 'lib/health-data-standards/util/vs_api.rb', line 9 def api_url @api_url end |
#password ⇒ Object
Returns the value of attribute password.
9 10 11 |
# File 'lib/health-data-standards/util/vs_api.rb', line 9 def password @password end |
#ticket_url ⇒ Object
Returns the value of attribute ticket_url.
9 10 11 |
# File 'lib/health-data-standards/util/vs_api.rb', line 9 def ticket_url @ticket_url end |
#username ⇒ Object
Returns the value of attribute username.
9 10 11 |
# File 'lib/health-data-standards/util/vs_api.rb', line 9 def username @username end |
Class Method Details
.get_tgt_using_credentials(username, password, ticket_url) ⇒ Object
49 50 51 |
# File 'lib/health-data-standards/util/vs_api.rb', line 49 def self.get_tgt_using_credentials(username, password, ticket_url) RestClient.post(ticket_url, username: username, password: password) end |
Instance Method Details
#get_proxy_ticket ⇒ Object
39 40 41 42 43 |
# File 'lib/health-data-standards/util/vs_api.rb', line 39 def get_proxy_ticket # the content type is set and the body is a string becuase the NLM service does not support urlencoded content and # throws an error on that contnet type RestClient.post(@ticket_url, username: @username, password: @password) end |
#get_ticket ⇒ Object
45 46 47 |
# File 'lib/health-data-standards/util/vs_api.rb', line 45 def get_ticket RestClient.post("#{ticket_url}/#{proxy_ticket}", service: "http://umlsks.nlm.nih.gov") end |
#get_valueset(oid, effective_date = nil, include_draft = false) {|oid, vs| ... } ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/health-data-standards/util/vs_api.rb', line 19 def get_valueset(oid, effective_date = nil, include_draft = false, &block) params = { id: oid, ticket: get_ticket } params[:effectiveDate] = effective_date if effective_date params[:includeDraft] = 'yes' if include_draft vs = RestClient.get(api_url, params: params) yield oid, vs if block_given? vs end |
#process_valuesets(oids, effective_date = nil, &block) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/health-data-standards/util/vs_api.rb', line 28 def process_valuesets(oids, effective_date = nil, &block) oids.each do |oid| vs = get_valueset(oid,effective_date) yield oid,vs end end |
#proxy_ticket ⇒ Object
35 36 37 |
# File 'lib/health-data-standards/util/vs_api.rb', line 35 def proxy_ticket @proxy_ticket ||= get_proxy_ticket end |