Class: EY::ServicesAPI::Integration

Inherits:
Object
  • Object
show all
Defined in:
lib/ey_services_api/integration.rb,
lib/ey_services_api/integration/server.rb

Defined Under Namespace

Classes: Server

Class Method Summary collapse

Class Method Details

.connectionObject



43
44
45
46
47
48
# 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) ⇒ Object



37
38
39
40
41
# 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) ⇒ Object



33
34
35
# 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

.mapperObject



17
18
19
# File 'lib/ey_services_api/integration.rb', line 17

def self.mapper
  @mapper
end

.mapper=(mapper) ⇒ Object



13
14
15
# File 'lib/ey_services_api/integration.rb', line 13

def self.mapper=(mapper)
  @mapper = mapper
end

.register_service(registration_url, service_url) ⇒ Object



5
6
7
# 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

.serverObject



9
10
11
# File 'lib/ey_services_api/integration.rb', line 9

def self.server
  Server
end

.service_registration_params(base_url) ⇒ Object



23
24
25
26
27
28
29
30
31
# 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) ⇒ Object



50
51
52
53
# 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