Class: Courier::Bulk::BulkIngestUsersResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/trycourier/bulk/types/bulk_ingest_users_response.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(total:, errors: nil, additional_properties: nil) ⇒ Bulk::BulkIngestUsersResponse

Parameters:

  • total (Integer)
  • errors (Array<Bulk::BulkIngestError>) (defaults to: nil)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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_propertiesObject (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

#errorsObject (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

#totalObject (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

Parameters:

  • json_object (JSON)

Returns:



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.

Parameters:

  • obj (Object)

Returns:

  • (Void)


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

Returns:

  • (JSON)


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