hubspot-api-client 7.3.0 → 8.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/lib/hubspot-api-client.rb +55 -24
  4. data/lib/hubspot/codegen/cms/hubdb/api/default_api.rb +2090 -0
  5. data/lib/hubspot/codegen/cms/hubdb/api_client.rb +422 -0
  6. data/lib/hubspot/codegen/cms/hubdb/api_error.rb +61 -0
  7. data/lib/hubspot/codegen/cms/hubdb/configuration.rb +251 -0
  8. data/lib/hubspot/codegen/cms/hubdb/models/batch_input_hub_db_table_row_v3.rb +217 -0
  9. data/lib/hubspot/codegen/cms/hubdb/models/batch_input_json_node.rb +215 -0
  10. data/lib/hubspot/codegen/cms/hubdb/models/batch_input_string.rb +217 -0
  11. data/lib/hubspot/codegen/cms/hubdb/models/batch_response_hub_db_table_row_v3_with_errors.rb +333 -0
  12. data/lib/hubspot/codegen/cms/hubdb/models/collection_response_with_total_hub_db_table_row_v3.rb +240 -0
  13. data/lib/hubspot/codegen/cms/hubdb/models/collection_response_with_total_hub_db_table_v3.rb +240 -0
  14. data/lib/hubspot/codegen/cms/hubdb/models/column.rb +388 -0
  15. data/lib/hubspot/codegen/cms/hubdb/models/column_input.rb +288 -0
  16. data/lib/hubspot/codegen/cms/hubdb/models/error.rb +292 -0
  17. data/lib/hubspot/codegen/cms/hubdb/models/error_detail.rb +258 -0
  18. data/lib/hubspot/codegen/cms/hubdb/models/foreign_id.rb +243 -0
  19. data/lib/hubspot/codegen/cms/hubdb/models/hub_db_table_clone_request.rb +241 -0
  20. data/lib/hubspot/codegen/cms/hubdb/models/hub_db_table_row_v3.rb +291 -0
  21. data/lib/hubspot/codegen/cms/hubdb/models/hub_db_table_row_v3_input.rb +243 -0
  22. data/lib/hubspot/codegen/cms/hubdb/models/hub_db_table_v3.rb +383 -0
  23. data/lib/hubspot/codegen/cms/hubdb/models/hub_db_table_v3_input.rb +295 -0
  24. data/lib/hubspot/codegen/cms/hubdb/models/hub_db_table_v3_live_input.rb +241 -0
  25. data/lib/hubspot/codegen/cms/hubdb/models/import_result.rb +263 -0
  26. data/lib/hubspot/codegen/cms/hubdb/models/next_page.rb +224 -0
  27. data/lib/hubspot/codegen/cms/hubdb/models/option.rb +257 -0
  28. data/lib/hubspot/codegen/cms/hubdb/models/paging.rb +219 -0
  29. data/lib/hubspot/codegen/cms/hubdb/models/previous_page.rb +224 -0
  30. data/lib/hubspot/codegen/cms/hubdb/models/simple_user.rb +257 -0
  31. data/lib/hubspot/version.rb +1 -1
  32. data/sample-apps/timeline-events-app/.env.template +1 -1
  33. data/sample-apps/timeline-events-app/Gemfile.lock +1 -1
  34. data/sample-apps/timeline-events-app/README.md +30 -0
  35. data/sample-apps/timeline-events-app/app/assets/stylesheets/application.css +78 -8
  36. data/sample-apps/timeline-events-app/app/controllers/timeline_events_controller.rb +1 -1
  37. data/sample-apps/timeline-events-app/app/views/timeline_events/index.html.erb +17 -19
  38. metadata +46 -12
