osdn-client 0.0.20160304 → 0.0.20160711

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 (82) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +201 -0
  3. data/README.md +182 -0
  4. data/docs/DefaultApi.md +115 -0
  5. data/docs/Group.md +23 -0
  6. data/docs/GroupToolFlags.md +17 -0
  7. data/docs/News.md +14 -0
  8. data/docs/Package.md +13 -0
  9. data/docs/Pong.md +11 -0
  10. data/docs/ProjectApi.md +1511 -0
  11. data/docs/ProjectFrsApi.md +888 -0
  12. data/docs/ProjectNewsApi.md +576 -0
  13. data/docs/RelFile.md +19 -0
  14. data/docs/Release.md +16 -0
  15. data/docs/SimpleChamber.md +11 -0
  16. data/docs/SimpleGroup.md +11 -0
  17. data/docs/SimpleUser.md +10 -0
  18. data/docs/Skill.md +11 -0
  19. data/docs/Token.md +12 -0
  20. data/docs/User.md +20 -0
  21. data/docs/UserApi.md +63 -0
  22. data/lib/osdn-client.rb +32 -9
  23. data/lib/osdn-client/api/default_api.rb +50 -39
  24. data/lib/osdn-client/api/project_api.rb +661 -773
  25. data/lib/osdn-client/api/project_frs_api.rb +350 -412
  26. data/lib/osdn-client/api/project_news_api.rb +217 -244
  27. data/lib/osdn-client/api/user_api.rb +35 -20
  28. data/lib/osdn-client/api_client.rb +74 -13
  29. data/lib/osdn-client/api_error.rb +23 -0
  30. data/lib/osdn-client/configuration.rb +45 -1
  31. data/lib/osdn-client/models/group.rb +103 -65
  32. data/lib/osdn-client/models/group_tool_flags.rb +91 -47
  33. data/lib/osdn-client/models/news.rb +85 -38
  34. data/lib/osdn-client/models/package.rb +83 -35
  35. data/lib/osdn-client/models/pong.rb +79 -29
  36. data/lib/osdn-client/models/rel_file.rb +95 -53
  37. data/lib/osdn-client/models/release.rb +89 -44
  38. data/lib/osdn-client/models/simple_chamber.rb +79 -29
  39. data/lib/osdn-client/models/simple_group.rb +79 -29
  40. data/lib/osdn-client/models/simple_user.rb +77 -26
  41. data/lib/osdn-client/models/skill.rb +79 -29
  42. data/lib/osdn-client/models/token.rb +81 -32
  43. data/lib/osdn-client/models/user.rb +97 -56
  44. data/lib/osdn-client/version.rb +24 -1
  45. data/osdn-client.gemspec +30 -7
  46. data/spec/api/default_api_spec.rb +73 -0
  47. data/spec/api/{ProjectApi_spec.rb → project_api_spec.rb} +187 -264
  48. data/spec/api/{ProjectFrsApi_spec.rb → project_frs_api_spec.rb} +103 -136
  49. data/spec/api/{ProjectNewsApi_spec.rb → project_news_api_spec.rb} +71 -88
  50. data/spec/api/user_api_spec.rb +58 -0
  51. data/spec/api_client_spec.rb +315 -0
  52. data/spec/configuration_spec.rb +48 -0
  53. data/spec/models/group_spec.rb +143 -0
  54. data/spec/models/group_tool_flags_spec.rb +107 -0
  55. data/spec/models/news_spec.rb +89 -0
  56. data/spec/models/package_spec.rb +83 -0
  57. data/spec/models/pong_spec.rb +71 -0
  58. data/spec/models/rel_file_spec.rb +119 -0
  59. data/spec/models/release_spec.rb +101 -0
  60. data/spec/models/simple_chamber_spec.rb +71 -0
  61. data/spec/models/simple_group_spec.rb +71 -0
  62. data/spec/models/simple_user_spec.rb +65 -0
  63. data/spec/models/skill_spec.rb +71 -0
  64. data/spec/models/token_spec.rb +77 -0
  65. data/spec/models/user_spec.rb +125 -0
  66. data/spec/spec_helper.rb +122 -0
  67. metadata +87 -59
  68. data/spec/api/DefaultApi_spec.rb +0 -58
  69. data/spec/api/UserApi_spec.rb +0 -39
  70. data/spec/models/GroupToolFlags_spec.rb +0 -124
  71. data/spec/models/Group_spec.rb +0 -184
  72. data/spec/models/News_spec.rb +0 -94
  73. data/spec/models/Package_spec.rb +0 -84
  74. data/spec/models/Pong_spec.rb +0 -64
  75. data/spec/models/RelFile_spec.rb +0 -144
  76. data/spec/models/Release_spec.rb +0 -114
  77. data/spec/models/SimpleChamber_spec.rb +0 -64
  78. data/spec/models/SimpleGroup_spec.rb +0 -64
  79. data/spec/models/SimpleUser_spec.rb +0 -54
  80. data/spec/models/Skill_spec.rb +0 -64
  81. data/spec/models/Token_spec.rb +0 -74
  82. data/spec/models/User_spec.rb +0 -154
