Class: Nylas::Drafts
- Includes:
- ApiOperations::Delete, ApiOperations::Get, ApiOperations::Post, ApiOperations::Put
- Defined in:
- lib/nylas/resources/drafts.rb
Overview
Nylas Drafts API
Instance Method Summary collapse
-
#create(identifier:, request_body:) ⇒ Array(Hash, String)
Create an draft.
-
#destroy(identifier:, draft_id:) ⇒ Array(TrueClass, String)
Delete an draft.
-
#find(identifier:, draft_id:) ⇒ Array(Hash, String)
Return an draft.
-
#list(identifier:, query_params: nil) ⇒ Array(Array(Hash), String, String)
Return all drafts.
-
#send(identifier:, draft_id:) ⇒ Array(Hash, String)
Send an draft.
-
#update(identifier:, draft_id:, request_body:) ⇒ Array(Hash, String)
Update an draft.
Methods inherited from Resource
Constructor Details
This class inherits a constructor from Nylas::Resource
Instance Method Details
#create(identifier:, request_body:) ⇒ Array(Hash, String)
Create an draft.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/nylas/resources/drafts.rb', line 45 def create(identifier:, request_body:) payload = request_body opened_files = [] # Use form data only if the attachment size is greater than 3mb = request_body[:attachments] || request_body["attachments"] || [] = &.sum { || [:size] || 0 } || 0 if >= FileUtils::FORM_DATA_ATTACHMENT_SIZE payload, opened_files = FileUtils.build_form_request(request_body) end response = post( path: "#{api_uri}/v3/grants/#{identifier}/drafts", request_body: payload ) opened_files.each(&:close) response end |
#destroy(identifier:, draft_id:) ⇒ Array(TrueClass, String)
Delete an draft.
102 103 104 105 106 107 108 |
# File 'lib/nylas/resources/drafts.rb', line 102 def destroy(identifier:, draft_id:) _, request_id = delete( path: "#{api_uri}/v3/grants/#{identifier}/drafts/#{draft_id}" ) [true, request_id] end |
#find(identifier:, draft_id:) ⇒ Array(Hash, String)
Return an draft.
32 33 34 35 36 |
# File 'lib/nylas/resources/drafts.rb', line 32 def find(identifier:, draft_id:) get( path: "#{api_uri}/v3/grants/#{identifier}/drafts/#{draft_id}" ) end |
#list(identifier:, query_params: nil) ⇒ Array(Array(Hash), String, String)
Return all drafts.
20 21 22 23 24 25 |
# File 'lib/nylas/resources/drafts.rb', line 20 def list(identifier:, query_params: nil) get_list( path: "#{api_uri}/v3/grants/#{identifier}/drafts", query_params: query_params ) end |
#send(identifier:, draft_id:) ⇒ Array(Hash, String)
Send an draft.
115 116 117 118 119 |
# File 'lib/nylas/resources/drafts.rb', line 115 def send(identifier:, draft_id:) post( path: "#{api_uri}/v3/grants/#{identifier}/drafts/#{draft_id}" ) end |
#update(identifier:, draft_id:, request_body:) ⇒ Array(Hash, String)
Update an draft.
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/nylas/resources/drafts.rb', line 75 def update(identifier:, draft_id:, request_body:) payload = request_body opened_files = [] # Use form data only if the attachment size is greater than 3mb = request_body[:attachments] || request_body["attachments"] || [] = &.sum { || [:size] || 0 } || 0 if >= FileUtils::FORM_DATA_ATTACHMENT_SIZE payload, opened_files = FileUtils.build_form_request(request_body) end response = put( path: "#{api_uri}/v3/grants/#{identifier}/drafts/#{draft_id}", request_body: payload ) opened_files.each(&:close) response end |