Sha256: 7467525fae099b7b522ae544dbaaa62825ca1a0d460d9c4d8a822fc7c811e0e2

Contents?: true

Size: 650 Bytes

Versions: 2

Compression:

Stored size: 650 Bytes

Contents

module Siteleaf
  class SourceFile < Entity
    
    attr_accessor :file, :name, :site_id
    attr_reader :name, :url, :download_url, :type, :filesize, :sha, :created_at, :updated_at, :user_id
    
    def create_endpoint
      ::File.join("sites", site_id, "source", URI.escape(identifier))
    end
    
    def entity_endpoint
      create_endpoint
    end
    
    def identifier
      name
    end
    
    def to_file
      response = Client.get(::File.join("sites", site_id, "source", "#{URI.escape(identifier)}?download"))
      raise response['message'] if response['message'] # indicates API error
      response.body 
    end
    
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
siteleaf-2.0.0 lib/siteleaf/source_file.rb
siteleaf-2.0.0.pre.beta9 lib/siteleaf/source_file.rb