Class: Forem::Billboard

Inherits:
APIResource show all
Extended by:
APIOperations::Create, APIOperations::List, APIOperations::Retrieve, APIOperations::Update
Includes:
APIOperations::Save
Defined in:
lib/forem/resources/billboard.rb

Overview

Represents a Forem billboard (display advertisement).

Billboards are configurable ad units shown to readers on a Forem instance. They support full CRUD operations plus an unpublish action that reverts a live billboard back to draft status. Managing billboards requires an admin API key.

Available operations (via mixins):

- +List+     — GET /api/billboards
- +Create+   — POST /api/billboards
- +Retrieve+ — GET /api/billboards/:id
- +Update+   — PUT /api/billboards/:id
- +Save+     — instance-level save (create or update)

Billboard Fields

  • name (String) — Internal name to distinguish ads
  • body_markdown (String, required) — The ad content in markdown
  • approved (Boolean) — Must be both published AND approved to appear in rotation
  • published (Boolean) — Must be both published AND approved to appear in rotation
  • expires_at (String) — ISO 8601 timestamp; automatically unapproved after this time
  • placement_area (String) — Which area of the site layout the ad appears in
  • tag_list (String) — Tags on which the ad can display (blank = all tags)
  • exclude_article_ids (String) — Comma-separated Article IDs where ad should NOT appear
  • audience_segment_id (Integer) — Target a specific audience segment
  • audience_segment_type (String) — Must match audience_segment_id if both provided
  • target_geolocations (Array) — ISO 3166-2 country/region codes (blank = all locations)
  • display_to (String) — Limits which visitors see the ad
  • type_of (String) — One of: "in_house" (admin-created), "community" (entity content), "external" (everywhere)

Examples:

List all billboards

billboards = client.billboards.list
billboards.data.each { |b| puts "#{b.id}: #{b.name}" }

Create a billboard (flat params — there is no billboard: wrapper)

billboard = client.billboards.create(
  name: "Summer Sale",
  body_markdown: "**50% off** all plans!",
  placement_area: "sidebar_left"
)

Retrieve a billboard by ID

billboard = client.billboards.retrieve(7)
puts billboard.name

See Also:

Constant Summary collapse

OBJECT_NAME =
"billboard"
RESOURCE_PATH =
"/api/billboards"

Instance Attribute Summary

Attributes inherited from ForemObject

#requestor

Instance Method Summary collapse

Methods included from APIOperations::Create

create

Methods included from APIOperations::List

list

Methods included from APIOperations::Retrieve

retrieve

Methods included from APIOperations::Update

update

Methods included from APIOperations::Save

#save

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

Instance Method Details

#unpublish(opts = {}) ⇒ ForemResponse

Unpublish this billboard, reverting it to draft/inactive status.

Marks the billboard as unpublished. A billboard must be both published AND approved to appear in rotation.

Sends a PUT request to /api/billboards/:id/unpublish. Requires admin privileges.

Examples:

billboard = client.billboards.retrieve(7)
billboard.unpublish

Parameters:

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

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

Returns:

See Also:



72
73
74
# File 'lib/forem/resources/billboard.rb', line 72

def unpublish(opts = {})
  request(:put, "#{resource_url}/unpublish", {}, opts)
end