Class: Quovo::Api::Users

Inherits:
Base
  • Object
show all
Defined in:
lib/quovo/api/users.rb

Instance Attribute Summary

Attributes inherited from Base

#token

Instance Method Summary collapse

Methods inherited from Base

#api, #initialize

Methods included from Request

#request

Constructor Details

This class inherits a constructor from Quovo::Api::Base

Instance Method Details

#allObject



8
9
10
11
12
# File 'lib/quovo/api/users.rb', line 8

def all
  api(:get, '/users')
    .fetch('users')
    .cast(User)
end

#create(params) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/quovo/api/users.rb', line 21

def create(params)
  params
    .permit!(:username, :name, :email, :phone)
    .require!(:username)
  api(:post, '/users', params)
    .fetch('user')
    .cast(User)
end

#delete(id) ⇒ Object



38
39
40
41
# File 'lib/quovo/api/users.rb', line 38

def delete(id)
  id.require!(as: :id)
  api(:delete, "/users/#{id}")
end

#find(id) ⇒ Object



14
15
16
17
18
19
# File 'lib/quovo/api/users.rb', line 14

def find(id)
  id.require!(as: :id)
  api(:get, "/users/#{id}")
    .fetch('user')
    .cast(User)
end

#update(id, params) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/quovo/api/users.rb', line 30

def update(id, params)
  id.require!(as: :id)
  params.permit!(:name, :email, :phone)
  api(:put, "/users/#{id}", params)
    .fetch('user')
    .cast(User)
end