Skip to content

Commit

Permalink
Finish unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Cataldo committed Dec 5, 2023
1 parent 8b26cec commit 4a368bf
Show file tree
Hide file tree
Showing 57 changed files with 662 additions and 1,952 deletions.
28 changes: 14 additions & 14 deletions _example/account/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@ func getAccountBalance() {

func updateAccount() {
resp, err := accountAsaas.Update(context.TODO(), asaas.UpdateAccountRequest{
PersonType: asaas.PersonTypePhysical,
CpfCnpj: "29376892000101",
PersonType: "",
CpfCnpj: "",
BirthDate: asaas.Date{},
CompanyType: asaas.CompanyTypeLimited,
Email: "[email protected]",
Phone: "",
MobilePhone: "",
Site: "",
PostalCode: "69620-970",
Address: "Praça São Cristovão, s/n",
AddressNumber: "10",
Complement: "",
Province: "Centro",
CompanyType: nil,
Email: "",
Phone: nil,
MobilePhone: nil,
Site: nil,
PostalCode: "",
Address: nil,
AddressNumber: nil,
Complement: nil,
Province: nil,
})
if err != nil {
fmt.Println("error:", err)
Expand All @@ -54,8 +54,8 @@ func updateAccount() {

func getAccountStatement() {
resp, err := accountAsaas.GetAccountStatement(context.TODO(), asaas.GetAccountStatementRequest{
StartDate: nil,
FinishDate: nil,
StartDate: asaas.Date{},
FinishDate: asaas.Date{},
Offset: 0,
Limit: 10,
Order: asaas.OrderDesc,
Expand Down
6 changes: 3 additions & 3 deletions _example/anticipation/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func main() {

func simulateAnticipation() {
resp, err := anticipationAsaas.Simulate(context.TODO(), asaas.AnticipationSimulateRequest{
Payment: "pay_jxqnfvp1qt8qpf5s",
Payment: "",
Installment: "",
})
if err != nil {
Expand All @@ -33,7 +33,7 @@ func simulateAnticipation() {

func requestAnticipation() {
resp, err := anticipationAsaas.Request(context.TODO(), asaas.AnticipationRequest{
Payment: "pay_jxqnfvp1qt8qpf5s",
Payment: "",
Installment: "",
Documents: nil,
})
Expand All @@ -47,7 +47,7 @@ func requestAnticipation() {
}

func getAnticipationById() {
resp, err := anticipationAsaas.GetById(context.TODO(), "5be2e7dd-f573-49f2-b693-bce455d6e0aa")
resp, err := anticipationAsaas.GetById(context.TODO(), "")
if err != nil {
fmt.Println("error:", err)
} else if resp.IsSuccess() {
Expand Down
146 changes: 20 additions & 126 deletions _example/charge/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,134 +5,26 @@ import (
"fmt"
"github.com/GabrielHCataldo/go-asaas/asaas"
"os"
"time"
)

var chargeAsaas asaas.Charge

func main() {
chargeAsaas = asaas.NewCharge(asaas.EnvSandbox, os.Getenv("ASAAS_ACCESS_TOKEN"))
createChargePix()
createChargeBill()
createChargeUndefined()
createChargeCreditCard()
createCharge()
updateChargeById()
getChargeById()
getAllCustomers()
deleteChargeById()
}

func createChargePix() {
func createCharge() {
resp, err := chargeAsaas.Create(context.TODO(), asaas.CreateChargeRequest{
Customer: "cus_000005799255",
BillingType: asaas.BillingTypePix,
Value: 10,
DueDate: asaas.NewDate(2023, 12, 2, time.Local),
Description: "Example pix charge",
ExternalReference: "",
Discount: nil,
Interest: nil,
Fine: nil,
PostalService: false,
Split: nil,
Callback: nil,
CreditCard: nil,
CreditCardHolderInfo: nil,
CreditCardToken: "",
InstallmentCount: 0,
InstallmentValue: 0,
})
if err != nil {
fmt.Println("error:", err)
} else if resp.IsSuccess() {
fmt.Println("success:", resp)
} else {
fmt.Println("failure:", resp.Errors)
}
}

func createChargeBill() {
resp, err := chargeAsaas.Create(context.TODO(), asaas.CreateChargeRequest{
Customer: "cus_000005799255",
BillingType: asaas.BillingTypeBankSlip,
Value: 10,
DueDate: asaas.NewDate(2023, 12, 2, time.Local),
Description: "Example bill charge",
ExternalReference: "",
Discount: nil,
Interest: nil,
Fine: nil,
PostalService: false,
Split: nil,
Callback: nil,
CreditCard: nil,
CreditCardHolderInfo: nil,
CreditCardToken: "",
InstallmentCount: 0,
InstallmentValue: 0,
})
if err != nil {
fmt.Println("error:", err)
} else if resp.IsSuccess() {
fmt.Println("success:", resp)
} else {
fmt.Println("failure:", resp.Errors)
}
}

func createChargeCreditCard() {
resp, err := chargeAsaas.Create(context.TODO(), asaas.CreateChargeRequest{
Customer: "cus_000005799255",
BillingType: asaas.BillingTypeCreditCard,
Value: 10,
DueDate: asaas.NewDate(2023, 12, 1, time.Local),
Description: "Example bill charge",
ExternalReference: "",
Discount: nil,
Interest: nil,
Fine: nil,
PostalService: false,
Split: nil,
Callback: nil,
CreditCard: &asaas.CreditCardRequest{
HolderName: "unit test go",
Number: "4000000000000010",
ExpiryMonth: "05",
ExpiryYear: "2035",
Ccv: "123",
},
CreditCardHolderInfo: &asaas.CreditCardHolderInfoRequest{
Name: "Example go",
CpfCnpj: "29376892000101",
Email: "[email protected]",
Phone: "4738010919",
MobilePhone: "47998781877",
PostalCode: "89223-005",
AddressNumber: "10",
AddressComplement: "",
},
CreditCardToken: "",
InstallmentCount: 2,
InstallmentValue: 5,
AuthorizeOnly: false,
RemoteIp: "",
})
if err != nil {
fmt.Println("error:", err)
} else if resp.IsSuccess() {
fmt.Println("success:", resp)
} else {
fmt.Println("failure:", resp.Errors)
}
}

func createChargeUndefined() {
resp, err := chargeAsaas.Create(context.TODO(), asaas.CreateChargeRequest{
Customer: "cus_000005799255",
BillingType: asaas.BillingTypeUndefined,
Value: 10,
DueDate: asaas.NewDate(2023, 12, 2, time.Local),
Description: "Example bill charge",
Customer: "",
BillingType: "",
Value: 0,
DueDate: asaas.Date{},
Description: "",
ExternalReference: "",
Discount: nil,
Interest: nil,
Expand All @@ -145,6 +37,8 @@ func createChargeUndefined() {
CreditCardToken: "",
InstallmentCount: 0,
InstallmentValue: 0,
AuthorizeOnly: false,
RemoteIp: "",
})
if err != nil {
fmt.Println("error:", err)
Expand All @@ -156,21 +50,21 @@ func createChargeUndefined() {
}

func updateChargeById() {
resp, err := chargeAsaas.UpdateById(context.TODO(), "pay_jxqnfvp1qt8qpf5s", asaas.UpdateChargeRequest{
resp, err := chargeAsaas.UpdateById(context.TODO(), "", asaas.UpdateChargeRequest{
Customer: "",
BillingType: asaas.BillingTypeBankSlip,
Value: 5,
BillingType: "",
Value: 0,
DueDate: asaas.Date{},
Description: asaas.Pointer("updated"),
ExternalReference: asaas.Pointer(""),
Description: nil,
ExternalReference: nil,
Discount: nil,
Interest: nil,
Fine: nil,
PostalService: asaas.Pointer(false),
PostalService: nil,
Split: nil,
Callback: nil,
InstallmentCount: 2,
InstallmentValue: 2.5,
InstallmentCount: 0,
InstallmentValue: 0,
})
if err != nil {
fmt.Println("error:", err)
Expand All @@ -182,7 +76,7 @@ func updateChargeById() {
}

func deleteChargeById() {
deleteResponse, err := chargeAsaas.DeleteById(context.TODO(), "pay_484rmiebm04419ey")
deleteResponse, err := chargeAsaas.DeleteById(context.TODO(), "")
if err != nil {
fmt.Println("error:", err)
} else if deleteResponse.IsSuccess() {
Expand All @@ -193,7 +87,7 @@ func deleteChargeById() {
}

func getChargeById() {
resp, err := chargeAsaas.GetById(context.TODO(), "pay_jxqnfvp1qt8qpf5s")
resp, err := chargeAsaas.GetById(context.TODO(), "")
if err != nil {
fmt.Println("error:", err)
} else if resp.IsSuccess() {
Expand Down Expand Up @@ -229,7 +123,7 @@ func getAllCustomers() {
DueDateLe: asaas.Date{},
User: "",
Offset: 0,
Limit: 10,
Limit: 0,
})
if err != nil {
fmt.Println("error:", err)
Expand Down
10 changes: 5 additions & 5 deletions _example/credit_bureau/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ func main() {

func getCreditBureauReport() {
resp, err := creditBureauAsaas.GetReport(context.TODO(), asaas.GetReportRequest{
Customer: "cus_000005791749",
Customer: "",
CpfCnpj: "",
State: "SP",
State: "",
})
if err != nil {
fmt.Println("error:", err)
Expand All @@ -46,10 +46,10 @@ func getCreditBureauReportById() {

func getAllCreditBureauReports() {
resp, err := creditBureauAsaas.GetAllReports(context.TODO(), asaas.GetAllReportsRequest{
StartDate: nil,
EndDate: nil,
StartDate: asaas.Date{},
EndDate: asaas.Date{},
Offset: 0,
Limit: 10,
Limit: 0,
})
if err != nil {
fmt.Println("error:", err)
Expand Down
12 changes: 6 additions & 6 deletions _example/customer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ func main() {

func createCustomer() {
resp, err := customerAsaas.Create(context.TODO(), asaas.CreateCustomerRequest{
Name: "Go Asaas Test",
CpfCnpj: "85185238003",
Name: "",
CpfCnpj: "",
Email: "",
Phone: "",
MobilePhone: "",
Expand Down Expand Up @@ -49,7 +49,7 @@ func createCustomer() {
}

func updateCustomerById() {
resp, err := customerAsaas.UpdateById(context.TODO(), "cus_000005799255", asaas.UpdateCustomerRequest{
resp, err := customerAsaas.UpdateById(context.TODO(), "", asaas.UpdateCustomerRequest{
Name: "",
CpfCnpj: nil,
Email: nil,
Expand Down Expand Up @@ -79,7 +79,7 @@ func updateCustomerById() {
}

func deleteCustomerById() {
deleteResponse, err := customerAsaas.DeleteById(context.TODO(), "cus_000005791749")
deleteResponse, err := customerAsaas.DeleteById(context.TODO(), "")
if err != nil {
fmt.Println("error:", err)
} else if deleteResponse.IsSuccess() {
Expand All @@ -90,7 +90,7 @@ func deleteCustomerById() {
}

func getCustomerById() {
resp, err := customerAsaas.GetById(context.TODO(), "cus_000005799255")
resp, err := customerAsaas.GetById(context.TODO(), "")
if err != nil {
fmt.Println("error:", err)
} else if resp.IsSuccess() {
Expand All @@ -110,7 +110,7 @@ func getAllCustomers() {
GroupName: "",
ExternalReference: "",
Offset: 0,
Limit: 10,
Limit: 0,
})
if err != nil {
fmt.Println("error:", err)
Expand Down
28 changes: 14 additions & 14 deletions _example/fiscal_info/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ func main() {
func saveFiscalInfo() {
resp, err := fiscalInfoAsaas.Save(context.TODO(), asaas.SaveFiscalInfoRequest{
Email: "",
MunicipalInscription: "",
SimplesNacional: false,
CulturalProjectsPromoter: false,
Cnae: "",
SpecialTaxRegime: "",
ServiceListItem: "",
RpsSerie: "",
RpsNumber: 0,
LoteNumber: 0,
Username: "",
Password: "",
AccessToken: "",
MunicipalInscription: nil,
SimplesNacional: nil,
CulturalProjectsPromoter: nil,
Cnae: nil,
SpecialTaxRegime: nil,
ServiceListItem: nil,
RpsSerie: nil,
RpsNumber: nil,
LoteNumber: nil,
Username: nil,
Password: nil,
AccessToken: nil,
CertificateFile: nil,
CertificatePassword: "",
CertificatePassword: nil,
})
if err != nil {
fmt.Println("error:", err)
Expand Down Expand Up @@ -60,7 +60,7 @@ func getAllFiscalInfoServices() {
resp, err := fiscalInfoAsaas.GetAllServices(context.TODO(), asaas.GetAllServicesRequest{
Description: "",
Offset: 0,
Limit: 10,
Limit: 0,
})
if err != nil {
fmt.Println("error:", err)
Expand Down
Loading

0 comments on commit 4a368bf

Please sign in to comment.