Sha256: 50060efcaa1a9020a9086a894b7582397a9e909cc68be32841affede3a089088

Contents?: true

Size: 537 Bytes

Versions: 5

Compression:

Stored size: 537 Bytes

Contents

module BulutfonDashboard
  class BulutfonUser < ActiveRecord::Base
    belongs_to :user, class_name: BulutfonDashboard.user_class.to_s
    validates_presence_of :user_id, :api_token
    validate :check_api_token_is_valid

    private

    def check_api_token_is_valid
      if self.api_token.present?
        begin
          bulutfon = BulutfonSDK::REST::Bulutfon.new(self.api_token)
          bulutfon.details
        rescue BulutfonSDK::REST::RequestError
          self.errors.add(:api_token)
        end
      end
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
bulutfon_dashboard-0.7.4 app/models/bulutfon_dashboard/bulutfon_user.rb
bulutfon_dashboard-0.7.3 app/models/bulutfon_dashboard/bulutfon_user.rb
bulutfon_dashboard-0.7.2 app/models/bulutfon_dashboard/bulutfon_user.rb
bulutfon_dashboard-0.7.1 app/models/bulutfon_dashboard/bulutfon_user.rb
bulutfon_dashboard-0.7.0 app/models/bulutfon_dashboard/bulutfon_user.rb