Class: Io::Flow::V0::Models::WebhookDelivery

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Overview

A webhook delivery represents an event that matched a webhook’s event types. Each delivery will be attempted one or more times subject to the settings of your webhook.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ WebhookDelivery

Returns a new instance of WebhookDelivery.



55658
55659
55660
55661
55662
55663
55664
55665
55666
55667
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 55658

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :webhook, :status, :created_at], 'WebhookDelivery')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @webhook = (x = opts.delete(:webhook); x.is_a?(::Io::Flow::V0::Models::WebhookReference) ? x : ::Io::Flow::V0::Models::WebhookReference.new(x))
  @status = (x = opts.delete(:status); x.is_a?(::Io::Flow::V0::Models::WebhookStatus) ? x : ::Io::Flow::V0::Models::WebhookStatus.apply(x))
  @created_at = HttpClient::Preconditions.assert_class('created_at', HttpClient::Helper.to_date_time_iso8601(opts.delete(:created_at)), DateTime)
  @latest = (x = opts.delete(:latest); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::WebhookRequest) ? x : ::Io::Flow::V0::Models::WebhookRequest.new(x)))
  @next_attempt_at = (x = opts.delete(:next_attempt_at); x.nil? ? nil : HttpClient::Preconditions.assert_class('next_attempt_at', HttpClient::Helper.to_date_time_iso8601(x), DateTime))
end

Instance Attribute Details

#created_atObject (readonly)

Returns the value of attribute created_at.



55656
55657
55658
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 55656

def created_at
  @created_at
end

#idObject (readonly)

Returns the value of attribute id.



55656
55657
55658
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 55656

def id
  @id
end

#latestObject (readonly)

Returns the value of attribute latest.



55656
55657
55658
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 55656

def latest
  @latest
end

#next_attempt_atObject (readonly)

Returns the value of attribute next_attempt_at.



55656
55657
55658
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 55656

def next_attempt_at
  @next_attempt_at
end

#statusObject (readonly)

Returns the value of attribute status.



55656
55657
55658
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 55656

def status
  @status
end

#webhookObject (readonly)

Returns the value of attribute webhook.



55656
55657
55658
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 55656

def webhook
  @webhook
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



55673
55674
55675
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 55673

def copy(incoming={})
  WebhookDelivery.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
end

#to_hashObject



55677
55678
55679
55680
55681
55682
55683
55684
55685
55686
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 55677

def to_hash
  {
    :id => id,
    :webhook => webhook.to_hash,
    :status => status.value,
    :created_at => created_at,
    :latest => latest.nil? ? nil : latest.to_hash,
    :next_attempt_at => next_attempt_at
  }
end

#to_jsonObject



55669
55670
55671
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 55669

def to_json
  JSON.dump(to_hash)
end