Class: Inbox::Draft
Instance Method Summary
collapse
Methods inherited from Message
#files, #inflate, #raw
#==, collection_name, #destroy, #inflate, #initialize, #save!, #update, #url
#time_attr_accessor
Methods included from Parameters
included, #parameters
Instance Method Details
#as_json(options = {}) ⇒ Object
15
16
17
18
19
20
21
22
|
# File 'lib/draft.rb', line 15
def as_json(options = {})
grandparent = self.class.superclass.superclass
meth = grandparent.instance_method(:as_json)
meth.bind(self).call
end
|
#attach(file) ⇒ Object
10
11
12
13
|
# File 'lib/draft.rb', line 10
def attach(file)
file.save! unless file.id
@file_ids.push(file.id)
end
|
#send! ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/draft.rb', line 24
def send!
url = @_api.url_for_path("/send")
if @id
data = {:draft_id => @id, :version => @version}
else
data = as_json()
end
::RestClient.post(url, data.to_json, :content_type => :json) do |response, request, result|
json = Inbox.interpret_response(result, response, :expected_class => Object)
self.inflate(json)
end
self
end
|