Class: AlephApi::XServicesClient

Inherits:
Object
  • Object
show all
Defined in:
lib/aleph_api/x_services_client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ XServicesClient

Returns a new instance of XServicesClient.



12
13
14
15
16
17
# File 'lib/aleph_api/x_services_client.rb', line 12

def initialize(options = {})
  options.symbolize_keys.try do |_sanitized_options|
    @host = (_sanitized_options[:host] || ENV["ALEPH_X_XSERVICES_HOST"] || ENV["ALEPH_API_HOST"]).try(:strip)
    @url = (_sanitized_options[:url] || ENV["ALEPH_X_SERVICES_URL"]).try(:strip)
  end
end

Instance Attribute Details

#hostObject

Returns the value of attribute host.



5
6
7
# File 'lib/aleph_api/x_services_client.rb', line 5

def host
  @host
end

#urlObject

Returns the value of attribute url.



6
7
8
# File 'lib/aleph_api/x_services_client.rb', line 6

def url
  @url
end

Instance Method Details

#get(params = {}) ⇒ Object



19
20
21
# File 'lib/aleph_api/x_services_client.rb', line 19

def get(params = {})
  Faraday.get(self.url, params).body
end

#post(params = {}) ⇒ Object



23
24
25
# File 'lib/aleph_api/x_services_client.rb', line 23

def post(params = {})
  Faraday.post(self.url, params).body
end