Class: Streambird
- Inherits:
-
Object
- Object
- Streambird
- Defined in:
- lib/streambird.rb,
lib/streambird/api.rb,
lib/streambird/api/errors.rb,
lib/streambird/api/magic_links.rb
Defined Under Namespace
Classes: Api
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#default_request_params ⇒ Object
Returns the value of attribute default_request_params.
-
#logging ⇒ Object
Returns the value of attribute logging.
Class Method Summary collapse
Instance Method Summary collapse
- #client ⇒ Object
-
#initialize(api_key: nil, default_request_params: {}, logging: false) ⇒ Streambird
constructor
A new instance of Streambird.
- #live? ⇒ Boolean (also: #live, #live_mode?)
- #magic_links ⇒ Object
- #test? ⇒ Boolean (also: #test, #test_mode?)
Constructor Details
#initialize(api_key: nil, default_request_params: {}, logging: false) ⇒ Streambird
Returns a new instance of Streambird.
10 11 12 13 14 15 16 |
# File 'lib/streambird.rb', line 10 def initialize(api_key: nil, default_request_params: {}, logging: false) Streambird.validate_api_key(api_key) self.api_key = api_key self.default_request_params = default_request_params self.logging = logging end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
2 3 4 |
# File 'lib/streambird.rb', line 2 def api_key @api_key end |
#default_request_params ⇒ Object
Returns the value of attribute default_request_params.
2 3 4 |
# File 'lib/streambird.rb', line 2 def default_request_params @default_request_params end |
#logging ⇒ Object
Returns the value of attribute logging.
2 3 4 |
# File 'lib/streambird.rb', line 2 def logging @logging end |
Class Method Details
.validate_api_key(api_key) ⇒ Object
4 5 6 7 8 |
# File 'lib/streambird.rb', line 4 def self.validate_api_key(api_key) if api_key.length < 5 || !(api_key.start_with?('sk_live') || api_key.start_with?('sk_test')) raise Api::APIKeyInvalid end end |
Instance Method Details
#client ⇒ Object
26 27 28 29 |
# File 'lib/streambird.rb', line 26 def client puts default_request_params @client ||= Api.new(api_key, default_request_params, logging) end |
#live? ⇒ Boolean Also known as: live, live_mode?
18 19 20 |
# File 'lib/streambird.rb', line 18 def live? api_key.start_with?('sk_live') end |
#magic_links ⇒ Object
31 32 33 |
# File 'lib/streambird.rb', line 31 def magic_links @magic_links ||= Streambird::Api::MagicLinks.new(client) end |
#test? ⇒ Boolean Also known as: test, test_mode?
22 23 24 |
# File 'lib/streambird.rb', line 22 def test? api_key.start_with?('sk_test') end |