This repository has been archived by the owner on May 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
/
connector.rb
82 lines (66 loc) · 2.06 KB
/
connector.rb
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
77
78
79
80
81
82
#
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. Licensed under the Elastic License;
# you may not use this file except in compliance with the Elastic License.
#
# frozen_string_literal: true
require 'connectors_sdk/base/connector'
require 'connectors_sdk/office365/config'
require 'connectors_sdk/share_point/extractor'
require 'connectors_sdk/share_point/authorization'
module ConnectorsSdk
module SharePoint
class Connector < ConnectorsSdk::Base::Connector
SERVICE_TYPE = 'share_point'
def compare_secrets(params)
missing_secrets?(params)
previous_user = client(:access_token => params[:other_secret][:access_token]).me
equivalent = previous_user.nil? ? false : previous_user.id == client(:access_token => params[:secret][:access_token]).me&.id
{
:equivalent => equivalent
}
end
def display_name
'SharePoint Online'
end
def connection_requires_redirect
true
end
def configurable_fields
[
{
'key' => 'client_id',
'label' => 'Client ID'
},
{
'key' => 'client_secret',
'label' => 'Client Secret'
},
]
end
private
def extractor_class
ConnectorsSdk::SharePoint::Extractor
end
def authorization
ConnectorsSdk::SharePoint::Authorization
end
def client(params)
ConnectorsSdk::Office365::CustomClient.new(:access_token => params[:access_token], :cursors => params.fetch(:cursors, {}) || {})
end
def custom_client_error
ConnectorsSdk::Office365::CustomClient::ClientError
end
def config(params)
ConnectorsSdk::Office365::Config.new(
:cursors => params.fetch(:cursors, {}) || {},
:drive_ids => 'all',
:index_permissions => params[:index_permissions] || false
)
end
def health_check(params)
client(params).me
end
end
end
end