Class: Io::Flow::V0::Models::WebhookRequest

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ WebhookRequest

Returns a new instance of WebhookRequest.



67595
67596
67597
67598
67599
67600
67601
67602
67603
67604
67605
67606
67607
67608
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 67595

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :headers, :method, :body, :status], 'WebhookRequest')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @headers = HttpClient::Preconditions.assert_class('headers', opts.delete(:headers), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::Header) ? x : ::Io::Flow::V0::Models::Header.new(x)) }
  @method = (x = opts.delete(:method); x.is_a?(::Io::Flow::V0::Models::Method) ? x : ::Io::Flow::V0::Models::Method.apply(x))
  @body = HttpClient::Preconditions.assert_class('body', opts.delete(:body), String)
  @status = (x = opts.delete(:status); x.is_a?(::Io::Flow::V0::Models::WebhookStatus) ? x : ::Io::Flow::V0::Models::WebhookStatus.apply(x))
  @started_at = (x = opts.delete(:started_at); x.nil? ? nil : HttpClient::Preconditions.assert_class('started_at', HttpClient::Helper.to_date_time_iso8601(x), DateTime))
  @completed_at = (x = opts.delete(:completed_at); x.nil? ? nil : HttpClient::Preconditions.assert_class('completed_at', HttpClient::Helper.to_date_time_iso8601(x), DateTime))
  @duration_ms = (x = opts.delete(:duration_ms); x.nil? ? nil : HttpClient::Preconditions.assert_class('duration_ms', x, Integer))
  @response = (x = opts.delete(:response); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::WebhookResponse) ? x : ::Io::Flow::V0::Models::WebhookResponse.new(x)))
  @error = (x = opts.delete(:error); x.nil? ? nil : HttpClient::Preconditions.assert_class('error', x, String))
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



67593
67594
67595
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 67593

def body
  @body
end

#completed_atObject (readonly)

Returns the value of attribute completed_at.



67593
67594
67595
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 67593

def completed_at
  @completed_at
end

#duration_msObject (readonly)

Returns the value of attribute duration_ms.



67593
67594
67595
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 67593

def duration_ms
  @duration_ms
end

#errorObject (readonly)

Returns the value of attribute error.



67593
67594
67595
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 67593

def error
  @error
end

#headersObject (readonly)

Returns the value of attribute headers.



67593
67594
67595
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 67593

def headers
  @headers
end

#idObject (readonly)

Returns the value of attribute id.



67593
67594
67595
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 67593

def id
  @id
end

#methodObject (readonly)

Returns the value of attribute method.



67593
67594
67595
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 67593

def method
  @method
end

#responseObject (readonly)

Returns the value of attribute response.



67593
67594
67595
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 67593

def response
  @response
end

#started_atObject (readonly)

Returns the value of attribute started_at.



67593
67594
67595
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 67593

def started_at
  @started_at
end

#statusObject (readonly)

Returns the value of attribute status.



67593
67594
67595
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 67593

def status
  @status
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



67614
67615
67616
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 67614

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

#to_hashObject



67618
67619
67620
67621
67622
67623
67624
67625
67626
67627
67628
67629
67630
67631
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 67618

def to_hash
  {
    :id => id,
    :headers => headers.map { |o| o.to_hash },
    :method => method.value,
    :body => body,
    :status => status.value,
    :started_at => started_at,
    :completed_at => completed_at,
    :duration_ms => duration_ms,
    :response => response.nil? ? nil : response.to_hash,
    :error => error
  }
end

#to_jsonObject



67610
67611
67612
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 67610

def to_json
  JSON.dump(to_hash)
end