27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/haveapi/resources/action_state.rb', line 27
def state_to_hash(state)
hash = {
id: state.id,
label: state.label,
status: state.status,
created_at: state.created_at,
updated_at: state.updated_at,
can_cancel: state.can_cancel?,
}
if state.finished?
hash[:finished] = true
else
hash[:finished] = false
end
progress = state.progress
hash[:current] = progress[:current] || 0
hash[:total] = progress[:total] || 0
hash[:unit] = progress[:unit]
hash
end
|