class EY::ServicesAPI::Integration

Public Class Methods

mapper() click to toggle source
# File lib/ey_services_api/integration.rb, line 17
def self.mapper
  @mapper
end
mapper=(mapper) click to toggle source
# File lib/ey_services_api/integration.rb, line 13
def self.mapper=(mapper)
  @mapper = mapper
end
register_service(registration_url, service_url) click to toggle source
# File lib/ey_services_api/integration.rb, line 5
def self.register_service(registration_url, service_url)
  create_service(service_registration_params(service_url), registration_url)
end
server() click to toggle source
# File lib/ey_services_api/integration.rb, line 9
def self.server
  Server
end

Private Class Methods

connection() click to toggle source
# File lib/ey_services_api/integration.rb, line 43
def self.connection
  unless EY::ServicesAPI.setup?
    EY::ServicesAPI.setup!(mapper.api_creds)
  end
  EY::ServicesAPI.connection
end
create_service(registration_params, service_registration_url) click to toggle source
# File lib/ey_services_api/integration.rb, line 37
def self.create_service(registration_params, service_registration_url)
  remote_service = connection.register_service(service_registration_url, registration_params)
  mapper.save_service_url(remote_service.url)
  remote_service
end
fetch_from_description(thing) click to toggle source
# File lib/ey_services_api/integration.rb, line 33
def self.fetch_from_description(thing)
  mapper.description[thing] or raise "Expected 'description' to define a #{thing} for your service"
end
service_registration_params(base_url) click to toggle source
# File lib/ey_services_api/integration.rb, line 23
def self.service_registration_params(base_url)
  {
    :name                     => fetch_from_description(:name),
    :label                    =>  fetch_from_description(:label),
    :service_accounts_url     => "#{base_url + mapper.api_root}/service_accounts",
    :home_url                 => fetch_from_description(:home_url),
    :terms_and_conditions_url => fetch_from_description(:terms_and_conditions_url),
  }
end
test_setup(auth_id, auth_key, tresfiestas_url, tresfiestas_rackapp) click to toggle source
# File lib/ey_services_api/integration.rb, line 50
def self.test_setup(auth_id, auth_key, tresfiestas_url, tresfiestas_rackapp)
  mapper.save_api_creds(auth_id, auth_key)
  connection.backend = tresfiestas_rackapp
end