phrase 1.0.2 → 1.0.7

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 (141) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +13 -3
  3. data/docs/Account.md +2 -0
  4. data/docs/AccountDetails.md +3 -3
  5. data/docs/AccountsApi.md +2 -2
  6. data/docs/AuthorizationsApi.md +2 -2
  7. data/docs/BlacklistedKeysApi.md +4 -2
  8. data/docs/BranchesApi.md +2 -2
  9. data/docs/CommentsApi.md +2 -2
  10. data/docs/DistributionsApi.md +2 -2
  11. data/docs/Document.md +23 -0
  12. data/docs/DocumentsApi.md +137 -0
  13. data/docs/GitHubSyncApi.md +130 -0
  14. data/docs/GitLabSyncApi.md +2 -2
  15. data/docs/GithubSyncExportParameters.md +17 -0
  16. data/docs/GithubSyncImportParameters.md +17 -0
  17. data/docs/GlossariesApi.md +2 -2
  18. data/docs/GlossaryTermsApi.md +2 -2
  19. data/docs/InlineResponse422.md +19 -0
  20. data/docs/InlineResponse422Errors.md +21 -0
  21. data/docs/InvitationsApi.md +2 -2
  22. data/docs/Job.md +5 -1
  23. data/docs/JobCreateParameters.md +2 -0
  24. data/docs/JobDetails.md +4 -0
  25. data/docs/JobLocalesApi.md +2 -2
  26. data/docs/JobUpdateParameters.md +3 -1
  27. data/docs/JobsApi.md +74 -2
  28. data/docs/KeysApi.md +4 -4
  29. data/docs/LocalesApi.md +2 -2
  30. data/docs/MembersApi.md +2 -2
  31. data/docs/OrdersApi.md +2 -2
  32. data/docs/Project.md +2 -0
  33. data/docs/ProjectDetails.md +2 -2
  34. data/docs/ProjectsApi.md +2 -2
  35. data/docs/ReleasesApi.md +2 -2
  36. data/docs/ScreenshotMarkersApi.md +2 -2
  37. data/docs/ScreenshotsApi.md +4 -2
  38. data/docs/SpacesApi.md +4 -4
  39. data/docs/StyleGuidesApi.md +2 -2
  40. data/docs/TagsApi.md +2 -2
  41. data/docs/TeamsApi.md +2 -2
  42. data/docs/TranslationsApi.md +8 -8
  43. data/docs/UploadsApi.md +2 -2
  44. data/docs/VersionsHistoryApi.md +2 -2
  45. data/docs/WebhookCreateParameters.md +2 -0
  46. data/docs/WebhookUpdateParameters.md +2 -0
  47. data/docs/WebhooksApi.md +2 -2
  48. data/lib/phrase.rb +7 -0
  49. data/lib/phrase/api/accounts_api.rb +2 -2
  50. data/lib/phrase/api/authorizations_api.rb +2 -2
  51. data/lib/phrase/api/blacklisted_keys_api.rb +5 -2
  52. data/lib/phrase/api/branches_api.rb +2 -2
  53. data/lib/phrase/api/comments_api.rb +2 -2
  54. data/lib/phrase/api/distributions_api.rb +2 -2
  55. data/lib/phrase/api/documents_api.rb +152 -0
  56. data/lib/phrase/api/git_hub_sync_api.rb +146 -0
  57. data/lib/phrase/api/git_lab_sync_api.rb +2 -2
  58. data/lib/phrase/api/glossaries_api.rb +2 -2
  59. data/lib/phrase/api/glossary_terms_api.rb +2 -2
  60. data/lib/phrase/api/invitations_api.rb +2 -2
  61. data/lib/phrase/api/job_locales_api.rb +2 -2
  62. data/lib/phrase/api/jobs_api.rb +83 -2
  63. data/lib/phrase/api/keys_api.rb +4 -4
  64. data/lib/phrase/api/locales_api.rb +2 -2
  65. data/lib/phrase/api/members_api.rb +2 -2
  66. data/lib/phrase/api/orders_api.rb +2 -2
  67. data/lib/phrase/api/projects_api.rb +2 -2
  68. data/lib/phrase/api/releases_api.rb +2 -2
  69. data/lib/phrase/api/screenshot_markers_api.rb +2 -2
  70. data/lib/phrase/api/screenshots_api.rb +5 -2
  71. data/lib/phrase/api/spaces_api.rb +4 -4
  72. data/lib/phrase/api/style_guides_api.rb +2 -2
  73. data/lib/phrase/api/tags_api.rb +2 -2
  74. data/lib/phrase/api/teams_api.rb +2 -2
  75. data/lib/phrase/api/translations_api.rb +8 -8
  76. data/lib/phrase/api/uploads_api.rb +2 -2
  77. data/lib/phrase/api/versions_history_api.rb +2 -2
  78. data/lib/phrase/api/webhooks_api.rb +2 -2
  79. data/lib/phrase/api_client.rb +2 -2
  80. data/lib/phrase/models/account.rb +10 -1
  81. data/lib/phrase/models/account_details.rb +13 -13
  82. data/lib/phrase/models/document.rb +221 -0
  83. data/lib/phrase/models/github_sync_export_parameters.rb +195 -0
  84. data/lib/phrase/models/github_sync_import_parameters.rb +195 -0
  85. data/lib/phrase/models/inline_response422.rb +205 -0
  86. data/lib/phrase/models/inline_response422_errors.rb +212 -0
  87. data/lib/phrase/models/job.rb +22 -4
  88. data/lib/phrase/models/job_create_parameters.rb +11 -1
  89. data/lib/phrase/models/job_details.rb +19 -1
  90. data/lib/phrase/models/job_update_parameters.rb +14 -4
  91. data/lib/phrase/models/project.rb +10 -1
  92. data/lib/phrase/models/project_details.rb +10 -10
  93. data/lib/phrase/models/webhook_create_parameters.rb +11 -1
  94. data/lib/phrase/models/webhook_update_parameters.rb +11 -1
  95. data/lib/phrase/version.rb +1 -1
  96. data/spec/api/accounts_api_spec.rb +1 -1
  97. data/spec/api/authorizations_api_spec.rb +1 -1
  98. data/spec/api/blacklisted_keys_api_spec.rb +2 -1
  99. data/spec/api/branches_api_spec.rb +1 -1
  100. data/spec/api/comments_api_spec.rb +1 -1
  101. data/spec/api/distributions_api_spec.rb +1 -1
  102. data/spec/api/documents_api_spec.rb +52 -0
  103. data/spec/api/git_hub_sync_api_spec.rb +49 -0
  104. data/spec/api/git_lab_sync_api_spec.rb +1 -1
  105. data/spec/api/glossaries_api_spec.rb +1 -1
  106. data/spec/api/glossary_terms_api_spec.rb +1 -1
  107. data/spec/api/invitations_api_spec.rb +1 -1
  108. data/spec/api/job_locales_api_spec.rb +1 -1
  109. data/spec/api/jobs_api_spec.rb +19 -1
  110. data/spec/api/keys_api_spec.rb +2 -2
  111. data/spec/api/locales_api_spec.rb +1 -1
  112. data/spec/api/members_api_spec.rb +1 -1
  113. data/spec/api/orders_api_spec.rb +1 -1
  114. data/spec/api/projects_api_spec.rb +1 -1
  115. data/spec/api/releases_api_spec.rb +1 -1
  116. data/spec/api/screenshot_markers_api_spec.rb +1 -1
  117. data/spec/api/screenshots_api_spec.rb +2 -1
  118. data/spec/api/spaces_api_spec.rb +2 -2
  119. data/spec/api/style_guides_api_spec.rb +1 -1
  120. data/spec/api/tags_api_spec.rb +1 -1
  121. data/spec/api/teams_api_spec.rb +1 -1
  122. data/spec/api/translations_api_spec.rb +4 -4
  123. data/spec/api/uploads_api_spec.rb +1 -1
  124. data/spec/api/versions_history_api_spec.rb +1 -1
  125. data/spec/api/webhooks_api_spec.rb +1 -1
  126. data/spec/models/account_details_spec.rb +4 -4
  127. data/spec/models/account_spec.rb +6 -0
  128. data/spec/models/document_spec.rb +47 -0
  129. data/spec/models/github_sync_export_parameters_spec.rb +29 -0
  130. data/spec/models/github_sync_import_parameters_spec.rb +29 -0
  131. data/spec/models/inline_response422_errors_spec.rb +41 -0
  132. data/spec/models/inline_response422_spec.rb +35 -0
  133. data/spec/models/job_create_parameters_spec.rb +6 -0
  134. data/spec/models/job_details_spec.rb +12 -0
  135. data/spec/models/job_spec.rb +12 -0
  136. data/spec/models/job_update_parameters_spec.rb +6 -0
  137. data/spec/models/project_details_spec.rb +6 -6
  138. data/spec/models/project_spec.rb +6 -0
  139. data/spec/models/webhook_create_parameters_spec.rb +6 -0
  140. data/spec/models/webhook_update_parameters_spec.rb +6 -0
  141. metadata +183 -155
