google_apps 0.4.9.1 → 0.4.9.2
Sign up to get free protection for your applications and to get access to all the features.
@@ -49,9 +49,10 @@ module GoogleApps
|
|
49
49
|
map = Atom::MAPS[map_key]
|
50
50
|
|
51
51
|
@document.root.each do |entry|
|
52
|
-
|
53
|
-
|
54
|
-
|
52
|
+
intersect = map.keys & entry.attributes.to_h.keys.map(&:to_sym)
|
53
|
+
unless intersect.empty?
|
54
|
+
intersect.each do |attribute|
|
55
|
+
instance_variable_set "@#{map[attribute]}", check_value(entry.attributes[attribute])
|
55
56
|
end
|
56
57
|
end
|
57
58
|
end
|
@@ -112,7 +113,7 @@ module GoogleApps
|
|
112
113
|
ns[:gd] = Atom::NAMESPACES[:gd]
|
113
114
|
end
|
114
115
|
|
115
|
-
ns
|
116
|
+
ns
|
116
117
|
end
|
117
118
|
end
|
118
119
|
end
|
@@ -1,13 +1,22 @@
|
|
1
1
|
module GoogleApps
|
2
2
|
module Atom
|
3
3
|
class MessageAttributes
|
4
|
+
include Document
|
5
|
+
include Node
|
6
|
+
|
4
7
|
attr_reader :labels
|
5
8
|
attr_accessor :property
|
6
9
|
|
7
|
-
def initialize
|
8
|
-
|
9
|
-
|
10
|
-
|
10
|
+
def initialize(xml = nil)
|
11
|
+
if xml
|
12
|
+
@document = parse(xml)
|
13
|
+
find_labels
|
14
|
+
get_item_property
|
15
|
+
else
|
16
|
+
@labels = []
|
17
|
+
@document = Atom::XML::Document.new
|
18
|
+
set_header
|
19
|
+
end
|
11
20
|
end
|
12
21
|
|
13
22
|
def add_property(prop)
|
@@ -69,6 +78,14 @@ module GoogleApps
|
|
69
78
|
|
70
79
|
header
|
71
80
|
end
|
81
|
+
|
82
|
+
def find_labels
|
83
|
+
@labels = @document.find('//apps:label').inject([]) { |labels, entry| labels << entry.attributes['labelName']; labels }
|
84
|
+
end
|
85
|
+
|
86
|
+
def get_item_property
|
87
|
+
@property = @document.find('//apps:mailItemProperty').first.attributes['value']
|
88
|
+
end
|
72
89
|
end
|
73
90
|
end
|
74
91
|
end
|
@@ -15,13 +15,16 @@ module GoogleApps
|
|
15
15
|
}
|
16
16
|
|
17
17
|
def initialize(domain, targets = {})
|
18
|
+
@feeds_root = 'https://apps-apis.google.com/a/feeds'
|
18
19
|
@auth = targets[:auth] || "https://www.google.com/accounts/ClientLogin"
|
19
|
-
@user = targets[:user] || "
|
20
|
-
@pubkey = targets[:pubkey] || "
|
21
|
-
@migration = targets[:migration] || "
|
22
|
-
@group = targets[:group] || "
|
23
|
-
@nickname = targets[:nickname] || "
|
24
|
-
@
|
20
|
+
@user = targets[:user] || "#{@feeds_root}/#{domain}/user/2.0"
|
21
|
+
@pubkey = targets[:pubkey] || "#{@feeds_root}/compliance/audit/publickey/#{domain}"
|
22
|
+
@migration = targets[:migration] || "#{@feeds_root}/migration/2.0/#{domain}"
|
23
|
+
@group = targets[:group] || "#{@feeds_root}/group/2.0/#{domain}"
|
24
|
+
@nickname = targets[:nickname] || "#{@feeds_root}/#{domain}/nickname/2.0"
|
25
|
+
@audit = "#{@feeds_root}/compliance/audit/mail"
|
26
|
+
@export = targets[:export] || "#{@audit}/export/#{domain}"
|
27
|
+
@monitor = targets[:monitor] || "#{@audit}/monitor/#{domain}"
|
25
28
|
@domain = domain
|
26
29
|
@requester = AppsRequest || targets[:requester]
|
27
30
|
@doc_handler = DocumentHandler.new format: (targets[:format] || :atom)
|
@@ -61,8 +64,9 @@ module GoogleApps
|
|
61
64
|
def request_export(username, document)
|
62
65
|
result = add(@export + "/#{username}", :export_response, document)
|
63
66
|
|
64
|
-
|
65
|
-
|
67
|
+
result.find('//apps:property').inject(nil) do |request_id, node|
|
68
|
+
node.attributes['name'] == 'requestId' ? node.attributes['value'].to_i : request_id
|
69
|
+
end
|
66
70
|
end
|
67
71
|
|
68
72
|
|
@@ -182,7 +186,7 @@ module GoogleApps
|
|
182
186
|
options[:limit] ? limit = options[:limit] : limit = 1000000
|
183
187
|
options[:start] ? get(instance_variable_get("@#{type}") + "?#{start_query(type)}=#{options[:start]}", :feed) : get(instance_variable_get("@#{type}"), :feed)
|
184
188
|
|
185
|
-
fetch_feed(page, limit)
|
189
|
+
fetch_feed(page, limit, :feed)
|
186
190
|
|
187
191
|
@response
|
188
192
|
end
|
@@ -379,20 +383,20 @@ module GoogleApps
|
|
379
383
|
|
380
384
|
|
381
385
|
# get_next_page retrieves the next page in the response.
|
382
|
-
def get_next_page
|
383
|
-
get @feeds.last.next_page
|
386
|
+
def get_next_page(type)
|
387
|
+
get @feeds.last.next_page, type
|
384
388
|
add_feed
|
385
389
|
end
|
386
390
|
|
387
391
|
|
388
392
|
# fetch_feed retrieves the remaining pages in the request.
|
389
393
|
# It takes a page and a limit as arguments.
|
390
|
-
def fetch_feed(page, limit)
|
394
|
+
def fetch_feed(page, limit, type)
|
391
395
|
add_feed
|
392
396
|
page += 1
|
393
397
|
|
394
398
|
while (@feeds.last.next_page) and (page * PAGE_SIZE[:user] < limit)
|
395
|
-
get_next_page
|
399
|
+
get_next_page type
|
396
400
|
page += 1
|
397
401
|
end
|
398
402
|
end
|
@@ -421,16 +425,6 @@ module GoogleApps
|
|
421
425
|
@feeds << GoogleApps::Atom.feed(@response.body)
|
422
426
|
end
|
423
427
|
|
424
|
-
# get_values returns an array of all the value attributes
|
425
|
-
# on elements matching the given key_attrib pair on the
|
426
|
-
# specified element type.
|
427
|
-
def get_values(document, element, key_attrib, value = 'value')
|
428
|
-
document.find('//' + element).inject([]) do |values, element|
|
429
|
-
values << element.attributes[value] if element.attributes[key_attrib[0]].match key_attrib[1]
|
430
|
-
values
|
431
|
-
end
|
432
|
-
end
|
433
|
-
|
434
428
|
|
435
429
|
def headers(category)
|
436
430
|
case category
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google_apps
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.9.
|
4
|
+
version: 0.4.9.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-08-
|
12
|
+
date: 2012-08-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: libxml-ruby
|