2020-02-12 19:08:46 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module API
|
|
|
|
module Entities
|
|
|
|
module Releases
|
|
|
|
class Link < Grape::Entity
|
|
|
|
expose :id
|
|
|
|
expose :name
|
|
|
|
expose :url
|
2020-02-27 10:09:24 -05:00
|
|
|
expose :direct_asset_url
|
2020-02-12 19:08:46 -05:00
|
|
|
expose :external?, as: :external
|
2020-06-02 17:08:00 -04:00
|
|
|
expose :link_type
|
2020-02-27 10:09:24 -05:00
|
|
|
|
|
|
|
def direct_asset_url
|
|
|
|
return object.url unless object.filepath
|
|
|
|
|
2020-11-12 10:09:09 -05:00
|
|
|
release = object.release.present
|
|
|
|
release.download_url(object.filepath)
|
2020-02-27 10:09:24 -05:00
|
|
|
end
|
2020-02-12 19:08:46 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|