Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
hugmouse committed Mar 29, 2020
2 parents 990feb7 + f34372e commit 7e44021
Show file tree
Hide file tree
Showing 52 changed files with 1,646 additions and 83 deletions.
48 changes: 48 additions & 0 deletions API/addPaymentNotification/addPaymentNotification.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package addPaymentNotification

import (
"github.com/hugmouse/gocapitalist/requests"
"github.com/hugmouse/gocapitalist/responses"
"github.com/hugmouse/gocapitalist/internal"
)

type AddPaymentNotification struct {
*internal.BaseClient
}

// https://capitalist.net/developers/api/page/add_payment_notification
func (b *AddPaymentNotification) Get(request requests.AddPaymentNotification) (*responses.AddPaymentNotification, error) {
data, errResponse := new(responses.AddPaymentNotification), new(responses.ErrorResponse)

httpParams, logParams := request.Params()
for k, v := range b.Auth.ParamsForAuth {
httpParams[k] = v
}

b.Logger.Debug("make request", httpParams["operation"], logParams, nil)

resp, err := b.R().
SetFormData(httpParams).
EnableTrace().
SetResult(data).
SetError(errResponse).
SetHeader("x-response-format", "json").
Post("/")

if err != nil {
b.Logger.Error("http error", httpParams["operation"], logParams, err)
return nil, err
}

b.Metrics.Collect(httpParams["operation"], resp.StatusCode(), errResponse.Code, resp.Time())

if resp.Error() != nil {
b.Logger.Error("app error", httpParams["operation"], errResponse.ErrLogParams(logParams), errResponse)
return nil, errResponse
}

b.Logger.Debug("success request", httpParams["operation"], logParams, nil)

return data, nil

}
48 changes: 48 additions & 0 deletions API/createAccount/createAccount.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package createAccount

import (
"github.com/hugmouse/gocapitalist/internal"
"github.com/hugmouse/gocapitalist/requests"
"github.com/hugmouse/gocapitalist/responses"
)

type CreateAccount struct {
*internal.BaseClient
}

// https://capitalist.net/developers/api/page/create_account
func (b *CreateAccount) New(request requests.CreateAccount) (*responses.CreateAccount, error) {
data, errResponse := new(responses.CreateAccount), new(responses.ErrorResponse)

httpParams, logParams := request.Params()
for k, v := range b.Auth.ParamsForAuth {
httpParams[k] = v
}

b.Logger.Debug("make request", httpParams["operation"], logParams, nil)

resp, err := b.R().
SetFormData(httpParams).
EnableTrace().
SetResult(data).
SetError(errResponse).
SetHeader("x-response-format", "json").
Post("/")

if err != nil {
b.Logger.Error("http error", httpParams["operation"], logParams, err)
return nil, err
}

b.Metrics.Collect(httpParams["operation"], resp.StatusCode(), errResponse.Code, resp.Time())

if resp.Error() != nil {
b.Logger.Error("app error", httpParams["operation"], errResponse.ErrLogParams(logParams), errResponse)
return nil, errResponse
}

b.Logger.Debug("success request", httpParams["operation"], logParams, nil)

return data, nil

}
48 changes: 48 additions & 0 deletions API/documentsSearch/documentsSearch.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package documentsSearch

import (
"github.com/hugmouse/gocapitalist/internal"
"github.com/hugmouse/gocapitalist/requests"
"github.com/hugmouse/gocapitalist/responses"
)

type DocumentsSearch struct {
*internal.BaseClient
}

