Sha256: 9833e03e279b068cba7aaded66ecb398e454978a1145a7e231c0a0e761b45a29

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

module Account
  class FeedbackForm < ApplicationForm
    attribute :id,         Integer
    attribute :order_id,   Integer
    attribute :rate,       Integer
    attribute :content,    String
    attribute :updated_at, DateTime

    validates :order_id, presence: true
    validates :rate, presence: true, numericality: { greater_than_or_equal_to: 1,
                                                     less_than_or_equal_to: 5,
                                                     only_integer: true }
    validates :content, presence: true, length: { maximum: 1000 }

    def submit
      return false unless valid?

      api_answer = if id.blank?
                     TranslationCms::Api::Customers::Feedback.create(attributes)
                   else
                     TranslationCms::Api::Customers::Feedback.update(
                       attributes.reverse_merge(violation_content: 'bla-bla')
                     )
                   end
      merge_responce! api_answer
      errors.empty?
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
translation_cms-0.1.5 app/forms/account/feedback_form.rb