Module: YellowApi::Client::GetBusinessDetails
- Included in:
- YellowApi::Client
- Defined in:
- lib/yellow_api/client/get_business_details.rb
Constant Summary
- PROVINCE_ABBREVIATION_MAP =
{ :ab => "Alberta", :bc => "British-Columbia", :mb => "Manitoba", :nb => "New-Brunswick", :nl => "Newfoundland-and-Labrador", :nt => "Northwest-Territories", :ns => "Nova-Scotia", :nu => "Nunavut", :on => "Ontario", :pe => "Prince-Edward-Island", :qc => "Quebec", :sk => "Saskatchewan", :yt => "Yukon" }
Instance Method Summary (collapse)
-
- (Object) expand_province(prov)
Expands an abbreviated province.
-
- (Hash) get_business_details(province, business_name, listing_id, options = {})
Gets business details.
-
- (Object) normalize(s)
Normalizes a given string.
Instance Method Details
- (Object) expand_province(prov)
Expands an abbreviated province
This handles the fact that FindBusiness returns abbreviated provinces codes yet expects full province names for GetBusinessDetails
66 67 68 |
# File 'lib/yellow_api/client/get_business_details.rb', line 66 def (prov) PROVINCE_ABBREVIATION_MAP.fetch(prov.downcase.to_sym, prov) end |
- (Hash) get_business_details(province, business_name, listing_id, options = {})
Note:
Requires a FindBusiness call first.
Gets business details.
Information returned on this first call provides the necessary information for the GetBusinessDetails call. If not available, use "Canada"
40 41 42 43 44 45 46 47 |
# File 'lib/yellow_api/client/get_business_details.rb', line 40 def get_business_details(province, business_name, listing_id, ={}) [:prov] = normalize((province)) ["bus-name"] = normalize(business_name) [:listingId] = listing_id [:city] = normalize([:city]) if .has_key? :city get('/GetBusinessDetails/', ) end |
- (Object) normalize(s)
Normalizes a given string
All accents are removed (i.e. ???????? becomes ???a???), and All non-alphanumeric characters are replaced by dash ???-???, and Multiple dashes are replaced by a single dash.
57 58 59 60 |
# File 'lib/yellow_api/client/get_business_details.rb', line 57 def normalize(s) s.mb_chars.normalize(:kd).gsub(/[^\x00-\x7F]/n, '').to_s .gsub(/[\W]/, '-').gsub(/-+/, '-') end |