Sha256: 2029514751f38d2435366718b7e62a1984511b4bdb2466be2cf7ec92101eecdf

Contents?: true

Size: 1.26 KB

Versions: 4

Compression:

Stored size: 1.26 KB

Contents

require 'dato/site/repo/base'

module Dato
  module Site
    module Repo
      class User < Base

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

          post_request "/users", body
        end

        def update(user_id, resource_attributes)
          body = JsonApiSerializer.new(
            type: :user,
            attributes: %i(email first_name is_admin last_name password),
          ).serialize(resource_attributes, user_id)

          put_request "/users/#{user_id}", body
        end

        def all()
          get_request "/users"
        end

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

        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

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

      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dato-0.1.5 lib/dato/site/repo/user.rb
dato-0.1.4 lib/dato/site/repo/user.rb
dato-0.1.3 lib/dato/site/repo/user.rb
dato-0.1.2 lib/dato/site/repo/user.rb