Class: NdsApi::Url
- Inherits:
-
Object
show all
- Defined in:
- lib/nds_api/url.rb
Instance Method Summary
collapse
Constructor Details
#initialize(options = { dev: false }) ⇒ Url
Returns a new instance of Url.
3
4
5
6
|
# File 'lib/nds_api/url.rb', line 3
def initialize(options = { dev: false })
@options = options
@prod = !@options[:dev]
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_sym, *arguments, &block) ⇒ Object
cover: “create_XXXXXX”, “update_XXXXXX”
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
# File 'lib/nds_api/url.rb', line 154
def method_missing(method_sym, *arguments, &block)
create_prefix = 'create_'
update_prefix = 'update_'
prefix = create_prefix if method_sym[0..create_prefix.length - 1] == create_prefix
prefix = update_prefix if method_sym[0..update_prefix.length - 1] == update_prefix
if method_sym[0..prefix.length - 1] == prefix
entities = method_sym[prefix.length..method_sym.length]
send(entities)
else
super
end
end
|
Instance Method Details
#child_by_uid(uid) ⇒ Object
43
44
45
|
# File 'lib/nds_api/url.rb', line 43
def child_by_uid(uid)
"#{children}/#{uid}"
end
|
#children ⇒ Object
39
40
41
|
# File 'lib/nds_api/url.rb', line 39
def children
"#{base_url}/children"
end
|
#children_by_client_id(client_id) ⇒ Object
47
48
49
|
# File 'lib/nds_api/url.rb', line 47
def children_by_client_id(client_id)
"#{base_url}/clients/#{client_id}/children"
end
|
#client_by_email(email) ⇒ Object
21
22
23
|
# File 'lib/nds_api/url.rb', line 21
def client_by_email(email)
"#{client_search}/findByEmail?email=#{email}"
end
|
#client_by_first_name_and_last_name(first_name, last_name) ⇒ Object
29
30
31
|
# File 'lib/nds_api/url.rb', line 29
def client_by_first_name_and_last_name(first_name, last_name)
"#{client_search}/findByName?lastName=#{last_name}&firstName=#{first_name}"
end
|
#client_by_id(id) ⇒ Object
33
34
35
|
# File 'lib/nds_api/url.rb', line 33
def client_by_id(id)
"#{clients}/#{id}"
end
|
#client_by_phone(phone) ⇒ Object
25
26
27
|
# File 'lib/nds_api/url.rb', line 25
def client_by_phone(phone)
"#{client_search}/findByPhone?phone=#{phone}"
end
|
#clients ⇒ Object
17
18
19
|
# File 'lib/nds_api/url.rb', line 17
def clients
"#{base_url}/clients"
end
|
#communities ⇒ Object
53
54
55
|
# File 'lib/nds_api/url.rb', line 53
def communities
"#{base_url}/communities?sort=lastModifiedTime,DESC"
end
|
#get_agency_option(type_id = nil) ⇒ Object
10
11
12
13
|
# File 'lib/nds_api/url.rb', line 10
def get_agency_option(type_id = nil)
raise 'NDS API ERROR: Agency Key required' unless @options[:agency_key]
"#{base_url}/agencies/config/options?agencyKey=#{@options[:agency_key]}#{type_id ? "&typeId=#{type_id}" : ''}"
end
|
#person_by_id(id) ⇒ Object
63
64
65
|
# File 'lib/nds_api/url.rb', line 63
def person_by_id(id)
"#{persons}/#{id}"
end
|
#persons ⇒ Object
59
60
61
|
# File 'lib/nds_api/url.rb', line 59
def persons
"#{base_url}/persons"
end
|
#positions_by_work_email(email) ⇒ Object
69
70
71
|
# File 'lib/nds_api/url.rb', line 69
def positions_by_work_email(email)
"#{base_url}/positions/search/findByWorkEmail?workEmail=#{email}"
end
|
#provider_by_id(id) ⇒ Object
92
93
94
|
# File 'lib/nds_api/url.rb', line 92
def provider_by_id(id)
"#{base_url}/providers/search/findByProviderId?providerId=#{id}"
end
|
#provider_by_uid(uid) ⇒ Object
88
89
90
|
# File 'lib/nds_api/url.rb', line 88
def provider_by_uid(uid)
"#{base_url}/providers/#{uid}"
end
|
#provider_enrollments(uid) ⇒ Object
117
118
119
|
# File 'lib/nds_api/url.rb', line 117
def provider_enrollments(uid)
"#{providers}/#{uid}/enrollments"
end
|
#provider_rates(uid) ⇒ Object
113
114
115
|
# File 'lib/nds_api/url.rb', line 113
def provider_rates(uid)
"#{providers}/#{uid}/rates"
end
|
#provider_schedule(uid) ⇒ Object
109
110
111
|
# File 'lib/nds_api/url.rb', line 109
def provider_schedule(uid)
"#{providers}/#{uid}/schedule"
end
|
#providers ⇒ Object
84
85
86
|
# File 'lib/nds_api/url.rb', line 84
def providers
"#{base_url}/providers"
end
|
#providers_by_center_name(center_name) ⇒ Object
101
102
103
|
# File 'lib/nds_api/url.rb', line 101
def providers_by_center_name(center_name)
"#{provider_search}/findByCenterName?centerName=#{center_name}"
end
|
#providers_by_email(email) ⇒ Object
105
106
107
|
# File 'lib/nds_api/url.rb', line 105
def providers_by_email(email)
"#{provider_search}/findByEmail?email=#{email}"
end
|
#providers_by_owner_or_center_name(params) ⇒ Object
96
97
98
99
|
# File 'lib/nds_api/url.rb', line 96
def providers_by_owner_or_center_name(params)
params = URI.encode_www_form(params) if params
"#{provider_search}/findByOwnerOrCenterName#{params ? "?#{params}" : ''}"
end
|
#referral_by_client_id(id) ⇒ Object
135
136
137
|
# File 'lib/nds_api/url.rb', line 135
def referral_by_client_id(id)
"#{clients}/#{id}/referrals"
end
|
#referral_by_id(id) ⇒ Object
131
132
133
|
# File 'lib/nds_api/url.rb', line 131
def referral_by_id(id)
"#{referrals}/#{id}"
end
|
#referrals ⇒ Object
127
128
129
|
# File 'lib/nds_api/url.rb', line 127
def referrals
"#{base_url}/referrals"
end
|
#referrals_after_date(date) ⇒ Object
143
144
145
|
# File 'lib/nds_api/url.rb', line 143
def referrals_after_date(date)
"#{referral_search}/findByDateAfter?date=#{date}"
end
|
#referrals_before_date(date) ⇒ Object
139
140
141
|
# File 'lib/nds_api/url.rb', line 139
def referrals_before_date(date)
"#{referral_search}/findByDateBefore?date=#{date}"
end
|
#referrals_in_date_range(start_date, end_date) ⇒ Object
147
148
149
|
# File 'lib/nds_api/url.rb', line 147
def referrals_in_date_range(start_date, end_date)
"#{referral_search}/findByDateBetween?startDate=#{start_date}&endDate=#{end_date}"
end
|
#search_providers(params = nil) ⇒ Object
75
76
77
78
|
# File 'lib/nds_api/url.rb', line 75
def search_providers(params = nil)
params = URI.encode_www_form(params) if params
"#{providers}/search/findByCriteriaObject#{params ? "?#{params}" : ''}"
end
|
#search_providers_bulk ⇒ Object
121
122
123
|
# File 'lib/nds_api/url.rb', line 121
def search_providers_bulk
"#{providers}/bulk"
end
|
#search_providers_elastic ⇒ Object
80
81
82
|
# File 'lib/nds_api/url.rb', line 80
def search_providers_elastic
"#{providers}/search"
end
|