class Pinterest::Pin

A object representing a Pinterest pin.

Constants

FIELDS

The list of fields of the object.

Public Class Methods

create(data) click to toggle source

Creates a new pin object.

@param data [Hash] The data of the new object. For a list of valid fields, see `Pinterest::Pin::FIELDS`. @return [Pinterest::Board] The new pin object.

# File lib/pinterest/models/pin.rb, line 18
def self.create(data)
  data["created_at"] = Pinterest::Entity.parse_timestamp(data["created_at"]) if data["created_at"]
  data = create_relationships(data)
  new(data)
end
create_relationships(data) click to toggle source

Converts the relationships (user, board, images) of the pin to a gem object.

@param data [Hash] The raw data. @return [Hash] The input data where relationships are gem objects.

# File lib/pinterest/models/pin.rb, line 28
def self.create_relationships(data)
  data["creator"] = Pinterest::User.create(data["creator"]) if data["creator"]
  data["board"] = Pinterest::Board.create(data["board"]) if data["board"]
  data["image"] = Pinterest::Image.new(data["image"]) if data["image"]
  data
end

Public Instance Methods

as_json(options = {}) click to toggle source

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

@param options [Hash] The options to use to serialize. @return [Hash] The serialized object.

Calls superclass method Pinterest::Entity#as_json
# File lib/pinterest/models/pin.rb, line 39
def as_json(options = {})
  super(::Pinterest::Pin::FIELDS, options)
end