module Juhe::Express
Attributes
companies[RW]
Public Class Methods
company_code_of(company_name, options = nil)
click to toggle source
# File lib/juhe_ruby/express.rb, line 25 def self.company_code_of(company_name, options = nil) refresh_companies(options) if @companies.nil? @companies.each do |company| return company["no"] if company["com"] == company_name end end
refresh_companies(options)
click to toggle source
# File lib/juhe_ruby/express.rb, line 34 def self.refresh_companies(options) app_key = (options[:app_key] if options) || Juhe::Express.app_key result = JSON.parse(open(BASE_URL+"/com?key="+app_key).read) raise result["reason"] if result["resultcode"] != "200" @companies = result["result"] end
search(company_name, number, options = nil)
click to toggle source
# File lib/juhe_ruby/express.rb, line 12 def self.search(company_name, number, options = nil) app_key = (options[:app_key] if options) || Juhe::Express.app_key url = BASE_URL \ + "/index?key=" + app_key \ + "&no=" + number \ + "&com=" + company_code_of(company_name, options) result = JSON.parse(open(url).read) raise result["reason"] if result["resultcode"] != "200" result["result"] end