Class: Leash::Integrations::Gmail

Inherits:
Base
  • Object
show all
Defined in:
lib/leash/integrations/gmail.rb

Overview

‘leash.integrations.gmail` — mirrors TS `leash.integrations.gmail`.

Constant Summary collapse

PROVIDER =
"gmail"

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Leash::Integrations::Base

Instance Method Details

#get_message(message_id, format: "full") ⇒ Object

Parameters:

  • message_id (String)
  • format ('full', 'metadata', 'minimal', 'raw') (defaults to: "full")


27
28
29
# File 'lib/leash/integrations/gmail.rb', line 27

def get_message(message_id, format: "full")
  call("get-message", { "messageId" => message_id, "format" => format })
end

#get_profileObject



55
56
57
# File 'lib/leash/integrations/gmail.rb', line 55

def get_profile
  call("get-profile")
end

#list_labelsObject



51
52
53
# File 'lib/leash/integrations/gmail.rb', line 51

def list_labels
  call("list-labels")
end

#list_messages(query: nil, max_results: nil, label_ids: nil, page_token: nil) ⇒ Object

Parameters:

  • query (String, nil) (defaults to: nil)

    Gmail search query

  • max_results (Integer, nil) (defaults to: nil)
  • label_ids (Array<String>, nil) (defaults to: nil)
  • page_token (String, nil) (defaults to: nil)


15
16
17
18
19
20
21
22
23
# File 'lib/leash/integrations/gmail.rb', line 15

def list_messages(query: nil, max_results: nil, label_ids: nil, page_token: nil)
  params = compact_params(
    "query" => query,
    "maxResults" => max_results,
    "labelIds" => label_ids,
    "pageToken" => page_token
  )
  call("list-messages", params.empty? ? nil : params)
end

#search_messages(query, max_results: nil) ⇒ Object

Parameters:

  • query (String)
  • max_results (Integer, nil) (defaults to: nil)


45
46
47
48
49
# File 'lib/leash/integrations/gmail.rb', line 45

def search_messages(query, max_results: nil)
  params = { "query" => query }
  params["maxResults"] = max_results unless max_results.nil?
  call("search-messages", params)
end

#send_message(to:, subject:, body:, cc: nil, bcc: nil) ⇒ Object

Parameters:

  • to (String)
  • subject (String)
  • body (String)
  • cc (String, nil) (defaults to: nil)
  • bcc (String, nil) (defaults to: nil)


36
37
38
39
40
41
# File 'lib/leash/integrations/gmail.rb', line 36

def send_message(to:, subject:, body:, cc: nil, bcc: nil)
  params = compact_params(
    "to" => to, "subject" => subject, "body" => body, "cc" => cc, "bcc" => bcc
  )
  call("send-message", params)
end