Class: Hook0::Generated::RequestAttempt

Inherits:
Object
  • Object
show all
Defined in:
lib/hook0/generated/models.rb

Overview

The RequestAttempt the API declares.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(created_at:, event:, event_id:, request_attempt_id:, retry_count:, status:, subscription:, delay_until: nil, failed_at: nil, http_response_status: nil, picked_at: nil, response_id: nil, succeeded_at: nil) ⇒ RequestAttempt

Returns a new instance of RequestAttempt.

Parameters:

  • created_at (Time)

    carries created_at.

  • event (RequestAttemptEvent)

    carries event.

  • event_id (String)

    carries event_id.

  • request_attempt_id (String)

    carries request_attempt_id.

  • retry_count (Integer)

    carries retry_count.

  • status (RequestAttemptStatus)

    carries status: Status of a request attempt. The 'type' field indicates the status variant. - waiting: since, until - Scheduled for future delivery - pending: since - Ready to be processed - in_progre

  • subscription (RequestAttemptSubscription)

    carries subscription.

  • delay_until (Time, nil) (defaults to: nil)

    carries delay_until.

  • failed_at (Time, nil) (defaults to: nil)

    carries failed_at.

  • http_response_status (Integer, nil) (defaults to: nil)

    carries http_response_status.

  • picked_at (Time, nil) (defaults to: nil)

    carries picked_at.

  • response_id (String, nil) (defaults to: nil)

    carries response_id.

  • succeeded_at (Time, nil) (defaults to: nil)

    carries succeeded_at.



2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
# File 'lib/hook0/generated/models.rb', line 2279

def initialize(
  created_at:,
  event:,
  event_id:,
  request_attempt_id:,
  retry_count:,
  status:,
  subscription:,
  delay_until: nil,
  failed_at: nil,
  http_response_status: nil,
  picked_at: nil,
  response_id: nil,
  succeeded_at: nil
)
  @created_at = created_at
  @event = event
  @event_id = event_id
  @request_attempt_id = request_attempt_id
  @retry_count = retry_count
  @status = status
  @subscription = subscription
  @delay_until = delay_until
  @failed_at = failed_at
  @http_response_status = http_response_status
  @picked_at = picked_at
  @response_id = response_id
  @succeeded_at = succeeded_at
  freeze
end

Instance Attribute Details

#created_atObject (readonly)

Returns the value of attribute created_at.



2250
2251
2252
# File 'lib/hook0/generated/models.rb', line 2250

def created_at
  @created_at
end

#delay_untilObject (readonly)

Returns the value of attribute delay_until.



2250
2251
2252
# File 'lib/hook0/generated/models.rb', line 2250

def delay_until
  @delay_until
end

#eventObject (readonly)

Returns the value of attribute event.



2250
2251
2252
# File 'lib/hook0/generated/models.rb', line 2250

def event
  @event
end

#event_idObject (readonly)

Returns the value of attribute event_id.



2250
2251
2252
# File 'lib/hook0/generated/models.rb', line 2250

def event_id
  @event_id
end

#failed_atObject (readonly)

Returns the value of attribute failed_at.



2250
2251
2252
# File 'lib/hook0/generated/models.rb', line 2250

def failed_at
  @failed_at
end

#http_response_statusObject (readonly)

Returns the value of attribute http_response_status.



2250
2251
2252
# File 'lib/hook0/generated/models.rb', line 2250

def http_response_status
  @http_response_status
end

#picked_atObject (readonly)

Returns the value of attribute picked_at.



2250
2251
2252
# File 'lib/hook0/generated/models.rb', line 2250

def picked_at
  @picked_at
end

#request_attempt_idObject (readonly)

Returns the value of attribute request_attempt_id.



2250
2251
2252
# File 'lib/hook0/generated/models.rb', line 2250

def request_attempt_id
  @request_attempt_id
end

#response_idObject (readonly)

Returns the value of attribute response_id.



2250
2251
2252
# File 'lib/hook0/generated/models.rb', line 2250

