All Files
(10.0%
covered at
0.1
hits/line)
2 files in total.
10 relevant lines.
1 lines covered and
9 lines missed
-
1
require 'nypl_collections/client'
-
-
module Collections
-
class << self
-
-
def new
-
@client ||= Collections::Client.new
-
end
-
-
def method_missing(method, *args, &block)
-
return super unless new.respond_to?(method)
-
new.send(method, *args, &block)
-
end
-
-
def respond_to?(method, include_private=false)
-
new.respond_to?(method, include_private) || super(method, include_private)
-
end
-
end
-
end
-
require 'json'
-
require 'httparty'
-
require 'nypl_collections/configuration'
-
require 'pry'
-
require 'dotenv'
-
Dotenv.load "../.env"
-
-
module Collections
-
class Client
-
include Collections::Configuration
-
include HTTParty
-
-
BASE_URL = "http://api.repo.nypl.org/api/v1/items/"
-
BASE_URL
-
-
def initialize
-
reset
-
end
-
-
def set_urlparam(url, name, options)
-
return unless options[name]
-
url << "&#{name.to_s.gsub(/ /,'_')}=#{options[name]}"
-
end
-
-
def return_captures_for_uuid(uuid, options= {})
-
url = BASE_URL.clone
-
token = auth_token
-
uuid = uuid
-
-
url << uuid
-
-
if options[:response]
-
url << ".xml"
-
end
-
-
url << "?"
-
-
if options[:withTitles]
-
title = options[:withTitles]
-
url << "withTitles=#{title}"
-
end
-
-
[:per_page, :page].each do |thing|
-
set_urlparam(url, thing, options)
-
end
-
-
HTTParty.get(url,
-
:headers => {
-
"Authorization" => "Token token=#{token}"
-
})
-
end
-
-
def return_uuid_for_local_identifier(local_id_name, local_id_value)
-
url = BASE_URL.clone
-
token = auth_token
-
local_id_name = local_id_name
-
local_id_value = local_id_value
-
-
url << "#{local_id_name}/#{local_id_value}"
-
-
if
-
-
HTTParty.get(url,
-
:headers => {
-
"Authorization" => "Token token=#{token}"
-
})
-
-
end
-
-
def search_in_mods_field
-
end
-
-
def search_all_mods_fields
-
end
-
-
def return_mods_record_for_capture_uuid
-
end
-
-
end
-
end
-
-
-
# @client = Collections::Client.new
-
# @client.configure do |config|
-
# config.auth_token = ENV['AUTH_TOKEN']
-
# binding.pry
-
# end
-
binding.pry