@@ -1,6 +1,30 @@
1
+ =begin
2
+ #OSDN REST API v0 beta
3
+
4
+ #OSDN REST API. Currently this API is experimental release. Pelase refer documentation on https://osdn.jp/projects/osdn-codes/wiki/APIGuide and you can get client libraries from https://osdn.jp/projects/osdn-codes/releases/p14859 .
5
+
6
+ OpenAPI spec version: 0.0.20160304
7
+ Contact: admin@osdn.jp
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+ Licensed under the Apache License, Version 2.0 (the "License");
11
+ you may not use this file except in compliance with the License.
12
+ You may obtain a copy of the License at
13
+
14
+ http://www.apache.org/licenses/LICENSE-2.0
15
+
16
+ Unless required by applicable law or agreed to in writing, software
17
+ distributed under the License is distributed on an "AS IS" BASIS,
18
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ See the License for the specific language governing permissions and
20
+ limitations under the License.
21
+
22
+ =end
23
+
1
24
  require 'date'
2
25
 
3
26
  module OSDNClient
27
+
4
28
  class SimpleChamber
5
29
  attr_accessor :id
6
30
 
@@ -10,18 +34,14 @@ module OSDNClient
10
34
 
11
35
  attr_accessor :last_update
12
36
 
37
+
13
38
  # Attribute mapping from ruby-style variable name to JSON key.
14
39
  def self.attribute_map
15
40
  {
16
-
17
41
  :'id' => :'id',
18
-
19
42
  :'name' => :'name',
20
-
21
43
  :'display_name' => :'display_name',
22
-
23
44
  :'last_update' => :'last_update'
24
-
25
45
  }
26
46
  end
27
47
 
@@ -32,36 +52,50 @@ module OSDNClient
32
52
  :'name' => :'String',
33
53
  :'display_name' => :'String',
34
54
  :'last_update' => :'DateTime'
35
-
36
55
  }
37
56
  end
38
57
 
58
+ # Initializes the object
59
+ # @param [Hash] attributes Model attributes in the form of hash
39
60
  def initialize(attributes = {})
40
61
  return unless attributes.is_a?(Hash)
41
62
 
42
63
  # convert string to symbol for hash key
43
- attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
64
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
44
65
 
45
-
46
- if attributes[:'id']
66
+ if attributes.has_key?(:'id')
47
67
  self.id = attributes[:'id']
48
68
  end
49
-
50
- if attributes[:'name']
69
+
70
+ if attributes.has_key?(:'name')
51
71
  self.name = attributes[:'name']
52
72
  end
53
-
54
- if attributes[:'display_name']
73
+
74
+ if attributes.has_key?(:'display_name')
55
75
  self.display_name = attributes[:'display_name']
