forked from glongman/contextio-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontextio.rb
More file actions
76 lines (68 loc) · 2.7 KB
/
contextio.rb
File metadata and controls
76 lines (68 loc) · 2.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# Provides an object-oriented interface for the Context.IO API.
#
# To use it, you have to [sign up for an account](http://context.io).
#
# Once you have an account, you can create a new `ContextIO` object and interact
# with the API using the methods on that object as a starting point.
class ContextIO
# @private
# Handle for the `API` instance. For internal use only.
attr_reader :api
# Creates a new `ContextIO` instance and makes a new handle for the API.
# This is your entry point to your Context.IO account. For a web app, you
# probably want to instantiate this in some kind of initializer and keep it
# around for the life of the process.
#
# @param [String] key Your OAuth consumer key for your Context.IO account
# @param [String] secret Your OAuth consumer secret for your Context.IO
# account
# @param [Hash] opts Optional options for OAuth connections. ie. :timeout and :open_timeout are supported
def initialize(key, secret, opts={})
@api = API.new(key, secret, opts)
end
# Your entry point for dealing with oauth providers.
#
# @return [OAuthProviderCollection] Allows you to work with the providers for
# your account as a group.
def oauth_providers
OAuthProviderCollection.new(api)
end
# Your entry point for dealing with connect tokens.
#
# @return [ConnectTokenCollection] Allows you to work with the tokens for
# your account as a group.
def connect_tokens
ConnectTokenCollection.new(api)
end
# Your entry point for dealing with accounts.
#
# @return [AccountCollection] Allows you to work with the email accounts for
# your account as a group.
def accounts
AccountCollection.new(api)
end
# Discover the IMAP settings for an email account.
#
# @param [String] email_address The email address in question.
# @param [String] source_type The only source type currently supported by the
# API is 'IMAP'.
#
# @return [EmailSettings] Allows you to inspec the settings for an account's
# IMAP server.
def email_settings_for(email_address, source_type = 'IMAP')
EmailSettings.new(api, email_address, source_type)
end
end
require_relative 'contextio/version'
require_relative 'contextio/api'
require_relative 'contextio/oauth_provider_collection'
require_relative 'contextio/email_settings'
require_relative 'contextio/connect_token_collection'
require_relative 'contextio/account_collection'
require_relative 'contextio/source_collection'
require_relative 'contextio/folder_collection'
require_relative 'contextio/message_collection'
require_relative 'contextio/body_part_collection'
require_relative 'contextio/thread_collection'
require_relative 'contextio/webhook_collection'
require_relative 'contextio/contact_collection'