import Http from './http';
import Form from './form';
import FormErrors from './form-errors';

function Plugin (Vue) {

    Object.defineProperty(Vue, '$form', {

        /*
         * Create a new Form instance.
         */
        create(fields) {
            return new Form(fields);
        },

        /*
         * Create a new FormErrors instance.
         */
        errors() {
            return new FormErrors();
        },

        /*
         * Submit the given Form to the given URI via a DELETE request.
         */
        delete(uri, form) {
            return Http.deleteForm(uri, form);
        },

        /*
         * Submit the given Form to the given URI via a POST request.
         */
        post(uri, form) {
            return Http.postForm(uri, form);
        },

        /*
         * Submit the given Form to the given URI via a PUT request
         */
        put(uri, form) {
            return Http.putForm(uri, form);
        },

        /*
         * Submit the given Form to the given URI using the given HTTP method.
         */
        submit(method, uri, form, formData = null) {
            return Http.sendForm(method, uri, form, formData);
        }

    });
}

if (typeof window !== 'undefined' && window.Vue) {
    window.Vue.use(Plugin);
}

export { Plugin, Http, Form, FormErrors }

@@ -97,22 +97,27 @@
 unction 
-Plugin
+FormHelpers
  (Vue) %7B
@@ -1273,22 +1273,27 @@
 Vue.use(
-Plugin
+FormHelpers
 );%0A%7D%0A%0Aex
@@ -1303,14 +1303,19 @@
 t %7B 
-Plugin
+FormHelpers
 , Ht

rename vue plugin function