Class: Dato::Site::Repo::User

Inherits:
Base
  • Object
show all
Defined in:
lib/dato/site/repo/user.rb

Instance Attribute Summary

Attributes inherited from Base

#client

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Dato::Site::Repo::Base

Instance Method Details

#allObject



18
19
20
# File 'lib/dato/site/repo/user.rb', line 18

def all
  get_request '/users'
end

#create(resource_attributes) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/dato/site/repo/user.rb', line 8

def create(resource_attributes)
  body = JsonApiSerializer.new(
    type: :user,
    attributes: %i(email first_name last_name),
    required_attributes: %i(email first_name last_name)
  ).serialize(resource_attributes)

  post_request '/users', body
end

#destroy(user_id) ⇒ Object



36
37
38
# File 'lib/dato/site/repo/user.rb', line 36

def destroy(user_id)
  delete_request "/users/#{user_id}"
end

#find(user_id) ⇒ Object



22
23
24
# File 'lib/dato/site/repo/user.rb', line 22

def find(user_id)
  get_request "/users/#{user_id}"
end

#reset_password(resource_attributes) ⇒ Object



26
27
28
29
30
31
32
33
34
# File 'lib/dato/site/repo/user.rb', line 26

def reset_password(resource_attributes)
  body = JsonApiSerializer.new(
    type: :user,
    attributes: %i(email),
    required_attributes: %i(email)
  ).serialize(resource_attributes)

  post_request '/users/reset_password', body
end