phrase 2.0.0 → 2.3.1

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 (139) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +41 -3
  3. data/docs/Account.md +3 -1
  4. data/docs/AccountDetails.md +5 -1
  5. data/docs/AccountDetails1.md +3 -1
  6. data/docs/AccountSearchResult.md +29 -0
  7. data/docs/Branch.md +5 -1
  8. data/docs/Comment.md +3 -1
  9. data/docs/JobCreateParameters.md +2 -0
  10. data/docs/JobDetails.md +2 -0
  11. data/docs/JobDetails1.md +2 -0
  12. data/docs/JobTemplate.md +29 -0
  13. data/docs/JobTemplateCreateParameters.md +21 -0
  14. data/docs/JobTemplateLocale.md +23 -0
  15. data/docs/JobTemplateLocaleUpdateParameters.md +23 -0
  16. data/docs/JobTemplateLocalesApi.md +347 -0
  17. data/docs/JobTemplateLocalesCreateParameters.md +23 -0
  18. data/docs/JobTemplatePreview.md +19 -0
  19. data/docs/JobTemplateUpdateParameters.md +21 -0
  20. data/docs/JobTemplateUserPreview.md +23 -0
  21. data/docs/JobTemplatesApi.md +337 -0
  22. data/docs/KeysApi.md +132 -4
  23. data/docs/KeysExcludeParameters.md +23 -0
  24. data/docs/KeysIncludeParameters.md +23 -0
  25. data/docs/KeysSearchParameters.md +1 -1
  26. data/docs/KeysTagParameters.md +1 -1
  27. data/docs/KeysUntagParameters.md +1 -1
  28. data/docs/LocalePreview1.md +23 -0
  29. data/docs/LocalesApi.md +73 -3
  30. data/docs/MemberSpaces.md +2 -2
  31. data/docs/MemberUpdateParameters.md +4 -2
  32. data/docs/Notification.md +41 -0
  33. data/docs/NotificationGroup.md +23 -0
  34. data/docs/NotificationGroupDetail.md +27 -0
  35. data/docs/NotificationGroupsApi.md +194 -0
  36. data/docs/NotificationsApi.md +194 -0
  37. data/docs/OrderCreateParameters.md +2 -0
  38. data/docs/Project.md +2 -0
  39. data/docs/ProjectCreateParameters.md +35 -1
  40. data/docs/ProjectDetails.md +2 -0
  41. data/docs/ProjectsApi.md +7 -1
  42. data/docs/SearchApi.md +72 -0
  43. data/docs/SearchInAccountParameters.md +23 -0
  44. data/docs/Space1.md +25 -0
  45. data/docs/Subscription.md +19 -0
  46. data/docs/TranslationOrder.md +2 -0
  47. data/docs/TranslationsVerifyParameters.md +3 -5
  48. data/docs/User.md +0 -2
  49. data/lib/phrase/api/job_template_locales_api.rb +417 -0
  50. data/lib/phrase/api/job_templates_api.rb +387 -0
  51. data/lib/phrase/api/keys_api.rb +152 -4
  52. data/lib/phrase/api/locales_api.rb +80 -2
  53. data/lib/phrase/api/notification_groups_api.rb +202 -0
  54. data/lib/phrase/api/notifications_api.rb +202 -0
  55. data/lib/phrase/api/projects_api.rb +9 -0
  56. data/lib/phrase/api/search_api.rb +84 -0
  57. data/lib/phrase/models/account.rb +13 -4
  58. data/lib/phrase/models/account_details.rb +22 -4
  59. data/lib/phrase/models/account_details1.rb +10 -1
  60. data/lib/phrase/models/account_search_result.rb +250 -0
  61. data/lib/phrase/models/branch.rb +19 -1
  62. data/lib/phrase/models/comment.rb +15 -4
  63. data/lib/phrase/models/job_create_parameters.rb +11 -1
  64. data/lib/phrase/models/job_details.rb +10 -1
  65. data/lib/phrase/models/job_details1.rb +10 -1
  66. data/lib/phrase/models/job_template.rb +248 -0
  67. data/lib/phrase/models/job_template_create_parameters.rb +220 -0
  68. data/lib/phrase/models/job_template_locale.rb +223 -0
  69. data/lib/phrase/models/job_template_locale_update_parameters.rb +234 -0
  70. data/lib/phrase/models/job_template_locales_create_parameters.rb +234 -0
  71. data/lib/phrase/models/job_template_preview.rb +203 -0
  72. data/lib/phrase/models/job_template_update_parameters.rb +220 -0
  73. data/lib/phrase/models/job_template_user_preview.rb +221 -0
  74. data/lib/phrase/models/keys_exclude_parameters.rb +225 -0
  75. data/lib/phrase/models/keys_include_parameters.rb +225 -0
  76. data/lib/phrase/models/keys_search_parameters.rb +1 -1
  77. data/lib/phrase/models/keys_tag_parameters.rb +1 -1
  78. data/lib/phrase/models/keys_untag_parameters.rb +1 -1
  79. data/lib/phrase/models/locale_preview1.rb +221 -0
  80. data/lib/phrase/models/member_spaces.rb +2 -2
  81. data/lib/phrase/models/member_update_parameters.rb +12 -2
  82. data/lib/phrase/models/notification.rb +302 -0
  83. data/lib/phrase/models/notification_group.rb +221 -0
  84. data/lib/phrase/models/notification_group_detail.rb +239 -0
  85. data/lib/phrase/models/order_create_parameters.rb +11 -1
  86. data/lib/phrase/models/project.rb +10 -1
  87. data/lib/phrase/models/project_create_parameters.rb +174 -4
  88. data/lib/phrase/models/project_details.rb +10 -1
  89. data/lib/phrase/models/search_in_account_parameters.rb +225 -0
  90. data/lib/phrase/models/space1.rb +230 -0
  91. data/lib/phrase/models/subscription.rb +203 -0
  92. data/lib/phrase/models/translation_order.rb +10 -1
  93. data/lib/phrase/models/translations_verify_parameters.rb +14 -24
  94. data/lib/phrase/models/user.rb +1 -10
  95. data/lib/phrase/version.rb +1 -1
  96. data/lib/phrase.rb +23 -0
  97. data/spec/api/job_template_locales_api_spec.rb +103 -0
  98. data/spec/api/job_templates_api_spec.rb +98 -0
  99. data/spec/api/keys_api_spec.rb +30 -2
  100. data/spec/api/locales_api_spec.rb +18 -1
  101. data/spec/api/notification_groups_api_spec.rb +62 -0
  102. data/spec/api/notifications_api_spec.rb +62 -0
  103. data/spec/api/projects_api_spec.rb +3 -0
  104. data/spec/api/search_api_spec.rb +37 -0
  105. data/spec/models/account_details1_spec.rb +6 -0
  106. data/spec/models/account_details_spec.rb +12 -0
  107. data/spec/models/account_search_result_spec.rb +65 -0
  108. data/spec/models/account_spec.rb +6 -0
  109. data/spec/models/branch_spec.rb +12 -0
  110. data/spec/models/comment_spec.rb +6 -0
  111. data/spec/models/job_create_parameters_spec.rb +6 -0
  112. data/spec/models/job_details1_spec.rb +6 -0
  113. data/spec/models/job_details_spec.rb +6 -0
  114. data/spec/models/job_template_create_parameters_spec.rb +41 -0
  115. data/spec/models/job_template_locale_spec.rb +47 -0
  116. data/spec/models/job_template_locale_update_parameters_spec.rb +47 -0
  117. data/spec/models/job_template_locales_create_parameters_spec.rb +47 -0
  118. data/spec/models/job_template_preview_spec.rb +35 -0
  119. data/spec/models/job_template_spec.rb +65 -0
  120. data/spec/models/job_template_update_parameters_spec.rb +41 -0
  121. data/spec/models/job_template_user_preview_spec.rb +47 -0
  122. data/spec/models/keys_exclude_parameters_spec.rb +47 -0
  123. data/spec/models/keys_include_parameters_spec.rb +47 -0
  124. data/spec/models/locale_preview1_spec.rb +47 -0
  125. data/spec/models/member_update_parameters_spec.rb +6 -0
  126. data/spec/models/notification_group_detail_spec.rb +59 -0
  127. data/spec/models/notification_group_spec.rb +47 -0
  128. data/spec/models/notification_spec.rb +101 -0
  129. data/spec/models/order_create_parameters_spec.rb +6 -0
  130. data/spec/models/project_create_parameters_spec.rb +102 -0
  131. data/spec/models/project_details_spec.rb +6 -0
  132. data/spec/models/project_spec.rb +6 -0
  133. data/spec/models/search_in_account_parameters_spec.rb +47 -0
  134. data/spec/models/space1_spec.rb +53 -0
  135. data/spec/models/subscription_spec.rb +35 -0
  136. data/spec/models/translation_order_spec.rb +6 -0
  137. data/spec/models/translations_verify_parameters_spec.rb +2 -8
  138. data/spec/models/user_spec.rb +0 -6
  139. metadata +262 -170
