Sha256: a16ed17bad7b8b144f8349703d8c3157c7cadfcd0596b51a12eeba7b2e09e9e3

Contents?: true

Size: 1.16 KB

Versions: 1

Compression:

Stored size: 1.16 KB

Contents

#
# This file is part of the pinterest-ruby gem. Copyright (C) 2017 and above Shogun <shogun@cowtech.it>.
# Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
#

module Pinterest
  # A object representing a Pinterest user.
  class User < Entity
    # The list of fields of the object.
    FIELDS = ["id", "username", "first_name", "last_name", "bio", "created_at", "counts", "image"].freeze

    attr_accessor(*FIELDS)

    # Creates a new user object.
    #
    # @param data [Hash] The data of the new object. For a list of valid fields, see `Pinterest::User::FIELDS`.
    # @return [Pinterest::Board] The new user object.
    def self.create(data)
      data["created_at"] = Pinterest::Entity.parse_timestamp(data["created_at"]) if data["created_at"]
      data["image"] = Pinterest::Image.new(data["image"]) if data["image"]

      new(data)
    end

    # 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.
    def as_json(options = {})
      super(::Pinterest::User::FIELDS, options)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pinterest-ruby-1.0.0 lib/pinterest/models/user.rb