module HoujinBangou
@see www.houjin-bangou.nta.go.jp/webapi @see www.houjin-bangou.nta.go.jp/documents/k-web-api-kinou.pdf
Constants
- API_VERSION
- VERSION
Attributes
application_id[RW]
base_url[RW]
open_timeout[RW]
read_timeout[RW]
Public Class Methods
APIEndpoint(path)
click to toggle source
# File lib/houjin-bangou/api_endpoint.rb, line 2 def self.APIEndpoint(path) Module.new do |m| define_method :endpoint_url do URI.parse(HoujinBangou.base_url + path) end end end
request(url, query, src_encoding: Encoding::Shift_JIS)
click to toggle source
# File lib/houjin-bangou.rb, line 21 def self.request(url, query, src_encoding: Encoding::Shift_JIS) query = { id: application_id }.merge(query) url.query = URI.encode_www_form(query) http = Net::HTTP.new(url.host, url.port) http.use_ssl = true if url.scheme == 'https' http.open_timeout = open_timeout http.read_timeout = read_timeout response = http.start do |http| request = Net::HTTP::Get.new(url.request_uri) http.request(request) end case response when Net::HTTPSuccess HoujinBangou::ResultSet.new(response.body, src_encoding) else response.value end end