@@ -2,6 +2,10 @@ require 'date'
2
2
 
3
3
  module Phrase
4
4
  class Branch
5
+ attr_accessor :base_project_id
6
+
7
+ attr_accessor :branch_project_id
8
+
5
9
  attr_accessor :name
6
10
 
7
11
  attr_accessor :created_at
@@ -19,6 +23,8 @@ module Phrase
19
23
  # Attribute mapping from ruby-style variable name to JSON key.
20
24
  def self.attribute_map
21
25
  {
26
+ :'base_project_id' => :'base_project_id',
27
+ :'branch_project_id' => :'branch_project_id',
22
28
  :'name' => :'name',
23
29
  :'created_at' => :'created_at',
24
30
  :'updated_at' => :'updated_at',
@@ -32,6 +38,8 @@ module Phrase
32
38
  # Attribute type mapping.
33
39
  def self.openapi_types
34
40
  {
41
+ :'base_project_id' => :'String',
42
+ :'branch_project_id' => :'String',
35
43
  :'name' => :'String',
36
44
  :'created_at' => :'DateTime',
37
45
  :'updated_at' => :'DateTime',
@@ -63,6 +71,14 @@ module Phrase
63
71
  h[k.to_sym] = v
64
72
  }
65
73
 
74
+ if attributes.key?(:'base_project_id')
75
+ self.base_project_id = attributes[:'base_project_id']
76
+ end
77
+
78
+ if attributes.key?(:'branch_project_id')
79
+ self.branch_project_id = attributes[:'branch_project_id']
80
+ end
81
+
66
82
  if attributes.key?(:'name')
67
83
  self.name = attributes[:'name']
68
84
  end
@@ -110,6 +126,8 @@ module Phrase
110
126
  def ==(o)
111
127
  return true if self.equal?(o)
112
128
  self.class == o.class &&
129
+ base_project_id == o.base_project_id &&
130
+ branch_project_id == o.branch_project_id &&
113
131
  name == o.name &&
114
132
  created_at == o.created_at &&
115
133
  updated_at == o.updated_at &&
@@ -128,7 +146,7 @@ module Phrase
128
146
  # Calculates hash code according to all attributes.
129
147
  # @return [Integer] Hash code
130
148
  def hash
131
- [name, created_at, updated_at, merged_at, merged_by, created_by, state].hash
149
+ [base_project_id, branch_project_id, name, created_at, updated_at, merged_at, merged_by, created_by, state].hash
132
150
  end
133
151
 
134
152
  # Builds the object from hash
@@ -12,6 +12,8 @@ module Phrase
12
12
 
13
13
  attr_accessor :updated_at
14
14
 
15
+ attr_accessor :mentioned_users
16
+
15
17
  # Attribute mapping from ruby-style variable name to JSON key.
16
18
  def self.attribute_map
17
19
  {
@@ -19,7 +21,8 @@ module Phrase
19
21
  :'message' => :'message',
20
22
  :'user' => :'user',
21
23
  :'created_at' => :'created_at',
22
- :'updated_at' => :'updated_at'
24
+ :'updated_at' => :'updated_at',
25
+ :'mentioned_users' => :'mentioned_users'
23
26
  }
24
27
  end
25
28
 
@@ -30,7 +33,8 @@ module Phrase
30
33
  :'message' => :'String',
31
34
  :'user' => :'UserPreview',
32
35
  :'created_at' => :'DateTime',
33
- :'updated_at' => :'DateTime'
36
+ :'updated_at' => :'DateTime',
37
+ :'mentioned_users' => :'Array<UserPreview>'
34
38
  }
