Class: Pinterest::Board

Inherits:
Entity
  • Object
show all
Defined in:
lib/pinterest/models/board.rb

Overview

A object representing a Pinterest board.

Constant Summary collapse

FIELDS =

The list of fields of the object.

["id", "name", "url", "description", "creator", "created_at", "counts", "image"].freeze

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Entity

#initialize, parse_timestamp

Constructor Details

This class inherits a constructor from Pinterest::Entity

Class Method Details

.create(data) ⇒ Pinterest::Board

Creates a new board object.

Parameters:

  • data (Hash)

    The data of the new object. For a list of valid fields, see Pinterest::Board::FIELDS.

Returns:



18
19
20
21
22
23
24
# File 'lib/pinterest/models/board.rb', line 18

def self.create(data)
  data["created_at"] = Pinterest::Entity.parse_timestamp(data["created_at"]) if data["created_at"]
  data["creator"] = Pinterest::User.create(data["creator"]) if data["creator"]
  data["image"] = Pinterest::Image.new(data["image"]) if data["image"]

  new(data)
end

Instance Method Details

#as_json(options = {}) ⇒ Hash

Serialize the object as a Hash that can be serialized as JSON.

Parameters:

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

    The options to use to serialize.

Returns:

  • (Hash)

    The serialized object.



30
31
32
# File 'lib/pinterest/models/board.rb', line 30

def as_json(options = {})
  super(::Pinterest::Board::FIELDS, options)
end