Class: Courier::Bulk::BulkIngestUsersResponse
- Inherits:
-
Object
- Object
- Courier::Bulk::BulkIngestUsersResponse
- Defined in:
- lib/trycourier/bulk/types/bulk_ingest_users_response.rb
Instance Attribute Summary collapse
-
#additional_properties ⇒ Object
readonly
Returns the value of attribute additional_properties.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#total ⇒ Object
readonly
Returns the value of attribute total.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Bulk::BulkIngestUsersResponse
Deserialize a JSON object to an instance of BulkIngestUsersResponse.
-
.validate_raw(obj:) ⇒ Void
Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object’s property definitions.
Instance Method Summary collapse
- #initialize(total:, errors: nil, additional_properties: nil) ⇒ Bulk::BulkIngestUsersResponse constructor
-
#to_json(*_args) ⇒ JSON
Serialize an instance of BulkIngestUsersResponse to a JSON object.
Constructor Details
#initialize(total:, errors: nil, additional_properties: nil) ⇒ Bulk::BulkIngestUsersResponse
15 16 17 18 19 20 21 22 |
# File 'lib/trycourier/bulk/types/bulk_ingest_users_response.rb', line 15 def initialize(total:, errors: nil, additional_properties: nil) # @type [Integer] @total = total # @type [Array<Bulk::BulkIngestError>] @errors = errors # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties end |
Instance Attribute Details
#additional_properties ⇒ Object (readonly)
Returns the value of attribute additional_properties.
9 10 11 |
# File 'lib/trycourier/bulk/types/bulk_ingest_users_response.rb', line 9 def additional_properties @additional_properties end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
9 10 11 |
# File 'lib/trycourier/bulk/types/bulk_ingest_users_response.rb', line 9 def errors @errors end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
9 10 11 |
# File 'lib/trycourier/bulk/types/bulk_ingest_users_response.rb', line 9 def total @total end |
Class Method Details
.from_json(json_object:) ⇒ Bulk::BulkIngestUsersResponse
Deserialize a JSON object to an instance of BulkIngestUsersResponse
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/trycourier/bulk/types/bulk_ingest_users_response.rb', line 28 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) total = struct.total errors = parsed_json["errors"]&.map do |v| v = v.to_json Bulk::BulkIngestError.from_json(json_object: v) end new(total: total, errors: errors, additional_properties: struct) end |
.validate_raw(obj:) ⇒ Void
Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object’s property definitions.
50 51 52 53 |
# File 'lib/trycourier/bulk/types/bulk_ingest_users_response.rb', line 50 def self.validate_raw(obj:) obj.total.is_a?(Integer) != false || raise("Passed value for field obj.total is not the expected type, validation failed.") obj.errors&.is_a?(Array) != false || raise("Passed value for field obj.errors is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ JSON
Serialize an instance of BulkIngestUsersResponse to a JSON object
42 43 44 |
# File 'lib/trycourier/bulk/types/bulk_ingest_users_response.rb', line 42 def to_json(*_args) { "total": @total, "errors": @errors }.to_json end |