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:, custom_data: nil) ⇒ Object

Creates a user with the given credentials.



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

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

    parse(response.body)
  end
end

#delete(id) ⇒ Object

Deletes the user with the given ID.



60
61
62
63
64
65
66
67
# File 'lib/base/endpoints/users.rb', line 60

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.



50
51
52
53
54
55
56
57
# File 'lib/base/endpoints/users.rb', line 50

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

    parse(response.body)
  end
end

#list(page: 1, per_page: 10) ⇒ Object

Lists the files of a project



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

def list(page: 1, per_page: 10)
  request do
    response =
      connection.get('', per_page: per_page, page: page)

    parse(response.body)
  end
end

#update(id:, email:, custom_data: nil) ⇒ Object

Updates a user with the given data.



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

def update(id:, email:, custom_data: nil)
  request do
    response =
      connection.post(id,
                      'custom_data' => custom_data.to_json,
                      'email' => email)

    parse(response.body)
  end
end