Class: Forem::ProfileImage

Inherits:
APIResource show all
Defined in:
lib/forem/resources/profile_image.rb

Overview

Represents the profile image associated with a Forem user or organization.

Retrieve a user's profile image URL by their username.

Profile images are avatar graphics that appear alongside user and organization names across the Forem UI. This resource exposes a single retrieve operation that looks up the image by username (or organization slug) and returns URLs to the image at various sizes.

Examples:

Retrieve a user's profile image

image = client.profile_images.retrieve("alice")
puts image.profile_image
puts image.profile_image_90

Retrieve an organization's profile image

image = client.profile_images.retrieve("acme-corp")
puts image.profile_image

See Also:

Constant Summary collapse

OBJECT_NAME =
"profile_image"
RESOURCE_PATH =
"/api/profile_images"

Instance Attribute Summary

Attributes inherited from ForemObject

#requestor

Class Method Summary collapse

Methods inherited from APIResource

#refresh, resource_path, #resource_url

Methods inherited from ForemObject

#==, #[], #[]=, construct_from, cursor_list, #initialize, #inspect, #method_missing, paginated_list, #respond_to_missing?, #to_hash

Methods included from APIOperations::Request

included, #request

Constructor Details

This class inherits a constructor from Forem::ForemObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Forem::ForemObject

Class Method Details

.retrieve(username, opts = {}) ⇒ Forem::ProfileImage

Retrieve the profile image URLs for a user or organization.

Sends a GET request to /api/profile_images/:username.

Examples:

image = client.profile_images.retrieve("alice")
puts image.profile_image        # full-size URL
puts image.profile_image_90     # 90px thumbnail URL

Parameters:

  • username (String)

    the username or organization slug to look up

  • opts (Hash) (defaults to: {})

    per-request options (e.g., :api_key)

Returns:

See Also:



39
40
41
42
# File 'lib/forem/resources/profile_image.rb', line 39

def self.retrieve(username, opts = {})
  resp = request(:get, "#{resource_path}/#{CGI.escape(username)}", {}, opts)
  construct_from(resp.parsed_body)
end