Class: Forem::Services::BillboardService

Inherits:
BaseService show all
Defined in:
lib/forem/services/billboard_service.rb

Overview

Service for interacting with the Forem Billboards API.

Billboards are display ads shown within Forem communities. Access via Client#billboards. All methods inject the client's requestor automatically so no additional configuration is required.

Examples:

client = Forem::Client.new("your-api-key")
billboards = client.billboards.list
billboard  = client.billboards.retrieve(3)

See Also:

Instance Method Summary collapse

Methods inherited from BaseService

#initialize

Constructor Details

This class inherits a constructor from Forem::Services::BaseService

Instance Method Details

#create(params = {}, opts = {}) ⇒ Billboard

Create a new billboard.

Examples:

client.billboards.create(
  name: "Summer Promo",
  body_markdown: "## Sale!\nUp to 50% off.",
  placement_area: "sidebar_left",
  published: true
)

Parameters:

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

    billboard attributes

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

    per-request options

Options Hash (params):

  • :name (String)

    internal name for the billboard

  • :body_markdown (String)

    ad body in Markdown / HTML

  • :placement_area (String)

    where to display the billboard

  • :published (Boolean)

    whether the billboard is live

  • :organization_id (Integer)

    organization this billboard belongs to

Returns:

  • (Billboard)

    the newly created billboard

See Also:



54
55
56
# File 'lib/forem/services/billboard_service.rb', line 54

def create(params = {}, opts = {})
  Billboard.create(params, opts_with_requestor(opts))
end

#list(params = {}, opts = {}) ⇒ Array<Billboard>

List all billboards (display ads).

Examples:

client.billboards.list

Parameters:

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

    query parameters

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

    per-request options

Options Hash (params):

  • :page (Integer)

    page number (default: 1)

  • :per_page (Integer)

    number of results per page

Returns:

See Also:



29
30
31
# File 'lib/forem/services/billboard_service.rb', line 29

def list(params = {}, opts = {})
  Billboard.list(params, opts_with_requestor(opts))
end

#retrieve(id, opts = {}) ⇒ Billboard

Retrieve a single billboard by its numeric ID.

Examples:

client.billboards.retrieve(3)

Parameters:

  • id (Integer, String)

    the billboard ID

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

    per-request options

Returns:

  • (Billboard)

    the billboard with the given ID

See Also:



68
69
70
# File 'lib/forem/services/billboard_service.rb', line 68

def retrieve(id, opts = {})
  Billboard.retrieve(id, opts_with_requestor(opts))
end

#update(id, params = {}, opts = {}) ⇒ Billboard

Update an existing billboard.

Examples:

client.billboards.update(3, published: false)

Parameters:

  • id (Integer, String)

    the billboard ID to update

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

    billboard attributes to change

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

    per-request options

Options Hash (params):

  • :name (String)

    new internal name

  • :body_markdown (String)

    new body content

  • :published (Boolean)

    publish or unpublish the billboard

Returns:

See Also:



86
87
88
# File 'lib/forem/services/billboard_service.rb', line 86

def update(id, params = {}, opts = {})
  Billboard.update(id, params, opts_with_requestor(opts))
end