lib/nds_api/url.rb in nds_api-0.1.9 vs lib/nds_api/url.rb in nds_api-0.1.11
- old
+ new
@@ -5,12 +5,12 @@
@prod = !@options[:dev]
end
##### Agency #####
- def get_agency_option(type_id=nil)
- raise 'NDS API GEM: Agency Key required' unless @options[:agency_key]
+ 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
##### CLIENTS #####
@@ -70,11 +70,11 @@
"#{base_url}/positions/search/findByWorkEmail?workEmail=#{email}"
end
##### PROVIDERS #####
- def search_providers(params=nil)
+ def search_providers(params = nil)
params = URI.encode_www_form(params) if params
"#{providers}/search/findByCriteriaObject#{params ? "?#{params}" : ''}"
end
def providers
@@ -135,10 +135,26 @@
"#{referral_search}/findByDateBetween?startDate=#{start_date}&endDate=#{end_date}"
end
private
+ # cover: "create_XXXXXX", "update_XXXXXX"
+ 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
+
def client_search
"#{clients}/search"
end
def provider_search
@@ -149,12 +165,12 @@
"#{referrals}/search"
end
def base_url
if @prod
- "https://uatup.naccrraware.net/nds-api"
+ 'https://uatup.naccrraware.net/nds-api'
else
- "http://staging-nds-api-app.emrcsv38cq.us-east-1.elasticbeanstalk.com"
+ 'http://staging-nds-api-app.emrcsv38cq.us-east-1.elasticbeanstalk.com'
end
end
end
end