Class: Smyte::Client
- Inherits:
-
Object
- Object
- Smyte::Client
- Defined in:
- lib/smyte/client.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#api_secret ⇒ Object
readonly
Returns the value of attribute api_secret.
-
#enabled ⇒ Object
readonly
Returns the value of attribute enabled.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
- #action(event_name, payload) ⇒ Object
- #classify(event_name, payload, options = {}) ⇒ Object
-
#initialize(options = nil) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(options = nil) ⇒ Client
Returns a new instance of Client.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/smyte/client.rb', line 9 def initialize(=nil) ||= {} [:api_key, :api_secret, :logger, :enabled].each do |key| if .has_key?(key) value = [key] else value = Smyte.send(key) end instance_variable_set("@#{key}", value) end end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
7 8 9 |
# File 'lib/smyte/client.rb', line 7 def api_key @api_key end |
#api_secret ⇒ Object (readonly)
Returns the value of attribute api_secret.
7 8 9 |
# File 'lib/smyte/client.rb', line 7 def api_secret @api_secret end |
#enabled ⇒ Object (readonly)
Returns the value of attribute enabled.
7 8 9 |
# File 'lib/smyte/client.rb', line 7 def enabled @enabled end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
7 8 9 |
# File 'lib/smyte/client.rb', line 7 def logger @logger end |
Instance Method Details
#action(event_name, payload) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/smyte/client.rb', line 21 def action(event_name, payload) return true if !enabled process(event_name, payload, "/v2/action") true # any success is just true - nothing else to know end |
#classify(event_name, payload, options = {}) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/smyte/client.rb', line 28 def classify(event_name, payload, ={}) return Smyte::Classification.allowed if !enabled response = process(event_name, payload, "/v2/action/classify") Smyte::Classification.new(response, ) end |