Sha256: 0201f22166d7fb920e903e3bdb10f413250df6b3fe6e9d066e09fd0487fe2e76

Contents?: true

Size: 1.16 KB

Versions: 7

Compression:

Stored size: 1.16 KB

Contents

module Ribose
  class Profile < Ribose::Base
    include Ribose::Actions::Fetch
    include Ribose::Actions::Update

    def set_login
      update_login_name[resource_key]
    end

    # Fetch user profile
    #
    # @param options [Hash] The query parameters
    # @return [Sawyer::Resource] The user profile
    #
    def self.fetch(options = {})
      new(resource_id: nil, **options).fetch
    end

    # Update user profile
    #
    # @param attributes [Hash] The new attributes
    # @return [Sawyer::Resource] The user profile
    #
    def self.update(attributes)
      new(resource_id: nil, **attributes).update
    end

    # Set login name
    #
    # @param login [String] The user login name
    # @return [Sawyer::Resource] The user profile
    #
    def self.set_login(name, options = {})
      new(login: name, **options).set_login
    end

    private

    def resource
      "user"
    end

    def resources_path
      "people/profile"
    end

    def update_login_name
      Ribose::Request.put(
        "people/users/#{fetch.user_id}",
        custom_option.merge(
          resource_key.to_sym => { login: attributes[:login] }
        ),
      )
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ribose-0.5.0 lib/ribose/profile.rb
ribose-0.4.1 lib/ribose/profile.rb
ribose-0.4.0 lib/ribose/profile.rb
ribose-0.3.2 lib/ribose/profile.rb
ribose-0.3.1 lib/ribose/profile.rb
ribose-0.3.0 lib/ribose/profile.rb
ribose-0.2.0 lib/ribose/profile.rb