Sha256: 41454c7de07c34745bcc9f94878e3de68caf5f1154f1b9d63099eb3f915efc9b
Contents?: true
Size: 1.02 KB
Versions: 1
Compression:
Stored size: 1.02 KB
Contents
module Pina class Contact class << self def new(params = nil) Pina::Models::Contact.new(params) end def find(id) response = Pina::RestAdapter.get(:contacts, id) return Pina::Models::Contact.new(attributes(response)) if response.ok? response end def all(page = nil) response = Pina::RestAdapter.get(:contacts, page) return Pina::Models::ContactList.new(attributes(response)) if response.ok? response end def create(contact) response = Pina::RestAdapter.post(:contacts, contact) return Pina::Models::Contact.new(attributes(response)) if response.ok? response end def update(id, contact) response = Pina::RestAdapter.patch(:contacts, id, contact) return Pina::Models::Contact.new(attributes(response)) if response.ok? response end private def attributes(response) response.to_hash.merge(response: response) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pina-0.1.0 | lib/pina/contact.rb |