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
#auth_method, #execute, included, #model_class, #persisted?, #reload, #resource_path, #resources_path, #save_all_attributes, #to_json, #update_all_attributes
Instance Method Details
#create ⇒ Object
60
61
62
63
64
|
# File 'lib/nylas/draft.rb', line 60
def create
super
end
|
#destroy ⇒ Object
82
83
84
|
# File 'lib/nylas/draft.rb', line 82
def destroy
execute(method: :delete, path: resource_path, payload: attributes.serialize_for_api(keys: [:version]))
end
|
#save ⇒ Object
86
87
88
89
90
|
# File 'lib/nylas/draft.rb', line 86
def save
super
end
|
#send! ⇒ Object
66
67
68
69
70
71
72
|
# File 'lib/nylas/draft.rb', line 66
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
74
75
76
|
# File 'lib/nylas/draft.rb', line 74
def starred?
starred
end
|
#unread? ⇒ Boolean
78
79
80
|
# File 'lib/nylas/draft.rb', line 78
def unread?
unread
end
|
#update(**data) ⇒ Object
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/nylas/draft.rb', line 49
def update(**data)
self.files = data[:files] if data[:files]
data[:file_ids] = file_ids
data[:version] = version unless data[:version]
super
end
|