Class: SmbCloud::Auth::Client
- Inherits:
-
Object
- Object
- SmbCloud::Auth::Client
- Defined in:
- lib/auth.rb
Instance Attribute Summary collapse
-
#app_id ⇒ Object
readonly
Returns the value of attribute app_id.
-
#app_secret ⇒ Object
readonly
Returns the value of attribute app_secret.
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
Instance Method Summary collapse
-
#initialize(environment:, app_id:, app_secret:) ⇒ Client
constructor
A new instance of Client.
- #login(email:, password:) ⇒ Object
- #logout(access_token:) ⇒ Object
- #me(access_token:) ⇒ Object
- #remove(access_token:) ⇒ Object
-
#reset_password(email:) ⇒ Object
Requests password-reset instructions for the given email.
- #signup(email:, password:) ⇒ Object
Constructor Details
#initialize(environment:, app_id:, app_secret:) ⇒ Client
Returns a new instance of Client.
30 31 32 33 34 |
# File 'lib/auth.rb', line 30 def initialize(environment:, app_id:, app_secret:) @environment = environment @app_id = app_id @app_secret = app_secret end |
Instance Attribute Details
#app_id ⇒ Object (readonly)
Returns the value of attribute app_id.
28 29 30 |
# File 'lib/auth.rb', line 28 def app_id @app_id end |
#app_secret ⇒ Object (readonly)
Returns the value of attribute app_secret.
28 29 30 |
# File 'lib/auth.rb', line 28 def app_secret @app_secret end |
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
28 29 30 |
# File 'lib/auth.rb', line 28 def environment @environment end |
Instance Method Details
#login(email:, password:) ⇒ Object
42 43 44 45 46 |
# File 'lib/auth.rb', line 42 def login(email:, password:) Auth.send(:parse_json, Auth.__login_with_client(environment, app_id, app_secret, email, password)) rescue RuntimeError => e raise Auth.send(:normalize_error, e) end |
#logout(access_token:) ⇒ Object
64 65 66 67 68 |
# File 'lib/auth.rb', line 64 def logout(access_token:) Auth.__logout_with_client(environment, app_id, app_secret, access_token) rescue RuntimeError => e raise Auth.send(:normalize_error, e) end |
#me(access_token:) ⇒ Object
58 59 60 61 62 |
# File 'lib/auth.rb', line 58 def me(access_token:) Auth.send(:parse_json, Auth.__me_with_client(environment, app_id, app_secret, access_token)) rescue RuntimeError => e raise Auth.send(:normalize_error, e) end |
#remove(access_token:) ⇒ Object
70 71 72 73 74 |
# File 'lib/auth.rb', line 70 def remove(access_token:) Auth.__remove_with_client(environment, app_id, app_secret, access_token) rescue RuntimeError => e raise Auth.send(:normalize_error, e) end |
#reset_password(email:) ⇒ Object
Requests password-reset instructions for the given email. The endpoint never reveals whether the account exists (no enumeration), and calling it again re-issues the token, so this also serves the “resend reset instructions” flow. Returns { code:, message: }.
52 53 54 55 56 |
# File 'lib/auth.rb', line 52 def reset_password(email:) Auth.send(:parse_json, Auth.__reset_password_with_client(environment, app_id, app_secret, email)) rescue RuntimeError => e raise Auth.send(:normalize_error, e) end |