Class: Nylas::Draft
- Inherits:
-
Object
show all
- Includes:
- Model
- Defined in:
- lib/nylas/draft.rb
Overview
Ruby representatin of a Nylas Draft object
Instance Attribute Summary
Attributes included from Model
#api
Instance Method Summary
collapse
Methods included from Model
#execute, included, #model_class, #persisted?, #reload, #resource_path, #resources_path, #save_all_attributes, #to_json, #update_all_attributes
Instance Method Details
#create ⇒ Object
54
55
56
57
58
|
# File 'lib/nylas/draft.rb', line 54
def create
super
end
|
#destroy ⇒ Object
76
77
78
|
# File 'lib/nylas/draft.rb', line 76
def destroy
execute(method: :delete, path: resource_path, payload: attributes.serialize_for_api(keys: [:version]))
end
|
#save ⇒ Object
80
81
82
83
84
|
# File 'lib/nylas/draft.rb', line 80
def save
super
end
|
#send! ⇒ Object
60
61
62
63
64
65
66
|
# File 'lib/nylas/draft.rb', line 60
def send!
return execute(method: :post, path: "/send", payload: to_json) unless id
data = { draft_id: id, version: version }
data[:tracking] = tracking.to_h if tracking
execute(method: :post, path: "/send", payload: JSON.dump(data))
end
|
#starred? ⇒ Boolean
68
69
70
|
# File 'lib/nylas/draft.rb', line 68
def starred?
starred
end
|
#unread? ⇒ Boolean
72
73
74
|
# File 'lib/nylas/draft.rb', line 72
def unread?
unread
end
|
#update(**data) ⇒ Object
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/nylas/draft.rb', line 43
def update(**data)
self.files = data[:files] if data[:files]
data[:file_ids] = file_ids
data[:version] = version unless data[:version]
super
end
|