Class: SelfSDK::App
- Inherits:
-
Object
- Object
- SelfSDK::App
- Defined in:
- lib/selfsdk.rb
Overview
Abstract base class for CLI utilities. Provides some helper methods for the option parser
Constant Summary collapse
- BASE_URL =
"https://api.joinself.com".freeze
- MESSAGING_URL =
"wss://messaging.joinself.com/v1/messaging".freeze
Instance Attribute Summary collapse
-
#app_id ⇒ Types
readonly
the identifier of the current app.
-
#app_key ⇒ Types
readonly
the api key for the current app.
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#messaging_client ⇒ Object
Returns the value of attribute messaging_client.
Instance Method Summary collapse
-
#authentication ⇒ Object
Provides access to SelfSDK::Services::Authentication service.
-
#close ⇒ Object
Closes the websocket connection.
-
#facts ⇒ Object
Provides access to SelfSDK::Services::Facts service.
-
#identity ⇒ Object
Provides access to SelfSDK::Services::Identity service.
-
#initialize(app_id, app_key, storage_key, storage_dir, opts = {}) ⇒ App
constructor
Initializes a SelfSDK App.
-
#messaging ⇒ Object
Provides access to SelfSDK::Services::Messaging service.
Constructor Details
permalink #initialize(app_id, app_key, storage_key, storage_dir, opts = {}) ⇒ App
Initializes a SelfSDK App
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/selfsdk.rb', line 49 def initialize(app_id, app_key, storage_key, storage_dir, opts = {}) SelfSDK.logger.debug "syncing ntp times #{SelfSDK::Time.now}" env = opts.fetch(:env, "") @client = RestClient.new(base_url(opts), app_id, app_key, env) messaging_url = messaging_url(opts) unless messaging_url.nil? @messaging_client = MessagingClient.new(messaging_url, @client, storage_key, storage_dir: storage_dir, auto_reconnect: opts.fetch(:auto_reconnect, MessagingClient::DEFAULT_AUTO_RECONNECT), device_id: opts.fetch(:device_id, MessagingClient::DEFAULT_DEVICE)) end end |
Instance Attribute Details
permalink #app_id ⇒ Types (readonly)
the identifier of the current app.
31 32 33 |
# File 'lib/selfsdk.rb', line 31 def app_id @app_id end |
permalink #app_key ⇒ Types (readonly)
the api key for the current app.
31 32 33 |
# File 'lib/selfsdk.rb', line 31 def app_key @app_key end |
permalink #client ⇒ Object (readonly)
Returns the value of attribute client.
35 36 37 |
# File 'lib/selfsdk.rb', line 35 def client @client end |
permalink #messaging_client ⇒ Object
Returns the value of attribute messaging_client.
36 37 38 |
# File 'lib/selfsdk.rb', line 36 def messaging_client @messaging_client end |
Instance Method Details
permalink #authentication ⇒ Object
Provides access to SelfSDK::Services::Authentication service
71 72 73 |
# File 'lib/selfsdk.rb', line 71 def authentication @authentication ||= SelfSDK::Services::Authentication.new(messaging, @client) end |
permalink #close ⇒ Object
Closes the websocket connection
94 95 96 |
# File 'lib/selfsdk.rb', line 94 def close @messaging_client.close end |
permalink #facts ⇒ Object
Provides access to SelfSDK::Services::Facts service
66 67 68 |
# File 'lib/selfsdk.rb', line 66 def facts @facts ||= SelfSDK::Services::Facts.new(messaging, @client) end |