Class: DingSDK::Ding

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/ding_sdk/ding.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client: nil, security: nil, server_idx: nil, server_url: nil, url_params: 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/ding.rb', line 26

def initialize(client: nil,
               security: nil,
               server_idx: nil,
               server_url: nil,
               url_params: nil)

  ## Instantiates the SDK configuring it with the provided parameters.
  # @param [Faraday::Request] client The faraday HTTP client to use for all operations
  # @param [Shared::Security] security The security details required for authentication
  # @param [Integer] server_idx The index of the server 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

  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_idx = 0 if server_idx.nil?

  

  @sdk_configuration = SDKConfiguration.new(client, security, server_url, server_idx)
  init_sdks
end

Instance Attribute Details

#gen_versionObject

Returns the value of attribute gen_version.



17
18
19
# File 'lib/ding_sdk/ding.rb', line 17

def gen_version
  @gen_version
end

#languageObject

Returns the value of attribute language.



17
18
19
# File 'lib/ding_sdk/ding.rb', line 17

def language
  @language
end

#lookupObject

Returns the value of attribute lookup.



15
16
17
# File 'lib/ding_sdk/ding.rb', line 15

def lookup
  @lookup
end

#otpObject

Returns the value of attribute otp.



15
16
17
# File 'lib/ding_sdk/ding.rb', line 15

def otp
  @otp
end

#sdk_versionObject

Returns the value of attribute sdk_version.



17
18
19
# File 'lib/ding_sdk/ding.rb', line 17

def sdk_version
  @sdk_version
end

#securityObject

Returns the value of attribute security.



17
18
19
# File 'lib/ding_sdk/ding.rb', line 17

def security
  @security
end

Instance Method Details

#config_security(security) ⇒ Object



70
71
72
73
# File 'lib/ding_sdk/ding.rb', line 70

def config_security(security)
  @security = security
  @sdk_configuration.security = security
end

#config_server_url(params) ⇒ Object



62
63
64
65
66
67
# File 'lib/ding_sdk/ding.rb', line 62

def config_server_url(params)
  if !params.nil?
    @server_url = Utils.template_url(@server_url, params)
  end
  init_sdks
end

#init_sdksObject



76
77
78
79
# File 'lib/ding_sdk/ding.rb', line 76

def init_sdks
  @otp = Otp.new(@sdk_configuration)
  @lookup = Lookup.new(@sdk_configuration)
end