durfdoen-2.0/lib/data_sources/dsa_api.rb
2020-08-29 17:17:46 +02:00

35 lines
923 B
Ruby

require 'faraday'
require 'json'
require 'byebug'
class DSADataSource < ::Nanoc::DataSource
identifier :dsa_api
def items
verenigingen = JSON.parse Faraday.get('https://dsa.ugent.be/api/verenigingen').body
puts
verenigingen["associations"].map do |vereniging|
# byebug
puts "Loading #{vereniging["abbreviation"]} from dsa api"
new_item(
'',
vereniging,
"/verenigingen/#{vereniging["abbreviation"]}"
)
new_item(
Faraday.get(vereniging["logo"]).body,
vereniging,
"/images/#{vereniging["abbreviation"]}"
)
end
verenigingen["associations"].map do |vereniging|
# byebug
puts "Loading #{vereniging["abbreviation"]} from dsa api"
new_item(
Faraday.get(vereniging["logo"]).body,
vereniging,
"/images/#{vereniging["abbreviation"]}.jpg"
)
end
end
end