Class: Courier::Bulk::JobDetails

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(definition:, enqueued:, failures:, received:, status:, additional_properties: nil) ⇒ Bulk::JobDetails

Parameters:

  • definition (Bulk::InboundBulkMessage)
  • enqueued (Integer)
  • failures (Integer)
  • received (Integer)
  • status (Bulk::BulkJobStatus)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/trycourier/bulk/types/job_details.rb', line 19

def initialize(definition:, enqueued:, failures:, received:, status:, additional_properties: nil)
  # @type [Bulk::InboundBulkMessage]
  @definition = definition
  # @type [Integer]
  @enqueued = enqueued
  # @type [Integer]
  @failures = failures
  # @type [Integer]
  @received = received
  # @type [Bulk::BulkJobStatus]
  @status = status
  # @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.



10
11
12
# File 'lib/trycourier/bulk/types/job_details.rb', line 10

def additional_properties
  @additional_properties
end

#definitionObject (readonly)

Returns the value of attribute definition.



10
11
12
# File 'lib/trycourier/bulk/types/job_details.rb', line 10

def definition
  @definition
end

#enqueuedObject (readonly)

Returns the value of attribute enqueued.



10
11
12
# File 'lib/trycourier/bulk/types/job_details.rb', line 10

def enqueued
  @enqueued
end

#failuresObject (readonly)

Returns the value of attribute failures.



10
11
12
# File 'lib/trycourier/bulk/types/job_details.rb', line 10

def failures
  @failures
end

#receivedObject (readonly)

Returns the value of attribute received.



10
11
12
# File 'lib/trycourier/bulk/types/job_details.rb', line 10

def received
  @received
end

#statusObject (readonly)

Returns the value of attribute status.



10
11
12
# File 'lib/trycourier/bulk/types/job_details.rb', line 10

def status
  @status
end

Class Method Details

.from_json(json_object:) ⇒ Bulk::JobDetails

Deserialize a JSON object to an instance of JobDetails

Parameters:

  • json_object (JSON)

Returns:



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/trycourier/bulk/types/job_details.rb', line 38

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  if parsed_json["definition"].nil?
    definition = nil
  else
    definition = parsed_json["definition"].to_json
    definition = Bulk::InboundBulkMessage.from_json(json_object: definition)
  end
  enqueued = struct.enqueued
  failures = struct.failures
  received = struct.received
  status = struct.status
  new(definition: definition, enqueued: enqueued, failures: failures, received: received, status: status,
      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)


72
73
74
75
76
77
78
# File 'lib/trycourier/bulk/types/job_details.rb', line 72

def self.validate_raw(obj:)
  Bulk::InboundBulkMessage.validate_raw(obj: obj.definition)
  obj.enqueued.is_a?(Integer) != false || raise("Passed value for field obj.enqueued is not the expected type, validation failed.")
  obj.failures.is_a?(Integer) != false || raise("Passed value for field obj.failures is not the expected type, validation failed.")
  obj.received.is_a?(Integer) != false || raise("Passed value for field obj.received is not the expected type, validation failed.")
  obj.status.is_a?(Bulk::BulkJobStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ JSON

Serialize an instance of JobDetails to a JSON object

Returns:

  • (JSON)


58
59
60
61
62
63
64
65
66
# File 'lib/trycourier/bulk/types/job_details.rb', line 58

def to_json(*_args)
  {
    "definition": @definition,
    "enqueued": @enqueued,
    "failures": @failures,
    "received": @received,
    "status": @status
  }.to_json
end