microslop_one_drive 5.1.0 → 5.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/microslop_one_drive/client.rb +7 -6
- data/lib/microslop_one_drive/deserializers/granted_to_deserializer.rb +3 -0
- data/lib/microslop_one_drive/deserializers/permission_deserializer.rb +1 -1
- data/lib/microslop_one_drive/endpoints/revoke_grants.rb +5 -1
- data/lib/microslop_one_drive/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1260d248788e7480366222b43716bdcfd51694eb2da87d192c533bcdc064401f
|
|
4
|
+
data.tar.gz: 8bfab49dad19e8a720856977873f1f4ccf7aef70716dfe5e104dc0e7038837b3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 75d5f9f86a4a9d31ce34720517e2cb72d735cdcb4ab5c04751c48229549b4f7e1e495006135b38823c104b95353a79a1b156ab618de176f6a25fc0b1ffd0736b
|
|
7
|
+
data.tar.gz: ec1b7ccfa3bd4fca6212fab4f79ea190b975930f41475457f3b8e35c1154dd06467db57fbc5e9224c059aff20466336ae129adf31f305d840e5aa34e9fe7eaf5
|
|
@@ -3,6 +3,7 @@ require "json"
|
|
|
3
3
|
module MicroslopOneDrive
|
|
4
4
|
class Client
|
|
5
5
|
BASE_URL = "https://graph.microsoft.com/v1.0".freeze
|
|
6
|
+
BETA_BASE_URL = "https://graph.microsoft.com/beta".freeze
|
|
6
7
|
|
|
7
8
|
include Endpoints::Me
|
|
8
9
|
include Endpoints::Drive
|
|
@@ -34,8 +35,8 @@ module MicroslopOneDrive
|
|
|
34
35
|
|
|
35
36
|
private
|
|
36
37
|
|
|
37
|
-
def get(path:, query: {})
|
|
38
|
-
url = "#{
|
|
38
|
+
def get(path:, query: {}, base_url: BASE_URL)
|
|
39
|
+
url = "#{base_url}/#{path}"
|
|
39
40
|
log_request("GET", url, query: query)
|
|
40
41
|
|
|
41
42
|
response = HTTParty.get(url, headers: @headers, query: query)
|
|
@@ -44,8 +45,8 @@ module MicroslopOneDrive
|
|
|
44
45
|
response
|
|
45
46
|
end
|
|
46
47
|
|
|
47
|
-
def post(path:, body:)
|
|
48
|
-
url = "#{
|
|
48
|
+
def post(path:, body:, base_url: BASE_URL)
|
|
49
|
+
url = "#{base_url}/#{path}"
|
|
49
50
|
log_request("POST", url, body: body)
|
|
50
51
|
|
|
51
52
|
response = HTTParty.post(url, headers: @headers, body: body)
|
|
@@ -54,8 +55,8 @@ module MicroslopOneDrive
|
|
|
54
55
|
response
|
|
55
56
|
end
|
|
56
57
|
|
|
57
|
-
def delete(path:)
|
|
58
|
-
url = "#{
|
|
58
|
+
def delete(path:, base_url: BASE_URL)
|
|
59
|
+
url = "#{base_url}/#{path}"
|
|
59
60
|
log_request("DELETE", url, body: nil)
|
|
60
61
|
|
|
61
62
|
response = HTTParty.delete(url, headers: @headers)
|
|
@@ -2,6 +2,9 @@ module MicroslopOneDrive
|
|
|
2
2
|
module Deserializers
|
|
3
3
|
class GrantedToDeserializer
|
|
4
4
|
def self.create_from_hash(granted_to_hash)
|
|
5
|
+
return nil if granted_to_hash.nil?
|
|
6
|
+
return nil if granted_to_hash.empty?
|
|
7
|
+
|
|
5
8
|
granted_to_hash = Utils.deep_symbolize_keys(granted_to_hash)
|
|
6
9
|
|
|
7
10
|
if granted_to_hash.key?(:siteUser)
|
|
@@ -47,7 +47,7 @@ module MicroslopOneDrive
|
|
|
47
47
|
common_parameters = build_common_parameters(permission_hash)
|
|
48
48
|
|
|
49
49
|
granted_to_hash_list = permission_hash.fetch(:grantedToIdentitiesV2, [])
|
|
50
|
-
granted_to_list = granted_to_hash_list.map { GrantedToDeserializer.create_from_hash(it) }
|
|
50
|
+
granted_to_list = granted_to_hash_list.map { GrantedToDeserializer.create_from_hash(it) }.compact
|
|
51
51
|
|
|
52
52
|
has_password = permission_hash.fetch(:hasPassword, false)
|
|
53
53
|
|
|
@@ -19,7 +19,11 @@ module MicroslopOneDrive
|
|
|
19
19
|
def revoke_grants(item_id:, permission_id:, grantees:)
|
|
20
20
|
url = "me/drive/items/#{item_id}/permissions/#{permission_id}/revokeGrants"
|
|
21
21
|
|
|
22
|
-
response = post(
|
|
22
|
+
response = post(
|
|
23
|
+
path: url,
|
|
24
|
+
body: {grantees: grantees}.to_json,
|
|
25
|
+
base_url: MicroslopOneDrive::Client::BETA_BASE_URL
|
|
26
|
+
)
|
|
23
27
|
|
|
24
28
|
return true if response.success?
|
|
25
29
|
|