Class: Base::Endpoints::Users

Inherits:
Base::Endpoint show all
Defined in:
lib/base/endpoints/users.rb

Overview

This endpoint contains methods for creating and managing users.

Instance Attribute Summary

Attributes inherited from Base::Endpoint

#connection, #path

Instance Method Summary collapse

Methods inherited from Base::Endpoint

#io, #parse, #request

Constructor Details

#initialize(access_token:, url:) ⇒ Users

Initializes this endpoint.



8
9
10
11
# File 'lib/base/endpoints/users.rb', line 8

def initialize(access_token:, url:)
  @path = 'users'
  super
end

Instance Method Details

#create(email:, password:, confirmation:) ⇒ Object

Creates a user with the given credentials.



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/base/endpoints/users.rb', line 14

def create(email:, password:, confirmation:)
  request do
    response =
      connection.post('',
                      'confirmation' => confirmation,
                      'password' => password,
                      'email' => email)

    parse(response.body)
  end
end

#delete(id) ⇒ Object

Deletes the user with the given ID.



37
38
39
40
41
42
43
44
# File 'lib/base/endpoints/users.rb', line 37

def delete(id)
  request do
    response =
      connection.delete id

    parse(response.body)
  end
end

#get(id) ⇒ Object

Gets the details of the user with the given ID.



27
28
29
30
31
32
33
34
# File 'lib/base/endpoints/users.rb', line 27

def get(id)
  request do
    response =
      connection.get id

    parse(response.body)
  end
end