56
76
  end
57
-
58
- if attributes[:'last_update']
77
+
78
+ if attributes.has_key?(:'last_update')
59
79
  self.last_update = attributes[:'last_update']
60
80
  end
61
-
81
+
82
+ end
83
+
84
+ # Show invalid properties with the reasons. Usually used together with valid?
85
+ # @return Array for valid properies with the reasons
86
+ def list_invalid_properties
87
+ invalid_properties = Array.new
88
+ return invalid_properties
89
+ end
90
+
91
+ # Check to see if the all the properties in the model are valid
92
+ # @return true if the model is valid
93
+ def valid?
94
+ return true
62
95
  end
63
96
 
64
- # Check equality by comparing each attribute.
97
+ # Checks equality by comparing each attribute.
98
+ # @param [Object] Object to be compared
65
99
  def ==(o)
66
100
  return true if self.equal?(o)
67
101
  self.class == o.class &&
@@ -72,35 +106,41 @@ module OSDNClient
72
106
  end
73
107
 
74
108
  # @see the `==` method
109
+ # @param [Object] Object to be compared
75
110
  def eql?(o)
76
111
  self == o
77
112
  end
78
113
 
79
- # Calculate hash code according to all attributes.
114
+ # Calculates hash code according to all attributes.
115
+ # @return [Fixnum] Hash code
80
116
  def hash
81
117
  [id, name, display_name, last_update].hash
82
118
  end
83
119
 
84
- # build the object from hash
120
+ # Builds the object from hash
121
+ # @param [Hash] attributes Model attributes in the form of hash
122
+ # @return [Object] Returns the model itself
85
123
  def build_from_hash(attributes)
86
124
  return nil unless attributes.is_a?(Hash)
87
125
  self.class.swagger_types.each_pair do |key, type|
88
126
  if type =~ /^Array<(.*)>/i
127
+ # check to ensure the input is an array given that the the attribute
128
+ # is documented as an array but the input is not
89
129
  if attributes[self.class.attribute_map[key]].is_a?(Array)
90
130
  self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
91
- else
92
- #TODO show warning in debug mode
93
131
  end
94
132
  elsif !attributes[self.class.attribute_map[key]].nil?
95
133
  self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
96
- else
97
- # data not found in attributes(hash), not an issue as the data can be optional
98
- end
134
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
99
135
  end
100
136
 
101
137
  self
102
138
  end
103
139
 
140
+ # Deserializes the data based on type
141
+ # @param string type Data type
142
+ # @param string value Value to be deserialized
143
+ # @return [Object] Deserialized data
104
144
  def _deserialize(type, value)
105
145
  case type.to_sym
106
146
  when :DateTime
@@ -119,6 +159,9 @@ module OSDNClient
119
159
  else
120
160
  false
121
161
  end
162
+ when :Object
163
+ # generic object (usually a Hash), return directly
164
+ value
122
165
  when /\AArray<(?<inner_type>.+)>\z/
123
166
  inner_type = Regexp.last_match[:inner_type]
124
167
  value.map { |v| _deserialize(inner_type, v) }
@@ -131,21 +174,25 @@ module OSDNClient
131
174
  end
132
175
  end
133
176
  else # model
134
- _model = OSDNClient.const_get(type).new
135
- _model.build_from_hash(value)
177
+ temp_model = OSDNClient.const_get(type).new
178
+ temp_model.build_from_hash(value)
136
179
  end
137
180
  end
138
181
 
182
+ # Returns the string representation of the object
183
+ # @return [String] String presentation of the object
139
184
  def to_s
140
185
  to_hash.to_s
141
186
  end
142
187
 
143
- # to_body is an alias to to_body (backward compatibility))
188
+ # to_body is an alias to to_hash (backward compatibility)
189
+ # @return [Hash] Returns the object in the form of hash
144
190
  def to_body
145
191
  to_hash
146
192
  end
147
193
 
