nds_api 0.1.0 → 0.1.1
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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +2 -1
- data/Rakefile +1 -1
- data/lib/nds_api.rb +18 -50
- data/lib/nds_api/http.rb +3 -3
- data/lib/nds_api/method.rb +50 -0
- data/lib/nds_api/url.rb +112 -100
- data/lib/nds_api/utils.rb +11 -0
- data/lib/nds_api/version.rb +1 -1
- data/nds_api.gemspec +2 -2
- metadata +11 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ff25f4aa5ac9c5d7a6d6fecdd328f3cc1afcbf796298ac39fd1261428da1a2b
|
4
|
+
data.tar.gz: 29f356e9819fb9ffe7f76bc2eb2c92b6090580fb2e9a464e44c7cade4f5c9da6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c911221508e892aa31f3b8888525b27432a7bf9e0a1d6dc530c011087c15da567e29e82de074b0cfd3b9540bf68b80950dda4ef3a8ce64e4ba77222e134c934a
|
7
|
+
data.tar.gz: a152a13255b8e1b442f6e738d60298af0b967683bef7142700090ed0e8bcd1c3f9f755bc6e87551c7b7878e7013cbd7e3925885a6593b45dc2efe0de1599bb0a
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -88,9 +88,10 @@ nds.positions_by_work_email(email)
|
|
88
88
|
##### PROVIDERS
|
89
89
|
|
90
90
|
```ruby
|
91
|
+
nds.search_providers(search_params)
|
91
92
|
nds.update_provider(data)
|
92
93
|
|
93
|
-
nds.providers()
|
94
|
+
nds.providers()
|
94
95
|
nds.provider_by_uid(uid)
|
95
96
|
nds.provider_by_id(id)
|
96
97
|
nds.providers_by_center_name(center_name)
|
data/Rakefile
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
|
-
task :
|
2
|
+
task default: :spec
|
data/lib/nds_api.rb
CHANGED
@@ -1,78 +1,46 @@
|
|
1
1
|
require "nds_api/http"
|
2
|
+
require "nds_api/method"
|
2
3
|
require "nds_api/url"
|
4
|
+
require "nds_api/utils"
|
3
5
|
require "nds_api/version"
|
4
6
|
|
5
7
|
module NdsApi
|
6
8
|
class Client
|
7
|
-
|
8
9
|
# Create a new client instance
|
9
10
|
#
|
10
11
|
# @param [Hash] options
|
11
12
|
# @option options [String] :user NDS User
|
12
13
|
# @option options [String] :password NDS Password
|
13
14
|
#
|
14
|
-
# @return [NdsApi::Client]
|
15
|
-
|
16
|
-
|
17
|
-
# NdsApi::Client.new({user: 'exygy', password: 'SnowflakeFrog?'}).providers
|
15
|
+
# @return [NdsApi::Client] new client instance
|
18
16
|
|
19
17
|
def initialize(options = {})
|
20
18
|
@options = options.dup
|
21
19
|
@http = NdsApi::Http.new(options)
|
22
|
-
@url = NdsApi::Url
|
20
|
+
@url = NdsApi::Url.new(options)
|
23
21
|
end
|
24
22
|
|
25
23
|
def method_missing(method, *args, &block)
|
26
|
-
@method = method
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
@http.put(@url.send(url), data) if is_update?
|
31
|
-
else
|
32
|
-
@http.get(@url.send(method, *args, &block))
|
33
|
-
end
|
24
|
+
@method = NdsApi::Method.new(method)
|
25
|
+
@args = *args
|
26
|
+
response = http_action(method, *args, &block)
|
27
|
+
NdsApi::Utils.hash_keys_str_to_sym(JSON.parse(response.body))
|
34
28
|
end
|
35
29
|
|
36
30
|
private
|
37
31
|
|
38
|
-
def
|
39
|
-
@
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
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
|
32
|
+
def http_action(method, *args, &block)
|
33
|
+
if @method.is_create? or @method.is_search?
|
34
|
+
@http.post(@url.send(@method.action), data)
|
35
|
+
elsif @method.is_update?
|
36
|
+
@http.put(@url.send(@method.action), data)
|
37
|
+
else
|
38
|
+
@http.get(@url.send(method, *args))
|
39
|
+
end
|
56
40
|
end
|
57
41
|
|
58
|
-
def
|
59
|
-
|
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}"
|
42
|
+
def data
|
43
|
+
@args.include?(:data) ? @args[:data] : @args.first
|
75
44
|
end
|
76
|
-
|
77
45
|
end
|
78
46
|
end
|
data/lib/nds_api/http.rb
CHANGED
@@ -33,9 +33,9 @@ module NdsApi
|
|
33
33
|
'Content-Type' => 'application/json'
|
34
34
|
)
|
35
35
|
req.basic_auth api_user, api_password
|
36
|
-
req.use_ssl = true
|
37
|
-
req.
|
38
|
-
Net::HTTP.new(url.host, url.port).
|
36
|
+
# req.use_ssl = true
|
37
|
+
req.body = data.to_json
|
38
|
+
Net::HTTP.new(url.host, url.port).request(req)
|
39
39
|
rescue => e
|
40
40
|
puts "failed #{e}"
|
41
41
|
return e
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'net/http'
|
3
|
+
require 'open-uri'
|
4
|
+
require 'uri'
|
5
|
+
|
6
|
+
module NdsApi
|
7
|
+
class Method
|
8
|
+
def initialize(method = '')
|
9
|
+
@method = method.to_s
|
10
|
+
end
|
11
|
+
|
12
|
+
def is_create?
|
13
|
+
@method.include? 'create'
|
14
|
+
end
|
15
|
+
|
16
|
+
def is_update?
|
17
|
+
@method.include? 'update'
|
18
|
+
end
|
19
|
+
|
20
|
+
def is_search?
|
21
|
+
@method.include? 'search'
|
22
|
+
end
|
23
|
+
|
24
|
+
def action
|
25
|
+
action = method_split[0]
|
26
|
+
object_type =
|
27
|
+
case method_split[1]
|
28
|
+
when 'child'
|
29
|
+
'children'
|
30
|
+
when 'client'
|
31
|
+
'clients'
|
32
|
+
when 'referral'
|
33
|
+
'referrals'
|
34
|
+
when 'person'
|
35
|
+
'persons'
|
36
|
+
when 'provider'
|
37
|
+
'providers'
|
38
|
+
when 'providers'
|
39
|
+
'providers'
|
40
|
+
end
|
41
|
+
"#{action}_#{object_type}"
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def method_split
|
47
|
+
@method_split ||= @method.split('_')
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/lib/nds_api/url.rb
CHANGED
@@ -1,141 +1,153 @@
|
|
1
1
|
module NdsApi
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
class Url
|
3
|
+
def initialize(options = { dev: false })
|
4
|
+
@prod = !options[:dev]
|
5
|
+
end
|
5
6
|
|
6
|
-
|
7
|
-
"#{base_url}/clients"
|
8
|
-
end
|
7
|
+
##### CLIENTS #####
|
9
8
|
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
def clients
|
10
|
+
"#{base_url}/clients"
|
11
|
+
end
|
13
12
|
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
def client_by_email(email)
|
14
|
+
"#{client_search}/findByEmail?email=#{email}"
|
15
|
+
end
|
17
16
|
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
def client_by_phone(phone)
|
18
|
+
"#{client_search}/findByPhone?phone=#{phone}"
|
19
|
+
end
|
21
20
|
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
def client_by_first_name_and_last_name(first_name, last_name)
|
22
|
+
"#{client_search}/findByName?lastName=#{last_name}&firstName=#{first_name}"
|
23
|
+
end
|
25
24
|
|
26
|
-
|
25
|
+
def client_by_id(id)
|
26
|
+
"#{clients}/#{id}"
|
27
|
+
end
|
27
28
|
|
28
|
-
|
29
|
-
"#{base_url}/children"
|
30
|
-
end
|
29
|
+
##### CHILDREN #####
|
31
30
|
|
32
|
-
|
33
|
-
|
34
|
-
|
31
|
+
def children
|
32
|
+
"#{base_url}/children"
|
33
|
+
end
|
35
34
|
|
36
|
-
|
37
|
-
|
38
|
-
|
35
|
+
def child_by_uid(uid)
|
36
|
+
"#{children}/#{uid}"
|
37
|
+
end
|
39
38
|
|
40
|
-
|
39
|
+
def children_by_client_id(client_id)
|
40
|
+
"#{base_url}/clients/#{client_id}/children"
|
41
|
+
end
|
41
42
|
|
42
|
-
|
43
|
-
"#{base_url}/communities?sort=lastModifiedTime,DESC"
|
44
|
-
end
|
43
|
+
##### COMMUNITIES #####
|
45
44
|
|
46
|
-
|
45
|
+
def communities
|
46
|
+
"#{base_url}/communities?sort=lastModifiedTime,DESC"
|
47
|
+
end
|
47
48
|
|
48
|
-
|
49
|
-
"#{base_url}/persons"
|
50
|
-
end
|
49
|
+
##### PERSON #####
|
51
50
|
|
52
|
-
|
53
|
-
|
54
|
-
|
51
|
+
def persons
|
52
|
+
"#{base_url}/persons"
|
53
|
+
end
|
55
54
|
|
56
|
-
|
55
|
+
def person_by_id(id)
|
56
|
+
"#{persons}/#{id}"
|
57
|
+
end
|
57
58
|
|
58
|
-
|
59
|
-
"#{base_url}/positions/search/findByWorkEmail?workEmail=#{email}"
|
60
|
-
end
|
59
|
+
#### POSITIONS #####
|
61
60
|
|
62
|
-
|
61
|
+
def positions_by_work_email(email)
|
62
|
+
"#{base_url}/positions/search/findByWorkEmail?workEmail=#{email}"
|
63
|
+
end
|
63
64
|
|
64
|
-
|
65
|
-
"#{base_url}/providers"
|
66
|
-
end
|
65
|
+
##### PROVIDERS #####
|
67
66
|
|
68
|
-
|
69
|
-
|
70
|
-
|
67
|
+
def search_providers
|
68
|
+
stg_search = 'http://staging-nds-api-app.emrcsv38cq.us-east-1.elasticbeanstalk.com/providers/search/findByCriteriaObject'
|
69
|
+
prod_search = 'http://www.google.com'
|
71
70
|
|
72
|
-
|
73
|
-
"#{base_url}/providers/search/findByProviderId?providerId=#{id}"
|
74
|
-
end
|
71
|
+
puts @prod ? prod_search : stg_search
|
75
72
|
|
76
|
-
|
77
|
-
|
78
|
-
end
|
73
|
+
@prod ? prod_search : stg_search
|
74
|
+
end
|
79
75
|
|
80
|
-
|
81
|
-
|
82
|
-
|
76
|
+
def providers
|
77
|
+
"#{base_url}/providers"
|
78
|
+
end
|
83
79
|
|
84
|
-
|
85
|
-
|
86
|
-
|
80
|
+
def provider_by_uid(uid)
|
81
|
+
"#{base_url}/providers/#{uid}"
|
82
|
+
end
|
87
83
|
|
88
|
-
|
89
|
-
|
90
|
-
|
84
|
+
def provider_by_id(id)
|
85
|
+
"#{base_url}/providers/search/findByProviderId?providerId=#{id}"
|
86
|
+
end
|
91
87
|
|
92
|
-
|
93
|
-
|
94
|
-
|
88
|
+
def providers_by_center_name(center_name)
|
89
|
+
"#{provider_search}/findByCenterName?centerName=#{center_name}"
|
90
|
+
end
|
95
91
|
|
96
|
-
|
92
|
+
def providers_by_email(email)
|
93
|
+
"#{provider_search}/findByEmail?email=#{email}"
|
94
|
+
end
|
97
95
|
|
98
|
-
|
99
|
-
|
100
|
-
|
96
|
+
def provider_schedule(uid)
|
97
|
+
"#{providers}/#{uid}/schedule"
|
98
|
+
end
|
101
99
|
|
102
|
-
|
103
|
-
|
104
|
-
|
100
|
+
def provider_rates(uid)
|
101
|
+
"#{providers}/#{uid}/rates"
|
102
|
+
end
|
105
103
|
|
106
|
-
|
107
|
-
|
108
|
-
|
104
|
+
def provider_enrollments(uid)
|
105
|
+
"#{providers}/#{uid}/enrollments"
|
106
|
+
end
|
109
107
|
|
110
|
-
|
111
|
-
"#{referral_search}/findByDateBefore?date=#{date}"
|
112
|
-
end
|
108
|
+
##### REFERRALS #####
|
113
109
|
|
114
|
-
|
115
|
-
|
116
|
-
|
110
|
+
def referrals
|
111
|
+
"#{base_url}/referrals"
|
112
|
+
end
|
117
113
|
|
118
|
-
|
119
|
-
|
120
|
-
|
114
|
+
def referral_by_id(id)
|
115
|
+
"#{referrals}/#{id}"
|
116
|
+
end
|
121
117
|
|
122
|
-
|
118
|
+
def referral_by_client_id(id)
|
119
|
+
"#{clients}/#{id}/referrals"
|
120
|
+
end
|
123
121
|
|
124
|
-
|
125
|
-
|
126
|
-
|
122
|
+
def referrals_before_date(date)
|
123
|
+
"#{referral_search}/findByDateBefore?date=#{date}"
|
124
|
+
end
|
127
125
|
|
128
|
-
|
129
|
-
|
130
|
-
|
126
|
+
def referrals_after_date(date)
|
127
|
+
"#{referral_search}/findByDateAfter?date=#{date}"
|
128
|
+
end
|
131
129
|
|
132
|
-
|
133
|
-
|
134
|
-
|
130
|
+
def referrals_in_date_range(start_date, end_date)
|
131
|
+
"#{referral_search}/findByDateBetween?startDate=#{start_date}&endDate=#{end_date}"
|
132
|
+
end
|
133
|
+
|
134
|
+
private
|
135
|
+
|
136
|
+
def client_search
|
137
|
+
"#{clients}/search"
|
138
|
+
end
|
139
|
+
|
140
|
+
def provider_search
|
141
|
+
"#{providers}/search"
|
142
|
+
end
|
143
|
+
|
144
|
+
def referral_search
|
145
|
+
"#{referrals}/search"
|
146
|
+
end
|
135
147
|
|
136
|
-
|
137
|
-
|
138
|
-
|
148
|
+
def base_url
|
149
|
+
sub_domain = @prod ? 'uatup' : 'developer.staging'
|
150
|
+
"https://#{sub_domain}.naccrraware.net/nds-api"
|
139
151
|
end
|
140
152
|
end
|
141
153
|
end
|
data/lib/nds_api/version.rb
CHANGED
data/nds_api.gemspec
CHANGED
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Pierre Hunault"]
|
10
10
|
spec.email = ["pierre@exygy.com"]
|
11
11
|
|
12
|
-
spec.summary = %q{
|
13
|
-
spec.description = %q{
|
12
|
+
spec.summary = %q{NDS API is a Rubygem for easy interface with the NDS API. https://developer.uatup.naccrraware.net/}
|
13
|
+
spec.description = %q{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/}
|
14
14
|
spec.homepage = "http://exygy.com"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nds_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pierre Hunault
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,7 +38,12 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '12.0'
|
41
|
-
description:
|
41
|
+
description: NDS API is a Rubygem for easy interface with the NDS API. NDS is the
|
42
|
+
National Data System for Child Care. NDS is a variety of applications and services
|
43
|
+
that facilitate the work of Child Care R&Rs. This Ruby code is an interface to the
|
44
|
+
new NDS API. This code is built and maintained by Exygy, in San Francisco. NDS is
|
45
|
+
built by Child Care Aware of America. For any questions about using this code, please
|
46
|
+
contact hello@exygy.com. For more information about NDS please see https://usa.childcareaware.org/members-providers/data-services/
|
42
47
|
email:
|
43
48
|
- pierre@exygy.com
|
44
49
|
executables: []
|
@@ -55,7 +60,9 @@ files:
|
|
55
60
|
- bin/setup
|
56
61
|
- lib/nds_api.rb
|
57
62
|
- lib/nds_api/http.rb
|
63
|
+
- lib/nds_api/method.rb
|
58
64
|
- lib/nds_api/url.rb
|
65
|
+
- lib/nds_api/utils.rb
|
59
66
|
- lib/nds_api/version.rb
|
60
67
|
- nds_api.gemspec
|
61
68
|
homepage: http://exygy.com
|
@@ -81,5 +88,5 @@ rubyforge_project:
|
|
81
88
|
rubygems_version: 2.7.6
|
82
89
|
signing_key:
|
83
90
|
specification_version: 4
|
84
|
-
summary:
|
91
|
+
summary: NDS API is a Rubygem for easy interface with the NDS API. https://developer.uatup.naccrraware.net/
|
85
92
|
test_files: []
|