Class: Mints::Contact
- Inherits:
-
Object
- Object
- Mints::Contact
- Defined in:
- lib/contact.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
-
#change_password(data) ⇒ Object
Change Password.
-
#initialize(host, api_key, session_token = nil, contact_token_id = nil, debug = false) ⇒ Contact
constructor
Initialize.
-
#login(email, password) ⇒ Object
Login.
-
#logout ⇒ Object
Logout.
-
#me ⇒ Object
Me.
-
#oauth_login(data) ⇒ Object
OAuth Login.
-
#recover_password(data) ⇒ Object
Recover Password.
-
#reset_password(data) ⇒ Object
Reset Password.
-
#status ⇒ Object
Status.
-
#update(data) ⇒ Object
Update.
Constructor Details
#initialize(host, api_key, session_token = nil, contact_token_id = nil, debug = false) ⇒ Contact
Initialize.
Class constructor
10 11 12 |
# File 'lib/contact.rb', line 10 def initialize(host, api_key, session_token = nil, contact_token_id = nil, debug = false) @client = Mints::Client.new(host, api_key, "contact", session_token, contact_token_id, debug) end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
5 6 7 |
# File 'lib/contact.rb', line 5 def client @client end |
Instance Method Details
#change_password(data) ⇒ Object
Change Password.
Change password
46 47 48 |
# File 'lib/contact.rb', line 46 def change_password(data) return @client.raw("post", "/contacts/change-password", nil, data) end |
#login(email, password) ⇒ Object
Login.
Starts a contact session
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/contact.rb', line 18 def login(email, password) data = { email: email, password: password } response = @client.raw("post", "/contacts/login", nil, {data: data}) if response.key? "session_token" @client.session_token = response["session_token"] end return response end |
#logout ⇒ Object
Logout.
Ends a contact session
34 35 36 37 38 39 40 |
# File 'lib/contact.rb', line 34 def logout response = @client.raw("post", "/contacts/logout") if session_token? if response["success"] @client.session_token = nil end return response end |
#me ⇒ Object
Me.
Get contact logged info
78 79 80 |
# File 'lib/contact.rb', line 78 def me return @client.raw("get", "/contacts/me") end |
#oauth_login(data) ⇒ Object
OAuth Login.
Login a contact using oauth
70 71 72 |
# File 'lib/contact.rb', line 70 def oauth_login(data) return @client.raw("post", "/contacts/oauth-login", nil, data) end |
#recover_password(data) ⇒ Object
Recover Password.
Recover password
54 55 56 |
# File 'lib/contact.rb', line 54 def recover_password(data) return @client.raw("post", "/contacts/recover-password", nil, data) end |
#reset_password(data) ⇒ Object
Reset Password.
Reset password
62 63 64 |
# File 'lib/contact.rb', line 62 def reset_password(data) return @client.raw("post", "/contacts/reset-password", nil, data) end |
#status ⇒ Object
Status.
Get contact logged status
86 87 88 |
# File 'lib/contact.rb', line 86 def status return @client.raw("get", "/contacts/status") end |
#update(data) ⇒ Object
Update.
Update logged contact attributes
94 95 96 |
# File 'lib/contact.rb', line 94 def update(data) return @client.raw("put", "/contacts/update", nil, data) end |