// https://capitalist.net/developers/api/page/documents_search
func (b *DocumentsSearch) Get(request requests.DocumentsSearch) (*responses.DocumentsSearch, error) {
data, errResponse := new(responses.DocumentsSearch), new(responses.ErrorResponse)

httpParams, logParams := request.Params()
for k, v := range b.Auth.ParamsForAuth {
httpParams[k] = v
}

b.Logger.Debug("make request", httpParams["operation"], logParams, nil)

resp, err := b.R().
SetFormData(httpParams).
EnableTrace().
SetResult(data).
SetError(errResponse).
SetHeader("x-response-format", "json").
Post("/")

if err != nil {
b.Logger.Error("http error", httpParams["operation"], logParams, err)
return nil, err
}

b.Metrics.Collect(httpParams["operation"], resp.StatusCode(), errResponse.Code, resp.Time())

if resp.Error() != nil {
b.Logger.Error("app error", httpParams["operation"], errResponse.ErrLogParams(logParams), errResponse)
return nil, errResponse
}

b.Logger.Debug("success request", httpParams["operation"], logParams, nil)

return data, nil

}
48 changes: 48 additions & 0 deletions API/getAccounts/getAccounts.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package getAccounts

import (
"github.com/hugmouse/gocapitalist/internal"
"github.com/hugmouse/gocapitalist/requests"
"github.com/hugmouse/gocapitalist/responses"
)

type GetAccounts struct {
*internal.BaseClient
}

// https://capitalist.net/developers/api/page/get_accounts
func (b *GetAccounts) Get() (*responses.GetAccounts, error) {
data, errResponse := new(responses.GetAccounts), new(responses.ErrorResponse)

httpParams, logParams := (&requests.GetAccounts{}).Params()
for k, v := range b.Auth.ParamsForAuth {
httpParams[k] = v
}

b.Logger.Debug("make request", httpParams["operation"], logParams, nil)

resp, err := b.R().
SetFormData(httpParams).
EnableTrace().
SetResult(data).
SetError(errResponse).
SetHeader("x-response-format", "json").
Post("/")

if err != nil {
b.Logger.Error("http error", httpParams["operation"], logParams, err)
return nil, err
}

b.Metrics.Collect(httpParams["operation"], resp.StatusCode(), errResponse.Code, resp.Time())

if resp.Error() != nil {
b.Logger.Error("app error", httpParams["operation"], errResponse.ErrLogParams(logParams), errResponse)
return nil, errResponse
}

b.Logger.Debug("success request", httpParams["operation"], logParams, nil)

return data, nil

}
48 changes: 48 additions & 0 deletions API/getBatchInfo/getBatchInfo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package getBatchInfo

import (
"github.com/hugmouse/gocapitalist/internal"
"github.com/hugmouse/gocapitalist/requests"
"github.com/hugmouse/gocapitalist/responses"
)

type BatchInfo struct {
*internal.BaseClient
}

// https://capitalist.net/developers/api/page/get_batch_info
func (b *BatchInfo) Get(request requests.GetBatchInfo) (*responses.GetBatchInfo, error) {
data, errResponse := new(responses.GetBatchInfo), new(responses.ErrorResponse)

httpParams, logParams := request.Params()
for k, v := range b.Auth.ParamsForAuth {
httpParams[k] = v
}

b.Logger.Debug("make request", httpParams["operation"], logParams, nil)

resp, err := b.R().
SetFormData(httpParams).
EnableTrace().
SetResult(data).
SetError(errResponse).
SetHeader("x-response-format", "json").
Post("/")

if err != nil {
b.Logger.Error("http error", httpParams["operation"], logParams, err)
return nil, err
}

b.Metrics.Collect(httpParams["operation"], resp.StatusCode(), errResponse.Code, resp.Time())

if resp.Error() != nil {
b.Logger.Error("app error", httpParams["operation"], errResponse.ErrLogParams(logParams), errResponse)
return nil, errResponse
}

b.Logger.Debug("success request", httpParams["operation"], logParams, nil)

return data, nil

}
48 changes: 48 additions & 0 deletions API/getCashinRequisites/getCashinRequisites.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package getCashinRequisites

import (
"github.com/hugmouse/gocapitalist/internal"
"github.com/hugmouse/gocapitalist/requests"
"github.com/hugmouse/gocapitalist/responses"
)

type GetCashinRequisites struct {
*internal.BaseClient
}