148
- # return the object in the form of hash
194
+ # Returns the object in the form of hash
195
+ # @return [Hash] Returns the object in the form of hash
149
196
  def to_hash
150
197
  hash = {}
151
198
  self.class.attribute_map.each_pair do |attr, param|
@@ -156,8 +203,10 @@ module OSDNClient
156
203
  hash
157
204
  end
158
205
 
159
- # Method to output non-array value in the form of hash
206
+ # Outputs non-array value in the form of hash
160
207
  # For object, use to_hash. Otherwise, just return the value
208
+ # @param [Object] value Any valid value
209
+ # @return [Hash] Returns the value in the form of hash
161
210
  def _to_hash(value)
162
211
  if value.is_a?(Array)
163
212
  value.compact.map{ |v| _to_hash(v) }
@@ -173,4 +222,5 @@ module OSDNClient
173
222
  end
174
223
 
175
224
  end
225
+
176
226
  end
@@ -1,6 +1,30 @@
1
+ =begin
2
+ #OSDN REST API v0 beta
3
+
4
+ #OSDN REST API. Currently this API is experimental release. Pelase refer documentation on https://osdn.jp/projects/osdn-codes/wiki/APIGuide and you can get client libraries from https://osdn.jp/projects/osdn-codes/releases/p14859 .
5
+
6
+ OpenAPI spec version: 0.0.20160304
7
+ Contact: admin@osdn.jp
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+ Licensed under the Apache License, Version 2.0 (the "License");
11
+ you may not use this file except in compliance with the License.
12
+ You may obtain a copy of the License at
13
+
14
+ http://www.apache.org/licenses/LICENSE-2.0
15
+
16
+ Unless required by applicable law or agreed to in writing, software
17
+ distributed under the License is distributed on an "AS IS" BASIS,
18
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ See the License for the specific language governing permissions and
20
+ limitations under the License.
21
+
22
+ =end
23
+
1
24
  require 'date'
2
25
 
3
26
  module OSDNClient
27
+
4
28
  class SimpleGroup
5
29
  attr_accessor :id
6
30
 
@@ -10,18 +34,14 @@ module OSDNClient
10
34
 
11
35
  attr_accessor :last_update
12
36
 
37
+
13
38
  # Attribute mapping from ruby-style variable name to JSON key.
14
39
  def self.attribute_map
15
40
  {
16
-
17
41
  :'id' => :'id',
18
-
19
42
  :'name' => :'name',
20
-
21
43
  :'display_name' => :'display_name',
22
-
23
44
  :'last_update' => :'last_update'
24
-
25
45
  }
26
46
  end
27
47
 
@@ -32,36 +52,50 @@ module OSDNClient
32
52
  :'name' => :'String',
33
53
  :'display_name' => :'String',
34
54
  :'last_update' => :'DateTime'
35
-
36
55
  }
37
56
  end
38
57
 
58
+ # Initializes the object
59
+ # @param [Hash] attributes Model attributes in the form of hash
39
60
  def initialize(attributes = {})
40
61
  return unless attributes.is_a?(Hash)
41
62
 
42
63
  # convert string to symbol for hash key
43
- attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
64
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
44
65
 
45
-
46
- if attributes[:'id']
66
+ if attributes.has_key?(:'id')
47
67
  self.id = attributes[:'id']
48
68
  end
49
-
50
- if attributes[:'name']
69
+
70
+ if attributes.has_key?(:'name')
51
71
  self.name = attributes[:'name']
52
72
  end
53
-
54
- if attributes[:'display_name']
73
+
74
+ if attributes.has_key?(:'display_name')
55
75
  self.display_name = attributes[:'display_name']
56
76
  end
57
-
58
- if attributes[:'last_update']
77
+
78
+ if attributes.has_key?(:'last_update')
59
79
  self.last_update = attributes[:'last_update']
60
80
  end
