redox 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f64bfbcc2ac1671a0a5759f322f78db2dd8ed5b8
4
+ data.tar.gz: 4f89888f5eaa8dab551527840bca9a26f5373254
5
+ SHA512:
6
+ metadata.gz: 73b0882cffa6ec4f67229ea1e26f292fd1066e553c6a60b6f5748cb41bee9b66000ab63aab508a4c8bbd60a5daa0ba001ed1a7bcca5a389a9fa5d3307398f60e
7
+ data.tar.gz: 15226854bcdbd88eb650db21109bd3c24b6e67c312b057af4b2b50c3b0796c76c5ab00de5cbc95639fbc72c76d88df5b4be9fbf98620b5c8fcd0d9ce6eb82342
@@ -0,0 +1,26 @@
1
+ version: 2
2
+ jobs:
3
+ build:
4
+ working_directory: ~/weinfuse_api
5
+ docker:
6
+ - image: circleci/ruby:2.4
7
+ steps:
8
+ - checkout
9
+ - type: restore-cache
10
+ key: redox_{{ checksum "Gemfile.lock" }}
11
+ key: redox
12
+ - run: bundle install --path vendor/bundle --jobs 20 --retry 5
13
+ - type: cache-save
14
+ key: redox_{{ checksum "Gemfile.lock" }}
15
+ key: redox
16
+ paths:
17
+ - vendor/bundle
18
+ - type: shell
19
+ command: |
20
+ bundle exec rubocop
21
+ - type: shell
22
+ command: |
23
+ bundle exec rake test
24
+ - type: store_test_results
25
+ path: /tmp/test-results
26
+
@@ -0,0 +1,10 @@
1
+ root=true
2
+
3
+ [*]
4
+ indent_style = space
5
+ indent_size = 2
6
+ end_of_line = lf
7
+ charset = utf-8
8
+ trim_trailing_whitespace = true
9
+ insert_final_newline = true
10
+
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
@@ -0,0 +1,30 @@
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5
+ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [Unreleased]
8
+
9
+ # [0.1.2] - 2018-03-08
10
+ ### Added
11
+ - CircleCI config
12
+ - .editorconfig
13
+ - Added rubocop as dev dependency
14
+
15
+ ### Changed
16
+ - Corrected author email
17
+ - Tweaks to pass rubocop
18
+
19
+ # [0.1.1] - 2017-10-12
20
+ ### Removed
21
+ - Redundant .gem file
22
+ - Fix WeInfuse capitalization
23
+
24
+ ## 0.1.0 - 2017-10-12
25
+ ### Added
26
+ - Initial Release
27
+
28
+ [Unreleased]: https://github.com/WeInfuse/redox/compare/0.1.2...HEAD
29
+ [0.1.2]: https://github.com/WeInfuse/redox/compare/0.1.1...0.1.2
30
+ [0.1.1]: https://github.com/WeInfuse/redox/compare/0.1.0...0.1.1
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in redox.gemspec
4
+ gemspec
@@ -0,0 +1,60 @@
1
+ # Redox
2
+ Ruby API wrapper for [Redox Engine](https://www.redoxengine.com)
3
+
4
+ ## Installation
5
+
6
+ Add this line to your application's Gemfile:
7
+
8
+ ```ruby
9
+ gem 'redox'
10
+ ```
11
+
12
+ And then execute:
13
+
14
+ $ bundle
15
+
16
+ Or install it yourself as:
17
+
18
+ $ gem install redox
19
+
20
+ ## Usage
21
+
22
+ ```ruby
23
+ source = {
24
+ Name: 'Redox Dev Tools',
25
+ ID: ENV['REDOX_SRC_ID']
26
+ }
27
+
28
+ destinations = [
29
+ {
30
+ Name: 'Redox EMR',
31
+ ID: ENV['REDOX_DEST_ID']
32
+ }
33
+ ]
34
+
35
+ redox = Redox::Redox.new(
36
+ api_key: ENV['REDOX_KEY'],
37
+ secret: ENV['REDOX_SECRET'],
38
+ source: source,
39
+ destinations: destinations,
40
+ test: true
41
+ )
42
+
43
+ redox.add_patient(
44
+ Identifiers: [...],
45
+ Demographics: {
46
+ FirstName: 'Joe'
47
+ ...
48
+ }
49
+ )
50
+ ```
51
+
52
+ ## Development
53
+
54
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
55
+
56
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
57
+
58
+ ## Contributing
59
+
60
+ Bug reports and pull requests are welcome on GitHub at https://github.com/WeInfuse/redox.
@@ -0,0 +1,10 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << 'test'
6
+ t.libs << 'lib'
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ task default: :test
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'redox'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require 'irb'
14
+ IRB.start
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,104 @@
1
+ require 'redox/version'
2
+ require 'json'
3
+ require 'net/http'
4
+ require 'uri'
5
+
6
+ module Redox
7
+ # Redox API client
8
+ class Redox
9
+ # Instantiates a new Redox connection object
10
+ #
11
+ # @param [String] api_key API key for the connection
12
+ # @param [String] secret API secret for the connection
13
+ # @param [Hash] source source information
14
+ # @param [Array<Hash>] destinations list of destinations
15
+ # @param [Boolean] test whether to use test mode
16
+ # @example
17
+ # redox = Redox::Redox.new(
18
+ # api_key: ENV['REDOX_KEY'],
19
+ # secret: ENV['REDOX_SECRET'],
20
+ # source: source,
21
+ # destinations: destinations,
22
+ # test: true
23
+ # )
24
+ def initialize(api_key:, secret:, source:, destinations:, test: true)
25
+ @api_key = api_key
26
+ @secret = secret
27
+ @source = source
28
+ @destinations = destinations
29
+ @test = test
30
+ end
31
+
32
+ # Send NewPatient message
33
+ #
34
+ # @param [Hash] patient_params data to send in the Patient JSON object
35
+ # @return [Hash] parsed response object
36
+ # @example
37
+ # Redox::Redox.new(*connection_params).add_patient(
38
+ # Identifiers: [],
39
+ # Demographics: {
40
+ # FirstName: 'Joe'
41
+ # }
42
+ # )
43
+ def add_patient(patient_params)
44
+ patient_request = Net::HTTP::Post.new('/endpoint', auth_header)
45
+ request_body = request_meta(
46
+ data_model: 'PatientAdmin', event_type: 'NewPatient'
47
+ ).merge(Patient: patient_params)
48
+ patient_request.body = request_body.to_json
49
+
50
+ response = connection.request(patient_request)
51
+
52
+ JSON.parse(response.body)
53
+ end
54
+
55
+ private
56
+
57
+ attr_reader :api_key, :secret, :source, :destinations, :test
58
+
59
+ def access_token
60
+ return @access_token if @access_token
61
+
62
+ login_request = Net::HTTP::Post.new(
63
+ '/auth/authenticate', 'Content-Type' => 'application/json'
64
+ )
65
+ login_request.body = { apiKey: api_key, secret: secret }.to_json
66
+ response = connection.request(login_request)
67
+ body = JSON.parse(response.body)
68
+
69
+ @access_token = body['accessToken']
70
+ end
71
+
72
+ def connection
73
+ return @connection if @connection
74
+
75
+ uri = URI.parse('https://api.redoxengine.com/')
76
+ http = Net::HTTP.new(uri.host, uri.port)
77
+ http.use_ssl = true
78
+ http.verify_mode = OpenSSL::SSL::VERIFY_PEER
79
+ http.verify_depth = 5
80
+
81
+ @connection = http
82
+ end
83
+
84
+ def auth_header
85
+ {
86
+ 'Authorization' => "Bearer #{access_token}",
87
+ 'Content-Type' => 'application/json'
88
+ }
89
+ end
90
+
91
+ def request_meta(data_model:, event_type:)
92
+ {
93
+ Meta: {
94
+ DataModel: data_model,
95
+ EventType: event_type,
96
+ EventDateTime: Time.now.to_json,
97
+ Test: test,
98
+ Source: source,
99
+ Destinations: destinations
100
+ }
101
+ }
102
+ end
103
+ end
104
+ end
@@ -0,0 +1,3 @@
1
+ module Redox
2
+ VERSION = '0.1.2'.freeze
3
+ end
@@ -0,0 +1,35 @@
1
+ lib = File.expand_path('lib', __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'redox/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'redox'
7
+ spec.version = Redox::VERSION
8
+ spec.authors = ['Alexander Clark']
9
+ spec.email = ['sasha.jackal@gmail.com']
10
+
11
+ spec.summary = 'Ruby wrapper for the Redox Engine API'
12
+ spec.homepage = 'https://github.com/WeInfuse/redox'
13
+
14
+ # Prevent pushing this gem to RubyGems.org.
15
+ if spec.respond_to?(:metadata)
16
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
17
+ else
18
+ raise 'RubyGems 2.0 or newer is required to protect against ' \
19
+ 'public gem pushes.'
20
+ end
21
+
22
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
23
+ f.match(%r{^(test|spec|features)/})
24
+ end
25
+ spec.bindir = 'exe'
26
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
+ spec.require_paths = ['lib']
28
+
29
+ spec.add_development_dependency 'bundler', '~> 1.13'
30
+ spec.add_development_dependency 'minitest', '~> 5.0'
31
+ spec.add_development_dependency 'rake', '~> 10.0'
32
+ spec.add_development_dependency 'rubocop', '~> 0.5'
33
+ spec.add_development_dependency 'webmock', '~> 3.1'
34
+ spec.add_development_dependency 'yard', '~> 0.9'
35
+ end
metadata ADDED
@@ -0,0 +1,140 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: redox
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - Alexander Clark
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-03-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.13'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.13'
27
+ - !ruby/object:Gem::Dependency
28
+ name: minitest
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '5.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '5.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.5'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.5'
69
+ - !ruby/object:Gem::Dependency
70
+ name: webmock
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.1'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.1'
83
+ - !ruby/object:Gem::Dependency
84
+ name: yard
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.9'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.9'
97
+ description:
98
+ email:
99
+ - sasha.jackal@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".circleci/config.yml"
105
+ - ".editorconfig"
106
+ - ".gitignore"
107
+ - CHANGELOG.md
108
+ - Gemfile
109
+ - README.md
110
+ - Rakefile
111
+ - bin/console
112
+ - bin/setup
113
+ - lib/redox.rb
114
+ - lib/redox/version.rb
115
+ - redox.gemspec
116
+ homepage: https://github.com/WeInfuse/redox
117
+ licenses: []
118
+ metadata:
119
+ allowed_push_host: https://rubygems.org
120
+ post_install_message:
121
+ rdoc_options: []
122
+ require_paths:
123
+ - lib
124
+ required_ruby_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ required_rubygems_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ requirements: []
135
+ rubyforge_project:
136
+ rubygems_version: 2.5.1
137
+ signing_key:
138
+ specification_version: 4
139
+ summary: Ruby wrapper for the Redox Engine API
140
+ test_files: []