Class: ContextIO::ContextIO
Instance Attribute Summary collapse
Instance Method Summary
collapse
#build_url, #call_api_return_new_object, #call_api_return_updated_object, #delete, #get, #get_request, #parse_response, #return_post_api_call_made, #success?, #validate_params
#collection_return, #contact_collection_return
Constructor Details
#initialize(key:, secret:) ⇒ ContextIO
Returns a new instance of ContextIO.
33
34
35
36
|
# File 'lib/context_io.rb', line 33
def initialize(key:, secret:)
@connection = Connection.new(key, secret)
@call_url = "/2.0"
end
|
Instance Attribute Details
#call_url ⇒ Object
Returns the value of attribute call_url.
32
33
34
|
# File 'lib/context_io.rb', line 32
def call_url
@call_url
end
|
#connection ⇒ Object
Returns the value of attribute connection.
32
33
34
|
# File 'lib/context_io.rb', line 32
def connection
@connection
end
|
Instance Method Details
#discovery(email:) ⇒ Object
70
71
72
|
# File 'lib/context_io.rb', line 70
def discovery(email:)
Discovery.new(parent: self, email: email).get
end
|
#get_accounts(**kwargs) ⇒ Object
38
39
40
41
42
43
|
# File 'lib/context_io.rb', line 38
def get_accounts(**kwargs)
collection_return(url: "#{call_url}/accounts",
klass: Account,
valid_params: ValidGetParams::ACCOUNTS,
given_params: kwargs)
end
|
#get_connect_tokens ⇒ Object
55
56
57
58
|
# File 'lib/context_io.rb', line 55
def get_connect_tokens
collection_return(url: "#{call_url}/connect_tokens",
klass: ConnectToken)
end
|
#get_oauth_providers ⇒ Object
74
75
76
77
|
# File 'lib/context_io.rb', line 74
def get_oauth_providers
collection_return(url: "#{call_url}/oauth_providers",
klass: OauthProvider)
end
|
#get_webhooks ⇒ Object
89
90
91
92
|
# File 'lib/context_io.rb', line 89
def get_webhooks
collection_return(url: "#{call_url}/webhooks",
klass: Webhook)
end
|
#post_account(type: "IMAP", **kwargs) ⇒ Object
45
46
47
48
49
50
51
52
53
|
# File 'lib/context_io.rb', line 45
def post_account(type: "IMAP", **kwargs)
given_params = kwargs.merge(type: type)
account = call_api_return_new_object(klass: Account,
url: "#{call_url}/accounts",
method: :post,
valid_params: ValidPostParams::ACCOUNTS,
given_params: given_params)
return_post_api_call_made(account)
end
|
#post_connect_token(callback_url:, **kwargs) ⇒ Object
60
61
62
63
64
65
66
67
68
|
# File 'lib/context_io.rb', line 60
def post_connect_token(callback_url: , **kwargs)
given_params = kwargs.merge(callback_url: callback_url)
token = call_api_return_new_object(klass: ConnectToken,
url: "#{call_url}/connect_tokens",
method: :post,
valid_params: ValidPostParams::CONNECT_TOKEN,
given_params: given_params)
return_post_api_call_made(token)
end
|
#post_oauth_provider(type:, provider_consumer_key:, provider_consumer_secret:) ⇒ Object
79
80
81
82
83
84
85
86
87
|
# File 'lib/context_io.rb', line 79
def post_oauth_provider(type:, provider_consumer_key:, provider_consumer_secret:)
given_params = [type, provider_consumer_key, provider_consumer_secret]
provider = call_api_return_new_object(klass: OauthProvider,
url: "#{call_url}/oauth_provider",
method: :post,
valid_params: ValidPostParams::OAUTH_PROVIDER,
given_params: given_params)
return_post_api_call_made(provider)
end
|
#post_webhook(callback_url:, **kwargs) ⇒ Object
94
95
96
97
98
99
100
101
102
|
# File 'lib/context_io.rb', line 94
def post_webhook(callback_url:, **kwargs)
given_params = kwargs.merge(callback_url: callback_url)
token = call_api_return_new_object(klass: Webhook,
url: "#{call_url}/webhooks",
method: :post,
valid_params: ValidPostParams::WEBHOOK,
given_params: given_params)
return_post_api_call_made(token)
end
|