Class: SimpleConnect::Responses::VerifyResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_connect/responses/verify_response.rb

Overview

Wraps the ‘integrations.verify` success payload. Exposes the integration metadata (provider, status) plus an array of `EventFlow` objects — one per event key the integration supports, with its enabled/attention state and (optional) linked template.

Defined Under Namespace

Classes: EventFlow

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json) ⇒ VerifyResponse

Returns a new instance of VerifyResponse.



12
13
14
15
16
17
18
# File 'lib/simple_connect/responses/verify_response.rb', line 12

def initialize(json)
  @json        = json.is_a?(Hash) ? json : {}
  integration  = @json["integration"].is_a?(Hash) ? @json["integration"] : {}
  @provider    = integration["provider"]
  @status      = integration["status"]
  @event_flows = Array(@json["event_flows"]).map { |ef| EventFlow.new(ef) }
end

Instance Attribute Details

#event_flowsObject (readonly)

Returns the value of attribute event_flows.



10
11
12
# File 'lib/simple_connect/responses/verify_response.rb', line 10

def event_flows
  @event_flows
end

#providerObject (readonly)

Returns the value of attribute provider.



10
11
12
# File 'lib/simple_connect/responses/verify_response.rb', line 10

def provider
  @provider
end

#statusObject (readonly)

Returns the value of attribute status.



10
11
12
# File 'lib/simple_connect/responses/verify_response.rb', line 10

def status
  @status
end

Instance Method Details

#connected?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/simple_connect/responses/verify_response.rb', line 20

def connected?
  @status == "connected"
end

#event_flow(event_key) ⇒ Object



24
25
26
27
# File 'lib/simple_connect/responses/verify_response.rb', line 24

def event_flow(event_key)
  key = event_key.to_s
  @event_flows.find { |f| f.event_key == key }
end

#to_hObject



29
30
31
# File 'lib/simple_connect/responses/verify_response.rb', line 29

def to_h
  @json.dup
end