Class: GmailApiJp::Draft
- Inherits:
-
Object
- Object
- GmailApiJp::Draft
- Defined in:
- lib/gmail_api_jp.rb
Constant Summary collapse
- CONFIG =
YAML.load_file("gmail_draft.yml")
- OOB_URI =
'urn:ietf:wg:oauth:2.0:oob'- APPLICATION_NAME =
CONFIG["application_name"]
- CLIENT_SECRETS_PATH =
CONFIG["client_secrets_path"] || "client_secret.json"
- CREDENTIALS_PATH =
CONFIG["stored_credential_path"] || File.join(Dir.home, '.credentials', "gmail-draft-jp.yaml")
- SCOPE =
CONFIG["scope"] || "https://mail.google.com/"
Instance Method Summary collapse
- #create_draft ⇒ Object
-
#initialize(text) ⇒ Draft
constructor
the argument text should be like:.
Constructor Details
#initialize(text) ⇒ Draft
the argument text should be like:
Subject: Hello
Lorem ipsum dolor sit amet,
consectetur adipiscing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
27 28 29 30 31 32 |
# File 'lib/gmail_api_jp.rb', line 27 def initialize(text) @service = Google::Apis::GmailV1::GmailService.new @service..application_name = APPLICATION_NAME @service. = @text = text.encode("ISO-2022-JP") end |
Instance Method Details
#create_draft ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/gmail_api_jp.rb', line 34 def create_draft user_id = 'me' draft = Google::Apis::GmailV1::Draft.new = Google::Apis::GmailV1::Message.new .raw = @text draft. = @service.create_user_draft(user_id, draft) puts "====== Draft created =====" end |