lib/ragoon/services/schedule.rb in ragoon-0.3.1 vs lib/ragoon/services/schedule.rb in ragoon-0.4.0

- old
+ new

@@ -13,22 +13,28 @@ end_for_daily: options[:end].strftime('%F'), ) body_node.add_child(parameter_node) client.request(action_name, body_node) + events = client.result_set.xpath('//schedule_event'). find_all { |ev| ev[:event_type] != 'banner' }.map do |event| period = start_and_end(event) { + id: event_url(event[:id]), title: event[:detail], start_at: period[:start_at], end_at: period[:end_at], plan: event[:plan], facilities: facility_names(event), private: !(event[:public_type] == 'public'), allday: event[:allday] == 'true', } end + end + + def event_url(id) + "#{Ragoon::garoon_endpoint.gsub(/\?.*\Z/, '')}/schedule/view?event=#{id}" end def facility_names(event) event.xpath('ev:members', ev: "http://schemas.cybozu.co.jp/schedule/2008"). children.map { |c| c.xpath('ev:facility', ev: "http://schemas.cybozu.co.jp/schedule/2008").first }.