61
-
81
+
82
+ end
83
+
84
+ # Show invalid properties with the reasons. Usually used together with valid?
85
+ # @return Array for valid properies with the reasons
86
+ def list_invalid_properties
87
+ invalid_properties = Array.new
88
+ return invalid_properties
89
+ end
90
+
91
+ # Check to see if the all the properties in the model are valid
92
+ # @return true if the model is valid
93
+ def valid?
94
+ return true
62
95
  end
63
96
 
64
- # Check equality by comparing each attribute.
97
+ # Checks equality by comparing each attribute.
98
+ # @param [Object] Object to be compared
65
99
  def ==(o)
66
100
  return true if self.equal?(o)
67
101
  self.class == o.class &&
@@ -72,35 +106,41 @@ module OSDNClient
72
106
  end
73
107
 
74
108
  # @see the `==` method
109
+ # @param [Object] Object to be compared
75
110
  def eql?(o)
76
111
  self == o
77
112
  end
78
113
 
79
- # Calculate hash code according to all attributes.
114
+ # Calculates hash code according to all attributes.
115
+ # @return [Fixnum] Hash code
80
116
  def hash
81
117
  [id, name, display_name, last_update].hash
82
118
  end
83
119
 
84
- # build the object from hash
120
+ # Builds the object from hash
121
+ # @param [Hash] attributes Model attributes in the form of hash
122
+ # @return [Object] Returns the model itself
85
123
  def build_from_hash(attributes)
86
124
  return nil unless attributes.is_a?(Hash)
87
125
  self.class.swagger_types.each_pair do |key, type|
88
126
  if type =~ /^Array<(.*)>/i
127
+ # check to ensure the input is an array given that the the attribute
128
+ # is documented as an array but the input is not
89
129
  if attributes[self.class.attribute_map[key]].is_a?(Array)
90
130
  self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
91
- else
92
- #TODO show warning in debug mode
93
131
  end
94
132
  elsif !attributes[self.class.attribute_map[key]].nil?
95
133
  self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
96
- else
97
- # data not found in attributes(hash), not an issue as the data can be optional
98
- end
134
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
99
135
  end
100
136
 
101
137
  self
102
138
  end
103
139
 
140
+ # Deserializes the data based on type
141
+ # @param string type Data type
142
+ # @param string value Value to be deserialized
143
+ # @return [Object] Deserialized data
104
144
  def _deserialize(type, value)
105
145
  case type.to_sym
106
146
  when :DateTime
@@ -119,6 +159,9 @@ module OSDNClient
119
159
  else
120
160
  false
121
161
  end
162
+ when :Object
163
+ # generic object (usually a Hash), return directly
164
+ value
122
165
  when /\AArray<(?<inner_type>.+)>\z/
123
166
  inner_type = Regexp.last_match[:inner_type]
124
167
  value.map { |v| _deserialize(inner_type, v) }
@@ -131,21 +174,25 @@ module OSDNClient
131
174
  end
132
175
  end
133
176
  else # model
134
- _model = OSDNClient.const_get(type).new
135
- _model.build_from_hash(value)
177
+ temp_model = OSDNClient.const_get(type).new
178
+ temp_model.build_from_hash(value)
136
179
  end
137
180
  end
138
181
 
182
+ # Returns the string representation of the object
183
+ # @return [String] String presentation of the object
139
184
  def to_s
140
185
  to_hash.to_s
141
186
  end
142
187
 
143
- # to_body is an alias to to_body (backward compatibility))
188
+ # to_body is an alias to to_hash (backward compatibility)
189
+ # @return [Hash] Returns the object in the form of hash
144
190
  def to_body
145
191
  to_hash
146
192
  end
147
193
 
148
- # return the object in the form of hash
194
+ # Returns the object in the form of hash
195
+ # @return [Hash] Returns the object in the form of hash
149
196
  def to_hash
150
197
  hash = {}
151
198
  self.class.attribute_map.each_pair do |attr, param|
@@ -156,8 +203,10 @@ module OSDNClient
156
203
  hash
