nds_api 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4336a2664e431cb4dc5ae26fba7a53175c36c13f9f00517cc7d7941ccb553613
4
+ data.tar.gz: fba0168eae9939f7e921f0d2d42f25fc11fb4d81d511af0174afdf5b76919bb9
5
+ SHA512:
6
+ metadata.gz: 2acbe60167c1e1ff434f46cb3f90bfdb8055af22be44731967c64b57e4b34f3ff2943857d2507bc147752139b402a1ca0c97348a9023669ea96cbdd77897fc3d
7
+ data.tar.gz: 9244b5ddff0a135f29f46986f005d375c5ce1c33cfbcf9d959dc93e2213398c638cae4ebb877b4f27c6f04b792a4abbe958f60cebc7bd782992b5767e8289a1d
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in nds_api.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,20 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ nds_api (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ rake (12.3.1)
10
+
11
+ PLATFORMS
12
+ ruby
13
+
14
+ DEPENDENCIES
15
+ bundler (~> 1.16)
16
+ nds_api!
17
+ rake (~> 12.0)
18
+
19
+ BUNDLED WITH
20
+ 1.16.1
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Pierre
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,129 @@
1
+ # NdsApi
2
+
3
+ NDS API is a Rubygem for easy interface with the NDS API. NDS is the National Data System for Child Care. NDS is a variety of applications and services that facilitate the work of Child Care R&Rs. This Ruby code is an interface to the new NDS API. This code is built and maintained by Exygy, in San Francisco. NDS is built by Child Care Aware of America. For any questions about using this code, please contact hello@exygy.com. For more information about NDS please see https://usa.childcareaware.org/members-providers/data-services/
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'nds_api'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install nds_api
20
+
21
+ ## Usage
22
+
23
+ ```ruby
24
+ nds = NdsApi::Client.new(
25
+ user: 'username',
26
+ password: '############'
27
+ )
28
+ ```
29
+
30
+ ##### CLIENT
31
+
32
+
33
+ Create client
34
+
35
+ ```ruby
36
+ nds.create_client(data)
37
+ ```
38
+
39
+ Visit https://developer.uatup.naccrraware.net/#42d4c898-5868-19a8-0704-18235fa44a5e for fields
40
+
41
+ ```ruby
42
+ nds.update_client(data)
43
+ ```
44
+
45
+ ```ruby
46
+ nds.clients
47
+ nds.client_by_email(email)
48
+ nds.client_by_phone(phone)
49
+ nds.client_by_first_name_and_last_name(first_name, last_name)
50
+ nds.client_by_id(id)
51
+ ```
52
+
53
+ ##### CHILDREN
54
+
55
+ ```ruby
56
+
57
+ nds.create_child(data)
58
+ nds.update_child(data)
59
+
60
+ nds.children
61
+ nds.child_by_uid(uid)
62
+ nds.children_by_client_id(client_id)
63
+ ```
64
+
65
+ ##### COMMUNITIES
66
+
67
+ ```ruby
68
+ nds.communities()
69
+ ```
70
+
71
+ ##### PERSON
72
+
73
+ ```ruby
74
+
75
+ nds.create_person(data)
76
+ nds.update_person(data)
77
+
78
+ nds.persons()
79
+ nds.person_by_id(id)
80
+ ```
81
+
82
+ #### POSITIONS
83
+
84
+ ```ruby
85
+ nds.positions_by_work_email(email)
86
+ ```
87
+
88
+ ##### PROVIDERS
89
+
90
+ ```ruby
91
+ nds.update_provider(data)
92
+
93
+ nds.providers()
94
+ nds.provider_by_uid(uid)
95
+ nds.provider_by_id(id)
96
+ nds.providers_by_center_name(center_name)
97
+ nds.providers_by_email(email)
98
+ nds.provider_schedule(uid)
99
+ nds.provider_rates(uid)
100
+ nds.provider_enrollments(uid)
101
+ ```
102
+
103
+ ##### REFERRALS
104
+
105
+ ```ruby
106
+ nds.create_referral(data)
107
+
108
+ nds.referrals()
109
+ nds.referral_by_id(id)
110
+ nds.referral_by_client_id(id)
111
+ nds.referrals_before_date(date)
112
+ nds.referrals_after_date(date)
113
+ nds.referrals_in_date_range(start_date, end_date)
114
+ ```
115
+
116
+
117
+ ## Development
118
+
119
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
120
+
121
+ 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).
122
+
123
+ ## Contributing
124
+
125
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/nds_api.
126
+
127
+ ## License
128
+
129
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "nds_api"
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(__FILE__)
data/bin/setup ADDED
@@ -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
data/lib/nds_api.rb ADDED
@@ -0,0 +1,78 @@
1
+ require "nds_api/http"
2
+ require "nds_api/url"
3
+ require "nds_api/version"
4
+
5
+ module NdsApi
6
+ class Client
7
+
8
+ # Create a new client instance
9
+ #
10
+ # @param [Hash] options
11
+ # @option options [String] :user NDS User
12
+ # @option options [String] :password NDS Password
13
+ #
14
+ # @return [NdsApi::Client] a new client instance
15
+
16
+
17
+ # NdsApi::Client.new({user: 'exygy', password: 'SnowflakeFrog?'}).providers
18
+
19
+ def initialize(options = {})
20
+ @options = options.dup
21
+ @http = NdsApi::Http.new(options)
22
+ @url = NdsApi::Url
23
+ end
24
+
25
+ def method_missing(method, *args, &block)
26
+ @method = method
27
+ if is_create? or is_update?
28
+ @args = args
29
+ @http.post(@url.send(url), data) if is_create?
30
+ @http.put(@url.send(url), data) if is_update?
31
+ else
32
+ @http.get(@url.send(method, *args, &block))
33
+ end
34
+ end
35
+
36
+ private
37
+
38
+ def data
39
+ @args[:data]
40
+ end
41
+
42
+ def method_split
43
+ @method_split ||= method.split('_')
44
+ end
45
+
46
+ def is_create?
47
+ method.include? 'create'
48
+ end
49
+
50
+ def is_update?
51
+ method.include? 'update'
52
+ end
53
+
54
+ def method
55
+ @method_str ||= @method.to_s
56
+ end
57
+
58
+ def url
59
+ method_split ||= @method.split('_')
60
+ action = method_split[0]
61
+ object_type =
62
+ case method_split[1]
63
+ when 'child'
64
+ 'children'
65
+ when 'client'
66
+ 'clients'
67
+ when 'referral'
68
+ 'referrals'
69
+ when 'person'
70
+ 'persons'
71
+ when 'provider'
72
+ 'providers'
73
+ end
74
+ "#{action}_#{object_type}"
75
+ end
76
+
77
+ end
78
+ end
@@ -0,0 +1,57 @@
1
+ require 'json'
2
+ require 'net/http'
3
+ require 'open-uri'
4
+ require 'uri'
5
+
6
+ module NdsApi
7
+ class Http
8
+ def initialize(options = {})
9
+ @options = options.dup
10
+ end
11
+
12
+ def get(url)
13
+ JSON.parse(open(url, http_basic_authentication: [api_user, api_password]).read)
14
+ rescue => e
15
+ puts "failed #{e}"
16
+ return e
17
+ end
18
+
19
+ def post(url, data)
20
+ http_action('post', url, data)
21
+ end
22
+
23
+ def put(url, data)
24
+ http_action('put', url, data)
25
+ end
26
+
27
+ private
28
+
29
+ def http_action(post_or_put, url, data)
30
+ url = URI.parse(url)
31
+ req = http_verb_object(post_or_put).new(
32
+ url.path,
33
+ 'Content-Type' => 'application/json'
34
+ )
35
+ req.basic_auth api_user, api_password
36
+ req.use_ssl = true
37
+ req.form_data(data)
38
+ Net::HTTP.new(url.host, url.port).start{ |http| http.request(req) }
39
+ rescue => e
40
+ puts "failed #{e}"
41
+ return e
42
+ end
43
+
44
+ def http_verb_object(post_or_put)
45
+ return Net::HTTP::Post if post_or_put == "post"
46
+ return Net::HTTP::Put if post_or_put == "put"
47
+ end
48
+
49
+ def api_user
50
+ @options[:user]
51
+ end
52
+
53
+ def api_password
54
+ @options[:password]
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,141 @@
1
+ module NdsApi
2
+ module Url
3
+ class << self
4
+ ##### CLIENTS #####
5
+
6
+ def clients
7
+ "#{base_url}/clients"
8
+ end
9
+
10
+ def client_by_email(email)
11
+ "#{client_search}/findByEmail?email=#{email}"
12
+ end
13
+
14
+ def client_by_phone(phone)
15
+ "#{client_search}/findByPhone?phone=#{phone}"
16
+ end
17
+
18
+ def client_by_first_name_and_last_name(first_name, last_name)
19
+ "#{client_search}/findByName?lastName=#{last_name}&firstName=#{first_name}"
20
+ end
21
+
22
+ def client_by_id(id)
23
+ "#{clients}/#{id}"
24
+ end
25
+
26
+ ##### CHILDREN #####
27
+
28
+ def children
29
+ "#{base_url}/children"
30
+ end
31
+
32
+ def child_by_uid(uid)
33
+ "#{children}/#{uid}"
34
+ end
35
+
36
+ def children_by_client_id(client_id)
37
+ "#{base_url}/clients/#{client_id}/children"
38
+ end
39
+
40
+ ##### COMMUNITIES #####
41
+
42
+ def communities
43
+ "#{base_url}/communities?sort=lastModifiedTime,DESC"
44
+ end
45
+
46
+ ##### PERSON #####
47
+
48
+ def persons
49
+ "#{base_url}/persons"
50
+ end
51
+
52
+ def person_by_id(id)
53
+ "#{persons}/#{id}"
54
+ end
55
+
56
+ #### POSITIONS #####
57
+
58
+ def positions_by_work_email(email)
59
+ "#{base_url}/positions/search/findByWorkEmail?workEmail=#{email}"
60
+ end
61
+
62
+ ##### PROVIDERS #####
63
+
64
+ def providers
65
+ "#{base_url}/providers"
66
+ end
67
+
68
+ def provider_by_uid(uid)
69
+ "#{base_url}/providers/#{uid}"
70
+ end
71
+
72
+ def provider_by_id(id)
73
+ "#{base_url}/providers/search/findByProviderId?providerId=#{id}"
74
+ end
75
+
76
+ def providers_by_center_name(center_name)
77
+ "#{provider_search}/findByCenterName?centerName=#{center_name}"
78
+ end
79
+
80
+ def providers_by_email(email)
81
+ "#{provider_search}/findByEmail?email=#{email}"
82
+ end
83
+
84
+ def provider_schedule(uid)
85
+ "#{providers}/#{uid}/schedule"
86
+ end
87
+
88
+ def provider_rates(uid)
89
+ "#{providers}/#{uid}/rates"
90
+ end
91
+
92
+ def provider_enrollments(uid)
93
+ "#{providers}/#{uid}/enrollments"
94
+ end
95
+
96
+ ##### REFERRALS #####
97
+
98
+ def referrals
99
+ "#{base_url}/referrals"
100
+ end
101
+
102
+ def referral_by_id(id)
103
+ "#{referrals}/#{id}"
104
+ end
105
+
106
+ def referral_by_client_id(id)
107
+ "#{clients}/#{id}/referrals"
108
+ end
109
+
110
+ def referrals_before_date(date)
111
+ "#{referral_search}/findByDateBefore?date=#{date}"
112
+ end
113
+
114
+ def referrals_after_date(date)
115
+ "#{referral_search}/findByDateAfter?date=#{date}"
116
+ end
117
+
118
+ def referrals_in_date_range(start_date, end_date)
119
+ "#{referral_search}/findByDateBetween?startDate=#{start_date}&endDate=#{end_date}"
120
+ end
121
+
122
+ private
123
+
124
+ def client_search
125
+ "#{clients}/search"
126
+ end
127
+
128
+ def provider_search
129
+ "#{providers}/search"
130
+ end
131
+
132
+ def referral_search
133
+ "#{referrals}/search"
134
+ end
135
+
136
+ def base_url
137
+ 'https://uatup.naccrraware.net/nds-api'
138
+ end
139
+ end
140
+ end
141
+ end
@@ -0,0 +1,3 @@
1
+ module NdsApi
2
+ VERSION = "0.1.0"
3
+ end
data/nds_api.gemspec ADDED
@@ -0,0 +1,26 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "nds_api/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "nds_api"
8
+ spec.version = NdsApi::VERSION
9
+ spec.authors = ["Pierre Hunault"]
10
+ spec.email = ["pierre@exygy.com"]
11
+
12
+ spec.summary = %q{Connect to NDS API and retrieve records.}
13
+ spec.description = %q{Connect to NDS API and retrieve records.}
14
+ spec.homepage = "http://exygy.com"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.16"
25
+ spec.add_development_dependency "rake", "~> 12.0"
26
+ end
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nds_api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Pierre Hunault
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-04-26 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.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '12.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '12.0'
41
+ description: Connect to NDS API and retrieve records.
42
+ email:
43
+ - pierre@exygy.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - Gemfile.lock
51
+ - LICENSE.txt
52
+ - README.md
53
+ - Rakefile
54
+ - bin/console
55
+ - bin/setup
56
+ - lib/nds_api.rb
57
+ - lib/nds_api/http.rb
58
+ - lib/nds_api/url.rb
59
+ - lib/nds_api/version.rb
60
+ - nds_api.gemspec
61
+ homepage: http://exygy.com
62
+ licenses:
63
+ - MIT
64
+ metadata: {}
65
+ post_install_message:
66
+ rdoc_options: []
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ requirements: []
80
+ rubyforge_project:
81
+ rubygems_version: 2.7.6
82
+ signing_key:
83
+ specification_version: 4
84
+ summary: Connect to NDS API and retrieve records.
85
+ test_files: []