Class: MagicBell::User

Inherits:
ApiResource show all
Includes:
ApiOperations
Defined in:
lib/magicbell/api_resources/user.rb

Instance Attribute Summary collapse

Attributes inherited from ApiResource

#id

Instance Method Summary collapse

Methods included from ApiOperations

#get, #post, #put

Methods inherited from ApiResource

#attribute, #attributes, #create, create, create_path, #create_path, create_url, #create_url, find, #name, name, #retrieve, #update, #url

Constructor Details

#initialize(client, attributes) ⇒ User

Returns a new instance of User.



7
8
9
10
11
# File 'lib/magicbell/api_resources/user.rb', line 7

def initialize(client, attributes)
  @client = client
  @email = attributes["email"]
  super(client, attributes)
end

Instance Attribute Details

#emailObject (readonly)

Returns the value of attribute email.



5
6
7
# File 'lib/magicbell/api_resources/user.rb', line 5

def email
  @email
end

Instance Method Details

#authentication_headersObject



46
47
48
# File 'lib/magicbell/api_resources/user.rb', line 46

def authentication_headers
  MagicBell.authentication_headers.merge("X-MAGICBELL-USER-EMAIL" => email)
end

#find_notification(notification_id) ⇒ Object



18
19
20
21
# File 'lib/magicbell/api_resources/user.rb', line 18

def find_notification(notification_id)
  client = self
  MagicBell::UserNotification.find(client, notification_id)
end

#mark_all_notifications_as_readObject



23
24
25
26
# File 'lib/magicbell/api_resources/user.rb', line 23

def mark_all_notifications_as_read
  client = self
  MagicBell::UserNotificationsRead.new(client).create
end

#mark_all_notifications_as_seenObject



28
29
30
31
# File 'lib/magicbell/api_resources/user.rb', line 28

def mark_all_notifications_as_seen
  client = self
  MagicBell::UserNotificationsSeen.new(client).create
end

#notification_preferencesObject



33
34
35
36
# File 'lib/magicbell/api_resources/user.rb', line 33

def notification_preferences
  client = self
  MagicBell::UserNotificationPreferences.new(client)
end

#notifications(query_params = {}) ⇒ Object



13
14
15
16
# File 'lib/magicbell/api_resources/user.rb', line 13

def notifications(query_params = {})
  client = self
  MagicBell::UserNotifications.new(client, query_params)
end

#pathObject



38
39
40
41
42
43
44
# File 'lib/magicbell/api_resources/user.rb', line 38

def path
  if id
    self.class.path + "/#{id}"
  elsif email
    self.class.path + "/email:#{email}"
  end
end