#ifndef GITPUSH_H
#define GITPUSH_H
// generated from class_header.h
#include <nan.h>
#include <string>

extern "C" {
#include <git2.h>
}

#include "../include/push.h"
#include "../include/push_options.h"
#include "../include/remote.h"
#include "../include/signature.h"

using namespace node;
using namespace v8;

class GitPush : public ObjectWrap {
public:

  static Persistent<Function> constructor_template;
  static void InitializeComponent (Handle<v8::Object> target);

  git_push *GetValue();
  git_push **GetRefValue();

  static Handle<Value> New(void *raw, bool selfFreeing);
  bool selfFreeing;

private:
  GitPush(git_push *raw, bool selfFreeing);
  ~GitPush();

  static NAN_METHOD(JSNewFunction);


  static NAN_METHOD(AddRefspec);

  struct FinishBaton {
    int error_code;
    const git_error* error;
    git_push * push;
  };
  class FinishWorker : public NanAsyncWorker {
  public:
    FinishWorker(
      FinishBaton *_baton,
      NanCallback *callback
    ) : NanAsyncWorker(callback)
      , baton(_baton) {};
    ~FinishWorker() {};
    void Execute();
    void HandleOKCallback();

  private:
    FinishBaton *baton;
  };

  static NAN_METHOD(Finish);

  static NAN_METHOD(InitOptions);

  struct CreateBaton {
    int error_code;
    const git_error* error;
    git_push * out;
    git_remote * remote;
  };
  class CreateWorker : public NanAsyncWorker {
  public:
    CreateWorker(
      CreateBaton *_baton,
      NanCallback *callback
    ) : NanAsyncWorker(callback)
      , baton(_baton) {};
    ~CreateWorker() {};
    void Execute();
    void HandleOKCallback();

  private:
    CreateBaton *baton;
  };

  static NAN_METHOD(Create);

  static NAN_METHOD(SetOptions);

  static NAN_METHOD(UnpackOk);

  static NAN_METHOD(UpdateTips);
  git_push *raw;
};

#endif
