gbizinfo 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.openapi-generator/FILES +48 -0
- data/.openapi-generator/VERSION +1 -0
- data/.openapi-generator-ignore +30 -0
- data/.rspec +3 -0
- data/.rubocop.yml +13 -0
- data/CHANGELOG.md +3 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +64 -0
- data/LICENSE.txt +21 -0
- data/README.md +121 -0
- data/Rakefile +12 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/docs/ApiError.md +20 -0
- data/docs/CertificationInfo.md +30 -0
- data/docs/CommendationInfo.md +26 -0
- data/docs/CompatibilityOfChildcareAndWork.md +24 -0
- data/docs/Finance.md +24 -0
- data/docs/GBizINFORESTAPIApi.md +678 -0
- data/docs/GBizINFORESTAPIPeriodSpecifiedSearchApi.md +591 -0
- data/docs/HojinInfo.md +76 -0
- data/docs/HojinInfoResponse.md +24 -0
- data/docs/HojinInfoUpdateInfoResponse.md +30 -0
- data/docs/MajorShareholders.md +20 -0
- data/docs/ManagementIndex.md +66 -0
- data/docs/PatentInfo.md +26 -0
- data/docs/ProcurementInfo.md +26 -0
- data/docs/SubsidyInfo.md +32 -0
- data/docs/WomenActivityInfos.md +28 -0
- data/docs/WorkplaceBaseInfos.md +28 -0
- data/docs/WorkplaceInfoBean.md +22 -0
- data/gbizinfo.gemspec +37 -0
- data/git_push.sh +57 -0
- data/lib/gbizinfo/api/g_biz_inforestapi_api.rb +748 -0
- data/lib/gbizinfo/api/g_biz_inforestapi_period_specified_search_api.rb +670 -0
- data/lib/gbizinfo/api_client.rb +391 -0
- data/lib/gbizinfo/api_error.rb +58 -0
- data/lib/gbizinfo/configuration.rb +290 -0
- data/lib/gbizinfo/models/api_error.rb +225 -0
- data/lib/gbizinfo/models/certification_info.rb +275 -0
- data/lib/gbizinfo/models/commendation_info.rb +255 -0
- data/lib/gbizinfo/models/compatibility_of_childcare_and_work.rb +245 -0
- data/lib/gbizinfo/models/finance.rb +249 -0
- data/lib/gbizinfo/models/hojin_info.rb +515 -0
- data/lib/gbizinfo/models/hojin_info_response.rb +249 -0
- data/lib/gbizinfo/models/hojin_info_update_info_response.rb +279 -0
- data/lib/gbizinfo/models/major_shareholders.rb +225 -0
- data/lib/gbizinfo/models/management_index.rb +455 -0
- data/lib/gbizinfo/models/patent_info.rb +257 -0
- data/lib/gbizinfo/models/procurement_info.rb +257 -0
- data/lib/gbizinfo/models/subsidy_info.rb +287 -0
- data/lib/gbizinfo/models/women_activity_infos.rb +265 -0
- data/lib/gbizinfo/models/workplace_base_infos.rb +265 -0
- data/lib/gbizinfo/models/workplace_info_bean.rb +232 -0
- data/lib/gbizinfo/version.rb +15 -0
- data/lib/gbizinfo.rb +57 -0
- data/openapi/root.yaml +1377 -0
- data/sig/gbizinfo.rbs +4 -0
- metadata +105 -0
@@ -0,0 +1,287 @@
|
|
1
|
+
=begin
|
2
|
+
#gBizINFO REST API
|
3
|
+
|
4
|
+
#<div>各REST APIはHTTPリクエストヘッダX-hojinInfo-api-tokenに動作確認用のAPIトークンDTcLxzo1lZaUYaQPVdSRxdS4MzlXNCs4を指定して動作を確認することができます。</div><div>※動作確認用のAPIトークンはこのページでの動作確認でのみ使用してください。</div><div>※REST APIを利用する際は必ず、<a href='https://info.gbiz.go.jp/hojin/api_registration/form'>Web API利用申請</a>を行い、APIトークンを取得してください。</div>
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 1.0
|
7
|
+
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 7.0.0
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
require 'time'
|
15
|
+
|
16
|
+
module Gbizinfo
|
17
|
+
class SubsidyInfo
|
18
|
+
# 金額
|
19
|
+
attr_accessor :amount
|
20
|
+
|
21
|
+
# 認定日
|
22
|
+
attr_accessor :date_of_approval
|
23
|
+
|
24
|
+
# 府省
|
25
|
+
attr_accessor :government_departments
|
26
|
+
|
27
|
+
# 連名
|
28
|
+
attr_accessor :joint_signatures
|
29
|
+
|
30
|
+
# 備考
|
31
|
+
attr_accessor :note
|
32
|
+
|
33
|
+
# 補助金財源
|
34
|
+
attr_accessor :subsidy_resource
|
35
|
+
|
36
|
+
# 対象
|
37
|
+
attr_accessor :target
|
38
|
+
|
39
|
+
# 補助金等
|
40
|
+
attr_accessor :title
|
41
|
+
|
42
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
43
|
+
def self.attribute_map
|
44
|
+
{
|
45
|
+
:'amount' => :'amount',
|
46
|
+
:'date_of_approval' => :'date_of_approval',
|
47
|
+
:'government_departments' => :'government_departments',
|
48
|
+
:'joint_signatures' => :'joint_signatures',
|
49
|
+
:'note' => :'note',
|
50
|
+
:'subsidy_resource' => :'subsidy_resource',
|
51
|
+
:'target' => :'target',
|
52
|
+
:'title' => :'title'
|
53
|
+
}
|
54
|
+
end
|
55
|
+
|
56
|
+
# Returns all the JSON keys this model knows about
|
57
|
+
def self.acceptable_attributes
|
58
|
+
attribute_map.values
|
59
|
+
end
|
60
|
+
|
61
|
+
# Attribute type mapping.
|
62
|
+
def self.openapi_types
|
63
|
+
{
|
64
|
+
:'amount' => :'String',
|
65
|
+
:'date_of_approval' => :'String',
|
66
|
+
:'government_departments' => :'String',
|
67
|
+
:'joint_signatures' => :'Array<String>',
|
68
|
+
:'note' => :'String',
|
69
|
+
:'subsidy_resource' => :'String',
|
70
|
+
:'target' => :'String',
|
71
|
+
:'title' => :'String'
|
72
|
+
}
|
73
|
+
end
|
74
|
+
|
75
|
+
# List of attributes with nullable: true
|
76
|
+
def self.openapi_nullable
|
77
|
+
Set.new([
|
78
|
+
])
|
79
|
+
end
|
80
|
+
|
81
|
+
# Initializes the object
|
82
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
83
|
+
def initialize(attributes = {})
|
84
|
+
if (!attributes.is_a?(Hash))
|
85
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Gbizinfo::SubsidyInfo` initialize method"
|
86
|
+
end
|
87
|
+
|
88
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
89
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
90
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
91
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Gbizinfo::SubsidyInfo`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
92
|
+
end
|
93
|
+
h[k.to_sym] = v
|
94
|
+
}
|
95
|
+
|
96
|
+
if attributes.key?(:'amount')
|
97
|
+
self.amount = attributes[:'amount']
|
98
|
+
end
|
99
|
+
|
100
|
+
if attributes.key?(:'date_of_approval')
|
101
|
+
self.date_of_approval = attributes[:'date_of_approval']
|
102
|
+
end
|
103
|
+
|
104
|
+
if attributes.key?(:'government_departments')
|
105
|
+
self.government_departments = attributes[:'government_departments']
|
106
|
+
end
|
107
|
+
|
108
|
+
if attributes.key?(:'joint_signatures')
|
109
|
+
if (value = attributes[:'joint_signatures']).is_a?(Array)
|
110
|
+
self.joint_signatures = value
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
if attributes.key?(:'note')
|
115
|
+
self.note = attributes[:'note']
|
116
|
+
end
|
117
|
+
|
118
|
+
if attributes.key?(:'subsidy_resource')
|
119
|
+
self.subsidy_resource = attributes[:'subsidy_resource']
|
120
|
+
end
|
121
|
+
|
122
|
+
if attributes.key?(:'target')
|
123
|
+
self.target = attributes[:'target']
|
124
|
+
end
|
125
|
+
|
126
|
+
if attributes.key?(:'title')
|
127
|
+
self.title = attributes[:'title']
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
132
|
+
# @return Array for valid properties with the reasons
|
133
|
+
def list_invalid_properties
|
134
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
135
|
+
invalid_properties = Array.new
|
136
|
+
invalid_properties
|
137
|
+
end
|
138
|
+
|
139
|
+
# Check to see if the all the properties in the model are valid
|
140
|
+
# @return true if the model is valid
|
141
|
+
def valid?
|
142
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
143
|
+
true
|
144
|
+
end
|
145
|
+
|
146
|
+
# Checks equality by comparing each attribute.
|
147
|
+
# @param [Object] Object to be compared
|
148
|
+
def ==(o)
|
149
|
+
return true if self.equal?(o)
|
150
|
+
self.class == o.class &&
|
151
|
+
amount == o.amount &&
|
152
|
+
date_of_approval == o.date_of_approval &&
|
153
|
+
government_departments == o.government_departments &&
|
154
|
+
joint_signatures == o.joint_signatures &&
|
155
|
+
note == o.note &&
|
156
|
+
subsidy_resource == o.subsidy_resource &&
|
157
|
+
target == o.target &&
|
158
|
+
title == o.title
|
159
|
+
end
|
160
|
+
|
161
|
+
# @see the `==` method
|
162
|
+
# @param [Object] Object to be compared
|
163
|
+
def eql?(o)
|
164
|
+
self == o
|
165
|
+
end
|
166
|
+
|
167
|
+
# Calculates hash code according to all attributes.
|
168
|
+
# @return [Integer] Hash code
|
169
|
+
def hash
|
170
|
+
[amount, date_of_approval, government_departments, joint_signatures, note, subsidy_resource, target, title].hash
|
171
|
+
end
|
172
|
+
|
173
|
+
# Builds the object from hash
|
174
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
175
|
+
# @return [Object] Returns the model itself
|
176
|
+
def self.build_from_hash(attributes)
|
177
|
+
return nil unless attributes.is_a?(Hash)
|
178
|
+
attributes = attributes.transform_keys(&:to_sym)
|
179
|
+
transformed_hash = {}
|
180
|
+
openapi_types.each_pair do |key, type|
|
181
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
182
|
+
transformed_hash["#{key}"] = nil
|
183
|
+
elsif type =~ /\AArray<(.*)>/i
|
184
|
+
# check to ensure the input is an array given that the attribute
|
185
|
+
# is documented as an array but the input is not
|
186
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
187
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
188
|
+
end
|
189
|
+
elsif !attributes[attribute_map[key]].nil?
|
190
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
191
|
+
end
|
192
|
+
end
|
193
|
+
new(transformed_hash)
|
194
|
+
end
|
195
|
+
|
196
|
+
# Deserializes the data based on type
|
197
|
+
# @param string type Data type
|
198
|
+
# @param string value Value to be deserialized
|
199
|
+
# @return [Object] Deserialized data
|
200
|
+
def self._deserialize(type, value)
|
201
|
+
case type.to_sym
|
202
|
+
when :Time
|
203
|
+
Time.parse(value)
|
204
|
+
when :Date
|
205
|
+
Date.parse(value)
|
206
|
+
when :String
|
207
|
+
value.to_s
|
208
|
+
when :Integer
|
209
|
+
value.to_i
|
210
|
+
when :Float
|
211
|
+
value.to_f
|
212
|
+
when :Boolean
|
213
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
214
|
+
true
|
215
|
+
else
|
216
|
+
false
|
217
|
+
end
|
218
|
+
when :Object
|
219
|
+
# generic object (usually a Hash), return directly
|
220
|
+
value
|
221
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
222
|
+
inner_type = Regexp.last_match[:inner_type]
|
223
|
+
value.map { |v| _deserialize(inner_type, v) }
|
224
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
225
|
+
k_type = Regexp.last_match[:k_type]
|
226
|
+
v_type = Regexp.last_match[:v_type]
|
227
|
+
{}.tap do |hash|
|
228
|
+
value.each do |k, v|
|
229
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
230
|
+
end
|
231
|
+
end
|
232
|
+
else # model
|
233
|
+
# models (e.g. Pet) or oneOf
|
234
|
+
klass = Gbizinfo.const_get(type)
|
235
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
239
|
+
# Returns the string representation of the object
|
240
|
+
# @return [String] String presentation of the object
|
241
|
+
def to_s
|
242
|
+
to_hash.to_s
|
243
|
+
end
|
244
|
+
|
245
|
+
# to_body is an alias to to_hash (backward compatibility)
|
246
|
+
# @return [Hash] Returns the object in the form of hash
|
247
|
+
def to_body
|
248
|
+
to_hash
|
249
|
+
end
|
250
|
+
|
251
|
+
# Returns the object in the form of hash
|
252
|
+
# @return [Hash] Returns the object in the form of hash
|
253
|
+
def to_hash
|
254
|
+
hash = {}
|
255
|
+
self.class.attribute_map.each_pair do |attr, param|
|
256
|
+
value = self.send(attr)
|
257
|
+
if value.nil?
|
258
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
259
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
260
|
+
end
|
261
|
+
|
262
|
+
hash[param] = _to_hash(value)
|
263
|
+
end
|
264
|
+
hash
|
265
|
+
end
|
266
|
+
|
267
|
+
# Outputs non-array value in the form of hash
|
268
|
+
# For object, use to_hash. Otherwise, just return the value
|
269
|
+
# @param [Object] value Any valid value
|
270
|
+
# @return [Hash] Returns the value in the form of hash
|
271
|
+
def _to_hash(value)
|
272
|
+
if value.is_a?(Array)
|
273
|
+
value.compact.map { |v| _to_hash(v) }
|
274
|
+
elsif value.is_a?(Hash)
|
275
|
+
{}.tap do |hash|
|
276
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
277
|
+
end
|
278
|
+
elsif value.respond_to? :to_hash
|
279
|
+
value.to_hash
|
280
|
+
else
|
281
|
+
value
|
282
|
+
end
|
283
|
+
end
|
284
|
+
|
285
|
+
end
|
286
|
+
|
287
|
+
end
|
@@ -0,0 +1,265 @@
|
|
1
|
+
=begin
|
2
|
+
#gBizINFO REST API
|
3
|
+
|
4
|
+
#<div>各REST APIはHTTPリクエストヘッダX-hojinInfo-api-tokenに動作確認用のAPIトークンDTcLxzo1lZaUYaQPVdSRxdS4MzlXNCs4を指定して動作を確認することができます。</div><div>※動作確認用のAPIトークンはこのページでの動作確認でのみ使用してください。</div><div>※REST APIを利用する際は必ず、<a href='https://info.gbiz.go.jp/hojin/api_registration/form'>Web API利用申請</a>を行い、APIトークンを取得してください。</div>
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 1.0
|
7
|
+
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 7.0.0
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
require 'time'
|
15
|
+
|
16
|
+
module Gbizinfo
|
17
|
+
class WomenActivityInfos
|
18
|
+
# 女性管理職人数
|
19
|
+
attr_accessor :female_share_of_manager
|
20
|
+
|
21
|
+
# 女性役員人数
|
22
|
+
attr_accessor :female_share_of_officers
|
23
|
+
|
24
|
+
# 労働者に占める女性労働者の割合
|
25
|
+
attr_accessor :female_workers_proportion
|
26
|
+
|
27
|
+
# 労働者に占める女性労働者の割合種別
|
28
|
+
attr_accessor :female_workers_proportion_type
|
29
|
+
|
30
|
+
# 管理職に占める女性の割合
|
31
|
+
attr_accessor :gender_total_of_manager
|
32
|
+
|
33
|
+
# 役員全体人数(男女計)
|
34
|
+
attr_accessor :gender_total_of_officers
|
35
|
+
|
36
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
37
|
+
def self.attribute_map
|
38
|
+
{
|
39
|
+
:'female_share_of_manager' => :'female_share_of_manager',
|
40
|
+
:'female_share_of_officers' => :'female_share_of_officers',
|
41
|
+
:'female_workers_proportion' => :'female_workers_proportion',
|
42
|
+
:'female_workers_proportion_type' => :'female_workers_proportion_type',
|
43
|
+
:'gender_total_of_manager' => :'gender_total_of_manager',
|
44
|
+
:'gender_total_of_officers' => :'gender_total_of_officers'
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
# Returns all the JSON keys this model knows about
|
49
|
+
def self.acceptable_attributes
|
50
|
+
attribute_map.values
|
51
|
+
end
|
52
|
+
|
53
|
+
# Attribute type mapping.
|
54
|
+
def self.openapi_types
|
55
|
+
{
|
56
|
+
:'female_share_of_manager' => :'Integer',
|
57
|
+
:'female_share_of_officers' => :'Integer',
|
58
|
+
:'female_workers_proportion' => :'Float',
|
59
|
+
:'female_workers_proportion_type' => :'String',
|
60
|
+
:'gender_total_of_manager' => :'Integer',
|
61
|
+
:'gender_total_of_officers' => :'Integer'
|
62
|
+
}
|
63
|
+
end
|
64
|
+
|
65
|
+
# List of attributes with nullable: true
|
66
|
+
def self.openapi_nullable
|
67
|
+
Set.new([
|
68
|
+
])
|
69
|
+
end
|
70
|
+
|
71
|
+
# Initializes the object
|
72
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
73
|
+
def initialize(attributes = {})
|
74
|
+
if (!attributes.is_a?(Hash))
|
75
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Gbizinfo::WomenActivityInfos` initialize method"
|
76
|
+
end
|
77
|
+
|
78
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
79
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
80
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
81
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Gbizinfo::WomenActivityInfos`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
82
|
+
end
|
83
|
+
h[k.to_sym] = v
|
84
|
+
}
|
85
|
+
|
86
|
+
if attributes.key?(:'female_share_of_manager')
|
87
|
+
self.female_share_of_manager = attributes[:'female_share_of_manager']
|
88
|
+
end
|
89
|
+
|
90
|
+
if attributes.key?(:'female_share_of_officers')
|
91
|
+
self.female_share_of_officers = attributes[:'female_share_of_officers']
|
92
|
+
end
|
93
|
+
|
94
|
+
if attributes.key?(:'female_workers_proportion')
|
95
|
+
self.female_workers_proportion = attributes[:'female_workers_proportion']
|
96
|
+
end
|
97
|
+
|
98
|
+
if attributes.key?(:'female_workers_proportion_type')
|
99
|
+
self.female_workers_proportion_type = attributes[:'female_workers_proportion_type']
|
100
|
+
end
|
101
|
+
|
102
|
+
if attributes.key?(:'gender_total_of_manager')
|
103
|
+
self.gender_total_of_manager = attributes[:'gender_total_of_manager']
|
104
|
+
end
|
105
|
+
|
106
|
+
if attributes.key?(:'gender_total_of_officers')
|
107
|
+
self.gender_total_of_officers = attributes[:'gender_total_of_officers']
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
112
|
+
# @return Array for valid properties with the reasons
|
113
|
+
def list_invalid_properties
|
114
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
115
|
+
invalid_properties = Array.new
|
116
|
+
invalid_properties
|
117
|
+
end
|
118
|
+
|
119
|
+
# Check to see if the all the properties in the model are valid
|
120
|
+
# @return true if the model is valid
|
121
|
+
def valid?
|
122
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
123
|
+
true
|
124
|
+
end
|
125
|
+
|
126
|
+
# Checks equality by comparing each attribute.
|
127
|
+
# @param [Object] Object to be compared
|
128
|
+
def ==(o)
|
129
|
+
return true if self.equal?(o)
|
130
|
+
self.class == o.class &&
|
131
|
+
female_share_of_manager == o.female_share_of_manager &&
|
132
|
+
female_share_of_officers == o.female_share_of_officers &&
|
133
|
+
female_workers_proportion == o.female_workers_proportion &&
|
134
|
+
female_workers_proportion_type == o.female_workers_proportion_type &&
|
135
|
+
gender_total_of_manager == o.gender_total_of_manager &&
|
136
|
+
gender_total_of_officers == o.gender_total_of_officers
|
137
|
+
end
|
138
|
+
|
139
|
+
# @see the `==` method
|
140
|
+
# @param [Object] Object to be compared
|
141
|
+
def eql?(o)
|
142
|
+
self == o
|
143
|
+
end
|
144
|
+
|
145
|
+
# Calculates hash code according to all attributes.
|
146
|
+
# @return [Integer] Hash code
|
147
|
+
def hash
|
148
|
+
[female_share_of_manager, female_share_of_officers, female_workers_proportion, female_workers_proportion_type, gender_total_of_manager, gender_total_of_officers].hash
|
149
|
+
end
|
150
|
+
|
151
|
+
# Builds the object from hash
|
152
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
153
|
+
# @return [Object] Returns the model itself
|
154
|
+
def self.build_from_hash(attributes)
|
155
|
+
return nil unless attributes.is_a?(Hash)
|
156
|
+
attributes = attributes.transform_keys(&:to_sym)
|
157
|
+
transformed_hash = {}
|
158
|
+
openapi_types.each_pair do |key, type|
|
159
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
160
|
+
transformed_hash["#{key}"] = nil
|
161
|
+
elsif type =~ /\AArray<(.*)>/i
|
162
|
+
# check to ensure the input is an array given that the attribute
|
163
|
+
# is documented as an array but the input is not
|
164
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
165
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
166
|
+
end
|
167
|
+
elsif !attributes[attribute_map[key]].nil?
|
168
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
169
|
+
end
|
170
|
+
end
|
171
|
+
new(transformed_hash)
|
172
|
+
end
|
173
|
+
|
174
|
+
# Deserializes the data based on type
|
175
|
+
# @param string type Data type
|
176
|
+
# @param string value Value to be deserialized
|
177
|
+
# @return [Object] Deserialized data
|
178
|
+
def self._deserialize(type, value)
|
179
|
+
case type.to_sym
|
180
|
+
when :Time
|
181
|
+
Time.parse(value)
|
182
|
+
when :Date
|
183
|
+
Date.parse(value)
|
184
|
+
when :String
|
185
|
+
value.to_s
|
186
|
+
when :Integer
|
187
|
+
value.to_i
|
188
|
+
when :Float
|
189
|
+
value.to_f
|
190
|
+
when :Boolean
|
191
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
192
|
+
true
|
193
|
+
else
|
194
|
+
false
|
195
|
+
end
|
196
|
+
when :Object
|
197
|
+
# generic object (usually a Hash), return directly
|
198
|
+
value
|
199
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
200
|
+
inner_type = Regexp.last_match[:inner_type]
|
201
|
+
value.map { |v| _deserialize(inner_type, v) }
|
202
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
203
|
+
k_type = Regexp.last_match[:k_type]
|
204
|
+
v_type = Regexp.last_match[:v_type]
|
205
|
+
{}.tap do |hash|
|
206
|
+
value.each do |k, v|
|
207
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
208
|
+
end
|
209
|
+
end
|
210
|
+
else # model
|
211
|
+
# models (e.g. Pet) or oneOf
|
212
|
+
klass = Gbizinfo.const_get(type)
|
213
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
# Returns the string representation of the object
|
218
|
+
# @return [String] String presentation of the object
|
219
|
+
def to_s
|
220
|
+
to_hash.to_s
|
221
|
+
end
|
222
|
+
|
223
|
+
# to_body is an alias to to_hash (backward compatibility)
|
224
|
+
# @return [Hash] Returns the object in the form of hash
|
225
|
+
def to_body
|
226
|
+
to_hash
|
227
|
+
end
|
228
|
+
|
229
|
+
# Returns the object in the form of hash
|
230
|
+
# @return [Hash] Returns the object in the form of hash
|
231
|
+
def to_hash
|
232
|
+
hash = {}
|
233
|
+
self.class.attribute_map.each_pair do |attr, param|
|
234
|
+
value = self.send(attr)
|
235
|
+
if value.nil?
|
236
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
237
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
238
|
+
end
|
239
|
+
|
240
|
+
hash[param] = _to_hash(value)
|
241
|
+
end
|
242
|
+
hash
|
243
|
+
end
|
244
|
+
|
245
|
+
# Outputs non-array value in the form of hash
|
246
|
+
# For object, use to_hash. Otherwise, just return the value
|
247
|
+
# @param [Object] value Any valid value
|
248
|
+
# @return [Hash] Returns the value in the form of hash
|
249
|
+
def _to_hash(value)
|
250
|
+
if value.is_a?(Array)
|
251
|
+
value.compact.map { |v| _to_hash(v) }
|
252
|
+
elsif value.is_a?(Hash)
|
253
|
+
{}.tap do |hash|
|
254
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
255
|
+
end
|
256
|
+
elsif value.respond_to? :to_hash
|
257
|
+
value.to_hash
|
258
|
+
else
|
259
|
+
value
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
end
|
264
|
+
|
265
|
+
end
|