Class: Userstack::Client
- Inherits:
-
Object
- Object
- Userstack::Client
- Defined in:
- lib/userstack/client.rb
Overview
A class which wraps calls to Userstack API
Instance Method Summary collapse
-
#initialize(access_key, use_ssl: true, legacy: false) ⇒ Client
constructor
A new instance of Client.
-
#parse(useragent) ⇒ Hash
Parse an useragent using Userstack.
Constructor Details
#initialize(access_key, use_ssl: true, legacy: false) ⇒ Client
Returns a new instance of Client.
17 18 19 20 21 22 23 24 |
# File 'lib/userstack/client.rb', line 17 def initialize(access_key, use_ssl: true, legacy: false) raise ArgumentError, 'Invalid Access key' if access_key.nil? || access_key.empty? @access_key = access_key.freeze @use_ssl = use_ssl @legacy = legacy freeze end |
Instance Method Details
#parse(useragent) ⇒ Hash
Parse an useragent using Userstack
32 33 34 35 36 37 |
# File 'lib/userstack/client.rb', line 32 def parse(useragent) raise ArgumentError, 'Invalid useragent' if useragent.nil? || useragent.empty? response = request(useragent) parse_as_json(response.body) end |