Class: SecureNative::Client
- Inherits:
-
Object
- Object
- SecureNative::Client
- Defined in:
- lib/securenative/client.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
- ._flush ⇒ Object
- .init ⇒ Object
- .init_with_api_key(api_key) ⇒ Object
- .init_with_options(options) ⇒ Object
- .instance ⇒ Object
Instance Method Summary collapse
- #from_http_request(request) ⇒ Object
-
#initialize(options) ⇒ Client
constructor
A new instance of Client.
- #track(event_options) ⇒ Object
- #verify(event_options) ⇒ Object
- #verify_request_payload(request) ⇒ Object
Constructor Details
#initialize(options) ⇒ Client
Returns a new instance of Client.
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/securenative/client.rb', line 7 def initialize() @securenative = nil if SecureNative::Utils::Utils.null_or_empty?(.api_key) raise SecureNativeSDKError, 'You must pass your SecureNative api key' end = @event_manager = EventManager.new() @api_manager = SecureNative::ApiManager.new(@event_manager, ) SecureNative::Log.init_logger(.log_level) end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/securenative/client.rb', line 5 def end |
Class Method Details
._flush ⇒ Object
68 69 70 |
# File 'lib/securenative/client.rb', line 68 def self._flush @securenative = nil end |
.init ⇒ Object
49 50 51 52 |
# File 'lib/securenative/client.rb', line 49 def self.init = SecureNative::Config::ConfigurationManager.load_config () end |
.init_with_api_key(api_key) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/securenative/client.rb', line 30 def self.init_with_api_key(api_key) if SecureNative::Utils::Utils.null_or_empty?(api_key) raise SecureNativeConfigError, 'You must pass your SecureNative api key' end if @securenative.nil? = SecureNative::Config::ConfigurationBuilder.new(api_key: api_key) @securenative = SecureNative::Client.new() @securenative else SecureNative::Log.debug('This SDK was already initialized.') raise SecureNativeSDKError, 'This SDK was already initialized.' end end |
.init_with_options(options) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/securenative/client.rb', line 20 def self.() if @securenative.nil? @securenative = SecureNative::Client.new() @securenative else SecureNative::Log.debug('This SDK was already initialized.') raise SecureNativeSDKError, 'This SDK was already initialized.' end end |
.instance ⇒ Object
54 55 56 57 58 |
# File 'lib/securenative/client.rb', line 54 def self.instance raise SecureNativeSDKIllegalStateError if @securenative.nil? @securenative end |
Instance Method Details
#from_http_request(request) ⇒ Object
45 46 47 |
# File 'lib/securenative/client.rb', line 45 def from_http_request(request) SecureNative::Context.from_http_request(request, ) end |
#track(event_options) ⇒ Object
60 61 62 |
# File 'lib/securenative/client.rb', line 60 def track() @api_manager.track() end |
#verify(event_options) ⇒ Object
64 65 66 |
# File 'lib/securenative/client.rb', line 64 def verify() @api_manager.verify() end |
#verify_request_payload(request) ⇒ Object
72 73 74 75 76 77 |
# File 'lib/securenative/client.rb', line 72 def verify_request_payload(request) request_signature = request.header[SignatureUtils.SIGNATURE_HEADER] body = request.body SignatureUtils.valid_signature?(.api_key, body, request_signature) end |