Class: Nylas::File

Inherits:
RestfulModel show all
Defined in:
lib/file.rb

Instance Attribute Summary

Attributes inherited from RestfulModel

#raw_json

Instance Method Summary collapse

Methods inherited from RestfulModel

#==, #as_json, collection_name, #destroy, #initialize, #update, #url

Methods included from TimeAttrAccessor

#time_attr_accessor

Methods included from Parameters

included, #parameters

Constructor Details

This class inherits a constructor from Nylas::RestfulModel

Instance Method Details

#downloadObject



30
31
32
33
34
35
36
# File 'lib/file.rb', line 30

def download
  download_url = self.url('download')
  ::RestClient.get(download_url) do |response, request, result|
    Nylas.interpret_response(result, response, {:raw_response => true})
    response
  end
end

#inflate(json) ⇒ Object



16
17
18
19
# File 'lib/file.rb', line 16

def inflate(json)
  super
  content_type = json["content-type"] if json["content-type"]
end

#save!Object



21
22
23
24
25
26
27
28
# File 'lib/file.rb', line 21

def save!
  ::RestClient.post(url, {:file => @file}) do |response, request, result|
    json = Nylas.interpret_response(result, response, :expected_class => Object)
    json = json[0] if (json.class == Array)
    inflate(json)
  end
  self
end