import ngModule from '../module';

import './resource';

class LogMessagesProvider {

  $get(AvApiResource) {

    class AvLogMessagesResource extends AvApiResource {

      constructor() {
        super({
          version: '/v1',
          name: '/log-messages'
        });
      }

      buildRequest(level, entries) {

        const requestPayload = {};

        if (entries.level) {
          delete entries.level;
        }

        requestPayload.level = level;
        requestPayload.entries = entries;

        return requestPayload;

      }

      debug(entries) {
        return this.create(this.buildRequest('debug', entries));
      }

      info(entries) {
        return this.create(this.buildRequest('info', entries));
      }

      warn(entries) {
        return this.create(this.buildRequest('warn', entries));
      }

      error(entries) {
        return this.create(this.buildRequest('error', entries));
      }

    }

    return new AvLogMessagesResource();

  }

}

ngModule.provider('avLogMessagesResource', LogMessagesProvider);

export default ngModule;


@@ -284,22 +284,17 @@
 %0A%0A      
-buildR
+r
 equest(l
@@ -588,38 +588,33 @@
 his.create(this.
-buildR
+r
 equest('debug', 
@@ -679,38 +679,33 @@
 his.create(this.
-buildR
+r
 equest('info', e
@@ -769,38 +769,33 @@
 his.create(this.
-buildR
+r
 equest('warn', e
@@ -872,14 +872,9 @@
 his.
-buildR
+r
 eque

refactor logs resource