Class: Redox::Redox
- Inherits:
-
Object
- Object
- Redox::Redox
- Defined in:
- lib/redox.rb
Overview
Redox API client
Instance Method Summary collapse
-
#add_patient(patient_params) ⇒ Hash
Send NewPatient message.
-
#initialize(api_key:, secret:, source:, destinations:, facility_code: nil, test: true) ⇒ Redox
constructor
Instantiates a new Redox connection object.
-
#update_patient(patient_params) ⇒ Hash
Send PatientUpdate message.
Constructor Details
#initialize(api_key:, secret:, source:, destinations:, facility_code: nil, test: true) ⇒ Redox
Instantiates a new Redox connection object
24 25 26 27 28 29 30 31 |
# File 'lib/redox.rb', line 24 def initialize(api_key:, secret:, source:, destinations:, facility_code: nil, test: true) @api_key = api_key @secret = secret @source = source @destinations = destinations @facility_code = facility_code @test = test end |
Instance Method Details
#add_patient(patient_params) ⇒ Hash
Send NewPatient message
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/redox.rb', line 44 def add_patient(patient_params) patient_request = Net::HTTP::Post.new('/endpoint', auth_header) request_body = ( data_model: 'PatientAdmin', event_type: 'NewPatient' ).merge(Patient: patient_params) patient_request.body = request_body.to_json response = connection.request(patient_request) JSON.parse(response.body) end |
#update_patient(patient_params) ⇒ Hash
Send PatientUpdate message
67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/redox.rb', line 67 def update_patient(patient_params) patient_request = Net::HTTP::Post.new('/endpoint', auth_header) request_body = ( data_model: 'PatientAdmin', event_type: 'PatientUpdate' ).merge(Patient: patient_params) patient_request.body = request_body.to_json response = connection.request(patient_request) JSON.parse(response.body) end |