Sha256: ee1b616d15080ea076f55842418868c3276272dc9252e00c4feefaf0a5223d23

Contents?: true

Size: 1003 Bytes

Versions: 22

Compression:

Stored size: 1003 Bytes

Contents

# frozen_string_literal: true
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 last_name),
            required_attributes: %i(email first_name last_name)
          ).serialize(resource_attributes)

          post_request '/users', 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

22 entries across 22 versions & 1 rubygems

Version Path
dato-0.3.0 lib/dato/site/repo/user.rb
dato-0.2.7 lib/dato/site/repo/user.rb