Class: Infopark::Crm::Contact
- Inherits:
-
Infopark::Crm::Core::Resource
- Object
- ActiveResource::Base
- Infopark::Crm::Core::Resource
- Infopark::Crm::Contact
- Defined in:
- lib/crm_connector/contact.rb
Class Method Summary collapse
-
.authenticate(login, password) ⇒ Infopark::Crm::Contact
Looks for the user with the given
login
and check whether thepassword
is correct. -
.password_set(password, token) ⇒ String
Sets a new
password
for the contact, which is associated with the giventoken
. -
.search(input) ⇒ Array<Infopark::Crm::Contact>
Searches for contacts.
Instance Method Summary collapse
-
#account ⇒ Infopark::Crm::Account
Queries the WebCRM for the Account with the id
account_id
. -
#live_server_groups ⇒ Array<String>
Returns the live_server_groups of this contact as defined by
Configuration.live_server_groups_callback
. -
#live_server_groups=(value)
Overwrites
live_server_groups
, so live_server_groups_callback is not called for this object. -
#password_request(options = {}) ⇒ Object
Instructs the WebCRM to send the user an e-mail to let them set a new password.
-
#password_set(password)
Sets the password of this contact to
password
.
Class Method Details
.authenticate(login, password) ⇒ Infopark::Crm::Contact
Looks for the user with the given login
and check whether the password
is correct.
60 61 62 63 64 65 66 67 68 |
# File 'lib/crm_connector/contact.rb', line 60 def self.authenticate(login, password) begin response = post(:authenticate, {}, format.encode({:login => login, :password => password})) result = format.decode(response.body) find(result) rescue ActiveResource::ResourceInvalid raise Errors::AuthenticationFailed end end |
.password_set(password, token) ⇒ String
Sets a new password
for the contact, which is associated with the given token
.
76 77 78 79 |
# File 'lib/crm_connector/contact.rb', line 76 def self.password_set(password, token) response = post(:password_set, {}, format.encode({:password => password, :token => token})) format.decode(response.body) end |
.search(input) ⇒ Array<Infopark::Crm::Contact>
Searches for contacts
14 |
# File 'lib/crm_connector/contact.rb', line 14 has_search |
Instance Method Details
#account ⇒ Infopark::Crm::Account
Queries the WebCRM for the Account with the id account_id
.
49 50 51 |
# File 'lib/crm_connector/contact.rb', line 49 def account Infopark::Crm::Account.find(account_id) if account_id end |
#live_server_groups ⇒ Array<String>
Returns the live_server_groups of this contact as defined by Configuration.live_server_groups_callback
103 104 105 106 107 108 109 110 |
# File 'lib/crm_connector/contact.rb', line 103 def live_server_groups return @live_server_groups if defined?(@live_server_groups) callback = Configuration.live_server_groups_callback @live_server_groups = callback.call(self) if callback.respond_to?(:call) raise "live_server_groups_callback: not defined or unexpected result!" unless @live_server_groups @live_server_groups end |
#live_server_groups=(value)
This method returns an undefined value.
Overwrites live_server_groups
, so live_server_groups_callback is not called for this object.
115 116 117 |
# File 'lib/crm_connector/contact.rb', line 115 def live_server_groups=(value) @live_server_groups = value end |
#password_request(options = {}) ⇒ Object
Instructs the WebCRM to send the user an e-mail to let them set a new password.
95 96 97 98 99 |
# File 'lib/crm_connector/contact.rb', line 95 def password_request( = {}) params = [:params] || {} response = post(:password_request, {}, self.class.format.encode(params)) self.class.format.decode(response.body) end |
#password_set(password)
This method returns an undefined value.
Sets the password of this contact to password
.
85 86 87 88 |
# File 'lib/crm_connector/contact.rb', line 85 def password_set(password) token = password_request(:params => {:only_get_token => true}) self.class.password_set(password, token) end |