157
204
  end
158
205
 
159
- # Method to output non-array value in the form of hash
206
+ # Outputs non-array value in the form of hash
160
207
  # For object, use to_hash. Otherwise, just return the value
208
+ # @param [Object] value Any valid value
209
+ # @return [Hash] Returns the value in the form of hash
161
210
  def _to_hash(value)
162
211
  if value.is_a?(Array)
163
212
  value.compact.map{ |v| _to_hash(v) }
@@ -173,4 +222,5 @@ module OSDNClient
173
222
  end
174
223
 
175
224
  end
225
+
176
226
  end
@@ -1,6 +1,30 @@
1
+ =begin
2
+ #OSDN REST API v0 beta
3
+
4
+ #OSDN REST API. Currently this API is experimental release. Pelase refer documentation on https://osdn.jp/projects/osdn-codes/wiki/APIGuide and you can get client libraries from https://osdn.jp/projects/osdn-codes/releases/p14859 .
5
+
6
+ OpenAPI spec version: 0.0.20160304
7
+ Contact: admin@osdn.jp
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+ Licensed under the Apache License, Version 2.0 (the "License");
11
+ you may not use this file except in compliance with the License.
12
+ You may obtain a copy of the License at
13
+
14
+ http://www.apache.org/licenses/LICENSE-2.0
15
+
16
+ Unless required by applicable law or agreed to in writing, software
17
+ distributed under the License is distributed on an "AS IS" BASIS,
18
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ See the License for the specific language governing permissions and
20
+ limitations under the License.
21
+
22
+ =end
23
+
1
24
  require 'date'
2
25
 
3
26
  module OSDNClient
27
+
4
28
  class SimpleUser
5
29
  attr_accessor :id
6
30
 
@@ -8,16 +32,13 @@ module OSDNClient
8
32
 
9
33
  attr_accessor :display_name
10
34
 
35
+
11
36
  # Attribute mapping from ruby-style variable name to JSON key.
12
37
  def self.attribute_map
13
38
  {
14
-
15
39
  :'id' => :'id',
16
-
17
40
  :'name' => :'name',
18
-
19
41
  :'display_name' => :'display_name'
20
-
21
42
  }
22
43
  end
23
44
 
@@ -27,32 +48,46 @@ module OSDNClient
27
48
  :'id' => :'Integer',
28
49
  :'name' => :'String',
29
50
  :'display_name' => :'String'
30
-
31
51
  }
32
52
  end
33
53
 
54
+ # Initializes the object
55
+ # @param [Hash] attributes Model attributes in the form of hash
34
56
  def initialize(attributes = {})
35
57
  return unless attributes.is_a?(Hash)
36
58
 
37
59
  # convert string to symbol for hash key
38
- attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
60
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
39
61
 
40
-
41
- if attributes[:'id']
62
+ if attributes.has_key?(:'id')
42
63
  self.id = attributes[:'id']
43
64
  end
44
-
45
- if attributes[:'name']
65
+
66
+ if attributes.has_key?(:'name')
46
67
  self.name = attributes[:'name']
47
68
  end
48
-
49
- if attributes[:'display_name']
69
+
70
+ if attributes.has_key?(:'display_name')
50
71
  self.display_name = attributes[:'display_name']
51
72
  end
52
-
73
+
74
+ end
75
+
76
+ # Show invalid properties with the reasons. Usually used together with valid?
77
+ # @return Array for valid properies with the reasons
78
+ def list_invalid_properties
79
+ invalid_properties = Array.new
80
+ return invalid_properties
81
+ end
82
+
83
+ # Check to see if the all the properties in the model are valid
84
+ # @return true if the model is valid
85
+ def valid?
86
+ return true
53
87
  end
54
88
 
55
- # Check equality by comparing each attribute.
89
+ # Checks equality by comparing each attribute.
90
+ # @param [Object] Object to be compared
56
91
  def ==(o)
57
92
  return true if self.equal?(o)
