cns_openapi_ruby_client 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/Gemfile.lock +81 -0
  4. data/README.md +123 -0
  5. data/Rakefile +10 -0
  6. data/cns_openapi_ruby_client.gemspec +39 -0
  7. data/docs/CorporateType.md +15 -0
  8. data/docs/Corporation.md +76 -0
  9. data/docs/CorporationsApi.md +101 -0
  10. data/docs/CorrectCodeType.md +15 -0
  11. data/docs/ProcessCodeType.md +15 -0
  12. data/docs/Response.md +26 -0
  13. data/docs/ResponseWrapper.md +18 -0
  14. data/git_push.sh +58 -0
  15. data/lib/cns_openapi_ruby_client.rb +46 -0
  16. data/lib/cns_openapi_ruby_client/api/corporations_api.rb +168 -0
  17. data/lib/cns_openapi_ruby_client/api_client.rb +383 -0
  18. data/lib/cns_openapi_ruby_client/api_error.rb +57 -0
  19. data/lib/cns_openapi_ruby_client/configuration.rb +277 -0
  20. data/lib/cns_openapi_ruby_client/models/corporate_type.rb +45 -0
  21. data/lib/cns_openapi_ruby_client/models/corporation.rb +606 -0
  22. data/lib/cns_openapi_ruby_client/models/correct_code_type.rb +37 -0
  23. data/lib/cns_openapi_ruby_client/models/process_code_type.rb +45 -0
  24. data/lib/cns_openapi_ruby_client/models/response.rb +286 -0
  25. data/lib/cns_openapi_ruby_client/models/response_wrapper.rb +223 -0
  26. data/lib/cns_openapi_ruby_client/version.rb +15 -0
  27. data/spec/api/corporations_api_spec.rb +57 -0
  28. data/spec/api_client_spec.rb +197 -0
  29. data/spec/configuration_spec.rb +42 -0
  30. data/spec/models/corporate_type_spec.rb +28 -0
  31. data/spec/models/corporation_spec.rb +220 -0
  32. data/spec/models/correct_code_type_spec.rb +28 -0
  33. data/spec/models/process_code_type_spec.rb +28 -0
  34. data/spec/models/response_spec.rb +58 -0
  35. data/spec/models/response_wrapper_spec.rb +34 -0
  36. data/spec/spec_helper.rb +111 -0
  37. metadata +148 -0
