Class: Files::EmailPreference

Inherits:
Object
  • Object
show all
Defined in:
lib/files.com/models/email_preference.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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 = {}, options = {})
  @attributes = attributes || {}
  @options = options || {}
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



5
6
7
# File 'lib/files.com/models/email_preference.rb', line 5

def attributes
  @attributes
end

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/files.com/models/email_preference.rb', line 5

def options
  @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 = {}, options = {})
  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, options = Api.send_request("/email_preferences/#{params[:token]}", :patch, params, options)
  EmailPreference.new(response.data, options)
end

Instance Method Details

#emailObject

email - Email address



13
14
15
# File 'lib/files.com/models/email_preference.rb', line 13

def email
  @attributes[:email]
end

#notificationsObject

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_alertsObject

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