<commit_before># @see https://developers.podio.com/doc/widgets
class Podio::Widget < ActivePodio::Base
  property :widget_id, :integer
  property :ref_type, :string
  property :ref_id, :integer
  property :type, :string
  property :title, :string
  property :config, :hash
  property :ref, :hash
  property :rights, :array
  property :data, :hash
  property :x, :integer
  property :y, :integer
  property :rows, :integer
  property :cols, :integer

  class << self
    # @see https://developers.podio.com/doc/widgets/create-widget-22491
    def create(ref_type, ref_id, attributes)
      response = Podio.connection.post do |req|
        req.url "/widget/#{ref_type}/#{ref_id}/"
        req.body = attributes
      end

      response.body['widget_id']
    end

    # @see https://developers.podio.com/doc/widgets/update-widget-22490
    def update(id, attributes)
      response = Podio.connection.put do |req|
        req.url "/widget/#{id}"
        req.body = attributes
      end

      response.status
    end

    # @see https://developers.podio.com/doc/widgets/delete-widget-22492
    def delete(id)
      Podio.connection.delete("/widget/#{id}").status
    end

    # @see https://developers.podio.com/doc/widgets/update-widget-order-22495<commit_msg>Return a member instead of an id when creating a widget.<commit_after># @see https://developers.podio.com/doc/widgets
class Podio::Widget < ActivePodio::Base
  property :widget_id, :integer
  property :ref_type, :string
  property :ref_id, :integer
  property :type, :string
  property :title, :string
  property :config, :hash
  property :ref, :hash
  property :rights, :array
  property :data, :hash
  property :x, :integer
  property :y, :integer
  property :rows, :integer
  property :cols, :integer

  class << self
    # @see https://developers.podio.com/doc/widgets/create-widget-22491
    def create(ref_type, ref_id, attributes)
      response = Podio.connection.post do |req|
        req.url "/widget/#{ref_type}/#{ref_id}/"
        req.body = attributes
      end

      member response.body
    end

    # @see https://developers.podio.com/doc/widgets/update-widget-22490
    def update(id, attributes)
      response = Podio.connection.put do |req|
        req.url "/widget/#{id}"
        req.body = attributes
      end

      response.status
    end

    # @see https://developers.podio.com/doc/widgets/delete-widget-22492
    def delete(id)
      Podio.connection.delete("/widget/#{id}").status
    end

    # @see https://developers.podio.com/doc/widgets/update-widget-order-22495
{'fraction_non_alphanumeric': 0.13101290574892452, 'fraction_numerical': 0.01564333202972233, 'mean_word_length': 3.0538827258320125, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, 'https://': 10, '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': '5154292', 'n_tokens_mistral': 859, 'n_tokens_neox': 812, 'n_words': 186}