Class: Magic
- Inherits:
-
Object
- Object
- Magic
- Defined in:
- lib/magic-admin.rb
Overview
Magic Class to access resources
Constant Summary collapse
- RETRIES =
3
- TIMEOUT =
5
- BACKOFF =
0.02
Instance Attribute Summary collapse
-
#client_id ⇒ Object
readonly
attribute reader for magic client id.
-
#http_client ⇒ Object
readonly
attribute reader for magic http client.
-
#secret_key ⇒ Object
readonly
attribute reader for magic api secret key.
Instance Method Summary collapse
-
#initialize(api_secret_key: nil, retries: nil, timeout: nil, backoff: nil, client_id: nil) ⇒ Magic
constructor
The constructor allows you to specify your own API secret key and HTTP request strategy when your application interacting with the Magic API.
-
#token ⇒ Object
Description: Method provides you Token object for various utility methods of Token.
-
#user ⇒ Object
Description: Method provides you User object for interacting with the Magic API.
Constructor Details
#initialize(api_secret_key: nil, retries: nil, timeout: nil, backoff: nil, client_id: nil) ⇒ Magic
The constructor allows you to specify your own API secret key and HTTP request strategy when your application interacting with the Magic API.
It will automatically configure required arguments using the following environment variables
MAGIC_API_SECRET_KEY
MAGIC_API_RETRIES
MAGIC_API_TIMEOUT
MAGIC_API_BACKOFF
Arguments:
api_secret_key: Your API Secret Key retrieved from the Magic Dashboard.
retries: Total number of retries to allow.
timeout: A period of time the request is going to wait for a response.
backoff: A backoff factor to apply between retry attempts.
Returns:
A Magic object that provides access to all the supported resources.
Examples:
Magic.new
Magic.new api_secret_key: "SECRET_KEY>"
Magic.new api_secret_key: "SECRET_KEY>",
retries: 2,
timeout: 2,
backoff: 0.2
75 76 77 78 79 80 81 82 83 |
# File 'lib/magic-admin.rb', line 75 def initialize(api_secret_key: nil, retries: nil, timeout: nil, backoff: nil, client_id: nil) secret_key!(api_secret_key) http_client!(retries, timeout, backoff) client_id!(client_id, api_secret_key) end |
Instance Attribute Details
#client_id ⇒ Object (readonly)
attribute reader for magic client id
42 43 44 |
# File 'lib/magic-admin.rb', line 42 def client_id @client_id end |
#http_client ⇒ Object (readonly)
attribute reader for magic http client
39 40 41 |
# File 'lib/magic-admin.rb', line 39 def http_client @http_client end |
#secret_key ⇒ Object (readonly)
attribute reader for magic api secret key
36 37 38 |
# File 'lib/magic-admin.rb', line 36 def secret_key @secret_key end |
Instance Method Details
#token ⇒ Object
Description:
Method provides you Token object
for various utility methods of Token.
Returns:
A Token object that provides access to
all the supported resources.
105 106 107 |
# File 'lib/magic-admin.rb', line 105 def token MagicAdmin::Resource::Token.new(self) end |
#user ⇒ Object
Description:
Method provides you User object
for interacting with the Magic API.
Returns:
A User object that provides access to
all the supported resources.
93 94 95 |
# File 'lib/magic-admin.rb', line 93 def user MagicAdmin::Resource::User.new(self) end |