@@ -0,0 +1,215 @@
1
+ =begin
2
+ #HubDB endpoints
3
+
4
+ #HubDB is a relational data store that presents data as rows, columns, and cells in a table, much like a spreadsheet. HubDB tables can be added or modified [in the HubSpot CMS](https://knowledge.hubspot.com/cos-general/how-to-edit-hubdb-tables), but you can also use the API endpoints documented here. For more information on HubDB tables and using their data on a HubSpot site, see the [CMS developers site](https://designers.hubspot.com/docs/tools/hubdb). You can also see the [documentation for dynamic pages](https://designers.hubspot.com/docs/tutorials/how-to-build-dynamic-pages-with-hubdb) for more details about the `useForPages` field. HubDB tables now support `DRAFT` and `PUBLISHED` versions. This allows you to update data in the table, either for testing or to allow for a manual approval process, without affecting any live pages using the existing data. Draft data can be reviewed and published by a user working in HubSpot or published via the API. Draft data can also be discarded, allowing users to go back to the live version of the data without disrupting it.
5
+
6
+ The version of the OpenAPI document: v3
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.3.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module Hubspot
16
+ module Cms
17
+ module Hubdb
18
+ class BatchInputJsonNode
19
+ attr_accessor :inputs
20
+
21
+ # Attribute mapping from ruby-style variable name to JSON key.
22
+ def self.attribute_map
23
+ {
24
+ :'inputs' => :'inputs'
25
+ }
26
+ end
27
+
28
+ # Attribute type mapping.
29
+ def self.openapi_types
30
+ {
31
+ :'inputs' => :'Array'
32
+ }
33
+ end
34
+
35
+ # List of attributes with nullable: true
36
+ def self.openapi_nullable
37
+ Set.new([
38
+ ])
39
+ end
40
+
41
+ # Initializes the object
42
+ # @param [Hash] attributes Model attributes in the form of hash
43
+ def initialize(attributes = {})
44
+ if (!attributes.is_a?(Hash))
45
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Cms::Hubdb::BatchInputJsonNode` initialize method"
46
+ end
47
+
48
+ # check to see if the attribute exists and convert string to symbol for hash key
49
+ attributes = attributes.each_with_object({}) { |(k, v), h|
50
+ if (!self.class.attribute_map.key?(k.to_sym))
51
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Cms::Hubdb::BatchInputJsonNode`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
52
+ end
53
+ h[k.to_sym] = v
54
+ }
55
+
56
+ if attributes.key?(:'inputs')
57
+ self.inputs = attributes[:'inputs']
58
+ end
59
+ end
60
+
61
+ # Show invalid properties with the reasons. Usually used together with valid?
62
+ # @return Array for valid properties with the reasons
63
+ def list_invalid_properties
64
+ invalid_properties = Array.new
65
+ if @inputs.nil?
66
+ invalid_properties.push('invalid value for "inputs", inputs cannot be nil.')
67
+ end
68
+
69
+ invalid_properties
70
+ end
71
+
72
+ # Check to see if the all the properties in the model are valid
73
+ # @return true if the model is valid
74
+ def valid?
75
+ return false if @inputs.nil?
76
+ true
77
+ end
78
+
79
+ # Checks equality by comparing each attribute.
80
+ # @param [Object] Object to be compared
81
+ def ==(o)
82
+ return true if self.equal?(o)
83
+ self.class == o.class &&
84
+ inputs == o.inputs
85
+ end
86
+
87
+ # @see the `==` method
88
+ # @param [Object] Object to be compared
89
+ def eql?(o)
90
+ self == o
91
+ end
92
+
93
+ # Calculates hash code according to all attributes.
94
+ # @return [Integer] Hash code
95
+ def hash
96
+ [inputs].hash
97
+ end
98
+
99
+ # Builds the object from hash
100
+ # @param [Hash] attributes Model attributes in the form of hash
101
+ # @return [Object] Returns the model itself
102
+ def self.build_from_hash(attributes)
103
+ new.build_from_hash(attributes)
104
+ end
105
+
106
+ # Builds the object from hash
107
+ # @param [Hash] attributes Model attributes in the form of hash
108
+ # @return [Object] Returns the model itself
109
+ def build_from_hash(attributes)
110
+ return nil unless attributes.is_a?(Hash)
111
+ self.class.openapi_types.each_pair do |key, type|
112
+ if type =~ /\AArray<(.*)>/i
113
+ # check to ensure the input is an array given that the attribute
114
+ # is documented as an array but the input is not
115
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
116
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
117
+ end
118
+ elsif !attributes[self.class.attribute_map[key]].nil?
119
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
120
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
121
+ end
122
+
123
+ self
124
+ end
125
+
126
+ # Deserializes the data based on type
127
+ # @param string type Data type
128
+ # @param string value Value to be deserialized
129
+ # @return [Object] Deserialized data
130
+ def _deserialize(type, value)
131
+ case type.to_sym
132
+ when :DateTime
133
+ DateTime.parse(value)
134
+ when :Date
135
+ Date.parse(value)
136
+ when :String
137
+ value.to_s
138
+ when :Integer
139
+ value.to_i
140
+ when :Float
141
+ value.to_f
142
+ when :Boolean
143
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
144
+ true
145
+ else
146
+ false
147
+ end
148
+ when :Object
149
+ # generic object (usually a Hash), return directly
150
+ value
151
+ when /\AArray<(?<inner_type>.+)>\z/
152
+ inner_type = Regexp.last_match[:inner_type]
153
+ value.map { |v| _deserialize(inner_type, v) }
154
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
155
+ k_type = Regexp.last_match[:k_type]
156
+ v_type = Regexp.last_match[:v_type]
157
+ {}.tap do |hash|
158
+ value.each do |k, v|
159
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
160
+ end
161
+ end
162
+ else # model
163
+ Hubspot::Cms::Hubdb.const_get(type).build_from_hash(value)
164
+ end
165
+ end
166
+
167
+ # Returns the string representation of the object
168
+ # @return [String] String presentation of the object
169
+ def to_s
170
+ to_hash.to_s
171
+ end
172
+
173
+ # to_body is an alias to to_hash (backward compatibility)
174
+ # @return [Hash] Returns the object in the form of hash
175
+ def to_body
176
+ to_hash
177
+ end
178
+
179
+ # Returns the object in the form of hash
180
+ # @return [Hash] Returns the object in the form of hash
181
+ def to_hash
182
+ hash = {}
183
+ self.class.attribute_map.each_pair do |attr, param|
184
+ value = self.send(attr)
185
+ if value.nil?
186
+ is_nullable = self.class.openapi_nullable.include?(attr)
187
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
188
+ end
189
+
190
+ hash[param] = _to_hash(value)
191
+ end
192
+ hash
193
+ end
194
+
195
+ # Outputs non-array value in the form of hash
196
+ # For object, use to_hash. Otherwise, just return the value
197
+ # @param [Object] value Any valid value
198
+ # @return [Hash] Returns the value in the form of hash
199
+ def _to_hash(value)
200
+ if value.is_a?(Array)
201
+ value.compact.map { |v| _to_hash(v) }
202
+ elsif value.is_a?(Hash)
203
+ {}.tap do |hash|
204
+ value.each { |k, v| hash[k] = _to_hash(v) }
205
+ end
206
+ elsif value.respond_to? :to_hash
207
+ value.to_hash
208
+ else
209
+ value
210
+ end
211
+ end
212
+ end
213
+ end
214
+ end
215
+ end
@@ -0,0 +1,217 @@
1
+ =begin
2
+ #HubDB endpoints
3
+
4
+ #HubDB is a relational data store that presents data as rows, columns, and cells in a table, much like a spreadsheet. HubDB tables can be added or modified [in the HubSpot CMS](https://knowledge.hubspot.com/cos-general/how-to-edit-hubdb-tables), but you can also use the API endpoints documented here. For more information on HubDB tables and using their data on a HubSpot site, see the [CMS developers site](https://designers.hubspot.com/docs/tools/hubdb). You can also see the [documentation for dynamic pages](https://designers.hubspot.com/docs/tutorials/how-to-build-dynamic-pages-with-hubdb) for more details about the `useForPages` field. HubDB tables now support `DRAFT` and `PUBLISHED` versions. This allows you to update data in the table, either for testing or to allow for a manual approval process, without affecting any live pages using the existing data. Draft data can be reviewed and published by a user working in HubSpot or published via the API. Draft data can also be discarded, allowing users to go back to the live version of the data without disrupting it.
5
+
6
+ The version of the OpenAPI document: v3
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.3.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module Hubspot
16
+ module Cms
17
+ module Hubdb
18
+ class BatchInputString
19
+ attr_accessor :inputs
20
+
21
+ # Attribute mapping from ruby-style variable name to JSON key.
22
+ def self.attribute_map
23
+ {
24
+ :'inputs' => :'inputs'
25
+ }
26
+ end
27
+
28
+ # Attribute type mapping.
29
+ def self.openapi_types
30
+ {
31
+ :'inputs' => :'Array<String>'
32
+ }
33
+ end
34
+
35
+ # List of attributes with nullable: true
36
+ def self.openapi_nullable
37
+ Set.new([
38
+ ])
39
+ end
40
+
41
+ # Initializes the object
42
+ # @param [Hash] attributes Model attributes in the form of hash
43
+ def initialize(attributes = {})
44
+ if (!attributes.is_a?(Hash))
45
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Cms::Hubdb::BatchInputString` initialize method"
46
+ end
47
+
48
+ # check to see if the attribute exists and convert string to symbol for hash key
49
+ attributes = attributes.each_with_object({}) { |(k, v), h|
50
+ if (!self.class.attribute_map.key?(k.to_sym))
51
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Cms::Hubdb::BatchInputString`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
52
+ end
53
+ h[k.to_sym] = v
54
+ }
55
+
56
+ if attributes.key?(:'inputs')
57
+ if (value = attributes[:'inputs']).is_a?(Array)
58
+ self.inputs = value
59
+ end
60
+ end
61
+ end
62
+
63
+ # Show invalid properties with the reasons. Usually used together with valid?
64
+ # @return Array for valid properties with the reasons
65
+ def list_invalid_properties
66
+ invalid_properties = Array.new
67
+ if @inputs.nil?
68
+ invalid_properties.push('invalid value for "inputs", inputs cannot be nil.')
69
+ end
70
+
71
+ invalid_properties
72
+ end
73
+
74
+ # Check to see if the all the properties in the model are valid
75
+ # @return true if the model is valid
76
+ def valid?
77
+ return false if @inputs.nil?
78
+ true
79
+ end
80
+
81
+ # Checks equality by comparing each attribute.
82
+ # @param [Object] Object to be compared
83
+ def ==(o)
84
+ return true if self.equal?(o)
85
+ self.class == o.class &&
86
+ inputs == o.inputs
87
+ end
88
+
89
+ # @see the `==` method
90
+ # @param [Object] Object to be compared
91
+ def eql?(o)
92
+ self == o
93
+ end
94
+
95
+ # Calculates hash code according to all attributes.
96
+ # @return [Integer] Hash code
97
+ def hash
98
+ [inputs].hash
99
+ end
100
+
101
+ # Builds the object from hash
102
+ # @param [Hash] attributes Model attributes in the form of hash
103
+ # @return [Object] Returns the model itself
104
+ def self.build_from_hash(attributes)
105
+ new.build_from_hash(attributes)
106
+ end
107
+
108
+ # Builds the object from hash
109
+ # @param [Hash] attributes Model attributes in the form of hash
110
+ # @return [Object] Returns the model itself
111
+ def build_from_hash(attributes)
112
+ return nil unless attributes.is_a?(Hash)
113
+ self.class.openapi_types.each_pair do |key, type|
114
+ if type =~ /\AArray<(.*)>/i
115
+ # check to ensure the input is an array given that the attribute
116
+ # is documented as an array but the input is not
117
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
118
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
119
+ end
120
+ elsif !attributes[self.class.attribute_map[key]].nil?
121
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
122
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
123
+ end
124
+
125
+ self
126
+ end
127
+
128
+ # Deserializes the data based on type
129
+ # @param string type Data type
130
+ # @param string value Value to be deserialized
131
+ # @return [Object] Deserialized data
132
+ def _deserialize(type, value)
133
+ case type.to_sym
134
+ when :DateTime
135
+ DateTime.parse(value)
136
+ when :Date
137
+ Date.parse(value)
138
+ when :String
139
+ value.to_s
140
+ when :Integer
141
+ value.to_i
142
+ when :Float
143
+ value.to_f
144
+ when :Boolean
145
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
146
+ true
147
+ else
148
+ false
149
+ end
150
+ when :Object
151
+ # generic object (usually a Hash), return directly
152
+ value
153
+ when /\AArray<(?<inner_type>.+)>\z/
154
+ inner_type = Regexp.last_match[:inner_type]
155
+ value.map { |v| _deserialize(inner_type, v) }
156
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
157
+ k_type = Regexp.last_match[:k_type]
158
+ v_type = Regexp.last_match[:v_type]
159
+ {}.tap do |hash|
160
+ value.each do |k, v|
161
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
162
+ end
163
+ end
164
+ else # model
165
+ Hubspot::Cms::Hubdb.const_get(type).build_from_hash(value)
166
+ end
167
+ end
168
+
169
+ # Returns the string representation of the object
170
+ # @return [String] String presentation of the object
171
+ def to_s
172
+ to_hash.to_s
173
+ end
174
+
175
+ # to_body is an alias to to_hash (backward compatibility)
176
+ # @return [Hash] Returns the object in the form of hash
177
+ def to_body
178
+ to_hash
179
+ end
180
+
181
+ # Returns the object in the form of hash
182
+ # @return [Hash] Returns the object in the form of hash
183
+ def to_hash
184
+ hash = {}
185
+ self.class.attribute_map.each_pair do |attr, param|
186
+ value = self.send(attr)
187
+ if value.nil?
188
+ is_nullable = self.class.openapi_nullable.include?(attr)
189
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
190
+ end
191
+
192
+ hash[param] = _to_hash(value)
193
+ end
194
+ hash
195
+ end
196
+
197
+ # Outputs non-array value in the form of hash
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
201
+ def _to_hash(value)
202
+ if value.is_a?(Array)
203
+ value.compact.map { |v| _to_hash(v) }
204
+ elsif value.is_a?(Hash)
205
+ {}.tap do |hash|
206
+ value.each { |k, v| hash[k] = _to_hash(v) }
207
+ end
208
+ elsif value.respond_to? :to_hash
209
+ value.to_hash
210
+ else
211
+ value
212
+ end
213
+ end
214
+ end
215
+ end
216
+ end
217
+ end
@@ -0,0 +1,333 @@
1
+ =begin
2
+ #HubDB endpoints
3
+
4
+ #HubDB is a relational data store that presents data as rows, columns, and cells in a table, much like a spreadsheet. HubDB tables can be added or modified [in the HubSpot CMS](https://knowledge.hubspot.com/cos-general/how-to-edit-hubdb-tables), but you can also use the API endpoints documented here. For more information on HubDB tables and using their data on a HubSpot site, see the [CMS developers site](https://designers.hubspot.com/docs/tools/hubdb). You can also see the [documentation for dynamic pages](https://designers.hubspot.com/docs/tutorials/how-to-build-dynamic-pages-with-hubdb) for more details about the `useForPages` field. HubDB tables now support `DRAFT` and `PUBLISHED` versions. This allows you to update data in the table, either for testing or to allow for a manual approval process, without affecting any live pages using the existing data. Draft data can be reviewed and published by a user working in HubSpot or published via the API. Draft data can also be discarded, allowing users to go back to the live version of the data without disrupting it.
5
+
6
+ The version of the OpenAPI document: v3
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.3.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module Hubspot
16
+ module Cms
17
+ module Hubdb
18
+ class BatchResponseHubDbTableRowV3WithErrors
19
+ attr_accessor :status
20
+
21
+ attr_accessor :results
22
+
23
+ attr_accessor :num_errors
24
+
25
+ attr_accessor :errors
26
+
27
+ attr_accessor :requested_at
28
+
29
+ attr_accessor :started_at
30
+
31
+ attr_accessor :completed_at
32
+
33
+ attr_accessor :links
34
+
35
+ class EnumAttributeValidator
36
+ attr_reader :datatype
37
+ attr_reader :allowable_values
38
+
39
+ def initialize(datatype, allowable_values)
40
+ @allowable_values = allowable_values.map do |value|
41
+ case datatype.to_s
42
+ when /Integer/i
43
+ value.to_i
44
+ when /Float/i
45
+ value.to_f
46
+ else
47
+ value
48
+ end
49
+ end
50
+ end
51
+
52
+ def valid?(value)
53
+ !value || allowable_values.include?(value)
54
+ end
55
+ end
56
+
57
+ # Attribute mapping from ruby-style variable name to JSON key.
58
+ def self.attribute_map
59
+ {
60
+ :'status' => :'status',
61
+ :'results' => :'results',
62
+ :'num_errors' => :'numErrors',
63
+ :'errors' => :'errors',
64
+ :'requested_at' => :'requestedAt',
65
+ :'started_at' => :'startedAt',
66
+ :'completed_at' => :'completedAt',
67
+ :'links' => :'links'
68
+ }
69
+ end
70
+
71
+ # Attribute type mapping.
72
+ def self.openapi_types
73
+ {
74
+ :'status' => :'String',
75
+ :'results' => :'Array<HubDbTableRowV3>',
76
+ :'num_errors' => :'Integer',
77
+ :'errors' => :'Array<Error>',
78
+ :'requested_at' => :'DateTime',
79
+ :'started_at' => :'DateTime',
80
+ :'completed_at' => :'DateTime',
81
+ :'links' => :'Hash<String, String>'
82
+ }
83
+ end
84
+
85
+ # List of attributes with nullable: true
86
+ def self.openapi_nullable
87
+ Set.new([
88
+ ])
89
+ end
90
+
91
+ # Initializes the object
92
+ # @param [Hash] attributes Model attributes in the form of hash
93
+ def initialize(attributes = {})
94
+ if (!attributes.is_a?(Hash))
95
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Hubspot::Cms::Hubdb::BatchResponseHubDbTableRowV3WithErrors` initialize method"
96
+ end
97
+
98
+ # check to see if the attribute exists and convert string to symbol for hash key
99
+ attributes = attributes.each_with_object({}) { |(k, v), h|
100
+ if (!self.class.attribute_map.key?(k.to_sym))
101
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Hubspot::Cms::Hubdb::BatchResponseHubDbTableRowV3WithErrors`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
102
+ end
103
+ h[k.to_sym] = v
104
+ }
105
+
106
+ if attributes.key?(:'status')
107
+ self.status = attributes[:'status']
108
+ end
109
+
110
+ if attributes.key?(:'results')
111
+ if (value = attributes[:'results']).is_a?(Array)
112
+ self.results = value
113
+ end
114
+ end
115
+
116
+ if attributes.key?(:'num_errors')
117
+ self.num_errors = attributes[:'num_errors']
118
+ end
119
+
120
+ if attributes.key?(:'errors')
121
+ if (value = attributes[:'errors']).is_a?(Array)
122
+ self.errors = value
123
+ end
124
+ end
125
+
126
+ if attributes.key?(:'requested_at')
127
+ self.requested_at = attributes[:'requested_at']
128
+ end
129
+
130
+ if attributes.key?(:'started_at')
131
+ self.started_at = attributes[:'started_at']
132
+ end
133
+
134
+ if attributes.key?(:'completed_at')
135
+ self.completed_at = attributes[:'completed_at']
136
+ end
137
+
138
+ if attributes.key?(:'links')
139
+ if (value = attributes[:'links']).is_a?(Hash)
140
+ self.links = value
141
+ end
142
+ end
143
+ end
144
+
145
+ # Show invalid properties with the reasons. Usually used together with valid?
146
+ # @return Array for valid properties with the reasons
147
+ def list_invalid_properties
148
+ invalid_properties = Array.new
149
+ if @status.nil?
150
+ invalid_properties.push('invalid value for "status", status cannot be nil.')
151
+ end
152
+
153
+ if @results.nil?
154
+ invalid_properties.push('invalid value for "results", results cannot be nil.')
155
+ end
156
+
157
+ if @started_at.nil?
158
+ invalid_properties.push('invalid value for "started_at", started_at cannot be nil.')
159
+ end
160
+
161
+ if @completed_at.nil?
162
+ invalid_properties.push('invalid value for "completed_at", completed_at cannot be nil.')
163
+ end
164
+
165
+ invalid_properties
166
+ end
167
+
168
+ # Check to see if the all the properties in the model are valid
169
+ # @return true if the model is valid
170
+ def valid?
171
+ return false if @status.nil?
172
+ status_validator = EnumAttributeValidator.new('String', ["PENDING", "PROCESSING", "CANCELED", "COMPLETE"])
173
+ return false unless status_validator.valid?(@status)
174
+ return false if @results.nil?
175
+ return false if @started_at.nil?
176
+ return false if @completed_at.nil?
177
+ true
178
+ end
179
+
180
+ # Custom attribute writer method checking allowed values (enum).
181
+ # @param [Object] status Object to be assigned
182
+ def status=(status)
183
+ validator = EnumAttributeValidator.new('String', ["PENDING", "PROCESSING", "CANCELED", "COMPLETE"])
184
+ unless validator.valid?(status)
185
+ fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}."
186
+ end
187
+ @status = status
188
+ end
189
+
190
+ # Checks equality by comparing each attribute.
191
+ # @param [Object] Object to be compared
192
+ def ==(o)
193
+ return true if self.equal?(o)
194
+ self.class == o.class &&
195
+ status == o.status &&
196
+ results == o.results &&
197
+ num_errors == o.num_errors &&
198
+ errors == o.errors &&
199
+ requested_at == o.requested_at &&
200
+ started_at == o.started_at &&
201
+ completed_at == o.completed_at &&
202
+ links == o.links
203
+ end
204
+
205
+ # @see the `==` method
206
+ # @param [Object] Object to be compared
207
+ def eql?(o)
208
+ self == o
209
+ end
210
+
211
+ # Calculates hash code according to all attributes.
212
+ # @return [Integer] Hash code
213
+ def hash
214
+ [status, results, num_errors, errors, requested_at, started_at, completed_at, links].hash
215
+ end
216
+
217
+ # Builds the object from hash
218
+ # @param [Hash] attributes Model attributes in the form of hash
219
+ # @return [Object] Returns the model itself
220
+ def self.build_from_hash(attributes)
221
+ new.build_from_hash(attributes)
222
+ end
223
+
224
+ # Builds the object from hash
225
+ # @param [Hash] attributes Model attributes in the form of hash
226
+ # @return [Object] Returns the model itself
227
+ def build_from_hash(attributes)
228
+ return nil unless attributes.is_a?(Hash)
229
+ self.class.openapi_types.each_pair do |key, type|
230
+ if type =~ /\AArray<(.*)>/i
231
+ # check to ensure the input is an array given that the attribute
232
+ # is documented as an array but the input is not
233
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
234
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
235
+ end
236
+ elsif !attributes[self.class.attribute_map[key]].nil?
237
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
238
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
239
+ end
240
+
241
+ self
242
+ end
243
+
244
+ # Deserializes the data based on type
245
+ # @param string type Data type
246
+ # @param string value Value to be deserialized
247
+ # @return [Object] Deserialized data
248
+ def _deserialize(type, value)
249
+ case type.to_sym
250
+ when :DateTime
251
+ DateTime.parse(value)
252
+ when :Date
253
+ Date.parse(value)
254
+ when :String
255
+ value.to_s
256
+ when :Integer
257
+ value.to_i
258
+ when :Float
259
+ value.to_f
260
+ when :Boolean
261
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
262
+ true
263
+ else
264
+ false
265
+ end
266
+ when :Object
267
+ # generic object (usually a Hash), return directly
268
+ value
269
+ when /\AArray<(?<inner_type>.+)>\z/
270
+ inner_type = Regexp.last_match[:inner_type]
271
+ value.map { |v| _deserialize(inner_type, v) }
272
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
273
+ k_type = Regexp.last_match[:k_type]
274
+ v_type = Regexp.last_match[:v_type]
275
+ {}.tap do |hash|
276
+ value.each do |k, v|
277
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
278
+ end
279
+ end
280
+ else # model
281
+ Hubspot::Cms::Hubdb.const_get(type).build_from_hash(value)
282
+ end
283
+ end
284
+
285
+ # Returns the string representation of the object
286
+ # @return [String] String presentation of the object
287
+ def to_s
288
+ to_hash.to_s
289
+ end
290
+
291
+ # to_body is an alias to to_hash (backward compatibility)
292
+ # @return [Hash] Returns the object in the form of hash
293
+ def to_body
294
+ to_hash
295
+ end
296
+
297
+ # Returns the object in the form of hash
298
+ # @return [Hash] Returns the object in the form of hash
299
+ def to_hash
300
+ hash = {}
301
+ self.class.attribute_map.each_pair do |attr, param|
302
+ value = self.send(attr)
303
+ if value.nil?
304
+ is_nullable = self.class.openapi_nullable.include?(attr)
305
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
306
+ end
307
+
308
+ hash[param] = _to_hash(value)
309
+ end
310
+ hash
311
+ end
312
+
313
+ # Outputs non-array value in the form of hash
314
+ # For object, use to_hash. Otherwise, just return the value
315
+ # @param [Object] value Any valid value
316
+ # @return [Hash] Returns the value in the form of hash
317
+ def _to_hash(value)
318
+ if value.is_a?(Array)
319
+ value.compact.map { |v| _to_hash(v) }
320
+ elsif value.is_a?(Hash)
321
+ {}.tap do |hash|
322
+ value.each { |k, v| hash[k] = _to_hash(v) }
323
+ end
324
+ elsif value.respond_to? :to_hash
325
+ value.to_hash
326
+ else
327
+ value
328
+ end
329
+ end
330
+ end
331
+ end
332
+ end
333
+ end