@@ -6,23 +6,23 @@ module Phrase
6
6
 
7
7
  attr_accessor :name
8
8
 
9
+ attr_accessor :slug
10
+
9
11
  attr_accessor :company
10
12
 
11
13
  attr_accessor :created_at
12
14
 
13
15
  attr_accessor :updated_at
14
16
 
15
- attr_accessor :slug
16
-
17
17
  # Attribute mapping from ruby-style variable name to JSON key.
18
18
  def self.attribute_map
19
19
  {
20
20
  :'id' => :'id',
21
21
  :'name' => :'name',
22
+ :'slug' => :'slug',
22
23
  :'company' => :'company',
23
24
  :'created_at' => :'created_at',
24
- :'updated_at' => :'updated_at',
25
- :'slug' => :'slug'
25
+ :'updated_at' => :'updated_at'
26
26
  }
27
27
  end
28
28
 
@@ -31,10 +31,10 @@ module Phrase
31
31
  {
32
32
  :'id' => :'String',
33
33
  :'name' => :'String',
34
+ :'slug' => :'String',
34
35
  :'company' => :'String',
35
36
  :'created_at' => :'DateTime',
36
- :'updated_at' => :'DateTime',
37
- :'slug' => :'String'
37
+ :'updated_at' => :'DateTime'
38
38
  }
