cns_openapi_ruby_client
Customized OpenApiGenerator generates code. Some code customized to parse xml.
CnsOpenapiRubyClient - the Ruby gem for the Corporate number system API v4
Corporate number system API v4
This SDK is automatically generated by the OpenAPI Generator project:
- API version: 1.0.0
- Package version: 1.0.0
- Build package: org.openapitools.codegen.languages.RubyClientCodegen For more information, please visit https://www.houjin-bangou.nta.go.jp/webapi/toiawase/
Customized
Below codes are not overwritten, even if you fix swagger definition and regenerate. Because it's customized and described in .openapi-generator-ignore
lib/cns_openapi_ruby_client/api_client.rb
- To accept xml
lib/cns_openapi_ruby_client/models/response.rb
- build_from_hash:184-188
- To put a hash in an array
- When API has only 1 candidate, return value is hash not array
Installation
Build a gem
To build the Ruby code into a gem:
gem build cns_openapi_ruby_client.gemspec
Then either install the gem locally:
gem install ./cns_openapi_ruby_client-1.0.0.gem
(for development, run gem install --dev ./cns_openapi_ruby_client-1.0.0.gem to install the development dependencies)
or publish the gem to a gem hosting service, e.g. RubyGems.
Finally add this to the Gemfile:
gem 'cns_openapi_ruby_client', '~> 1.0.0'
Install from Git
If the Ruby gem is hosted at a git repository: https://github.com/GIT_USER_ID/GIT_REPO_ID, then add the following in the Gemfile:
gem 'cns_openapi_ruby_client', :git => 'https://github.com/GIT_USER_ID/GIT_REPO_ID.git'
Include the Ruby code directly
Include the Ruby code directly using -I as follows:
ruby -Ilib script.rb
Getting Started
Please follow the installation procedure and then run the following code:
# Load the gem
require 'cns_openapi_ruby_client'
# Setup authorization
CnsOpenapiRubyClient.configure do |config|
# Configure API key authorization: id
config.api_key['id'] = 'YOUR API KEY'
# Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
# config.api_key_prefix['id'] = 'Bearer'
end
api_instance = CnsOpenapiRubyClient::CorporationsApi.new
name = 'name_example' # String | 取得の対象とする法人名を URL エンコード(UTF-8)した値をセットします。
type = '12' # String | リクエストに対して応答するデータのファイル形式と文字コードを指定します。
opts = {
mode: 1, # Integer | 検索方式を指定できます。 指定しない場合は、「1」(前方一致検索)で処理します。
target: 1, # Integer | 検索対象を指定できます。 指定しない場合は、「1」(JIS 第一・第二水準)で処理します。
address: 'address_example', # String | 国内所在地の都道府県コード又は 都道府県コードと市区町村コードを組み合わせたコードのいずれかを指定できます。 市区町村コードのみではエラー(エラーコード 051)となります。
kind: '01', # String | 法人種別を指定できます。
change: 0, # Integer | 法人名や所在地の変更があった法人等に ついて過去の情報を含めて検索するかどうかを指定できます。
close: 0, # Integer | 登記記録の閉鎖等があった法人等の情報を取得するかどうかを指定できます。
from: 'from_example', # String | 取得の対象とする法人番号指定年月日の開始日を指定できます。
to: 'to_example', # String | 取得の対象とする法人番号指定年月日の終了日を指定できます。
divide: 56 # Integer | 分割番号を指定できます。 指定しない場合は、「1」で処理します。
}
begin
#法人名を指定しリクエストすることで、指定した法人名の基本3情報及び付随する情報を取得することができます。
result = api_instance.get_corporations(name, type, opts)
p result
rescue CnsOpenapiRubyClient::ApiError => e
puts "Exception when calling CorporationsApi->get_corporations: #{e}"
end
Documentation for API Endpoints
All URIs are relative to https://api.houjin-bangou.nta.go.jp/4
| Class | Method | HTTP request | Description |
|---|---|---|---|
| CnsOpenapiRubyClient::CorporationsApi | get_corporations | GET /name | 法人名を指定しリクエストすることで、指定した法人名の基本3情報及び付随する情報を取得することができます。 |
Documentation for Models
- CnsOpenapiRubyClient::CorporateType
- CnsOpenapiRubyClient::Corporation
- CnsOpenapiRubyClient::CorrectCodeType
- CnsOpenapiRubyClient::ProcessCodeType
- CnsOpenapiRubyClient::Response
- CnsOpenapiRubyClient::ResponseWrapper
Documentation for Authorization
id
- Type: API key
- API key parameter name: id
- Location: URL query string