google_apps 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,26 +6,75 @@ module GoogleApps
6
6
  set_header
7
7
  end
8
8
 
9
+ # to_s returns @document as a string.
9
10
  def to_s
10
11
  @document.to_s
11
12
  end
12
13
 
14
+ # start_date specifies a start date for the extract.
15
+ # Matching results that occurred before this date will
16
+ # not be included in the result set. start_date takes
17
+ # a string as an argument, the format is as follows:
18
+ #
19
+ # 'yyyy-MM-dd HH:mm' where yyyy is the four digit year,
20
+ # MM is the two digit month, dd is the two digit day,
21
+ # HH is the hour of the day 0-23 and mm is the minute
22
+ # 0-59
23
+ #
24
+ # start_date '2012-01-01 00:00'
25
+ #
26
+ # start_date returns @document.root
13
27
  def start_date(date)
14
28
  add_prop('beginDate', date)
15
29
  end
16
30
 
31
+ # end_date specifies an end date for the extract.
32
+ # Matching results that occurred past this date will
33
+ # not be included in the result set. end_date takes
34
+ # a string as an argument, the format is as follows:
35
+ #
36
+ # 'yyyy-MM-dd HH:mm' where yyyy is the four digit year,
37
+ # MM is the two digit month, dd is the two digit day,
38
+ # HH is the hour of the day 0-23 and mm is the minute
39
+ # 0-59
40
+ #
41
+ # end_date '2012-01-01 08:30'
42
+ #
43
+ # end_date returns @document.root
17
44
  def end_date(date)
18
45
  add_prop('endDate', date)
19
46
  end
20
47
 
48
+ # include_deleted will specify that matches which
49
+ # have been deleted should be returned as well.
50
+ # The default is to omit deleted matches.
51
+ #
52
+ # include_deleted
53
+ #
54
+ # include_deleted returns @document.root
21
55
  def include_deleted
22
56
  add_prop('includeDeleted', 'true')
23
57
  end
24
58
 
59
+ # query specifies a query string to be used when
60
+ # filtering the messages to be returned. You can
61
+ # use any string that you could use in Google's
62
+ # Advanced Search interface.
63
+ #
64
+ # query 'from: Bob'
65
+ #
66
+ # query returns @document.root
25
67
  def query(query_string)
26
68
  add_prop('searchQuery', query_string)
27
69
  end
28
70
 
71
+ # content specifies the data to be returned in the
72
+ # mailbox export. There are two valid arguments:
73
+ # 'FULL_MESSAGE' or 'HEADER_ONLY'
74
+ #
75
+ # content 'HEADER_ONLY'
76
+ #
77
+ # content returns @document.root
29
78
  def content(type)
30
79
  add_prop('packageContent', type)
31
80
  end
@@ -33,6 +82,9 @@ module GoogleApps
33
82
 
34
83
  private
35
84
 
85
+ # set_header adds the appropriate XML boilerplate for
86
+ # a mailbox extract as specified by the GoogleApps
87
+ # Email Audit API.
36
88
  def set_header
37
89
  @document.root = Atom::XML::Node.new 'atom:entry'
38
90
 
@@ -40,6 +92,8 @@ module GoogleApps
40
92
  Atom::XML::Namespace.new(@document.root, 'apps', 'http://schemas.google.com/apps/2006')
41
93
  end
42
94
 
95
+ # add_prop adds an element of the type: apps:property
96
+ # to the extract document.
43
97
  def add_prop(name, value)
44
98
  prop = Atom::XML::Node.new('apps:property')
45
99
  prop['name'] = name
@@ -81,8 +81,9 @@ module GoogleApps
81
81
  (@response = request(uri)).body
82
82
  end
83
83
 
84
- def fetch_export(flename) # :nodoc:
84
+ def fetch_export(username, req_id, filename) # :nodoc:
85
85
  # TODO: Shouldn't rely on export_status being run first. Self, this is lazy and stupid.
86
+ export_status(username, req_id)
86
87
  doc = REXML::Document.new(@response.body)
87
88
  urls = []
88
89
  doc.elements.each('entry/apps:property') do |property|
@@ -90,7 +91,7 @@ module GoogleApps
90
91
  end
91
92
 
92
93
  urls.each do |url|
93
- download(url, filename)
94
+ download(url, filename + "#{urls.index[url]}")
94
95
  end
95
96
  end
96
97
 
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.3.1
4
+ version: 0.3.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: