Sha256: fce222387e975143b95d5ebe8fad4180305f573b32692cd6f01d11a257778100
Contents?: true
Size: 1.73 KB
Versions: 3
Compression:
Stored size: 1.73 KB
Contents
require 'pina/models/uploaded_document' require 'pina/collections/uploaded_document' module Pina class UploadedDocument class << self def create(uploaded_document) response = Pina::RestAdapter.post(:uploaded_documents, uploaded_document, multipart: true) if response.ok? Pina::Models::UploadedDocument.new(attributes(response)) else Pina::Models::Error.new(attributes_for_error(response)) end end def find(id) response = Pina::RestAdapter.get(:uploaded_documents, id) if response.ok? Pina::Models::UploadedDocument.new(attributes(response)) else Pina::Models::Error.new(attributes_for_error(response)) end end def where(hash, _page = nil) response = Pina::RestAdapter.get(:uploaded_documents, hash) return Pina::Collections::UploadedDocument.new(attributes(response)) if response.ok? response end def all(page = nil) response = Pina::RestAdapter.get(:uploaded_documents, page) return Pina::Collections::UploadedDocument.new(attributes(response)) if response.ok? response end def update(id, uploaded_document) response = Pina::RestAdapter.patch(:uploaded_documents, id, uploaded_document) if response.ok? Pina::Models::UploadedDocument.new(attributes(response)) else Pina::Models::Error.new(attributes_for_error(response)) end end private def attributes(response) response.to_hash.merge(response: response) end def attributes_for_error(response) response.to_hash.merge(status_code: response.status_code) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
pina-0.14.4 | lib/pina/uploaded_document.rb |
pina-0.14.3 | lib/pina/uploaded_document.rb |
pina-0.14.2 | lib/pina/uploaded_document.rb |