35
39
  end
36
40
 
@@ -74,6 +78,12 @@ module Phrase
74
78
  if attributes.key?(:'updated_at')
75
79
  self.updated_at = attributes[:'updated_at']
76
80
  end
81
+
82
+ if attributes.key?(:'mentioned_users')
83
+ if (value = attributes[:'mentioned_users']).is_a?(Array)
84
+ self.mentioned_users = value
85
+ end
86
+ end
77
87
  end
78
88
 
79
89
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -98,7 +108,8 @@ module Phrase
98
108
  message == o.message &&
99
109
  user == o.user &&
100
110
  created_at == o.created_at &&
101
- updated_at == o.updated_at
111
+ updated_at == o.updated_at &&
112
+ mentioned_users == o.mentioned_users
102
113
  end
103
114
 
104
115
  # @see the `==` method
@@ -110,7 +121,7 @@ module Phrase
110
121
  # Calculates hash code according to all attributes.
111
122
  # @return [Integer] Hash code
112
123
  def hash
113
- [id, message, user, created_at, updated_at].hash
124
+ [id, message, user, created_at, updated_at, mentioned_users].hash
114
125
  end
115
126
 
116
127
  # Builds the object from hash
@@ -8,6 +8,9 @@ module Phrase
8
8
  # Job name
