# frozen_string_literal: true module Simplyq module Model class DeliveryAttempt attr_accessor :id attr_accessor :event_id attr_accessor :endpoint_id # The endpoint url of the endpoint when the event delivery was attempted. attr_accessor :endpoint_url # The response of the endpoint when a delivery attempt was made or null if not yet attempted. attr_accessor :response # The response headers of the endpoint when the event delivery was attempted. attr_accessor :response_headers # The response code of the endpoint when the event delivery was attempted. attr_accessor :response_status_code # The response code class i.e. 2xx, 3xx, 4xx, 5xx of the endpoint when the event delivery was attempted. attr_accessor :response_status_code_class # The delivery status of the event to the endpoint attr_accessor :status # The tigger of the delivery attempt attr_accessor :trigger_type # Number of times an event delivery attempt failed before the current attempt. attr_accessor :retry_count # This is the timestamp of when the delivery attempt was made to the endpoint. # In case it has not yet been attempted and the status of the delivery attempt # is **pending**, then the value of the timestamp will be **null**. attr_accessor :attempted_at def initialize(attributes = {}) self.id = attributes[:id] if attributes.key?(:id) self.event_id = attributes[:event_id] if attributes.key?(:event_id) self.endpoint_id = attributes[:endpoint_id] if attributes.key?(:endpoint_id) self.endpoint_url = attributes[:endpoint_url] if attributes.key?(:endpoint_url) self.response = attributes[:response] if attributes.key?(:response) self.response_headers = attributes[:response_headers] if attributes.key?(:response_headers) self.response_status_code = attributes[:response_status_code] if attributes.key?(:response_status_code) if attributes.key?(:response_status_code_class) self.response_status_code_class = attributes[:response_status_code_class] end self.status = attributes[:status] if attributes.key?(:status) self.trigger_type = attributes[:trigger_type] if attributes.key?(:trigger_type) self.retry_count = attributes[:retry_count] if attributes.key?(:retry_count) self.attempted_at = attributes[:attempted_at] if attributes.key?(:attempted_at) end # The model identifier attribute used in list operations # # @return [Symbol] def self.identifier :id end # Serializes the object from a hash # # @param hash [Hash] Hash with the object data # @return [Simplyq::Model::Endpoint] def self.from_hash(hash) return if hash.nil? new(hash) end # Show invalid properties with the reasons. Usually used together with valid? # @return Array for valid properties with the reasons def validation_errors [] end # Check if the model is valid # @return true if valid, false otherwise def valid? validation_errors.empty? end def [](key) instance_variable_get(:"@#{key}") end def ==(other) return false if other.nil? self.class == other.class && id == other.id && event_id == other.event_id && endpoint_id == other.endpoint_id && endpoint_url == other.endpoint_url && response == other.response && response_headers == other.response_headers && response_status_code == other.response_status_code && response_status_code_class == other.response_status_code_class && status == other.status && trigger_type == other.trigger_type && retry_count == other.retry_count && attempted_at == other.attempted_at end def to_h { id: id, event_id: event_id, endpoint_id: endpoint_id, endpoint_url: endpoint_url, response: response, response_headers: response_headers, response_status_code: response_status_code, response_status_code_class: response_status_code_class, status: status, trigger_type: trigger_type, retry_count: retry_count, attempted_at: attempted_at } end def to_json(*args) to_h.to_json(*args) end end end end