lib/app/paymentmethod-helpers.go

89 lines
2.7 KiB
Go
Raw Normal View History

2021-01-14 06:36:35 +00:00
package app
import (
"database/sql"
"time"
"code.tnxs.net/taxnexus/lib/api/ops/ops_models"
"github.com/google/uuid"
)
2021-01-17 21:49:00 +00:00
func UnMarshalPaymentMethod(s *ops_models.PaymentMethod) *PaymentMethod {
2021-01-14 06:36:35 +00:00
if s.ID == "" {
s.ID = uuid.New().String()
}
createdDate, e0 := time.Parse(dateTimeFormat, s.CreatedDate)
lastModfiedDate, e1 := time.Parse(dateTimeFormat, s.LastModifiedDate)
expirationDate, e2 := time.Parse(dateTimeFormat, s.ExpirationDate)
return &PaymentMethod{
ID: s.ID,
AccountID: s.AccountID,
AchAccountType: s.AchAccountType,
AchBankAccount: s.AchBankAccount,
AchRouting: s.AchRouting,
Active: s.Active,
Autopay: s.Autopay,
BankName: s.BankName,
BillingContactID: s.BillingContactID,
CCnumber: s.CCnumber,
CCtype: s.CCtype,
CompanyID: s.CompanyID,
ContractID: s.ContractID,
CreatedByID: s.CreatedByID,
Default: s.Default,
ExpirationMonth: s.ExpirationMonth,
ExpirationYear: s.ExpirationYear,
Gateway: s.Gateway,
GatewayKey: s.GatewayKey,
LastModifiedByID: s.LastModifiedByID,
Nickname: s.Nickname,
RecordType: s.RecordType,
Ref: s.Ref,
TenantID: s.TenantID,
CreatedDate: sql.NullTime{
Time: createdDate,
Valid: e0 == nil,
},
LastModifiedDate: sql.NullTime{
Time: lastModfiedDate,
Valid: e1 == nil,
},
ExpirationDate: sql.NullTime{
Time: expirationDate,
Valid: e2 == nil,
},
}
}
// MarshalToSwagger encodes a first class object to swagger
func (obj *PaymentMethod) MarshalToSwagger() *ops_models.PaymentMethod {
return &ops_models.PaymentMethod{
ID: obj.ID,
AccountID: obj.AccountID,
AchAccountType: obj.AchAccountType,
AchBankAccount: obj.AchBankAccount,
AchRouting: obj.AchRouting,
Active: obj.Active,
Autopay: obj.Autopay,
BankName: obj.BankName,
BillingContactID: obj.BillingContactID,
CCnumber: obj.CCnumber,
CCtype: obj.CCtype,
CompanyID: obj.CompanyID,
ContractID: obj.ContractID,
CreatedByID: obj.CreatedByID,
CreatedDate: obj.CreatedDate.Time.Format(dateTimeFormat),
Default: obj.Default,
ExpirationDate: obj.ExpirationDate.Time.Format(dateTimeFormat),
ExpirationMonth: obj.ExpirationMonth,
ExpirationYear: obj.ExpirationYear,
Gateway: obj.Gateway,
GatewayKey: obj.GatewayKey,
LastModifiedByID: obj.LastModifiedByID,
LastModifiedDate: obj.LastModifiedDate.Time.Format(dateTimeFormat),
Nickname: obj.Nickname,
RecordType: obj.RecordType,
Ref: obj.Ref,
}
}