Sha256: f666077193209c13810e001520a40e991b2918bb11c707507f6b349c4e789b77

Contents?: true

Size: 928 Bytes

Versions: 2

Compression:

Stored size: 928 Bytes

Contents

# frozen_string_literal: true

module DevRuby
  module Resources
    class UsersResource < BaseResource
      def me
        response = get_request('users/me')

        if Helpers.expected_response?(response, 200)
          user = DevRuby::Objects::User.new(response.body)

          Success(user)
        else
          Failure(error_parser(response))
        end
      end

      def find(id)
        response = get_request("users/#{id}")

        if Helpers.expected_response?(response, 200)
          user = DevRuby::Objects::User.new(response.body)

          Success(user)
        else
          Failure(error_parser(response))
        end
      end

      def invite_user(**body)
        response = post_request('admin/users', body: body)

        if Helpers.expected_response?(response, 200)
          Success(response.body)
        else
          Failure(error_parser(response))
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dev_ruby-1.0.0 lib/dev_ruby/resources/users_resource.rb
dev_ruby-0.2.0 lib/dev_ruby/resources/users_resource.rb