Class: Mobiscroll::Connect::ConnectedAccount

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

Overview

One connected calendar account.

granted_scopes are the scopes the provider actually granted, which are not necessarily the ones Connect asked for: Google's consent screen lets the user untick the calendar permission and still complete sign-in.

calendar_permission_granted is false for exactly those accounts — connected, but no calendars can be read from them until the user reconnects and allows access. It is nil when the question does not apply (Apple and CalDav authenticate with a username and app password) or no scopes were recorded for the account.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#calendar_permission_grantedObject

Returns the value of attribute calendar_permission_granted

Returns:

  • (Object)

    the current value of calendar_permission_granted



60
61
62
# File 'lib/mobiscroll/connect/models.rb', line 60

def calendar_permission_granted
  @calendar_permission_granted
end

#displayObject

Returns the value of attribute display

Returns:

  • (Object)

    the current value of display



60
61
62
# File 'lib/mobiscroll/connect/models.rb', line 60

def display
  @display
end

#granted_scopesObject

Returns the value of attribute granted_scopes

Returns:

  • (Object)

    the current value of granted_scopes



60
61
62
# File 'lib/mobiscroll/connect/models.rb', line 60

def granted_scopes
  @granted_scopes
end

#idObject

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



60
61
62
# File 'lib/mobiscroll/connect/models.rb', line 60

def id
  @id
end

Class Method Details

.from_h(hash) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/mobiscroll/connect/models.rb', line 61

def self.from_h(hash)
  return nil if hash.nil?

  key = 'calendarPermissionGranted'
  granted = hash.key?(key) ? hash[key] : hash[key.to_sym]
  new(
    id: hash['id'] || hash[:id],
    display: hash['display'] || hash[:display],
    granted_scopes: Array(hash['grantedScopes'] || hash[:grantedScopes]),
    calendar_permission_granted: granted
  )
end