def response_id
  @response_id
end

#retry_countObject (readonly)

Returns the value of attribute retry_count.



2250
2251
2252
# File 'lib/hook0/generated/models.rb', line 2250

def retry_count
  @retry_count
end

#statusObject (readonly)

Returns the value of attribute status.



2250
2251
2252
# File 'lib/hook0/generated/models.rb', line 2250

def status
  @status
end

#subscriptionObject (readonly)

Returns the value of attribute subscription.



2250
2251
2252
# File 'lib/hook0/generated/models.rb', line 2250

def subscription
  @subscription
end

#succeeded_atObject (readonly)

Returns the value of attribute succeeded_at.



2250
2251
2252
# File 'lib/hook0/generated/models.rb', line 2250

def succeeded_at
  @succeeded_at
end

Class Method Details

.from_json(value) ⇒ RequestAttempt

Read one out of what the API answered.

Parameters:

  • value (Object)

    the JSON document the API answered

Returns:



2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
# File 'lib/hook0/generated/models.rb', line 2314

def self.from_json(value)
  fields = Runtime.as_fields(value, "RequestAttempt")
  new(
    created_at: Runtime.read(fields, "created_at", Runtime::DATE_TIME),
    event: Runtime.read(fields, "event", RequestAttemptEvent.method(:from_json)),
    event_id: Runtime.read(fields, "event_id", Runtime::UUID),
    request_attempt_id: Runtime.read(fields, "request_attempt_id", Runtime::UUID),
    retry_count: Runtime.read(fields, "retry_count", Runtime::INTEGER),
    status: Runtime.read(fields, "status", RequestAttemptStatus.method(:from_json)),
    subscription: Runtime.read(fields, "subscription", RequestAttemptSubscription.method(:from_json)),
    delay_until: Runtime.maybe(fields, "delay_until", Runtime::DATE_TIME),
    failed_at: Runtime.maybe(fields, "failed_at", Runtime::DATE_TIME),
    http_response_status: Runtime.maybe(fields, "http_response_status", Runtime::INTEGER),
    picked_at: Runtime.maybe(fields, "picked_at", Runtime::DATE_TIME),
    response_id: Runtime.maybe(fields, "response_id", Runtime::UUID),
    succeeded_at: Runtime.maybe(fields, "succeeded_at", Runtime::DATE_TIME)
  )
end

Instance Method Details

#==(other) ⇒ Boolean Also known as: eql?

Whether that value carries the same members as this one.

Parameters:

  • other (Object)

Returns:

  • (Boolean)


2358
2359
2360
# File 'lib/hook0/generated/models.rb', line 2358

def ==(other)
  other.is_a?(RequestAttempt) && to_h == other.to_h
end

#hashInteger

A value two equal instances share, so that either may key a hash.

Returns:

  • (Integer)


2366
2367
2368
# File 'lib/hook0/generated/models.rb', line 2366

def hash
  to_h.hash
end

#to_hHash{String => Object}

Write one back the way the API reads it.

Returns:

  • (Hash{String => Object})


2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
# File 'lib/hook0/generated/models.rb', line 2336

def to_h
  out = {}
  out["created_at"] = Runtime.moment(@created_at)
  out["event"] = @event.to_h
  out["event_id"] = @event_id
  out["request_attempt_id"] = @request_attempt_id
  out["retry_count"] = @retry_count
  out["status"] = @status.to_h
  out["subscription"] = @subscription.to_h
  out["delay_until"] = Runtime.moment(@delay_until) unless @delay_until.nil?
  out["failed_at"] = Runtime.moment(@failed_at) unless @failed_at.nil?
  out["http_response_status"] = @http_response_status unless @http_response_status.nil?
  out["picked_at"] = Runtime.moment(@picked_at) unless @picked_at.nil?
  out["response_id"] = @response_id unless @response_id.nil?
  out["succeeded_at"] = Runtime.moment(@succeeded_at) unless @succeeded_at.nil?
  out
end