blob: d674c79dc3be8048bf0dfeefb2e06eb1d5974d3c (
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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
class Validation
extend Enumerize
extend ActiveModel::Naming
include ActiveModel::Model
# enumerize :status, in: %w{created scheduled terminated canceled aborted}, default: "created", predicates: true
# enumerize :format, in: %w{neptune netex gtfs}, default: "neptune", predicates: true
attr_reader :datas
def initialize( response )
@datas = response
# @status = @datas.status.downcase if @datas.status?
# @format = @datas.type.downcase if @datas.type?
end
def report
report_path = datas.links.select{ |link| link["rel"] == "action_report"}.first.href
if report_path
response = Ievkit.get(report_path)
ValidationReport.new(response)
else
raise Ievkit::IevError("Impossible to access report path link for validation")
end
end
def compliance_check
compliance_check_path = datas.links.select{ |link| link["rel"] == "validation_report"}.first.href
if compliance_check_path
response = Ievkit.get(compliance_check_path)
ComplianceCheck.new(response)
else
raise Ievkit::Error("Impossible to access compliance check path link for validation")
end
end
def delete
delete_path = datas.links.select{ |link| link["rel"] == "delete"}.first.href
if delete_path
Ievkit.delete(delete_path)
else
raise Ievkit::Error("Impossible to access delete path link for validation")
end
end
def cancel
cancel_path = datas.links.select{ |link| link["rel"] == "cancel"}.first.href
if cancel_path
Ievkit.delete(cancel_path)
else
raise Ievkit::Error("Impossible to access cancel path link for validation")
end
end
def id
datas.id
end
def status
datas.status
end
def format
datas.type
end
# def filename
# datas.links.select{ |link| link["rel"] == "data"}.first.href.gsub( /\/.*\//, "" )
# end
# def filename_extension
# File.extname(filename) if filename
# end
def percentage_progress
if %w{created}.include? status
0
elsif %w{ terminated canceled aborted }.include? status
100
else
20
end
end
def referential_name
datas.referential
end
def name
datas.action_parameters.name
end
def user_name
datas.action_parameters.user_name
end
def no_save
datas.action_parameters.no_save
end
def created_at?
datas.created?
end
def created_at
Time.at(datas.created.to_i / 1000) if created_at?
end
def updated_at?
datas.updated?
end
def updated_at
Time.at(datas.updated.to_i / 1000) if updated_at?
end
end
|