Sha256: 2c5f3ff54eb14de6a2d0ba25996bf971390d701b05dcb38837e559cb4b9065c4

Contents?: true

Size: 811 Bytes

Versions: 32

Compression:

Stored size: 811 Bytes

Contents

require 'restclient'

class MLS::Photo < MLS::Resource

  property :id, Fixnum
  property :digest, String
  property :created_at, DateTime
  property :updated_at, DateTime
  property :file_content_type, String
  property :file_name, String
  property :file_size, Fixnum
  property :url_template, String
  property :caption, String

  def url(style='700x467#', protocol='http')
    "#{protocol}://#{MLS.image_host}/#{digest}.jpg?s=#{URI.escape(style)}"
  end

  def self.create(attrs)
    attrs[:file].rewind
    url = MLS.url.dup
    url.user = nil
    url.path = "/api/photos"
    response = RestClient.post(url.to_s, {:file => attrs[:file]}, MLS.headers)
    attrs[:file].close unless attrs[:file].closed?

    MLS::Photo::Parser.parse(response.body)
  end
  
end

class MLS::Photo::Parser < MLS::Parser

end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
mls-0.5.2 lib/mls/models/photo.rb
mls-0.5.1 lib/mls/models/photo.rb
mls-0.5.0 lib/mls/models/photo.rb
mls-0.4.0 lib/mls/models/photo.rb
mls-0.3.8 lib/mls/models/photo.rb
mls-0.3.7 lib/mls/models/photo.rb
mls-0.3.6 lib/mls/models/photo.rb
mls-0.3.5 lib/mls/models/photo.rb
mls-0.3.4 lib/mls/models/photo.rb
mls-0.3.3 lib/mls/models/photo.rb
mls-0.3.2 lib/mls/models/photo.rb
mls-0.3.1 lib/mls/models/photo.rb
mls-0.3.0 lib/mls/models/photo.rb
mls-0.2.54 lib/mls/models/photo.rb
mls-0.2.53 lib/mls/models/photo.rb
mls-0.2.52 lib/mls/models/photo.rb
mls-0.2.51 lib/mls/models/photo.rb
mls-0.2.50 lib/mls/models/photo.rb
mls-0.2.49 lib/mls/models/photo.rb
mls-0.2.48 lib/mls/models/photo.rb