Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/exclusives/account/getAccountBalance.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package main

import (
"fmt"
"github.com/gerencianet/gn-api-sdk-go/src/efipay/pix"
"github.com/gerencianet/gn-api-sdk-go/examples/configs"
"github.com/efipay/sdk-go-apis-efi/src/efipay/pix"
"github.com/efipay/sdk-go-apis-efi/examples/configs"
)

func main(){
Expand Down
4 changes: 2 additions & 2 deletions examples/exclusives/account/updateAccountConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package main

import (
"fmt"
"github.com/gerencianet/gn-api-sdk-go/src/efipay/pix"
"github.com/gerencianet/gn-api-sdk-go/examples/configs"
"github.com/efipay/sdk-go-apis-efi/src/efipay/pix"
"github.com/efipay/sdk-go-apis-efi/examples/configs"
)

func main(){
Expand Down
4 changes: 2 additions & 2 deletions examples/pix/send/pixSendDetail.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package main

import (
"fmt"
"github.com/gerencianet/gn-api-sdk-go/src/efipay/pix"
"github.com/gerencianet/gn-api-sdk-go/examples/configs"
"github.com/efipay/sdk-go-apis-efi/src/efipay/pix"
"github.com/efipay/sdk-go-apis-efi/examples/configs"
)

func main(){
Expand Down
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/efipay/sdk-go-apis-efi

go 1.24.6
6 changes: 3 additions & 3 deletions src/efipay/efipay.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package efipay

type efipay struct {
type Efipay struct {
endpoints
}

func NewEfiPay(configs map[string]interface{}) *efipay {
func NewEfiPay(configs map[string]interface{}) *Efipay {
clientID := configs["client_id"].(string)
clientSecret := configs["client_secret"].(string)
sandbox := configs["sandbox"].(bool)
timeout := configs["timeout"].(int)
//partner_token := configs["partner_token"].(string)

requester := newRequester(clientID, clientSecret, sandbox, timeout)
efi := efipay{}
efi := Efipay{}
efi.requester = *requester
return &efi
}
99 changes: 99 additions & 0 deletions src/efipay/efipay_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
package efipay

import (
"testing"
)

func TestNewEfiPay(t *testing.T) {
// Configurações de teste
configs := map[string]interface{}{
"client_id": "test_client_id",
"client_secret": "test_client_secret",
"sandbox": true,
"timeout": 30,
}

// Testa a criação da instância Efipay
efi := NewEfiPay(configs)

// Verifica se a instância não é nil
if efi == nil {
t.Fatal("NewEfiPay retornou nil")
}

// Verifica se é do tipo correto
if efi == nil {
t.Errorf("NewEfiPay não retornou uma instância válida")
}
}

func TestNewEfiPayWithInvalidConfigs(t *testing.T) {
// Testa com configurações inválidas (deve causar panic)
defer func() {
if r := recover(); r == nil {
t.Errorf("NewEfiPay deveria ter causado panic com configurações inválidas")
}
}()

// Configurações inválidas (faltando campos obrigatórios)
invalidConfigs := map[string]interface{}{
"client_id": "test_client_id",
// faltando client_secret, sandbox e timeout
}

NewEfiPay(invalidConfigs)
}

func TestNewEfiPayWithWrongTypes(t *testing.T) {
// Testa com tipos incorretos (deve causar panic)
defer func() {
if r := recover(); r == nil {
t.Errorf("NewEfiPay deveria ter causado panic com tipos incorretos")
}
}()

// Configurações com tipos incorretos
wrongTypeConfigs := map[string]interface{}{
"client_id": "test_client_id",
"client_secret": "test_client_secret",
"sandbox": "true", // deveria ser bool
"timeout": 30,
}

NewEfiPay(wrongTypeConfigs)
}

func TestEfipayStructFields(t *testing.T) {
// Configurações de teste
configs := map[string]interface{}{
"client_id": "test_client_id",
"client_secret": "test_client_secret",
"sandbox": true,
"timeout": 30,
}

efi := NewEfiPay(configs)

// Verifica se a struct Efipay incorpora endpoints
// Testamos isso verificando se um método de endpoints está disponível
// Como CreateCharge é um método, apenas verificamos se podemos chamá-lo
// (não podemos comparar métodos com nil)
if efi == nil {
t.Errorf("Instância Efipay é nil")
}
}

// Teste de benchmark para medir performance da criação
func BenchmarkNewEfiPay(b *testing.B) {
configs := map[string]interface{}{
"client_id": "test_client_id",
"client_secret": "test_client_secret",
"sandbox": true,
"timeout": 30,
}

b.ResetTimer()
for i := 0; i < b.N; i++ {
NewEfiPay(configs)
}
}