<commit_before>require 'contextio/api/resource'

class ContextIO
  class Account
    include ContextIO::API::Resource

    self.primary_key = :id

    private

    # Builds the path that will fetch the attributes for this account.
    #
    # @return [String] The path of the resource.
    def build_resource_url
      "accounts/#{id}"
    end

    # def self.url
    #   'accounts'
    # end

    # def self.create(email, options={})
    #   result_hash = ContextIO::API.request(:post, url, email: email, first_name: options[:first_name], last_name: options[:last_name])

    #   fetch(result_hash['id'])
    # end

    # attr_reader :id, :username, :created, :suspended, :email_addresses,
    #             :first_name, :last_name, :password_expired, :sources,
    #             :nb_messages, :nb_files

    # def primary_key
    #   id
    # end

    # def update(attributes = {})
    #   attrs = {}

    #   attrs[:first_name] = attributes[:first_name] if attributes[:first_name]
    #   attrs[:last_name] = attributes[:last_name] if attributes[:last_name]

    #   return nil if attrs.empty?

    #   ContextIO::API.request(:post, url, attrs)['success']
    # end

    # def created_at
    #   Time.at(created) if created
    # end

    # def suspended_at
    #   Time.at(suspended) if suspended_at
    # end

    # def suspended?
    #   !!suspended
    # end

    # def password_expired_at
    #   Time.at(password_expired) if password_expired
    # end

    # def password_expired?
    #   !!password_expired
    # end
  end
end<commit_msg>Account attributes.<commit_after>require 'contextio/api/resource'

class ContextIO
  class Account
    include ContextIO::API::Resource

    self.primary_key = :id

    # @!attribute [r] id
    #   @return [String] The id assigned to this account by Context.IO.
    # @!attribute [r] username
    #   @return [String] The username assigned to this account by Context.IO.
    # @!attribute [r] email_addresses
    #   @return [Array<String] The email addresses associated with this account.
    # @!attribute [r] first_name
    #   @return [String] The account holder's first name.
    # @!attribute [r] last_name
    #   @return [String] The account holder's last name.
    lazy_attributes :id, :username, :created, :suspended, :email_addresses,
                    :first_name, :last_name, :password_expired, :nb_messages,
                    :nb_files
    private :created, :suspended, :password_expired

    # @!attribute [r] created_at
    #   @return [Time] The time this account was created (with Context.IO).
    def created_at
      @created_at ||= Time.at(created)
    end

    # @!attribute [r] suspended_at
    #   @return [Time] The time this account was suspended.
    def suspended_at
      return @suspended_at if instance_variable_defined?(:@suspended_at)

      @suspended_at = suspended == 0 ? nil : Time.at(suspended)

      @suspended_at
    end

    # @!attribute [r] suspended?
    #   @return [Boolean] Whether this account is currently suspended.
    def suspended?
      !!suspended_at
    end

    # @!attribute [r] password_expired_at
    #   @return [Time] The time this account's password expired.
    def password_expired_at
      return @password_expired_at if instance_variable_defined?(:@password_expired_at)

      @password_expired_at = password_expired == 0 ? nil : Time.at(password_expired)

      @password_expired_at
    end

    # @!attribute [r] password_expired?
    #   @return [Boolean] Whether this account's password is expired.
    def password_expired?
      !!password_expired_at
    end

    private

    # Builds the path that will fetch the attributes for this account.
    #
    # @return [String] The path of the resource.
    def build_resource_url
      "accounts/#{id}"
    end

    # def update(attributes = {})
    #   attrs = {}

    #   attrs[:first_name] = attributes[:first_name] if attributes[:first_name]
    #   attrs[:last_name] = attributes[:last_name] if attributes[:last_name]

    #   return nil if attrs.empty?

    #   ContextIO::API.request(:post, url, attrs)['success']
    # end
  end
end
{'fraction_non_alphanumeric': 0.10603112840466926, 'fraction_numerical': 0.00048638132295719845, 'mean_word_length': 2.880188679245283, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2816410', 'n_tokens_mistral': 1303, 'n_tokens_neox': 1265, 'n_words': 337}