Class: Moip2::NotificationsApi

Inherits:
Object
  • Object
show all
Defined in:
lib/moip2/notifications_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ NotificationsApi



5
6
7
# File 'lib/moip2/notifications_api.rb', line 5

def initialize(client)
  @client = client
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



3
4
5
# File 'lib/moip2/notifications_api.rb', line 3

def client
  @client
end

Instance Method Details

#base_path(app_id: nil, notification_id: nil) ⇒ Object



9
10
11
# File 'lib/moip2/notifications_api.rb', line 9

def base_path(app_id: nil, notification_id: nil)
  ["", "v2", "preferences", app_id, "notifications", notification_id].compact.join("/")
end

#create(notification, app_id = nil) ⇒ Object



13
14
15
# File 'lib/moip2/notifications_api.rb', line 13

def create(notification, app_id = nil)
  Resource::Notification.new client, client.post(base_path(app_id: app_id), notification)
end

#delete(notification_id) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/moip2/notifications_api.rb', line 25

def delete(notification_id)
  resp = Resource::Notification.new client, client.delete(
    base_path(notification_id: notification_id),
  )

  resp.success?
end

#find_allObject



21
22
23
# File 'lib/moip2/notifications_api.rb', line 21

def find_all
  Resource::Notification.new client, client.get(base_path)
end

#show(notification_id) ⇒ Object



17
18
19
# File 'lib/moip2/notifications_api.rb', line 17

def show(notification_id)
  Resource::Notification.new client, client.get(base_path(notification_id: notification_id))
end