Class: Montague::API::Publisher

Inherits:
Base
  • Object
show all
Defined in:
lib/montague/api/publisher.rb

Overview

Publisher API

Instance Method Summary collapse

Constructor Details

#initialize(config = {}) ⇒ Publisher

Returns a new instance of Publisher.

Parameters:

  • config (Hash) (defaults to: {})

Options Hash (config):

  • :api_url (String)

    URL of the SHERPA/RoMEO service (if it changes)

  • :api_key (String)

    API key of the SHERPA/RoMEO service user


10
11
12
# File 'lib/montague/api/publisher.rb', line 10

def initialize(config = {})
  super
end

Instance Method Details

#find_by_id(id) ⇒ Montague::Model::PublisherReport

Parameters:

  • id (Fixnum)

    RoMEO persistent ID

Returns:


16
17
18
19
20
# File 'lib/montague/api/publisher.rb', line 16

def find_by_id(id)
  url = "#{@config[:api_url]}?id=#{id}#{common_parameters}"
  response = HTTP.get URI.encode(url)
  publisher_report response
end

#find_by_name(text:, filter: :all) ⇒ Montague::Model::PublishersReport

Parameters:

  • text (String)

    e.g. 'optical society'

  • filter (Symbol) (defaults to: :all)
    • :all - All words present but in any order or location

    • :any - At least one of the words present

    • :exact - Intact phrase somewhere e.g. 'tute of'

Returns:


28
29
30
31
32
# File 'lib/montague/api/publisher.rb', line 28

def find_by_name(text:, filter: :all)
  url = "#{@config[:api_url]}?pub=#{text}&qtype=#{filter}#{common_parameters}"
  response = HTTP.get URI.encode(url)
  publishers_report response
end