Class: Pina::Contact
- Inherits:
-
Object
- Object
- Pina::Contact
- Defined in:
- lib/pina/contact.rb
Class Method Summary collapse
- .all(page = nil) ⇒ Object
- .create(contact) ⇒ Object
- .find(id) ⇒ Object
- .find_by(hash) ⇒ Object
- .new(params = nil) ⇒ Object
- .update(id, contact) ⇒ Object
- .where(hash, _page = nil) ⇒ Object
Class Method Details
.all(page = nil) ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/pina/contact.rb', line 38 def all(page = nil) response = Pina::RestAdapter.get(:contacts, page) return Pina::Collections::Contact.new(attributes(response)) if response.ok? response end |
.create(contact) ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/pina/contact.rb', line 47 def create(contact) response = Pina::RestAdapter.post(:contacts, contact) return Pina::Models::Contact.new(attributes(response)) if response.ok? response end |
.find(id) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/pina/contact.rb', line 30 def find(id) response = Pina::RestAdapter.get(:contacts, id) return Pina::Models::Contact.new(attributes(response)) if response.ok? response end |
.find_by(hash) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/pina/contact.rb', line 13 def find_by(hash) response = where(hash) return response.items.first if response.is_a? Pina::Collections::Contact response end |
.new(params = nil) ⇒ Object
9 10 11 |
# File 'lib/pina/contact.rb', line 9 def new(params = nil) Pina::Models::Contact.new(params) end |
.update(id, contact) ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/pina/contact.rb', line 55 def update(id, contact) response = Pina::RestAdapter.patch(:contacts, id, contact) return Pina::Models::Contact.new(attributes(response)) if response.ok? response end |
.where(hash, _page = nil) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/pina/contact.rb', line 21 def where(hash, _page = nil) response = Pina::RestAdapter.get(:contacts, hash) return Pina::Collections::Contact.new(attributes(response)) if response.ok? response end |