9
9
  attr_accessor :name
10
10
 
11
+ # The API id of the source language
12
+ attr_accessor :source_locale_id
13
+
11
14
  # Briefing for the translators
12
15
  attr_accessor :briefing
13
16
 
@@ -28,6 +31,7 @@ module Phrase
28
31
  {
29
32
  :'branch' => :'branch',
30
33
  :'name' => :'name',
34
+ :'source_locale_id' => :'source_locale_id',
31
35
  :'briefing' => :'briefing',
32
36
  :'due_date' => :'due_date',
33
37
  :'ticket_url' => :'ticket_url',
@@ -41,6 +45,7 @@ module Phrase
41
45
  {
42
46
  :'branch' => :'String',
43
47
  :'name' => :'String',
48
+ :'source_locale_id' => :'String',
44
49
  :'briefing' => :'String',
45
50
  :'due_date' => :'DateTime',
46
51
  :'ticket_url' => :'String',
@@ -78,6 +83,10 @@ module Phrase
78
83
  self.name = attributes[:'name']
79
84
  end
80
85
 
86
+ if attributes.key?(:'source_locale_id')
87
+ self.source_locale_id = attributes[:'source_locale_id']
88
+ end
89
+
81
90
  if attributes.key?(:'briefing')
82
91
  self.briefing = attributes[:'briefing']
83
92
  end
@@ -123,6 +132,7 @@ module Phrase
123
132
  self.class == o.class &&
124
133
  branch == o.branch &&
125
134
  name == o.name &&
135
+ source_locale_id == o.source_locale_id &&
126
136
  briefing == o.briefing &&
127
137
  due_date == o.due_date &&
128
138
  ticket_url == o.ticket_url &&
@@ -139,7 +149,7 @@ module Phrase
139
149
  # Calculates hash code according to all attributes.
140
150
  # @return [Integer] Hash code
141
151
  def hash
142
- [branch, name, briefing, due_date, ticket_url, tags, translation_key_ids].hash
152
+ [branch, name, source_locale_id, briefing, due_date, ticket_url, tags, translation_key_ids].hash
143
153
  end
144
154
 
145
155
  # Builds the object from hash
@@ -26,6 +26,8 @@ module Phrase
26
26
 
27
27
  attr_accessor :job_tag_name
28
28
 
29
+ attr_accessor :source_locale
30
+
29
31
  attr_accessor :locales
30
32
 
31
33
  attr_accessor :keys
@@ -45,6 +47,7 @@ module Phrase
45
47
  :'updated_at' => :'updated_at',
46
48
  :'owner' => :'owner',
47
49
  :'job_tag_name' => :'job_tag_name',
50
+ :'source_locale' => :'source_locale',
48
51
  :'locales' => :'locales',
49
52
  :'keys' => :'keys'
50
53
  }
@@ -65,6 +68,7 @@ module Phrase
65
68
  :'updated_at' => :'DateTime',
66
69
  :'owner' => :'UserPreview',
67
70
  :'job_tag_name' => :'String',
71
+ :'source_locale' => :'LocalePreview',
68
72
  :'locales' => :'Array<LocalePreview>',
69
73
  :'keys' => :'Array<KeyPreview>'
70
74
  }
