Class: Files::EmailPreference
- Inherits:
-
Object
- Object
- Files::EmailPreference
- Defined in:
- lib/files.com/models/email_preference.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
-
.update(token, params = {}, options = {}) ⇒ Object
Parameters: token (required) - string - Email preferences token.
Instance Method Summary collapse
-
#email ⇒ Object
email - Email address.
-
#initialize(attributes = {}, options = {}) ⇒ EmailPreference
constructor
A new instance of EmailPreference.
-
#notifications ⇒ Object
array - A list of notifications.
-
#receive_admin_alerts ⇒ Object
boolean - Receive admin alerts?.
Constructor Details
#initialize(attributes = {}, options = {}) ⇒ EmailPreference
Returns a new instance of EmailPreference.
7 8 9 10 |
# File 'lib/files.com/models/email_preference.rb', line 7 def initialize(attributes = {}, = {}) @attributes = attributes || {} @options = || {} end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
5 6 7 |
# File 'lib/files.com/models/email_preference.rb', line 5 def attributes @attributes end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/files.com/models/email_preference.rb', line 5 def @options end |
Class Method Details
.update(token, params = {}, options = {}) ⇒ Object
Parameters:
token (required) - string - Email preferences token.
user[receive_admin_alerts] - boolean
user[unsubscribed] - boolean
user[notifications][id] (required) - array
user[notifications][group] - array
user[notifications][send_interval] - array
user[notifications][unsubscribe] - array
user[unsubscribe] - string
36 37 38 39 40 41 42 43 44 |
# File 'lib/files.com/models/email_preference.rb', line 36 def self.update(token, params = {}, = {}) params ||= {} params[:token] = token raise InvalidParameterError.new("Bad parameter: token must be an String") if params.dig(:token) and !params.dig(:token).is_a?(String) raise MissingParameterError.new("Parameter missing: token") unless params.dig(:token) response, = Api.send_request("/email_preferences/#{params[:token]}", :patch, params, ) EmailPreference.new(response.data, ) end |
Instance Method Details
#email ⇒ Object
email - Email address
13 14 15 |
# File 'lib/files.com/models/email_preference.rb', line 13 def email @attributes[:email] end |
#notifications ⇒ Object
array - A list of notifications
18 19 20 |
# File 'lib/files.com/models/email_preference.rb', line 18 def notifications @attributes[:notifications] end |
#receive_admin_alerts ⇒ Object
boolean - Receive admin alerts?
23 24 25 |
# File 'lib/files.com/models/email_preference.rb', line 23 def receive_admin_alerts @attributes[:receive_admin_alerts] end |