Class: Mobiscroll::Connect::ConnectionStatus

Inherits:
Struct
  • Object
show all
Defined in:
lib/mobiscroll/connect/models.rb

Overview

Result of Auth#get_connection_status. connections is keyed by lowercase provider name to match the API wire form.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#connectionsObject

Returns the value of attribute connections

Returns:

  • (Object)

    the current value of connections



77
78
79
# File 'lib/mobiscroll/connect/models.rb', line 77

def connections
  @connections
end

#limit_reachedObject

Returns the value of attribute limit_reached

Returns:

  • (Object)

    the current value of limit_reached



77
78
79
# File 'lib/mobiscroll/connect/models.rb', line 77

def limit_reached
  @limit_reached
end

Class Method Details

.from_h(hash) ⇒ Object



78
79
80
81
82
83
84
85
86
# File 'lib/mobiscroll/connect/models.rb', line 78

def self.from_h(hash)
  return new(connections: {}, limit_reached: false) if hash.nil?

  raw = hash['connections'] || hash[:connections] || {}
  connections = raw.each_with_object({}) do |(provider, accounts), acc|
    acc[provider.to_s] = Array(accounts).map { |a| ConnectedAccount.from_h(a) }
  end
  new(connections: connections, limit_reached: hash['limitReached'] || hash[:limitReached] || false)
end