Module: Poms::MergedSeries

Extended by:
MergedSeries
Included in:
MergedSeries
Defined in:
lib/poms/merged_series.rb

Overview

Methods for working with the merged series api from NPO.

Constant Summary collapse

TEST_URL =
'https://rs-test.poms.omroep.nl/v1/api/media/redirects/'.freeze
PRODUCTION_URL =
'https://rs.poms.omroep.nl/v1/api/media/redirects/'.freeze

Instance Method Summary collapse

Instance Method Details

#serie_mids(api_url = PRODUCTION_URL, key = '', secret = '', origin = '') ⇒ Hash

Gets the merged serie mids as a hash. Expects a JSON response from the server with a ‘map` key. Throws a PomsError if the call timeouts, has an HTTP error or JSON parse error.

Parameters:

  • api_url (defaults to: PRODUCTION_URL)

    the API url to query

Returns:

  • (Hash)

    a hash with old_mid => new_mid pairs



19
20
21
22
23
24
25
26
# File 'lib/poms/merged_series.rb', line 19

def serie_mids(api_url = PRODUCTION_URL, key = '', secret = '', origin = '')
  Timeout.timeout(3) do
    data = Poms::Api::Request.new(api_url, key, secret, origin).call.read
    JSON.parse(data).fetch('map')
  end
rescue OpenURI::HTTPError, JSON::ParserError, Timeout::Error => e
  raise Poms::PomsError, e.message
end