class BBC::Cosmos::Tools::API
Public Class Methods
new(host, key_path)
click to toggle source
# File lib/bbc/cosmos/tools/api.rb, line 9 def initialize(host, key_path) @connection = Faraday.new host, :ssl => { :client_key => client_key(key_path), :client_cert => client_cert(key_path), :verify => false, :version => "TLSv1" } end
Public Instance Methods
client_cert(path)
click to toggle source
# File lib/bbc/cosmos/tools/api.rb, line 22 def client_cert(path) OpenSSL::X509::Certificate.new(File.read path) end
client_key(path)
click to toggle source
# File lib/bbc/cosmos/tools/api.rb, line 18 def client_key(path) OpenSSL::PKey::RSA.new(File.read path) end
content_type_from(type)
click to toggle source
# File lib/bbc/cosmos/tools/api.rb, line 40 def content_type_from(type) @connection.headers[:content_type] = type end
get(path)
click to toggle source
# File lib/bbc/cosmos/tools/api.rb, line 26 def get(path) @connection.get path end
post(path, payload, content_type = "application/json")
click to toggle source
# File lib/bbc/cosmos/tools/api.rb, line 35 def post(path, payload, content_type = "application/json") content_type_from content_type @connection.post path, payload end
put(path, payload, content_type = "application/json")
click to toggle source
# File lib/bbc/cosmos/tools/api.rb, line 30 def put(path, payload, content_type = "application/json") content_type_from content_type @connection.put path, payload end