Sha256: 02e56842a11eaa7870daf6de588cfc55d583a01b8108dca387a51c1ddcc6179a

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

module Account
  class TicketForm < ApplicationForm
    attribute :order_id, String
    attribute :customer_id, Integer
    attribute :assignee_id, Integer
    attribute :reporter_id, Integer
    attribute :department_id, Integer
    attribute :subject_query_id, Integer
    attribute :writer_id, String
    attribute :description, String
    attribute :deadline_extension, String
    attribute :fileupload_guid, String
    attribute :state, String
    attribute :updated_at, String

    validates :order_id, length: { minimum: 5, maximum: 50 }, allow_blank: true
    validates :description, presence: true, length: { maximum: 1024 * 4 }
    validates :fileupload_guid, presence: true, length: { minimum: 16, maximum: 64 }

    def submit
      return false unless valid?

      api_answer = TranslationCms::Api::Customers::Ticket.create(attributes)
      merge_responce! api_answer
      errors.empty?
    end

    def self.build(params = {})
      tmp = new(params)
      tmp.fileupload_guid ||= SecureRandom.base64(15).tr('+/=', 'xyz')
      tmp
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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