Method: Osm::Event#add_badge_link

Defined in:
lib/osm/event.rb

Add a badge link to the event in OSM

Parameters:

  • api (Osm::Api)

    The api to use to make the request

  • link (Osm::Event::BadgeLink)

    The badge link to add, if column_id is nil then a new column is created with requirement_label as the name

Returns:

  • (Boolean)

    whether the update succedded

Raises:



426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
# File 'lib/osm/event.rb', line 426

def add_badge_link(api, link)
  raise Osm::ObjectIsInvalid, 'link is invalid' unless link.valid?

  data = api.perform_query("ext/badges/records/index.php?action=linkBadgeToItem&sectionid=#{section_id}", {
    'section' => link.badge_section,
    'sectionid' => section_id,
    'type' => 'event',
    'id' => id,
    'badge_id' => link.badge_id,
    'badge_version' => link.badge_version,
    'column_id' => link.requirement_id.to_i.eql?(0) ? -2 : link.requirement_id,
    'column_data' => link.data,
    'new_column_name' => link.requirement_id.to_i.eql?(0) ? link.requirement_label : '',
  })
  return (data.is_a?(Hash) && data['status'])
end