Sha256: dad829c371853e0524c89ea73818d873c9f1ca232ad6b84d5b4bc2014e314574

Contents?: true

Size: 665 Bytes

Versions: 2

Compression:

Stored size: 665 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.parsed_response.is_a?(Hash) && 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.2 lib/siteleaf/source_file.rb
siteleaf-2.0.1 lib/siteleaf/source_file.rb