Sha256: 507fcc5e6cfd01da9856387894f4f1aa1fde5b80b66a7b429791187b27dad0be

Contents?: true

Size: 895 Bytes

Versions: 1

Compression:

Stored size: 895 Bytes

Contents

# frozen_string_literal: true

module AffiliateProgram
  class RegistrationForm < ApplicationForm
    attribute :email, String
    attribute :phone_code, String
    attribute :phone_area, String
    attribute :phone_number, String

    validates :phone_code, presence: true, numericality: true, length: { minimum: 1, maximum: 10 }
    validates :phone_area, numericality: true, length: { maximum: 6 }, allow_blank: true
    validates :phone_number, presence: true, numericality: true, length: { minimum: 6, maximum: 12 }
    validates :email, presence: true, length: { maximum: 130 }, email: true

    def submit
      return false unless valid?

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

    protected

    def submit_params(params)
      params
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
translation_cms-0.1.5 app/forms/affiliate_program/registration_form.rb