@@ -147,6 +151,10 @@ module Phrase
147
151
  self.job_tag_name = attributes[:'job_tag_name']
148
152
  end
149
153
 
154
+ if attributes.key?(:'source_locale')
155
+ self.source_locale = attributes[:'source_locale']
156
+ end
157
+
150
158
  if attributes.key?(:'locales')
151
159
  if (value = attributes[:'locales']).is_a?(Array)
152
160
  self.locales = value
@@ -190,6 +198,7 @@ module Phrase
190
198
  updated_at == o.updated_at &&
191
199
  owner == o.owner &&
192
200
  job_tag_name == o.job_tag_name &&
201
+ source_locale == o.source_locale &&
193
202
  locales == o.locales &&
194
203
  keys == o.keys
195
204
  end
@@ -203,7 +212,7 @@ module Phrase
203
212
  # Calculates hash code according to all attributes.
204
213
  # @return [Integer] Hash code
205
214
  def hash
206
- [id, name, briefing, due_date, state, ticket_url, project, branch, created_at, updated_at, owner, job_tag_name, locales, keys].hash
215
+ [id, name, briefing, due_date, state, ticket_url, project, branch, created_at, updated_at, owner, job_tag_name, source_locale, locales, keys].hash
207
216
  end
208
217
 
209
218
  # Builds the object from hash
@@ -6,6 +6,8 @@ module Phrase
6
6
 
7
7
  attr_accessor :job_tag_name
8
8
 
9
+ attr_accessor :source_locale
10
+
9
11
  attr_accessor :locales
10
12
 
11
13
  attr_accessor :keys
@@ -15,6 +17,7 @@ module Phrase
15
17
  {
16
18
  :'owner' => :'owner',
17
19
  :'job_tag_name' => :'job_tag_name',
20
+ :'source_locale' => :'source_locale',
18
21
  :'locales' => :'locales',
19
22
  :'keys' => :'keys'
20
23
  }
@@ -25,6 +28,7 @@ module Phrase
25
28
  {
26
29
  :'owner' => :'UserPreview',
27
30
  :'job_tag_name' => :'String',
31
+ :'source_locale' => :'LocalePreview',
28
32
  :'locales' => :'Array<LocalePreview>',
29
33
  :'keys' => :'Array<KeyPreview>'
30
34
  }
@@ -59,6 +63,10 @@ module Phrase
59
63
  self.job_tag_name = attributes[:'job_tag_name']
60
64
  end
61
65
 
66
+ if attributes.key?(:'source_locale')
67
+ self.source_locale = attributes[:'source_locale']
68
+ end
69
+
62
70
  if attributes.key?(:'locales')
63
71
  if (value = attributes[:'locales']).is_a?(Array)
64
72
  self.locales = value
@@ -92,6 +100,7 @@ module Phrase
92
100
  self.class == o.class &&
93
101
  owner == o.owner &&
94
102
  job_tag_name == o.job_tag_name &&
103
+ source_locale == o.source_locale &&
95
104
  locales == o.locales &&
96
105
  keys == o.keys
97
106
  end
@@ -105,7 +114,7 @@ module Phrase
105
114
  # Calculates hash code according to all attributes.
