Class: Inbox::Draft

Inherits:
Message show all
Defined in:
lib/draft.rb

Instance Attribute Summary collapse

Attributes inherited from Message

#bcc, #body, #cc, #date, #file_ids, #from, #subject, #to

Attributes inherited from RestfulModel

#created_at, #id, #namespace_id

Instance Method Summary collapse

Methods inherited from Message

#files, #inflate

Methods inherited from RestfulModel

#==, #as_json, collection_name, #destroy, #inflate, #initialize, #save!, #update, #url

Constructor Details

This class inherits a constructor from Inbox::RestfulModel

Instance Attribute Details

#stateObject

Returns the value of attribute state.



8
9
10
# File 'lib/draft.rb', line 8

def state
  @state
end

#thread_idObject

Returns the value of attribute thread_id.



6
7
8
# File 'lib/draft.rb', line 6

def thread_id
  @thread_id
end

#versionObject

Returns the value of attribute version.



7
8
9
# File 'lib/draft.rb', line 7

def version
  @version
end

Instance Method Details

#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



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/draft.rb', line 15

def send!
  save! unless @id

  url = @_api.url_for_path("/n/#{@namespace_id}/send")
  data = {:draft_id => @id, :version => @version}

  ::RestClient.post(url, data.to_json, :content_type => :json) do |response, request, result|
    Inbox.interpret_response(result, response, :expected_class => Object)
  end

  self
end