Sha256: 0b2dad9d953ba712033ce34f1bc0afc545c71fb0c9d7210127cbb81fd819df8b

Contents?: true

Size: 1.17 KB

Versions: 2

Compression:

Stored size: 1.17 KB

Contents

require 'dato/repo/base'

module Dato
  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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dato-0.1.1 lib/dato/repo/user.rb
dato-0.1.0 lib/dato/repo/user.rb