39
39
  end
40
40
 
@@ -75,6 +75,10 @@ module Phrase
75
75
  self.name = attributes[:'name']
76
76
  end
77
77
 
78
+ if attributes.key?(:'slug')
79
+ self.slug = attributes[:'slug']
80
+ end
81
+
78
82
  if attributes.key?(:'company')
79
83
  self.company = attributes[:'company']
80
84
  end
@@ -86,10 +90,6 @@ module Phrase
86
90
  if attributes.key?(:'updated_at')
87
91
  self.updated_at = attributes[:'updated_at']
88
92
  end
89
-
90
- if attributes.key?(:'slug')
91
- self.slug = attributes[:'slug']
92
- end
93
93
  end
94
94
 
95
95
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -112,10 +112,10 @@ module Phrase
112
112
  self.class == o.class &&
113
113
  id == o.id &&
114
114
  name == o.name &&
115
+ slug == o.slug &&
115
116
  company == o.company &&
116
117
  created_at == o.created_at &&
117
- updated_at == o.updated_at &&
118
- slug == o.slug
118
+ updated_at == o.updated_at
119
119
  end
120
120
 
121
121
  # @see the `==` method
@@ -127,7 +127,7 @@ module Phrase
127
127
  # Calculates hash code according to all attributes.
128
128
  # @return [Integer] Hash code
129
129
  def hash
130
- [id, name, company, created_at, updated_at, slug].hash
130
+ [id, name, slug, company, created_at, updated_at].hash
131
131
  end
132
132
 
133
133
  # Builds the object from hash
