module StudyManagementClient
Constants
- VERSION
Public Class Methods
get_proposal(id)
click to toggle source
# File lib/study_management_client.rb, line 12 def self.get_proposal(id) conn = get_connection filter(JSON.parse(conn.get('/api/v1/nodes?filter[id]='+id).body)) end
get_proposals()
click to toggle source
# File lib/study_management_client.rb, line 7 def self.get_proposals conn = get_connection filter(JSON.parse(conn.get('/api/v1/nodes/').body)) end
Private Class Methods
filter(obj)
click to toggle source
# File lib/study_management_client.rb, line 31 def self.filter(obj) obj = obj["data"].reject{|k,v| k["attributes"]["cost-code"].to_s.empty?} obj.map { |item| filter_attrs(item) } end
filter_attrs(h)
click to toggle source
# File lib/study_management_client.rb, line 36 def self.filter_attrs(h) {id: h["id"], name: h["attributes"]["name"], cost_code: h["attributes"]["cost-code"]} end
get_connection()
click to toggle source
# File lib/study_management_client.rb, line 19 def self.get_connection conn = Faraday.new(:url => ENV['STUDY_URL']) do |faraday| faraday.proxy ENV['STUDY_URL'] faraday.request :url_encoded faraday.response :logger faraday.adapter Faraday.default_adapter end conn.headers = {'Content-Type' => 'application/vnd.api+json'} conn.headers = {'Accept' => 'application/vnd.api+json'} conn end