Sha256: cf0422b11f85fc8b00d0aa9ea52d7238431c491ec352486e278bf103b6578341

Contents?: true

Size: 771 Bytes

Versions: 22

Compression:

Stored size: 771 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

  def url(style='large', protocol='http')
    "#{protocol}://#{MLS.asset_host}/photos/#{style}/#{@digest}.jpg"
  end

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

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

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

end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
mls-0.2.21 lib/mls/models/photo.rb
mls-0.2.20 lib/mls/models/photo.rb
mls-0.2.19 lib/mls/models/photo.rb
mls-0.2.18 lib/mls/models/photo.rb
mls-0.2.17 lib/mls/models/photo.rb
mls-0.2.16 lib/mls/models/photo.rb
mls-0.2.15 lib/mls/models/photo.rb
mls-0.2.14 lib/mls/models/photo.rb
mls-0.2.13 lib/mls/models/photo.rb
mls-0.2.12 lib/mls/models/photo.rb
mls-0.2.11 lib/mls/models/photo.rb
mls-0.2.9.1 lib/mls/models/photo.rb
mls-0.2.10 lib/mls/models/photo.rb
mls-0.2.9 lib/mls/models/photo.rb
mls-0.2.8.2 lib/mls/models/photo.rb
mls-0.2.8.1 lib/mls/models/photo.rb
mls-0.2.8 lib/mls/models/photo.rb
mls-0.2.7 lib/mls/models/photo.rb
mls-0.2.6 lib/mls/models/photo.rb
mls-0.2.5 lib/mls/models/photo.rb