@@ -0,0 +1,221 @@
1
+ require 'date'
2
+
3
+ module Phrase
4
+ class Document
5
+ attr_accessor :id
6
+
7
+ attr_accessor :name
8
+
9
+ attr_accessor :created_at
10
+
11
+ attr_accessor :updated_at
12
+
13
+ # Attribute mapping from ruby-style variable name to JSON key.
14
+ def self.attribute_map
15
+ {
16
+ :'id' => :'id',
17
+ :'name' => :'name',
18
+ :'created_at' => :'created_at',
19
+ :'updated_at' => :'updated_at'
20
+ }
21
+ end
22
+
23
+ # Attribute type mapping.
24
+ def self.openapi_types
25
+ {
26
+ :'id' => :'String',
27
+ :'name' => :'String',
28
+ :'created_at' => :'DateTime',
29
+ :'updated_at' => :'DateTime'
30
+ }
31
+ end
32
+
33
+ # List of attributes with nullable: true
34
+ def self.openapi_nullable
35
+ Set.new([
36
+ ])
37
+ end
38
+
39
+ # Initializes the object
40
+ # @param [Hash] attributes Model attributes in the form of hash
41
+ def initialize(attributes = {})
42
+ if (!attributes.is_a?(Hash))
43
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Phrase::Document` initialize method"
44
+ end
45
+
46
+ # check to see if the attribute exists and convert string to symbol for hash key
47
+ attributes = attributes.each_with_object({}) { |(k, v), h|
48
+ if (!self.class.attribute_map.key?(k.to_sym))
49
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Phrase::Document`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
50
+ end
51
+ h[k.to_sym] = v
52
+ }
53
+
54
+ if attributes.key?(:'id')
55
+ self.id = attributes[:'id']
56
+ end
57
+
58
+ if attributes.key?(:'name')
59
+ self.name = attributes[:'name']
60
+ end
61
+
62
+ if attributes.key?(:'created_at')
63
+ self.created_at = attributes[:'created_at']
64
+ end
65
+
66
+ if attributes.key?(:'updated_at')
67
+ self.updated_at = attributes[:'updated_at']
68
+ end
69
+ end
70
+
71
+ # Show invalid properties with the reasons. Usually used together with valid?
72
+ # @return Array for valid properties with the reasons
73
+ def list_invalid_properties
74
+ invalid_properties = Array.new
75
+ invalid_properties
76
+ end
77
+
78
+ # Check to see if the all the properties in the model are valid
79
+ # @return true if the model is valid
80
+ def valid?
81
+ true
82
+ end
83
+
84
+ # Checks equality by comparing each attribute.
85
+ # @param [Object] Object to be compared
86
+ def ==(o)
87
+ return true if self.equal?(o)
88
+ self.class == o.class &&
89
+ id == o.id &&
90
+ name == o.name &&
91
+ created_at == o.created_at &&
92
+ updated_at == o.updated_at
93
+ end
94
+
95
+ # @see the `==` method
96
+ # @param [Object] Object to be compared
97
+ def eql?(o)
98
+ self == o
99
+ end
100
+
101
+ # Calculates hash code according to all attributes.
102
+ # @return [Integer] Hash code
103
+ def hash
104
+ [id, name, created_at, updated_at].hash
105
+ end
106
+
107
+ # Builds the object from hash
108
+ # @param [Hash] attributes Model attributes in the form of hash
109
+ # @return [Object] Returns the model itself
110
+ def self.build_from_hash(attributes)
111
+ new.build_from_hash(attributes)
112
+ end
113
+
114
+ # Builds the object from hash
115
+ # @param [Hash] attributes Model attributes in the form of hash
116
+ # @return [Object] Returns the model itself
117
+ def build_from_hash(attributes)
118
+ return nil unless attributes.is_a?(Hash)
119
+ self.class.openapi_types.each_pair do |key, type|
120
+ if type =~ /\AArray<(.*)>/i
121
+ # check to ensure the input is an array given that the attribute
122
+ # is documented as an array but the input is not
123
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
124
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
125
+ end
126
+ elsif !attributes[self.class.attribute_map[key]].nil?
127
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
128
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
129
+ end
130
+
131
+ self
132
+ end
133
+
134
+ # Deserializes the data based on type
135
+ # @param string type Data type
136
+ # @param string value Value to be deserialized
137
+ # @return [Object] Deserialized data
138
+ def _deserialize(type, value)
139
+ case type.to_sym
140
+ when :DateTime
141
+ DateTime.parse(value)
142
+ when :Date
143
+ Date.parse(value)
144
+ when :String
145
+ value.to_s
146
+ when :Integer
147
+ value.to_i
148
+ when :Float
149
+ value.to_f
150
+ when :Boolean
151
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
152
+ true
153
+ else
154
+ false
155
+ end
156
+ when :Object
157
+ # generic object (usually a Hash), return directly
158
+ value
159
+ when /\AArray<(?<inner_type>.+)>\z/
160
+ inner_type = Regexp.last_match[:inner_type]
161
+ value.map { |v| _deserialize(inner_type, v) }
162
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
163
+ k_type = Regexp.last_match[:k_type]
164
+ v_type = Regexp.last_match[:v_type]
165
+ {}.tap do |hash|
166
+ value.each do |k, v|
167
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
168
+ end
169
+ end
170
+ else # model
171
+ Phrase.const_get(type).build_from_hash(value)
172
+ end
173
+ end
174
+
175
+ # Returns the string representation of the object
176
+ # @return [String] String presentation of the object
177
+ def to_s
178
+ to_hash.to_s
179
+ end
180
+
181
+ # to_body is an alias to to_hash (backward compatibility)
182
+ # @return [Hash] Returns the object in the form of hash
183
+ def to_body
184
+ to_hash
185
+ end
186
+
187
+ # Returns the object in the form of hash
188
+ # @return [Hash] Returns the object in the form of hash
189
+ def to_hash
190
+ hash = {}
191
+ self.class.attribute_map.each_pair do |attr, param|
192
+ value = self.send(attr)
193
+ if value.nil?
194
+ is_nullable = self.class.openapi_nullable.include?(attr)
195
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
196
+ end
197
+
198
+ hash[param] = _to_hash(value)
199
+ end
200
+ hash
201
+ end
202
+
203
+ # Outputs non-array value in the form of hash
204
+ # For object, use to_hash. Otherwise, just return the value
205
+ # @param [Object] value Any valid value
206
+ # @return [Hash] Returns the value in the form of hash
207
+ def _to_hash(value)
208
+ if value.is_a?(Array)
209
+ value.compact.map { |v| _to_hash(v) }
210
+ elsif value.is_a?(Hash)
211
+ {}.tap do |hash|
212
+ value.each { |k, v| hash[k] = _to_hash(v) }
213
+ end
214
+ elsif value.respond_to? :to_hash
215
+ value.to_hash
216
+ else
217
+ value
218
+ end
219
+ end
220
+ end
221
+ end
@@ -0,0 +1,195 @@
1
+ require 'date'
2
+
3
+ module Phrase
4
+ class GithubSyncExportParameters
5
+ # Project ID to specify the actual project the GitHub export should be triggered in.
6
+ attr_accessor :project_id
7
+
8
+ # Attribute mapping from ruby-style variable name to JSON key.
9
+ def self.attribute_map
10
+ {
11
+ :'project_id' => :'project_id'
12
+ }
13
+ end
14
+
15
+ # Attribute type mapping.
16
+ def self.openapi_types
17
+ {
18
+ :'project_id' => :'String'
19
+ }
20
+ end
21
+
22
+ # List of attributes with nullable: true
23
+ def self.openapi_nullable
24
+ Set.new([
25
+ ])
26
+ end
27
+
28
+ # Initializes the object
29
+ # @param [Hash] attributes Model attributes in the form of hash
30
+ def initialize(attributes = {})
31
+ if (!attributes.is_a?(Hash))
32
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Phrase::GithubSyncExportParameters` initialize method"
33
+ end
34
+
35
+ # check to see if the attribute exists and convert string to symbol for hash key
36
+ attributes = attributes.each_with_object({}) { |(k, v), h|
37
+ if (!self.class.attribute_map.key?(k.to_sym))
38
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Phrase::GithubSyncExportParameters`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
39
+ end
40
+ h[k.to_sym] = v
41
+ }
42
+
43
+ if attributes.key?(:'project_id')
44
+ self.project_id = attributes[:'project_id']
45
+ end
46
+ end
47
+
48
+ # Show invalid properties with the reasons. Usually used together with valid?
49
+ # @return Array for valid properties with the reasons
50
+ def list_invalid_properties
51
+ invalid_properties = Array.new
52
+ invalid_properties
53
+ end
54
+
55
+ # Check to see if the all the properties in the model are valid
56
+ # @return true if the model is valid
57
+ def valid?
58
+ true
59
+ end
60
+
61
+ # Checks equality by comparing each attribute.
62
+ # @param [Object] Object to be compared
63
+ def ==(o)
64
+ return true if self.equal?(o)
65
+ self.class == o.class &&
66
+ project_id == o.project_id
67
+ end
68
+
69
+ # @see the `==` method
70
+ # @param [Object] Object to be compared
71
+ def eql?(o)
72
+ self == o
73
+ end
74
+
75
+ # Calculates hash code according to all attributes.
76
+ # @return [Integer] Hash code
77
+ def hash
78
+ [project_id].hash
79
+ end
80
+
81
+ # Builds the object from hash
82
+ # @param [Hash] attributes Model attributes in the form of hash
83
+ # @return [Object] Returns the model itself
84
+ def self.build_from_hash(attributes)
85
+ new.build_from_hash(attributes)
86
+ end
87
+
88
+ # Builds the object from hash
89
+ # @param [Hash] attributes Model attributes in the form of hash
90
+ # @return [Object] Returns the model itself
91
+ def build_from_hash(attributes)
92
+ return nil unless attributes.is_a?(Hash)
93
+ self.class.openapi_types.each_pair do |key, type|
94
+ if type =~ /\AArray<(.*)>/i
95
+ # check to ensure the input is an array given that the attribute
96
+ # is documented as an array but the input is not
97
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
98
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
99
+ end
100
+ elsif !attributes[self.class.attribute_map[key]].nil?
101
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
102
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
103
+ end
104
+
105
+ self
106
+ end
107
+
108
+ # Deserializes the data based on type
109
+ # @param string type Data type
110
+ # @param string value Value to be deserialized
111
+ # @return [Object] Deserialized data
112
+ def _deserialize(type, value)
113
+ case type.to_sym
114
+ when :DateTime
115
+ DateTime.parse(value)
116
+ when :Date
117
+ Date.parse(value)
118
+ when :String
119
+ value.to_s
120
+ when :Integer
121
+ value.to_i
122
+ when :Float
123
+ value.to_f
124
+ when :Boolean
125
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
126
+ true
127
+ else
128
+ false
129
+ end
130
+ when :Object
131
+ # generic object (usually a Hash), return directly
132
+ value
133
+ when /\AArray<(?<inner_type>.+)>\z/
134
+ inner_type = Regexp.last_match[:inner_type]
135
+ value.map { |v| _deserialize(inner_type, v) }
136
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
137
+ k_type = Regexp.last_match[:k_type]
138
+ v_type = Regexp.last_match[:v_type]
139
+ {}.tap do |hash|
140
+ value.each do |k, v|
141
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
142
+ end
143
+ end
144
+ else # model
145
+ Phrase.const_get(type).build_from_hash(value)
146
+ end
147
+ end
148
+
149
+ # Returns the string representation of the object
150
+ # @return [String] String presentation of the object
151
+ def to_s
152
+ to_hash.to_s
153
+ end
154
+
155
+ # to_body is an alias to to_hash (backward compatibility)
156
+ # @return [Hash] Returns the object in the form of hash
157
+ def to_body
158
+ to_hash
159
+ end
160
+
161
+ # Returns the object in the form of hash
162
+ # @return [Hash] Returns the object in the form of hash
163
+ def to_hash
164
+ hash = {}
165
+ self.class.attribute_map.each_pair do |attr, param|
166
+ value = self.send(attr)
167
+ if value.nil?
168
+ is_nullable = self.class.openapi_nullable.include?(attr)
169
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
170
+ end
171
+
172
+ hash[param] = _to_hash(value)
173
+ end
174
+ hash
175
+ end
176
+
177
+ # Outputs non-array value in the form of hash
178
+ # For object, use to_hash. Otherwise, just return the value
179
+ # @param [Object] value Any valid value
180
+ # @return [Hash] Returns the value in the form of hash
181
+ def _to_hash(value)
182
+ if value.is_a?(Array)
183
+ value.compact.map { |v| _to_hash(v) }
184
+ elsif value.is_a?(Hash)
185
+ {}.tap do |hash|
186
+ value.each { |k, v| hash[k] = _to_hash(v) }
187
+ end
188
+ elsif value.respond_to? :to_hash
189
+ value.to_hash
190
+ else
191
+ value
192
+ end
193
+ end
194
+ end
195
+ end