// https://capitalist.net/developers/api/page/get_cashin_requisites
func (b *GetCashinRequisites) Get() (*responses.GetCashinRequisites, error) {
data, errResponse := new(responses.GetCashinRequisites), new(responses.ErrorResponse)

httpParams, logParams := (&requests.GetCashinRequisites{}).Params()
for k, v := range b.Auth.ParamsForAuth {
httpParams[k] = v
}

b.Logger.Debug("make request", httpParams["operation"], logParams, nil)

resp, err := b.R().
SetFormData(httpParams).
EnableTrace().
SetResult(data).
SetError(errResponse).
SetHeader("x-response-format", "json").
Post("/")

if err != nil {
b.Logger.Error("http error", httpParams["operation"], logParams, err)
return nil, err
}

b.Metrics.Collect(httpParams["operation"], resp.StatusCode(), errResponse.Code, resp.Time())

if resp.Error() != nil {
b.Logger.Error("app error", httpParams["operation"], errResponse.ErrLogParams(logParams), errResponse)
return nil, errResponse
}

b.Logger.Debug("success request", httpParams["operation"], logParams, nil)

return data, nil

}
48 changes: 48 additions & 0 deletions API/getDocumentHistoryExt/getDocumentHistoryExt.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package getDocumentHistoryExt

import (
"github.com/hugmouse/gocapitalist/internal"
"github.com/hugmouse/gocapitalist/requests"
"github.com/hugmouse/gocapitalist/responses"
)

type GetDocumentHistoryExt struct {
*internal.BaseClient
}

// https://capitalist.net/developers/api/page/get_documents_history_ext
func (b *GetDocumentHistoryExt) Get(request requests.DocumentHistory) (*responses.DocumentHistory, error) {
data, errResponse := new(responses.DocumentHistory), new(responses.ErrorResponse)

httpParams, logParams := request.Params()
for k, v := range b.Auth.ParamsForAuth {
httpParams[k] = v
}

b.Logger.Debug("make request", httpParams["operation"], logParams, nil)

resp, err := b.R().
SetFormData(httpParams).
EnableTrace().
SetResult(data).
SetError(errResponse).
SetHeader("x-response-format", "json").
Post("/")

if err != nil {
b.Logger.Error("http error", httpParams["operation"], logParams, err)
return nil, err
}

b.Metrics.Collect(httpParams["operation"], resp.StatusCode(), errResponse.Code, resp.Time())

if resp.Error() != nil {
b.Logger.Error("app error", httpParams["operation"], errResponse.ErrLogParams(logParams), errResponse)
return nil, errResponse
}

b.Logger.Debug("success request", httpParams["operation"], logParams, nil)

return data, nil

}
51 changes: 51 additions & 0 deletions API/importBatchAdvanced/importBatchAdvanced.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package importBatchAdvanced

import (
"github.com/hugmouse/gocapitalist/internal"
"github.com/hugmouse/gocapitalist/requests"
"github.com/hugmouse/gocapitalist/responses"
)

type ImportBatchAdvanced struct {
*internal.BaseClient
}

// https://capitalist.net/developers/api/page/import_batch_advanced
func (b *ImportBatchAdvanced) Import(request requests.ImportBatchAdvanced) (*responses.ImportBatchAdvanced, error) {
data, errResponse := new(responses.ImportBatchAdvanced), new(responses.ErrorResponse)

httpParams, logParams, err := request.Params()
if err != nil {
return nil, err
}
for k, v := range b.Auth.ParamsForAuth {
httpParams[k] = v
}

b.Logger.Debug("make request", httpParams["operation"], logParams, nil)

resp, err := b.R().
SetFormData(httpParams).
EnableTrace().
SetResult(data).
SetError(errResponse).
SetHeader("x-response-format", "json").
Post("/")

if err != nil {
b.Logger.Error("http error", httpParams["operation"], logParams, err)
return nil, err
}

b.Metrics.Collect(httpParams["operation"], resp.StatusCode(), errResponse.Code, resp.Time())

if resp.Error() != nil {
b.Logger.Error("app error", httpParams["operation"], errResponse.ErrLogParams(logParams), errResponse)
return nil, errResponse
}

b.Logger.Debug("success request", httpParams["operation"], logParams, nil)

return data, nil

}
Loading

0 comments on commit 7e44021

Please sign in to comment.