class ResoTransport::Client
Attributes
authentication[R]
connection[R]
ds_cache[R]
ds_file[R]
endpoint[R]
md_cache[R]
md_file[R]
uid[R]
use_replication_endpoint[R]
vendor[R]
Public Class Methods
new(options)
click to toggle source
# File lib/reso_transport/client.rb, line 6 def initialize(options) @use_replication_endpoint = options.fetch(:use_replication_endpoint, false) @endpoint = options.fetch(:endpoint) @md_file = options.fetch(:md_file, nil) @ds_file = options.fetch(:ds_file, nil) @authentication = ensure_valid_auth_strategy(options.fetch(:authentication)) @vendor = options.fetch(:vendor, {}) @faraday_options = options.fetch(:faraday_options, {}) @logger = options.fetch(:logger, nil) @md_cache = options.fetch(:md_cache, ResoTransport::MetadataCache) @ds_cache = options.fetch(:ds_cache, ResoTransport::MetadataCache) @connection = establish_connection end
Public Instance Methods
datasystem()
click to toggle source
# File lib/reso_transport/client.rb, line 44 def datasystem @datasystem ||= Datasystem.new(self) end
establish_connection()
click to toggle source
# File lib/reso_transport/client.rb, line 20 def establish_connection Faraday.new(@endpoint, @faraday_options) do |faraday| faraday.request :url_encoded faraday.response :logger, @logger || ResoTransport.configuration.logger faraday.use Authentication::Middleware, @authentication faraday.adapter Faraday.default_adapter # unless faraday.builder.send(:adapter_set?) end end
inspect()
click to toggle source
# File lib/reso_transport/client.rb, line 52 def inspect to_s end
metadata()
click to toggle source
# File lib/reso_transport/client.rb, line 40 def metadata @metadata ||= Metadata.new(self) end
resource_for(entity_set)
click to toggle source
# File lib/reso_transport/client.rb, line 33 def resource_for(entity_set) localizations = {} localizations = datasystem.localizations_for(entity_set.entity_type) if metadata.datasystem? Resource.new(self, entity_set, localizations) end
resources()
click to toggle source
# File lib/reso_transport/client.rb, line 29 def resources @resources ||= metadata.entity_sets.map { |es| { es.name => resource_for(es) } }.reduce(:merge!) end
to_s()
click to toggle source
# File lib/reso_transport/client.rb, line 48 def to_s %(#<ResoTransport::Client endpoint="#{endpoint}", md_file="#{md_file}", ds_file="#{ds_file}">) end
Private Instance Methods
ensure_valid_auth_strategy(options)
click to toggle source
# File lib/reso_transport/client.rb, line 58 def ensure_valid_auth_strategy(options) case options when Hash if options.key?(:endpoint) Authentication::FetchTokenAuth.new(options) else Authentication::StaticTokenAuth.new(options) end else raise ArgumentError, "#{options.inspect} invalid: cannot determine strategy" end end