58
93
  self.class == o.class &&
@@ -62,35 +97,41 @@ module OSDNClient
62
97
  end
63
98
 
64
99
  # @see the `==` method
100
+ # @param [Object] Object to be compared
65
101
  def eql?(o)
66
102
  self == o
67
103
  end
68
104
 
69
- # Calculate hash code according to all attributes.
105
+ # Calculates hash code according to all attributes.
106
+ # @return [Fixnum] Hash code
70
107
  def hash
71
108
  [id, name, display_name].hash
72
109
  end
73
110
 
74
- # build the object from hash
111
+ # Builds the object from hash
112
+ # @param [Hash] attributes Model attributes in the form of hash
113
+ # @return [Object] Returns the model itself
75
114
  def build_from_hash(attributes)
76
115
  return nil unless attributes.is_a?(Hash)
77
116
  self.class.swagger_types.each_pair do |key, type|
78
117
  if type =~ /^Array<(.*)>/i
118
+ # check to ensure the input is an array given that the the attribute
119
+ # is documented as an array but the input is not
79
120
  if attributes[self.class.attribute_map[key]].is_a?(Array)
80
121
  self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
81
- else
82
- #TODO show warning in debug mode
83
122
  end
84
123
  elsif !attributes[self.class.attribute_map[key]].nil?
85
124
  self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
86
- else
87
- # data not found in attributes(hash), not an issue as the data can be optional
88
- end
125
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
89
126
  end
90
127
 
91
128
  self
92
129
  end
93
130
 
131
+ # Deserializes the data based on type
132
+ # @param string type Data type
133
+ # @param string value Value to be deserialized
134
+ # @return [Object] Deserialized data
94
135
  def _deserialize(type, value)
95
136
  case type.to_sym
96
137
  when :DateTime
@@ -109,6 +150,9 @@ module OSDNClient
109
150
  else
110
151
  false
111
152
  end
153
+ when :Object
154
+ # generic object (usually a Hash), return directly
155
+ value
112
156
  when /\AArray<(?<inner_type>.+)>\z/
113
157
  inner_type = Regexp.last_match[:inner_type]
114
158
  value.map { |v| _deserialize(inner_type, v) }
@@ -121,21 +165,25 @@ module OSDNClient
121
165
  end
122
166
  end
123
167
  else # model
124
- _model = OSDNClient.const_get(type).new
125
- _model.build_from_hash(value)
168
+ temp_model = OSDNClient.const_get(type).new
169
+ temp_model.build_from_hash(value)
126
170
  end
127
171
  end
128
172
 
173
+ # Returns the string representation of the object
174
+ # @return [String] String presentation of the object
129
175
  def to_s
130
176
  to_hash.to_s
131
177
  end
132
178
 
133
- # to_body is an alias to to_body (backward compatibility))
179
+ # to_body is an alias to to_hash (backward compatibility)
180
+ # @return [Hash] Returns the object in the form of hash
134
181
  def to_body
135
182
  to_hash
136
183
  end
137
184
 
138
- # return the object in the form of hash
185
+ # Returns the object in the form of hash
186
+ # @return [Hash] Returns the object in the form of hash
139
187
  def to_hash
140
188
  hash = {}
141
189
  self.class.attribute_map.each_pair do |attr, param|
@@ -146,8 +194,10 @@ module OSDNClient
146
194
  hash
147
195
  end
148
196
 
149
- # Method to output non-array value in the form of hash
197
+ # Outputs non-array value in the form of hash
150
198
  # For object, use to_hash. Otherwise, just return the value
199
+ # @param [Object] value Any valid value
200
+ # @return [Hash] Returns the value in the form of hash
151
201
  def _to_hash(value)
152
202
  if value.is_a?(Array)
153
203
  value.compact.map{ |v| _to_hash(v) }
@@ -163,4 +213,5 @@ module OSDNClient
163
213
  end
164
214
 
165
215
  end
216
+
166
217
  end