Class: Courier::Bulk::JobDetails
- Inherits:
-
Object
- Object
- Courier::Bulk::JobDetails
- Defined in:
- lib/trycourier/bulk/types/job_details.rb
Instance Attribute Summary collapse
-
#additional_properties ⇒ Object
readonly
Returns the value of attribute additional_properties.
-
#definition ⇒ Object
readonly
Returns the value of attribute definition.
-
#enqueued ⇒ Object
readonly
Returns the value of attribute enqueued.
-
#failures ⇒ Object
readonly
Returns the value of attribute failures.
-
#received ⇒ Object
readonly
Returns the value of attribute received.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Bulk::JobDetails
Deserialize a JSON object to an instance of JobDetails.
-
.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(definition:, enqueued:, failures:, received:, status:, additional_properties: nil) ⇒ Bulk::JobDetails constructor
-
#to_json(*_args) ⇒ JSON
Serialize an instance of JobDetails to a JSON object.
Constructor Details
#initialize(definition:, enqueued:, failures:, received:, status:, additional_properties: nil) ⇒ Bulk::JobDetails
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_properties ⇒ Object (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 |
#definition ⇒ Object (readonly)
Returns the value of attribute definition.
10 11 12 |
# File 'lib/trycourier/bulk/types/job_details.rb', line 10 def definition @definition end |
#enqueued ⇒ Object (readonly)
Returns the value of attribute enqueued.
10 11 12 |
# File 'lib/trycourier/bulk/types/job_details.rb', line 10 def enqueued @enqueued end |
#failures ⇒ Object (readonly)
Returns the value of attribute failures.
10 11 12 |
# File 'lib/trycourier/bulk/types/job_details.rb', line 10 def failures @failures end |
#received ⇒ Object (readonly)
Returns the value of attribute received.
10 11 12 |
# File 'lib/trycourier/bulk/types/job_details.rb', line 10 def received @received end |
#status ⇒ Object (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
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.
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
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 |