Class: Howitzer::GmailApi::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/howitzer/gmail_api/client.rb

Overview

A GmailApi::Client object is used to communicate with the Gmail API.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeClient

Returns a new instance of Client.


12
13
14
# File 'lib/howitzer/gmail_api/client.rb', line 12

def initialize
  self.client = Gmail.connect(Howitzer., Howitzer.gmail_password)
end

Class Method Details

.load_gmail_gem!Object


5
6
7
8
9
# File 'lib/howitzer/gmail_api/client.rb', line 5

def self.load_gmail_gem!
  require 'gmail'
rescue LoadError
  raise LoadError, "Unable to load `gmail` library, please add following code to your Gemfile:\n\ngem 'gmail'"
end

Instance Method Details

#find_message(recipient, subject) ⇒ Gmail::Message

Finds message according to given parameters

Parameters:

  • recipient (String)

    this is recipient mail address for message filtering

  • subject (String)

    this is subject of the message to filter particular message

Returns:

  • (Gmail::Message)

    gmail message object


22
23
24
# File 'lib/howitzer/gmail_api/client.rb', line 22

def find_message(recipient, subject)
  client.inbox.emails(to: recipient, subject: subject).last
end