Class: ResoTransport::Client
- Inherits:
-
Object
- Object
- ResoTransport::Client
- Defined in:
- lib/reso_transport/client.rb
Instance Attribute Summary collapse
-
#authentication ⇒ Object
readonly
Returns the value of attribute authentication.
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#ds_cache ⇒ Object
readonly
Returns the value of attribute ds_cache.
-
#ds_file ⇒ Object
readonly
Returns the value of attribute ds_file.
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
-
#md_cache ⇒ Object
readonly
Returns the value of attribute md_cache.
-
#md_file ⇒ Object
readonly
Returns the value of attribute md_file.
-
#uid ⇒ Object
readonly
Returns the value of attribute uid.
-
#use_replication_endpoint ⇒ Object
readonly
Returns the value of attribute use_replication_endpoint.
-
#vendor ⇒ Object
readonly
Returns the value of attribute vendor.
Instance Method Summary collapse
- #datasystem ⇒ Object
- #establish_connection ⇒ Object
-
#initialize(options) ⇒ Client
constructor
A new instance of Client.
- #inspect ⇒ Object
- #metadata ⇒ Object
- #resource_for(entity_set) ⇒ Object
- #resources ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(options) ⇒ Client
Returns a new instance of Client.
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/reso_transport/client.rb', line 6 def initialize() @use_replication_endpoint = .fetch(:use_replication_endpoint, false) @endpoint = .fetch(:endpoint) @md_file = .fetch(:md_file, nil) @ds_file = .fetch(:ds_file, nil) @authentication = ensure_valid_auth_strategy(.fetch(:authentication)) @vendor = .fetch(:vendor, {}) @faraday_options = .fetch(:faraday_options, {}) @logger = .fetch(:logger, nil) @md_cache = .fetch(:md_cache, ResoTransport::MetadataCache) @ds_cache = .fetch(:ds_cache, ResoTransport::MetadataCache) @connection = establish_connection end |
Instance Attribute Details
#authentication ⇒ Object (readonly)
Returns the value of attribute authentication.
3 4 5 |
# File 'lib/reso_transport/client.rb', line 3 def authentication @authentication end |
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
3 4 5 |
# File 'lib/reso_transport/client.rb', line 3 def connection @connection end |
#ds_cache ⇒ Object (readonly)
Returns the value of attribute ds_cache.
3 4 5 |
# File 'lib/reso_transport/client.rb', line 3 def ds_cache @ds_cache end |
#ds_file ⇒ Object (readonly)
Returns the value of attribute ds_file.
3 4 5 |
# File 'lib/reso_transport/client.rb', line 3 def ds_file @ds_file end |
#endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
3 4 5 |
# File 'lib/reso_transport/client.rb', line 3 def endpoint @endpoint end |
#md_cache ⇒ Object (readonly)
Returns the value of attribute md_cache.
3 4 5 |
# File 'lib/reso_transport/client.rb', line 3 def md_cache @md_cache end |
#md_file ⇒ Object (readonly)
Returns the value of attribute md_file.
3 4 5 |
# File 'lib/reso_transport/client.rb', line 3 def md_file @md_file end |
#uid ⇒ Object (readonly)
Returns the value of attribute uid.
3 4 5 |
# File 'lib/reso_transport/client.rb', line 3 def uid @uid end |
#use_replication_endpoint ⇒ Object (readonly)
Returns the value of attribute use_replication_endpoint.
3 4 5 |
# File 'lib/reso_transport/client.rb', line 3 def use_replication_endpoint @use_replication_endpoint end |
#vendor ⇒ Object (readonly)
Returns the value of attribute vendor.
3 4 5 |
# File 'lib/reso_transport/client.rb', line 3 def vendor @vendor end |
Instance Method Details
#datasystem ⇒ Object
44 45 46 |
# File 'lib/reso_transport/client.rb', line 44 def datasystem @datasystem ||= Datasystem.new(self) end |
#establish_connection ⇒ Object
20 21 22 23 24 25 26 27 |
# 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 ⇒ Object
52 53 54 |
# File 'lib/reso_transport/client.rb', line 52 def inspect to_s end |
#metadata ⇒ Object
40 41 42 |
# File 'lib/reso_transport/client.rb', line 40 def @metadata ||= Metadata.new(self) end |
#resource_for(entity_set) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/reso_transport/client.rb', line 33 def resource_for(entity_set) localizations = {} localizations = datasystem.localizations_for(entity_set.entity_type) if .datasystem? Resource.new(self, entity_set, localizations) end |
#resources ⇒ Object
29 30 31 |
# File 'lib/reso_transport/client.rb', line 29 def resources @resources ||= .entity_sets.map { |es| { es.name => resource_for(es) } }.reduce(:merge!) end |
#to_s ⇒ Object
48 49 50 |
# File 'lib/reso_transport/client.rb', line 48 def to_s %(#<ResoTransport::Client endpoint="#{endpoint}", md_file="#{md_file}", ds_file="#{ds_file}">) end |