Class: ContextIO::EmailSettings

Inherits:
Object
  • Object
show all
Defined in:
lib/contextio/email_settings.rb

Overview

Represents the IMAP settings for a given email address. The API documentation refers to this as 'discovery'. This process is hit-and-miss. If noting is found, many attributes are likely to be nil and blank. Check EmailSettings#found?.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api, email, source_type = 'IMAP') ⇒ EmailSettings

Returns a new instance of EmailSettings.

Parameters:

  • email (String)

    The email address to fetch the settings for.

  • source_type (String) (defaults to: 'IMAP')

    The only source type currently supported by the API is 'IMAP'.



47
48
49
50
51
# File 'lib/contextio/email_settings.rb', line 47

def initialize(api, email, source_type = 'IMAP')
  @api = api
  @email = email
  @source_type = source_type
end

Instance Attribute Details

#documentationArray<String> (readonly)

Returns A list of documentation pages that pertain to the provider. Will fetch from the API if necessary.

Returns:

  • (Array<String>)

    A list of documentation pages that pertain to the provider. Will fetch from the API if necessary.



24
25
26
27
28
29
30
# File 'lib/contextio/email_settings.rb', line 24

def documentation
  return @documentation if instance_variable_defined?(:@documentation)

  fetch_attributes

  @documentation
end

#emailString (readonly)

Returns The email address associated with these IMAP settings.

Returns:

  • (String)

    The email address associated with these IMAP settings.



34
35
36
# File 'lib/contextio/email_settings.rb', line 34

def email
  @email
end

#found?Boolean (readonly)

Returns Whether the settings were able to be fetched. Will fetch from the API if necessary.

Returns:

  • (Boolean)

    Whether the settings were able to be fetched. Will fetch from the API if necessary.



62
63
64
# File 'lib/contextio/email_settings.rb', line 62

def found?
  found
end

#oauth?Boolean (readonly)

Returns Whether the IMAP server supports OAuth or not. Will fetch from the API if necessary.

Returns:

  • (Boolean)

    Whether the IMAP server supports OAuth or not. Will fetch from the API if necessary.



90
91
92
# File 'lib/contextio/email_settings.rb', line 90

def oauth?
  !!imap['oauth']
end

#portInteger (readonly)

Returns The network port the IMAP server is listening on. Will fetch from the API if necessary.

Returns:

  • (Integer)

    The network port the IMAP server is listening on. Will fetch from the API if necessary.



83
84
85
# File 'lib/contextio/email_settings.rb', line 83

def port
  imap['port']
end

#resource_urlString (readonly)

Returns The path for discovering email settings.

Returns:

  • (String)

    The path for discovering email settings.



55
56
57
# File 'lib/contextio/email_settings.rb', line 55

def resource_url
  'discovery'
end

#serverString (readonly)

Returns FQDN of the IMAP server. Will fetch from the API if necessary.

Returns:

  • (String)

    FQDN of the IMAP server. Will fetch from the API if necessary.



69
70
71
# File 'lib/contextio/email_settings.rb', line 69

def server
  imap['server']
end

#source_typeString (readonly)

Returns The only source type currently supported by the API is 'IMAP'.

Returns:

  • (String)

    The only source type currently supported by the API is 'IMAP'.



34
35
36
# File 'lib/contextio/email_settings.rb', line 34

def source_type
  @source_type
end

#typeString (readonly)

Returns The type og the provider (like 'gmail'). Will fetch from the API if necessary.

Returns:

  • (String)

    The type og the provider (like 'gmail'). Will fetch from the API if necessary.



13
14
15
16
17
18
19
# File 'lib/contextio/email_settings.rb', line 13

def type
  return @type if instance_variable_defined?(:@type)

  fetch_attributes

  @type
end

#use_ssl?Boolean (readonly)

Returns Whether the IMAP server uses SSL for connections. Will fetch from the API if necessary.

Returns:

  • (Boolean)

    Whether the IMAP server uses SSL for connections. Will fetch from the API if necessary.



97
98
99
# File 'lib/contextio/email_settings.rb', line 97

def use_ssl?
  !!imap['use_ssl']
end

#usernameString (readonly)

Returns The username for authentication purposes. Will fetch from the API if necessary.

Returns:

  • (String)

    The username for authentication purposes. Will fetch from the API if necessary.



76
77
78
# File 'lib/contextio/email_settings.rb', line 76

def username
  imap['username']
end