Sha256: d095d16b6d9844772e1de35f320e51af05c846991b570ae6b5bf9e8faa3661e2

Contents?: true

Size: 842 Bytes

Versions: 5

Compression:

Stored size: 842 Bytes

Contents

module Moip2
  class NotificationsApi
    attr_reader :client

    def initialize(client)
      @client = client
    end

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

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

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

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

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

      resp.success?
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
moip2-1.3.1 lib/moip2/notifications_api.rb
moip2-1.2.1 lib/moip2/notifications_api.rb
moip2-1.2.0 lib/moip2/notifications_api.rb
moip2-1.1.0 lib/moip2/notifications_api.rb
moip2-1.0.0 lib/moip2/notifications_api.rb