Sha256: b599bc5a6db24282be6b0a9b20dce1694d3be521929ffc1905acfc4f1c63eed3

Contents?: true

Size: 944 Bytes

Versions: 5

Compression:

Stored size: 944 Bytes

Contents

module Howitzer
  module GmailApi
    # A GmailApi::Client object is used to communicate with the Gmail API.
    class Client
      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
      load_gmail_gem!

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

      # Finds message according to given parameters
      #
      # @param recipient [String] this is recipient mail address for message filtering
      # @param subject [String] this is subject of the message to filter particular message
      # @return [Gmail::Message] gmail message object

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

      private

      attr_accessor :client
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
howitzer-2.6.1 lib/howitzer/gmail_api/client.rb
howitzer-2.6.0 lib/howitzer/gmail_api/client.rb
howitzer-2.5.0 lib/howitzer/gmail_api/client.rb
howitzer-2.4.0 lib/howitzer/gmail_api/client.rb
howitzer-2.3.0 lib/howitzer/gmail_api/client.rb