Class: Gmail
- Inherits:
-
Object
- Object
- Gmail
- Defined in:
- lib/gmail.rb
Constant Summary collapse
- OOB_URI =
'urn:ietf:wg:oauth:2.0:oob'- APPLICATION_NAME =
'Lita Kintai'- CLIENT_SECRETS_PATH =
'client_secret.json'- CREDENTIALS_PATH =
File.join(Dir.home, '.credentials', "lita-kintai.yaml")
- SCOPE =
[Google::Apis::GmailV1::AUTH_GMAIL_READONLY, Google::Apis::GmailV1::AUTH_GMAIL_SEND]
- USER_ID =
'default'
Class Method Summary collapse
- .authorization_url ⇒ Object
- .authorized? ⇒ Boolean
- .credentials_from_code(code) ⇒ Object
- .find_mail(query) ⇒ Object
- .send_message(mail) ⇒ Object
Class Method Details
.authorization_url ⇒ Object
25 26 27 |
# File 'lib/gmail.rb', line 25 def self. .(base_url: OOB_URI) end |
.authorized? ⇒ Boolean
16 17 18 |
# File 'lib/gmail.rb', line 16 def self. !service.nil? && !service..nil? end |
.credentials_from_code(code) ⇒ Object
20 21 22 23 |
# File 'lib/gmail.rb', line 20 def self.credentials_from_code(code) .get_and_store_credentials_from_code( user_id: USER_ID, code: code, base_url: OOB_URI) end |
.find_mail(query) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/gmail.rb', line 29 def self.find_mail(query) ids = service.('me', q: query) return [] unless ids. ids..map do || find_mail_by_id(.id) end end |
.send_message(mail) ⇒ Object
38 39 40 41 |
# File 'lib/gmail.rb', line 38 def self.(mail) = Google::Apis::GmailV1::Message.new(raw: mail.to_s ) result = service.('me', ) end |