module Moip2
  class NotificationsApi
    attr_reader :client

    def initialize(client)
      @client = client
    end

    def base_path
      "/v2/preferences/notifications"
    end

    def base_path_app(app_id)
      "/v2/preferences/#{app_id}/notifications"
    end

    def create(notification, app_id = nil)
      path = app_id == nil ? base_path : base_path_app(app_id)

      Resource::Notification.new client, client.post(path, notification)
    end

    def show(notification_id)
      Resource::Notification.new client, client.get("#{base_path}/#{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}")

      resp.success?
    end
  end
end

module Moip2
  class NotificationsApi
    attr_reader :client

    def initialize(client)
      @client = client
    end

    def base_path
      "/v2/preferences/notifications"
    end

    def base_path_app(app_id)
      "/v2/preferences/#{app_id}/notifications"
    end

    def create(notification, app_id = nil)
      path = app_id.nil? ? base_path : base_path_app(app_id)

      Resource::Notification.new client, client.post(path, notification)
    end

    def show(notification_id)
      Resource::Notification.new client, client.get("#{base_path}/#{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}")

      resp.success?
    end
  end
end

Refactor create method from notifications API
refactor(Notifications): Refactor create method from notifications API

Refactor create method from notifications API
