aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/import/netex.rb
blob: 2b09822298320c3182ec9e09468028a1a8d630d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
require 'net/http'
class Import::Netex < Import::Base
  before_destroy :destroy_non_ready_referential

  after_commit :call_iev_callback, on: :create

  before_save def abort_unless_referential
    self.status = 'aborted' unless referential
  end

  validates_presence_of :parent

  private

  def iev_callback_url
    URI("#{Rails.configuration.iev_url}/boiv_iev/referentials/importer/new?id=#{id}")
  end

  def destroy_non_ready_referential
    if referential && !referential.ready
      referential.destroy
    end
  end
end