@@ -0,0 +1,57 @@
1
+ =begin
2
+ #Corporate number system API v4
3
+
4
+ #Corporate number system API v4
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.0.1
10
+
11
+ =end
12
+
13
+ module CnsOpenapiRubyClient
14
+ class ApiError < StandardError
15
+ attr_reader :code, :response_headers, :response_body
16
+
17
+ # Usage examples:
18
+ # ApiError.new
19
+ # ApiError.new("message")
20
+ # ApiError.new(:code => 500, :response_headers => {}, :response_body => "")
21
+ # ApiError.new(:code => 404, :message => "Not Found")
22
+ def initialize(arg = nil)
23
+ if arg.is_a? Hash
24
+ if arg.key?(:message) || arg.key?('message')
25
+ super(arg[:message] || arg['message'])
26
+ else
27
+ super arg
28
+ end
29
+
30
+ arg.each do |k, v|
31
+ instance_variable_set "@#{k}", v
32
+ end
33
+ else
34
+ super arg
35
+ end
36
+ end
37
+
38
+ # Override to_s to display a friendly error message
39
+ def to_s
40
+ message
41
+ end
42
+
43
+ def message
44
+ if @message.nil?
45
+ msg = "Error message: the server returns an error"
46
+ else
47
+ msg = @message
48
+ end
49
+
50
+ msg += "\nHTTP status code: #{code}" if code
51
+ msg += "\nResponse headers: #{response_headers}" if response_headers
52
+ msg += "\nResponse body: #{response_body}" if response_body
53
+
54
+ msg
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,277 @@
1
+ =begin
2
+ #Corporate number system API v4
3
+
4
+ #Corporate number system API v4
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.0.1
10
+
11
+ =end
12
+
13
+ module CnsOpenapiRubyClient
14
+ class Configuration
15
+ # Defines url scheme
16
+ attr_accessor :scheme
17
+
18
+ # Defines url host
19
+ attr_accessor :host
20
+
21
+ # Defines url base path
22
+ attr_accessor :base_path
23
+
24
+ # Define server configuration index
25
+ attr_accessor :server_index
26
+
27
+ # Define server operation configuration index
28
+ attr_accessor :server_operation_index
29
+
30
+ # Default server variables
31
+ attr_accessor :server_variables
32
+
33
+ # Default server operation variables
34
+ attr_accessor :server_operation_variables
35
+
36
+ # Defines API keys used with API Key authentications.
37
+ #
38
+ # @return [Hash] key: parameter name, value: parameter value (API key)
39
+ #
40
+ # @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
41
+ # config.api_key['api_key'] = 'xxx'
42
+ attr_accessor :api_key
43
+
44
+ # Defines API key prefixes used with API Key authentications.
45
+ #
46
+ # @return [Hash] key: parameter name, value: API key prefix
47
+ #
48
+ # @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
49
+ # config.api_key_prefix['api_key'] = 'Token'
50
+ attr_accessor :api_key_prefix
51
+
52
+ # Defines the username used with HTTP basic authentication.
53
+ #
54
+ # @return [String]
55
+ attr_accessor :username
56
+
57
+ # Defines the password used with HTTP basic authentication.
58
+ #
59
+ # @return [String]
60
+ attr_accessor :password
61
+
62
+ # Defines the access token (Bearer) used with OAuth2.
63
+ attr_accessor :access_token
64
+
65
+ # Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
66
+ # details will be logged with `logger.debug` (see the `logger` attribute).
67
+ # Default to false.
68
+ #
69
+ # @return [true, false]
70
+ attr_accessor :debugging
71
+
72
+ # Defines the logger used for debugging.
73
+ # Default to `Rails.logger` (when in Rails) or logging to STDOUT.
74
+ #
75
+ # @return [#debug]
76
+ attr_accessor :logger
77
+
78
+ # Defines the temporary folder to store downloaded files
79
+ # (for API endpoints that have file response).
80
+ # Default to use `Tempfile`.
81
+ #
82
+ # @return [String]
83
+ attr_accessor :temp_folder_path
84
+
85
+ # The time limit for HTTP request in seconds.
86
+ # Default to 0 (never times out).
87
+ attr_accessor :timeout
88
+
89
+ # Set this to false to skip client side validation in the operation.
90
+ # Default to true.
91
+ # @return [true, false]
92
+ attr_accessor :client_side_validation
93
+
94
+ ### TLS/SSL setting
95
+ # Set this to false to skip verifying SSL certificate when calling API from https server.
96
+ # Default to true.
97
+ #
98
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
99
+ #
100
+ # @return [true, false]
101
+ attr_accessor :verify_ssl
102
+
103
+ ### TLS/SSL setting
104
+ # Set this to false to skip verifying SSL host name
105
+ # Default to true.
106
+ #
107
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
108
+ #
109
+ # @return [true, false]
110
+ attr_accessor :verify_ssl_host
111
+
112
+ ### TLS/SSL setting
113
+ # Set this to customize the certificate file to verify the peer.
114
+ #
115
+ # @return [String] the path to the certificate file
116
+ #
117
+ # @see The `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code:
118
+ # https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
119
+ attr_accessor :ssl_ca_cert
120
+
121
+ ### TLS/SSL setting
122
+ # Client certificate file (for client certificate)
123
+ attr_accessor :cert_file
124
+
125
+ ### TLS/SSL setting
126
+ # Client private key file (for client certificate)
127
+ attr_accessor :key_file
128
+
129
+ # Set this to customize parameters encoding of array parameter with multi collectionFormat.
130
+ # Default to nil.
131
+ #
132
+ # @see The params_encoding option of Ethon. Related source code:
133
+ # https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
134
+ attr_accessor :params_encoding
135
+
136
+ attr_accessor :inject_format
137
+
138
+ attr_accessor :force_ending_format
139
+
140
+ def initialize
141
+ @scheme = 'https'
142
+ @host = 'api.houjin-bangou.nta.go.jp'
143
+ @base_path = '/4'
144
+ @server_index = 0
145
+ @server_operation_index = {}
146
+ @server_variables = {}
147
+ @server_operation_variables = {}
148
+ @api_key = {}
149
+ @api_key_prefix = {}
150
+ @timeout = 0
151
+ @client_side_validation = true
152
+ @verify_ssl = true
153
+ @verify_ssl_host = true
154
+ @params_encoding = nil
155
+ @cert_file = nil
156
+ @key_file = nil
157
+ @debugging = false
158
+ @inject_format = false
159
+ @force_ending_format = false
160
+ @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
161
+
162
+ yield(self) if block_given?
163
+ end
164
+
165
+ # The default Configuration object.
166
+ def self.default
167
+ @@default ||= Configuration.new
168
+ end
169
+
170
+ def configure
171
+ yield(self) if block_given?
172
+ end
173
+
174
+ def scheme=(scheme)
175
+ # remove :// from scheme
176
+ @scheme = scheme.sub(/:\/\//, '')
177
+ end
178
+
179
+ def host=(host)
180
+ # remove http(s):// and anything after a slash
181
+ @host = host.sub(/https?:\/\//, '').split('/').first
182
+ end
183
+
184
+ def base_path=(base_path)
185
+ # Add leading and trailing slashes to base_path
186
+ @base_path = "/#{base_path}".gsub(/\/+/, '/')
187
+ @base_path = '' if @base_path == '/'
188
+ end
189
+
190
+ # Returns base URL for specified operation based on server settings
191
+ def base_url(operation = nil)
192
+ index = server_operation_index.fetch(operation, server_index)
193
+ return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if index == nil
194
+
195
+ server_url(index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
196
+ end
197
+
198
+ # Gets API key (with prefix if set).
199
+ # @param [String] param_name the parameter name of API key auth
200
+ def api_key_with_prefix(param_name, param_alias = nil)
201
+ key = @api_key[param_name]
202
+ key = @api_key.fetch(param_alias, key) unless param_alias.nil?
203
+ if @api_key_prefix[param_name]
204
+ "#{@api_key_prefix[param_name]} #{key}"
205
+ else
206
+ key
207
+ end
208
+ end
209
+
210
+ # Gets Basic Auth token string
211
+ def basic_auth_token
212
+ 'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
213
+ end
214
+
215
+ # Returns Auth Settings hash for api client.
216
+ def auth_settings
217
+ {
218
+ 'id' =>
219
+ {
220
+ type: 'api_key',
221
+ in: 'query',
222
+ key: 'id',
223
+ value: api_key_with_prefix('id')
224
+ },
225
+ }
226
+ end
227
+
228
+ # Returns an array of Server setting
229
+ def server_settings
230
+ [
231
+ {
232
+ url: "https://api.houjin-bangou.nta.go.jp/4",
233
+ description: "No description provided",
234
+ }
235
+ ]
236
+ end
237
+
238
+ def operation_server_settings
239
+ {
240
+ }
241
+ end
242
+
243
+ # Returns URL based on server settings
244
+ #
245
+ # @param index array index of the server settings
246
+ # @param variables hash of variable and the corresponding value
247
+ def server_url(index, variables = {}, servers = nil)
248
+ servers = server_settings if servers == nil
249
+
250
+ # check array index out of bound
251
+ if (index < 0 || index >= servers.size)
252
+ fail ArgumentError, "Invalid index #{index} when selecting the server. Must be less than #{servers.size}"
253
+ end
254
+
255
+ server = servers[index]
256
+ url = server[:url]
257
+
258
+ return url unless server.key? :variables
259
+
260
+ # go through variable and assign a value
261
+ server[:variables].each do |name, variable|
262
+ if variables.key?(name)
263
+ if (!server[:variables][name].key?(:enum_values) || server[:variables][name][:enum_values].include?(variables[name]))
264
+ url.gsub! "{" + name.to_s + "}", variables[name]
265
+ else
266
+ fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."
267
+ end
268
+ else
269
+ # use default value
270
+ url.gsub! "{" + name.to_s + "}", server[:variables][name][:default_value]
271
+ end
272
+ end
273
+
274
+ url
275
+ end
276
+ end
277
+ end
@@ -0,0 +1,45 @@
1
+ =begin
2
+ #Corporate number system API v4
3
+
4
+ #Corporate number system API v4
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.0.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module CnsOpenapiRubyClient
17
+ class CorporateType
18
+ N101 = "101".freeze
19
+ N201 = "201".freeze
20
+ N301 = "301".freeze
21
+ N302 = "302".freeze
22
+ N303 = "303".freeze
23
+ N304 = "304".freeze
24
+ N305 = "305".freeze
25
+ N399 = "399".freeze
26
+ N401 = "401".freeze
27
+ N499 = "499".freeze
28
+
29
+ # Builds the enum from string
30
+ # @param [String] The enum value in the form of the string
31
+ # @return [String] The enum value
32
+ def self.build_from_hash(value)
33
+ new.build_from_hash(value)
34
+ end
35
+
36
+ # Builds the enum from string
37
+ # @param [String] The enum value in the form of the string
38
+ # @return [String] The enum value
39
+ def build_from_hash(value)
40
+ constantValues = CorporateType.constants.select { |c| CorporateType::const_get(c) == value }
41
+ raise "Invalid ENUM value #{value} for class #CorporateType" if constantValues.empty?
42
+ value
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,606 @@
1
+ =begin
2
+ #Corporate number system API v4
3
+
4
+ #Corporate number system API v4
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.0.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module CnsOpenapiRubyClient
17
+ # 法人種別を判別するためのデータ項目。
18
+ class Corporation
19
+ # 一連番号
20
+ attr_accessor :sequence_number
21
+
22
+ # 法人番号の指定を受けた者(以下「法人番号保有者」という。)の 法人番号を示すデータ項目。
23
+ attr_accessor :corporate_number
24
+
25
+ attr_accessor :process
26
+
27
+ attr_accessor :correct
28
+
29
+ # 法務省等からデータを受け取り、当庁でデータを更新した日付を表す。
30
+ attr_accessor :update_date
31
+
32
+ # 事由が発生した日付を表すデータ項目。
33
+ attr_accessor :change_date
34
+
35
+ # 法人番号保有者の商号又は名称を示すデータ項目。
36
+ attr_accessor :name
37
+
38
+ # 商号又は名称イメージIDは、 イメージファイルを閲覧するために指定する値(情報)。
39
+ attr_accessor :name_image_id
40
+
41
+ attr_accessor :kind
42
+
43
+ # 法人番号保有者の本店又は主たる事務所の所在地の都道府県名。
44
+ attr_accessor :prefecture_name
45
+
46
+ # 法人番号保有者の本店又は主たる事務所の所在地の市区町村名。
47
+ attr_accessor :city_name
48
+
49
+ # 法人番号保有者の本店又は主たる事務所の所在地の丁目番地等。
50
+ attr_accessor :street_number
51
+
52
+ # 国内所在地イメージIDは、 イメージファイルを閲覧するために指定する値(情報)。
53
+ attr_accessor :address_image_id
54
+
55
+ # 都道府県コード。データを取り込み、名寄せ作業や不要なデータを識別する際、 当該コードを活用することにより、効率的な作業を行うことができる。
56
+ attr_accessor :prefecture_code
57
+
58
+ # 市区町村コード
59
+ attr_accessor :city_code
60
+
61
+ # 国内所在地の文字情報を基に設定した郵便番号。
62
+ attr_accessor :post_code
63
+
64
+ # 本店又は主たる事務所の所在地が国外にある法人番号保有者の 国外における本店又は主たる事務所の所在地を示すデータ項目。
65
+ attr_accessor :address_outside
66
+
67
+ # 国外所在地イメージIDは、 イメージファイルを閲覧するために指定する値(情報)。
68
+ attr_accessor :address_outside_image_id
69
+
70
+ # 登記記録の閉鎖等の事由が生じた年月日を表す。
71
+ attr_accessor :close_date
72
+
73
+ # 閉鎖の事由は、登記記録の閉鎖等が生じた事由を表すデータ項目。
74
+ attr_accessor :close_cause
75
+
76
+ # 合併等による事業承継があったことにより 登記記録が閉鎖された場合の存続する法人の法人番号。
77
+ attr_accessor :successor_corporate_number
78
+
79
+ # 合併等による事業承継があった場合の事業承継内容を示すデータ項目。
80
+ attr_accessor :change_cause
81
+
82
+ # 法人番号指定年月日は、法人番号が指定された年月日を表す。
83
+ attr_accessor :assignment_date
84
+
85
+ # 応答結果のデータが、最新の情報か過去の情報かを表す。
86
+ attr_accessor :latest
87
+
88
+ # 法人番号保有者が登録した商号又は名称(英語表記)。
89
+ attr_accessor :en_name
90
+
91
+ # 法人番号保有者が登録した本店又は主たる事務所の 所在地の都道府県名(英語表記)。
92
+ attr_accessor :en_prefecture_name
93
+
94
+ # 法人番号保有者が登録した本店又は主たる事務所の 所在地の丁目番地等(英語表記)。
95
+ attr_accessor :en_city_name
96
+
97
+ # 本店又は主たる事務所の所在地が国外にある法人番号保有者が 登録した国外における本店又は主たる事務所の所在地(英語表記)。
98
+ attr_accessor :en_address_outside
99
+
100
+ # 法人番号保有者の商号又は名称に対するフリガナ情報を示すデータ項目。
101
+ attr_accessor :furigana
102
+
103
+ # 設立登記法人のうち、登記上の所在地が、住居表示の実施や区画整理等で 既に廃止されており、現在では存在しない住所表記となっていることが 確認できた法人について、検索対象から除外していることを示すデータ項目。
104
+ attr_accessor :hihyoji
105
+
106
+ class EnumAttributeValidator
107
+ attr_reader :datatype
108
+ attr_reader :allowable_values
109
+
110
+ def initialize(datatype, allowable_values)
111
+ @allowable_values = allowable_values.map do |value|
112
+ case datatype.to_s
113
+ when /Integer/i
114
+ value.to_i
115
+ when /Float/i
116
+ value.to_f
117
+ else
118
+ value
119
+ end
120
+ end
121
+ end
122
+
123
+ def valid?(value)
124
+ !value || allowable_values.include?(value)
125
+ end
126
+ end
127
+
128
+ # Attribute mapping from ruby-style variable name to JSON key.
129
+ def self.attribute_map
130
+ {
131
+ :'sequence_number' => :'sequenceNumber',
132
+ :'corporate_number' => :'corporateNumber',
133
+ :'process' => :'process',
134
+ :'correct' => :'correct',
135
+ :'update_date' => :'updateDate',
136
+ :'change_date' => :'changeDate',
137
+ :'name' => :'name',
138
+ :'name_image_id' => :'nameImageId',
139
+ :'kind' => :'kind',
140
+ :'prefecture_name' => :'prefectureName',
141
+ :'city_name' => :'cityName',
142
+ :'street_number' => :'streetNumber',
143
+ :'address_image_id' => :'addressImageId',
144
+ :'prefecture_code' => :'prefectureCode',
145
+ :'city_code' => :'cityCode',
146
+ :'post_code' => :'postCode',
147
+ :'address_outside' => :'addressOutside',
148
+ :'address_outside_image_id' => :'addressOutsideImageId',
149
+ :'close_date' => :'closeDate',
150
+ :'close_cause' => :'closeCause',
151
+ :'successor_corporate_number' => :'successorCorporateNumber',
152
+ :'change_cause' => :'changeCause',
153
+ :'assignment_date' => :'assignmentDate',
154
+ :'latest' => :'latest',
155
+ :'en_name' => :'enName',
156
+ :'en_prefecture_name' => :'enPrefectureName',
157
+ :'en_city_name' => :'enCityName',
158
+ :'en_address_outside' => :'enAddressOutside',
159
+ :'furigana' => :'furigana',
160
+ :'hihyoji' => :'hihyoji'
161
+ }
162
+ end
163
+
164
+ # Returns all the JSON keys this model knows about
165
+ def self.acceptable_attributes
166
+ attribute_map.values
167
+ end
168
+
169
+ # Attribute type mapping.
170
+ def self.openapi_types
171
+ {
172
+ :'sequence_number' => :'Integer',
173
+ :'corporate_number' => :'Integer',
174
+ :'process' => :'ProcessCodeType',
175
+ :'correct' => :'CorrectCodeType',
176
+ :'update_date' => :'Date',
177
+ :'change_date' => :'Date',
178
+ :'name' => :'String',
179
+ :'name_image_id' => :'Integer',
180
+ :'kind' => :'CorporateType',
181
+ :'prefecture_name' => :'String',
182
+ :'city_name' => :'String',
183
+ :'street_number' => :'String',
184
+ :'address_image_id' => :'Integer',
185
+ :'prefecture_code' => :'Integer',
186
+ :'city_code' => :'Integer',
187
+ :'post_code' => :'Integer',
188
+ :'address_outside' => :'String',
189
+ :'address_outside_image_id' => :'Integer',
190
+ :'close_date' => :'Date',
191
+ :'close_cause' => :'String',
192
+ :'successor_corporate_number' => :'Integer',
193
+ :'change_cause' => :'String',
194
+ :'assignment_date' => :'Date',
195
+ :'latest' => :'Integer',
196
+ :'en_name' => :'String',
197
+ :'en_prefecture_name' => :'String',
198
+ :'en_city_name' => :'String',
199
+ :'en_address_outside' => :'String',
200
+ :'furigana' => :'String',
201
+ :'hihyoji' => :'Integer'
202
+ }
203
+ end
204
+
205
+ # List of attributes with nullable: true
206
+ def self.openapi_nullable
207
+ Set.new([
208
+ ])
209
+ end
210
+
211
+ # Initializes the object
212
+ # @param [Hash] attributes Model attributes in the form of hash
213
+ def initialize(attributes = {})
214
+ if (!attributes.is_a?(Hash))
215
+ fail ArgumentError, "The input argument (attributes) must be a hash in `CnsOpenapiRubyClient::Corporation` initialize method"
216
+ end
217
+
218
+ # check to see if the attribute exists and convert string to symbol for hash key
219
+ attributes = attributes.each_with_object({}) { |(k, v), h|
220
+ if (!self.class.attribute_map.key?(k.to_sym))
221
+ fail ArgumentError, "`#{k}` is not a valid attribute in `CnsOpenapiRubyClient::Corporation`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
222
+ end
223
+ h[k.to_sym] = v
224
+ }
225
+
226
+ if attributes.key?(:'sequence_number')
227
+ self.sequence_number = attributes[:'sequence_number']
228
+ end
229
+
230
+ if attributes.key?(:'corporate_number')
231
+ self.corporate_number = attributes[:'corporate_number']
232
+ end
233
+
234
+ if attributes.key?(:'process')
235
+ self.process = attributes[:'process']
236
+ end
237
+
238
+ if attributes.key?(:'correct')
239
+ self.correct = attributes[:'correct']
240
+ end
241
+
242
+ if attributes.key?(:'update_date')
243
+ self.update_date = attributes[:'update_date']
244
+ end
245
+
246
+ if attributes.key?(:'change_date')
247
+ self.change_date = attributes[:'change_date']
248
+ end
249
+
250
+ if attributes.key?(:'name')
251
+ self.name = attributes[:'name']
252
+ end
253
+
254
+ if attributes.key?(:'name_image_id')
255
+ self.name_image_id = attributes[:'name_image_id']
256
+ end
257
+
258
+ if attributes.key?(:'kind')
259
+ self.kind = attributes[:'kind']
260
+ end
261
+
262
+ if attributes.key?(:'prefecture_name')
263
+ self.prefecture_name = attributes[:'prefecture_name']
264
+ end
265
+
266
+ if attributes.key?(:'city_name')
267
+ self.city_name = attributes[:'city_name']
268
+ end
269
+
270
+ if attributes.key?(:'street_number')
271
+ self.street_number = attributes[:'street_number']
272
+ end
273
+
274
+ if attributes.key?(:'address_image_id')
275
+ self.address_image_id = attributes[:'address_image_id']
276
+ end
277
+
278
+ if attributes.key?(:'prefecture_code')
279
+ self.prefecture_code = attributes[:'prefecture_code']
280
+ end
281
+
282
+ if attributes.key?(:'city_code')
283
+ self.city_code = attributes[:'city_code']
284
+ end
285
+
286
+ if attributes.key?(:'post_code')
287
+ self.post_code = attributes[:'post_code']
288
+ end
289
+
290
+ if attributes.key?(:'address_outside')
291
+ self.address_outside = attributes[:'address_outside']
292
+ end
293
+
294
+ if attributes.key?(:'address_outside_image_id')
295
+ self.address_outside_image_id = attributes[:'address_outside_image_id']
296
+ end
297
+
298
+ if attributes.key?(:'close_date')
299
+ self.close_date = attributes[:'close_date']
300
+ end
301
+
302
+ if attributes.key?(:'close_cause')
303
+ self.close_cause = attributes[:'close_cause']
304
+ end
305
+
306
+ if attributes.key?(:'successor_corporate_number')
307
+ self.successor_corporate_number = attributes[:'successor_corporate_number']
308
+ end
309
+
310
+ if attributes.key?(:'change_cause')
311
+ self.change_cause = attributes[:'change_cause']
312
+ end
313
+
314
+ if attributes.key?(:'assignment_date')
315
+ self.assignment_date = attributes[:'assignment_date']
316
+ end
317
+
318
+ if attributes.key?(:'latest')
319
+ self.latest = attributes[:'latest']
320
+ end
321
+
322
+ if attributes.key?(:'en_name')
323
+ self.en_name = attributes[:'en_name']
324
+ end
325
+
326
+ if attributes.key?(:'en_prefecture_name')
327
+ self.en_prefecture_name = attributes[:'en_prefecture_name']
328
+ end
329
+
330
+ if attributes.key?(:'en_city_name')
331
+ self.en_city_name = attributes[:'en_city_name']
332
+ end
333
+
334
+ if attributes.key?(:'en_address_outside')
335
+ self.en_address_outside = attributes[:'en_address_outside']
336
+ end
337
+
338
+ if attributes.key?(:'furigana')
339
+ self.furigana = attributes[:'furigana']
340
+ end
341
+
342
+ if attributes.key?(:'hihyoji')
343
+ self.hihyoji = attributes[:'hihyoji']
344
+ end
345
+ end
346
+
347
+ # Show invalid properties with the reasons. Usually used together with valid?
348
+ # @return Array for valid properties with the reasons
349
+ def list_invalid_properties
350
+ invalid_properties = Array.new
351
+ pattern = Regexp.new(/(北海道|青森県|岩手県|宮城県|秋田県|山形県|福島県|茨城県|栃木県|群馬県|埼玉県|千葉県|東京都|神奈川県|新潟県|富山県|石川県|福井県|山梨県|長野県|岐阜県|静岡県|愛知県|三重県|滋賀県|京都府|大阪府|兵庫県|奈良県|和歌山県|鳥取県|島根県|岡山県|広島県|山口県|徳島県|香川県|愛媛県|高知県|福岡県|佐賀県|長崎県|熊本県|大分県|宮崎県|鹿児島県|沖縄県)/)
352
+ if !@prefecture_name.nil? && @prefecture_name !~ pattern
353
+ invalid_properties.push("invalid value for \"prefecture_name\", must conform to the pattern #{pattern}.")
354
+ end
355
+
356
+ if !@prefecture_code.nil? && @prefecture_code > 47
357
+ invalid_properties.push('invalid value for "prefecture_code", must be smaller than or equal to 47.')
358
+ end
359
+
360
+ if !@prefecture_code.nil? && @prefecture_code < 1
361
+ invalid_properties.push('invalid value for "prefecture_code", must be greater than or equal to 1.')
362
+ end
363
+
364
+ invalid_properties
365
+ end
366
+
367
+ # Check to see if the all the properties in the model are valid
368
+ # @return true if the model is valid
369
+ def valid?
370
+ return false if !@prefecture_name.nil? && @prefecture_name !~ Regexp.new(/(北海道|青森県|岩手県|宮城県|秋田県|山形県|福島県|茨城県|栃木県|群馬県|埼玉県|千葉県|東京都|神奈川県|新潟県|富山県|石川県|福井県|山梨県|長野県|岐阜県|静岡県|愛知県|三重県|滋賀県|京都府|大阪府|兵庫県|奈良県|和歌山県|鳥取県|島根県|岡山県|広島県|山口県|徳島県|香川県|愛媛県|高知県|福岡県|佐賀県|長崎県|熊本県|大分県|宮崎県|鹿児島県|沖縄県)/)
371
+ return false if !@prefecture_code.nil? && @prefecture_code > 47
372
+ return false if !@prefecture_code.nil? && @prefecture_code < 1
373
+ close_cause_validator = EnumAttributeValidator.new('String', ["01", "11", "21", "31"])
374
+ return false unless close_cause_validator.valid?(@close_cause)
375
+ latest_validator = EnumAttributeValidator.new('Integer', [0, 1])
376
+ return false unless latest_validator.valid?(@latest)
377
+ hihyoji_validator = EnumAttributeValidator.new('Integer', [0, 1])
378
+ return false unless hihyoji_validator.valid?(@hihyoji)
379
+ true
380
+ end
381
+
382
+ # Custom attribute writer method with validation
383
+ # @param [Object] prefecture_name Value to be assigned
384
+ def prefecture_name=(prefecture_name)
385
+ pattern = Regexp.new(/(北海道|青森県|岩手県|宮城県|秋田県|山形県|福島県|茨城県|栃木県|群馬県|埼玉県|千葉県|東京都|神奈川県|新潟県|富山県|石川県|福井県|山梨県|長野県|岐阜県|静岡県|愛知県|三重県|滋賀県|京都府|大阪府|兵庫県|奈良県|和歌山県|鳥取県|島根県|岡山県|広島県|山口県|徳島県|香川県|愛媛県|高知県|福岡県|佐賀県|長崎県|熊本県|大分県|宮崎県|鹿児島県|沖縄県)/)
386
+ if !prefecture_name.nil? && prefecture_name !~ pattern
387
+ fail ArgumentError, "invalid value for \"prefecture_name\", must conform to the pattern #{pattern}."
388
+ end
389
+
390
+ @prefecture_name = prefecture_name
391
+ end
392
+
393
+ # Custom attribute writer method with validation
394
+ # @param [Object] prefecture_code Value to be assigned
395
+ def prefecture_code=(prefecture_code)
396
+ if !prefecture_code.nil? && prefecture_code > 47
397
+ fail ArgumentError, 'invalid value for "prefecture_code", must be smaller than or equal to 47.'
398
+ end
399
+
400
+ if !prefecture_code.nil? && prefecture_code < 1
401
+ fail ArgumentError, 'invalid value for "prefecture_code", must be greater than or equal to 1.'
402
+ end
403
+
404
+ @prefecture_code = prefecture_code
405
+ end
406
+
407
+ # Custom attribute writer method checking allowed values (enum).
408
+ # @param [Object] close_cause Object to be assigned
409
+ def close_cause=(close_cause)
410
+ validator = EnumAttributeValidator.new('String', ["01", "11", "21", "31"])
411
+ unless validator.valid?(close_cause)
412
+ fail ArgumentError, "invalid value for \"close_cause\", must be one of #{validator.allowable_values}."
413
+ end
414
+ @close_cause = close_cause
415
+ end
416
+
417
+ # Custom attribute writer method checking allowed values (enum).
418
+ # @param [Object] latest Object to be assigned
419
+ def latest=(latest)
420
+ validator = EnumAttributeValidator.new('Integer', [0, 1])
421
+ unless validator.valid?(latest)
422
+ fail ArgumentError, "invalid value for \"latest\", must be one of #{validator.allowable_values}."
423
+ end
424
+ @latest = latest
425
+ end
426
+
427
+ # Custom attribute writer method checking allowed values (enum).
428
+ # @param [Object] hihyoji Object to be assigned
429
+ def hihyoji=(hihyoji)
430
+ validator = EnumAttributeValidator.new('Integer', [0, 1])
431
+ unless validator.valid?(hihyoji)
432
+ fail ArgumentError, "invalid value for \"hihyoji\", must be one of #{validator.allowable_values}."
433
+ end
434
+ @hihyoji = hihyoji
435
+ end
436
+
437
+ # Checks equality by comparing each attribute.
438
+ # @param [Object] Object to be compared
439
+ def ==(o)
440
+ return true if self.equal?(o)
441
+ self.class == o.class &&
442
+ sequence_number == o.sequence_number &&
443
+ corporate_number == o.corporate_number &&
444
+ process == o.process &&
445
+ correct == o.correct &&
446
+ update_date == o.update_date &&
447
+ change_date == o.change_date &&
448
+ name == o.name &&
449
+ name_image_id == o.name_image_id &&
450
+ kind == o.kind &&
451
+ prefecture_name == o.prefecture_name &&
452
+ city_name == o.city_name &&
453
+ street_number == o.street_number &&
454
+ address_image_id == o.address_image_id &&
455
+ prefecture_code == o.prefecture_code &&
456
+ city_code == o.city_code &&
457
+ post_code == o.post_code &&
458
+ address_outside == o.address_outside &&
459
+ address_outside_image_id == o.address_outside_image_id &&
460
+ close_date == o.close_date &&
461
+ close_cause == o.close_cause &&
462
+ successor_corporate_number == o.successor_corporate_number &&
463
+ change_cause == o.change_cause &&
464
+ assignment_date == o.assignment_date &&
465
+ latest == o.latest &&
466
+ en_name == o.en_name &&
467
+ en_prefecture_name == o.en_prefecture_name &&
468
+ en_city_name == o.en_city_name &&
469
+ en_address_outside == o.en_address_outside &&
470
+ furigana == o.furigana &&
471
+ hihyoji == o.hihyoji
472
+ end
473
+
474
+ # @see the `==` method
475
+ # @param [Object] Object to be compared
476
+ def eql?(o)
477
+ self == o
478
+ end
479
+
480
+ # Calculates hash code according to all attributes.
481
+ # @return [Integer] Hash code
482
+ def hash
483
+ [sequence_number, corporate_number, process, correct, update_date, change_date, name, name_image_id, kind, prefecture_name, city_name, street_number, address_image_id, prefecture_code, city_code, post_code, address_outside, address_outside_image_id, close_date, close_cause, successor_corporate_number, change_cause, assignment_date, latest, en_name, en_prefecture_name, en_city_name, en_address_outside, furigana, hihyoji].hash
484
+ end
485
+
486
+ # Builds the object from hash
487
+ # @param [Hash] attributes Model attributes in the form of hash
488
+ # @return [Object] Returns the model itself
489
+ def self.build_from_hash(attributes)
490
+ new.build_from_hash(attributes)
491
+ end
492
+
493
+ # Builds the object from hash
494
+ # @param [Hash] attributes Model attributes in the form of hash
495
+ # @return [Object] Returns the model itself
496
+ def build_from_hash(attributes)
497
+ return nil unless attributes.is_a?(Hash)
498
+ self.class.openapi_types.each_pair do |key, type|
499
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
500
+ self.send("#{key}=", nil)
501
+ elsif type =~ /\AArray<(.*)>/i
502
+ # check to ensure the input is an array given that the attribute
503
+ # is documented as an array but the input is not
504
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
505
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
506
+ end
507
+ elsif !attributes[self.class.attribute_map[key]].nil?
508
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
509
+ end
510
+ end
511
+
512
+ self
513
+ end
514
+
515
+ # Deserializes the data based on type
516
+ # @param string type Data type
517
+ # @param string value Value to be deserialized
518
+ # @return [Object] Deserialized data
519
+ def _deserialize(type, value)
520
+ case type.to_sym
521
+ when :Time
522
+ Time.parse(value)
523
+ when :Date
524
+ Date.parse(value)
525
+ when :String
526
+ value.to_s
527
+ when :Integer
528
+ value.to_i
529
+ when :Float
530
+ value.to_f
531
+ when :Boolean
532
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
533
+ true
534
+ else
535
+ false
536
+ end
537
+ when :Object
538
+ # generic object (usually a Hash), return directly
539
+ value
540
+ when /\AArray<(?<inner_type>.+)>\z/
541
+ inner_type = Regexp.last_match[:inner_type]
542
+ value.map { |v| _deserialize(inner_type, v) }
543
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
544
+ k_type = Regexp.last_match[:k_type]
545
+ v_type = Regexp.last_match[:v_type]
546
+ {}.tap do |hash|
547
+ value.each do |k, v|
548
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
549
+ end
550
+ end
551
+ else # model
552
+ # models (e.g. Pet) or oneOf
553
+ klass = CnsOpenapiRubyClient.const_get(type)
554
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
555
+ end
556
+ end
557
+
558
+ # Returns the string representation of the object
559
+ # @return [String] String presentation of the object
560
+ def to_s
561
+ to_hash.to_s
562
+ end
563
+
564
+ # to_body is an alias to to_hash (backward compatibility)
565
+ # @return [Hash] Returns the object in the form of hash
566
+ def to_body
567
+ to_hash
568
+ end
569
+
570
+ # Returns the object in the form of hash
571
+ # @return [Hash] Returns the object in the form of hash
572
+ def to_hash
573
+ hash = {}
574
+ self.class.attribute_map.each_pair do |attr, param|
575
+ value = self.send(attr)
576
+ if value.nil?
577
+ is_nullable = self.class.openapi_nullable.include?(attr)
578
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
579
+ end
580
+
581
+ hash[param] = _to_hash(value)
582
+ end
583
+ hash
584
+ end
585
+
586
+ # Outputs non-array value in the form of hash
587
+ # For object, use to_hash. Otherwise, just return the value
588
+ # @param [Object] value Any valid value
589
+ # @return [Hash] Returns the value in the form of hash
590
+ def _to_hash(value)
591
+ if value.is_a?(Array)
592
+ value.compact.map { |v| _to_hash(v) }
593
+ elsif value.is_a?(Hash)
594
+ {}.tap do |hash|
595
+ value.each { |k, v| hash[k] = _to_hash(v) }
596
+ end
597
+ elsif value.respond_to? :to_hash
598
+ value.to_hash
599
+ else
600
+ value
601
+ end
602
+ end
603
+
604
+ end
605
+
606
+ end