Class: Workato::Connector::Sdk::Connection
- Inherits:
-
Object
- Object
- Workato::Connector::Sdk::Connection
- Extended by:
- T::Sig
- Includes:
- MonitorMixin
- Defined in:
- lib/workato/connector/sdk/connection.rb
Defined Under Namespace
Classes: Authorization
Instance Attribute Summary collapse
- #source ⇒ ActiveSupport::HashWithIndifferentAccess readonly private
Instance Method Summary collapse
- #authorization ⇒ Authorization
- #authorization? ⇒ Boolean private
- #base_uri(settings = nil) ⇒ String?
- #initialize(connection: {}, methods: {}, settings: {}) ⇒ void constructor
- #merge_settings!(settings) ⇒ SorbetTypes::SettingsHash private
- #settings ⇒ ActiveSupport::HashWithIndifferentAccess private
- #settings! ⇒ SorbetTypes::SettingsHash private
- #update_settings!(message, settings_before, &refresher) ⇒ Boolean private
Constructor Details
#initialize(connection: {}, methods: {}, settings: {}) ⇒ void
64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/workato/connector/sdk/connection.rb', line 64 def initialize(connection: {}, methods: {}, settings: {}) super() @methods_source = T.let( Utilities::HashWithIndifferentAccess.wrap(methods), ActiveSupport::HashWithIndifferentAccess ) @source = T.let( Utilities::HashWithIndifferentAccess.wrap(connection), ActiveSupport::HashWithIndifferentAccess ) @settings = T.let(settings, SorbetTypes::SettingsHash) end |
Instance Attribute Details
#source ⇒ ActiveSupport::HashWithIndifferentAccess (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
52 53 54 |
# File 'lib/workato/connector/sdk/connection.rb', line 52 def source @source end |
Instance Method Details
#authorization ⇒ Authorization
106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/workato/connector/sdk/connection.rb', line 106 def raise ::NotImplementedError, 'define authorization: before use' if source[:authorization].blank? ||= T.let( Authorization.new( connection: self, authorization: source[:authorization], methods: methods_source ), T.nilable(Authorization) ) end |
#authorization? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
101 102 103 |
# File 'lib/workato/connector/sdk/connection.rb', line 101 def source[:authorization].present? end |
#base_uri(settings = nil) ⇒ String?
120 121 122 123 124 125 |
# File 'lib/workato/connector/sdk/connection.rb', line 120 def base_uri(settings = nil) return unless source[:base_uri] merge_settings!(settings) if settings global_dsl_context.execute(self.settings, &source['base_uri']) end |
#merge_settings!(settings) ⇒ SorbetTypes::SettingsHash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
95 96 97 |
# File 'lib/workato/connector/sdk/connection.rb', line 95 def merge_settings!(settings) @settings.merge!(settings) end |
#settings ⇒ ActiveSupport::HashWithIndifferentAccess
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
85 86 87 88 89 90 91 |
# File 'lib/workato/connector/sdk/connection.rb', line 85 def settings # we can't freeze or memoise because some developers modify it for storing something temporary in it. # always return a new copy synchronize do @settings.with_indifferent_access end end |
#settings! ⇒ SorbetTypes::SettingsHash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
79 80 81 |
# File 'lib/workato/connector/sdk/connection.rb', line 79 def settings! @settings end |
#update_settings!(message, settings_before, &refresher) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/workato/connector/sdk/connection.rb', line 135 def update_settings!(, settings_before, &refresher) updater = lambda do new_settings = refresher.call next unless new_settings settings.merge(new_settings) end synchronize do new_settings = if on_settings_update T.must(on_settings_update).call(, settings_before, updater) else updater.call end return false unless new_settings merge_settings!(new_settings) true end end |