Sha256: fae204707c4ce4921585cd155e1051fc56e2b7c913c6701295f3f8bd4fe1453e

Contents?: true

Size: 1.09 KB

Versions: 13

Compression:

Stored size: 1.09 KB

Contents

module MyJohnDeere
  class File < OrganizationOwnedResource
    self.base_jd_resource = "files"
    self.list_resource_path = "organizations/%{organization_id}/#{self.base_jd_resource}"
    self.retrieve_resource_path = self.base_jd_resource
    attributes_to_pull_from_json(:id, :name, :type, :createdTime, :modifiedTime, :nativeSize, :source, :transferPending, :visibleViaShare, :shared, :status, :archived, :new)

    def initialize(json_object, access_token = nil)
      super(json_object, access_token)
    end

    def upload_url()
      "#{MyJohnDeere.configuration.endpoint}/#{self.class.build_resource_base_path!("#{self.class.retrieve_resource_path}/#{self.id}")}"
    end

    def self.create(access_token, organization_id, name: nil)
      raise ArgumentError.new("You must pass a name for the file") if name.nil?

      body = {
        name: name
      }
      
      response = send_create(access_token, body, {organization_id: organization_id})

      return nil if response.nil?
      response.organization_id = organization_id
      return response
    end

    # TODO: Support upload_file
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
myjohndeere-0.1.11 lib/myjohndeere/file.rb
myjohndeere-0.1.10 lib/myjohndeere/file.rb
myjohndeere-0.1.9 lib/myjohndeere/file.rb
myjohndeere-0.1.8 lib/myjohndeere/file.rb
myjohndeere-0.1.7 lib/myjohndeere/file.rb
myjohndeere-0.1.6 lib/myjohndeere/file.rb
myjohndeere-0.1.5 lib/myjohndeere/file.rb
myjohndeere-0.1.4 lib/myjohndeere/file.rb
myjohndeere-0.1.3 lib/myjohndeere/file.rb
myjohndeere-0.1.2 lib/myjohndeere/file.rb
myjohndeere-0.1.1 lib/myjohndeere/file.rb
myjohndeere-0.1.0 lib/myjohndeere/file.rb
myjohndeere-0.0.11 lib/myjohndeere/file.rb