106
115
  # @return [Integer] Hash code
107
116
  def hash
108
- [owner, job_tag_name, locales, keys].hash
117
+ [owner, job_tag_name, source_locale, locales, keys].hash
109
118
  end
110
119
 
111
120
  # Builds the object from hash
@@ -0,0 +1,248 @@
1
+ require 'date'
2
+
3
+ module Phrase
4
+ class JobTemplate
5
+ attr_accessor :id
6
+
7
+ attr_accessor :name
8
+
9
+ attr_accessor :briefing
10
+
11
+ attr_accessor :project
12
+
13
+ attr_accessor :branch
14
+
15
+ attr_accessor :created_at
16
+
17
+ attr_accessor :updated_at
18
+
19
+ # Attribute mapping from ruby-style variable name to JSON key.
20
+ def self.attribute_map
21
+ {
22
+ :'id' => :'id',
23
+ :'name' => :'name',
24
+ :'briefing' => :'briefing',
25
+ :'project' => :'project',
26
+ :'branch' => :'branch',
27
+ :'created_at' => :'created_at',
28
+ :'updated_at' => :'updated_at'
29
+ }
30
+ end
31
+
32
+ # Attribute type mapping.
33
+ def self.openapi_types
34
+ {
35
+ :'id' => :'String',
36
+ :'name' => :'String',
37
+ :'briefing' => :'String',
38
+ :'project' => :'ProjectShort',
39
+ :'branch' => :'Branch',
40
+ :'created_at' => :'DateTime',
41
+ :'updated_at' => :'DateTime'
42
+ }
43
+ end
44
+
45
+ # List of attributes with nullable: true
46
+ def self.openapi_nullable
47
+ Set.new([
48
+ ])
49
+ end
50
+
51
+ # Initializes the object
52
+ # @param [Hash] attributes Model attributes in the form of hash
53
+ def initialize(attributes = {})
54
+ if (!attributes.is_a?(Hash))
55
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Phrase::JobTemplate` initialize method"
56
+ end
57
+
58
+ # check to see if the attribute exists and convert string to symbol for hash key
59
+ attributes = attributes.each_with_object({}) { |(k, v), h|
60
+ if (!self.class.attribute_map.key?(k.to_sym))
61
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Phrase::JobTemplate`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
62
+ end
63
+ h[k.to_sym] = v
64
+ }
65
+
66
+ if attributes.key?(:'id')
67
+ self.id = attributes[:'id']
68
+ end
69
+
70
+ if attributes.key?(:'name')
71
+ self.name = attributes[:'name']
72
+ end
73
+
74
+ if attributes.key?(:'briefing')
75
+ self.briefing = attributes[:'briefing']
76
+ end
77
+
78
+ if attributes.key?(:'project')
79
+ self.project = attributes[:'project']
80
+ end
81
+
82
+ if attributes.key?(:'branch')
83
+ self.branch = attributes[:'branch']
84
+ end
85
+
86
+ if attributes.key?(:'created_at')
87
+ self.created_at = attributes[:'created_at']
88
+ end
89
+
90
+ if attributes.key?(:'updated_at')
91
+ self.updated_at = attributes[:'updated_at']
92
+ end
93
+ end
94
+
95
+ # Show invalid properties with the reasons. Usually used together with valid?
96
+ # @return Array for valid properties with the reasons
97
+ def list_invalid_properties
98
+ invalid_properties = Array.new
99
+ invalid_properties
100
+ end
101
+
102
+ # Check to see if the all the properties in the model are valid
103
+ # @return true if the model is valid
104
+ def valid?
105
+ true
106
+ end
107
+
108
+ # Checks equality by comparing each attribute.
109
+ # @param [Object] Object to be compared
110
+ def ==(o)
111
+ return true if self.equal?(o)
112
+ self.class == o.class &&
113
+ id == o.id &&
114
+ name == o.name &&
115
+ briefing == o.briefing &&
116
+ project == o.project &&
117
+ branch == o.branch &&
118
+ created_at == o.created_at &&
119
+ updated_at == o.updated_at
120
+ end
121
+
122
+ # @see the `==` method
123
+ # @param [Object] Object to be compared
124
+ def eql?(o)
125
+ self == o
126
+ end
127
+
128
+ # Calculates hash code according to all attributes.
129
+ # @return [Integer] Hash code
130
+ def hash
131
+ [id, name, briefing, project, branch, created_at, updated_at].hash
132
+ end
133
+
134
+ # Builds the object from hash
135
+ # @param [Hash] attributes Model attributes in the form of hash
136
+ # @return [Object] Returns the model itself
137
+ def self.build_from_hash(attributes)
138
+ new.build_from_hash(attributes)
139
+ end
140
+
141
+ # Builds the object from hash
142
+ # @param [Hash] attributes Model attributes in the form of hash
143
+ # @return [Object] Returns the model itself
144
+ def build_from_hash(attributes)
145
+ return nil unless attributes.is_a?(Hash)
146
+ self.class.openapi_types.each_pair do |key, type|
147
+ if type =~ /\AArray<(.*)>/i
148
+ # check to ensure the input is an array given that the attribute
149
+ # is documented as an array but the input is not
150
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
151
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
152
+ end
153
+ elsif !attributes[self.class.attribute_map[key]].nil?
154
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
155
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
156
+ end
157
+
158
+ self
159
+ end
160
+
161
+ # Deserializes the data based on type
162
+ # @param string type Data type
163
+ # @param string value Value to be deserialized
164
+ # @return [Object] Deserialized data
165
+ def _deserialize(type, value)
166
+ case type.to_sym
167
+ when :DateTime
168
+ DateTime.parse(value)
169
+ when :Date
170
+ Date.parse(value)
171
+ when :String
172
+ value.to_s
173
+ when :Integer
174
+ value.to_i
175
+ when :Float
176
+ value.to_f
177
+ when :Boolean
178
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
179
+ true
180
+ else
181
+ false
182
+ end
183
+ when :Object
184
+ # generic object (usually a Hash), return directly
185
+ value
186
+ when /\AArray<(?<inner_type>.+)>\z/
187
+ inner_type = Regexp.last_match[:inner_type]
188
+ value.map { |v| _deserialize(inner_type, v) }
189
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
190
+ k_type = Regexp.last_match[:k_type]
191
+ v_type = Regexp.last_match[:v_type]
192
+ {}.tap do |hash|
193
+ value.each do |k, v|
194
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
195
+ end
196
+ end
197
+ else # model
198
+ Phrase.const_get(type).build_from_hash(value)
199
+ end
200
+ end
201
+
202
+ # Returns the string representation of the object
203
+ # @return [String] String presentation of the object
204
+ def to_s
205
+ to_hash.to_s
206
+ end
207
+
208
+ # to_body is an alias to to_hash (backward compatibility)
209
+ # @return [Hash] Returns the object in the form of hash
210
+ def to_body
211
+ to_hash
212
+ end
213
+
214
+ # Returns the object in the form of hash
215
+ # @return [Hash] Returns the object in the form of hash
216
+ def to_hash
217
+ hash = {}
218
+ self.class.attribute_map.each_pair do |attr, param|
219
+ value = self.send(attr)
220
+ if value.nil?
221
+ is_nullable = self.class.openapi_nullable.include?(attr)
222
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
223
+ end
224
+
225
+ hash[param] = _to_hash(value)
226
+ end
227
+ hash
228
+ end
229
+
230
+ # Outputs non-array value in the form of hash
231
+ # For object, use to_hash. Otherwise, just return the value
232
+ # @param [Object] value Any valid value
233
+ # @return [Hash] Returns the value in the form of hash
234
+ def _to_hash(value)
235
+ if value.is_a?(Array)
236
+ value.compact.map { |v| _to_hash(v) }
237
+ elsif value.is_a?(Hash)
238
+ {}.tap do |hash|
239
+ value.each { |k, v| hash[k] = _to_hash(v) }
240
+ end
241
+ elsif value.respond_to? :to_hash
242
+ value.to_hash
243
+ else
244
+ value
245
+ end
246
+ end
247
+ end
248
+ end