Class: Leash::GmailClient
- Inherits:
-
Object
- Object
- Leash::GmailClient
- Defined in:
- lib/leash/gmail.rb
Overview
Client for Gmail operations via the Leash platform proxy.
Not instantiated directly – use Integrations#gmail instead.
Constant Summary collapse
- PROVIDER =
"gmail"
Instance Method Summary collapse
-
#get_message(message_id, format: "full") ⇒ Hash
Get a single message by ID.
-
#initialize(call_fn) ⇒ GmailClient
constructor
private
A new instance of GmailClient.
-
#list_labels ⇒ Hash
List all labels in the user’s mailbox.
-
#list_messages(query: nil, max_results: 20, label_ids: nil, page_token: nil) ⇒ Hash
List messages in the user’s mailbox.
-
#search_messages(query, max_results: 20) ⇒ Hash
Search messages using a Gmail query string.
-
#send_message(to:, subject:, body:, cc: nil, bcc: nil) ⇒ Hash
Send an email message.
Constructor Details
#initialize(call_fn) ⇒ GmailClient
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of GmailClient.
11 12 13 |
# File 'lib/leash/gmail.rb', line 11 def initialize(call_fn) @call = call_fn end |
Instance Method Details
#get_message(message_id, format: "full") ⇒ Hash
Get a single message by ID.
35 36 37 |
# File 'lib/leash/gmail.rb', line 35 def (, format: "full") @call.call(PROVIDER, "get-message", { "messageId" => , "format" => format }) end |
#list_labels ⇒ Hash
List all labels in the user’s mailbox.
66 67 68 |
# File 'lib/leash/gmail.rb', line 66 def list_labels @call.call(PROVIDER, "list-labels", {}) end |
#list_messages(query: nil, max_results: 20, label_ids: nil, page_token: nil) ⇒ Hash
List messages in the user’s mailbox.
22 23 24 25 26 27 28 |
# File 'lib/leash/gmail.rb', line 22 def (query: nil, max_results: 20, label_ids: nil, page_token: nil) params = { "maxResults" => max_results } params["query"] = query if query params["labelIds"] = label_ids if label_ids params["pageToken"] = page_token if page_token @call.call(PROVIDER, "list-messages", params) end |
#search_messages(query, max_results: 20) ⇒ Hash
Search messages using a Gmail query string.
59 60 61 |
# File 'lib/leash/gmail.rb', line 59 def (query, max_results: 20) @call.call(PROVIDER, "search-messages", { "query" => query, "maxResults" => max_results }) end |
#send_message(to:, subject:, body:, cc: nil, bcc: nil) ⇒ Hash
Send an email message.
47 48 49 50 51 52 |
# File 'lib/leash/gmail.rb', line 47 def (to:, subject:, body:, cc: nil, bcc: nil) params = { "to" => to, "subject" => subject, "body" => body } params["cc"] = cc if cc params["bcc"] = bcc if bcc @call.call(PROVIDER, "send-message", params) end |