Class: DingSDK::Ding
Instance Attribute Summary collapse
-
#gen_version ⇒ Object
Returns the value of attribute gen_version.
-
#language ⇒ Object
Returns the value of attribute language.
-
#lookup ⇒ Object
Returns the value of attribute lookup.
-
#otp ⇒ Object
Returns the value of attribute otp.
-
#sdk_version ⇒ Object
Returns the value of attribute sdk_version.
-
#security ⇒ Object
Returns the value of attribute security.
Instance Method Summary collapse
- #config_security(security) ⇒ Object
- #config_server(params) ⇒ Object
- #config_server_url(params) ⇒ Object
- #init_sdks ⇒ Object
-
#initialize(security: nil, server: nil, server_url: nil, url_params: nil, client: nil) ⇒ Ding
constructor
A new instance of Ding.
Constructor Details
#initialize(security: nil, server: nil, server_url: nil, url_params: nil, client: nil) ⇒ Ding
Returns a new instance of Ding.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/ding/sdk.rb', line 26 def initialize(security: nil, server: nil, server_url: nil, url_params: nil, client: nil) ## Instantiates the SDK configuring it with the provided parameters. # @param [Shared::Security] security The security details required for authentication # @param [String] server The server by name to use for all operations # @param [String] server_url The server URL to use for all operations # @param [Hash<Symbol, String>] url_params Parameters to optionally template the server URL with # @param [Faraday::Request] client The faraday HTTP client to use for all operations if client.nil? client = Faraday.new(request: { params_encoder: Faraday::FlatParamsEncoder }) do |f| f.request :multipart, {} # f.response :logger end end if !server_url.nil? if !url_params.nil? server_url = Utils.template_url(server_url, url_params) end end server = SERVER_PRODUCTION if server.nil? @sdk_configuration = SDKConfiguration.new(client, security, server_url, server) init_sdks end |
Instance Attribute Details
#gen_version ⇒ Object
Returns the value of attribute gen_version.
17 18 19 |
# File 'lib/ding/sdk.rb', line 17 def gen_version @gen_version end |
#language ⇒ Object
Returns the value of attribute language.
17 18 19 |
# File 'lib/ding/sdk.rb', line 17 def language @language end |
#lookup ⇒ Object
Returns the value of attribute lookup.
15 16 17 |
# File 'lib/ding/sdk.rb', line 15 def lookup @lookup end |
#otp ⇒ Object
Returns the value of attribute otp.
15 16 17 |
# File 'lib/ding/sdk.rb', line 15 def otp @otp end |
#sdk_version ⇒ Object
Returns the value of attribute sdk_version.
17 18 19 |
# File 'lib/ding/sdk.rb', line 17 def sdk_version @sdk_version end |
#security ⇒ Object
Returns the value of attribute security.
17 18 19 |
# File 'lib/ding/sdk.rb', line 17 def security @security end |
Instance Method Details
#config_security(security) ⇒ Object
78 79 80 81 |
# File 'lib/ding/sdk.rb', line 78 def config_security(security) @security = security @sdk_configuration.security = security end |
#config_server(params) ⇒ Object
70 71 72 73 74 75 |
# File 'lib/ding/sdk.rb', line 70 def config_server(params) raise StandardError, 'Invalid server' if !SERVERS.include? server config_server_url(params) init_sdks end |
#config_server_url(params) ⇒ Object
62 63 64 65 66 67 |
# File 'lib/ding/sdk.rb', line 62 def config_server_url(params) if !params.nil? @server_url = Utils.template_url(@server_url, params) end init_sdks end |