-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
742be06
commit f3b6a8a
Showing
11 changed files
with
140 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package boleto | ||
package cobranca | ||
|
||
type Conta struct { | ||
Banco string | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package cobranca | ||
|
||
const ( | ||
BancoNaoSuportado = "Banco não suportado." | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package remessa | ||
|
||
type Params struct { | ||
params map[string]string | ||
} | ||
|
||
func NewParams() Params { | ||
p := make(map[string]string) | ||
return Params{params: p} | ||
} | ||
|
||
func (p Params) Add(key, value string) Params { | ||
p.params[key] = value | ||
return p | ||
} | ||
|
||
func (p Params) Get(key string) string { | ||
return p.params[key] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package remessa | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestParams(t *testing.T) { | ||
name := "Breno" | ||
company := "Padmoney" | ||
p := NewParams() | ||
p.Add("name", name) | ||
p.Add("company", company) | ||
if got := p.Get("name"); got != name { | ||
t.Errorf("Expected '%s', got '%s'", name, got) | ||
} | ||
if got := p.Get("company"); got != company { | ||
t.Errorf("Expected '%s', got '%s'", company, got) | ||
} | ||
|
||
// updating | ||
newName := "Bernardo" | ||
p.Add("name", newName) | ||
if got := p.Get("name"); got != newName { | ||
t.Errorf("Expected '%s', got '%s'", newName, got) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package remessa | ||
|
||
import ( | ||
"errors" | ||
|
||
"github.com/padmoney/cobranca" | ||
) | ||
|
||
type RemessaGenerator interface { | ||
} | ||
|
||
type Remessa struct { | ||
Generator RemessaGenerator | ||
} | ||
|
||
func New(conta cobranca.Conta, params Params, sequential int64) (Remessa, error) { | ||
remessa := Remessa{} | ||
|
||
switch conta.Banco { | ||
case cobranca.CodigoSantander: | ||
remessa.Generator = NewSantander(conta, params, sequential) | ||
default: | ||
return remessa, errors.New(cobranca.BancoNaoSuportado) | ||
} | ||
return remessa, nil | ||
} | ||
|
||
/* | ||
public function __construct($conta, array $params = []) | ||
{ | ||
$this->conta = $conta; | ||
$this->params = $params; | ||
$agencia = explode('-', $conta->agencia()); | ||
$this->agencia = isset($agencia[0]) ? $agencia[0] : $conta->agencia(); | ||
$this->agencia_dv = $this->digitoAgencia(); | ||
$conta_numero = explode('-', $conta->contaCorrente()); | ||
$this->conta_numero = isset($conta_numero[0]) ? $conta_numero[0] : $conta->contaCorrente(); | ||
$this->conta_dv = isset($conta_numero[1]) ? $conta_numero[1] : ''; | ||
$this->nome_cedente = $conta->beneficiario()->nome(); | ||
$this->carteira = $conta->carteira(); | ||
$this->convenio = $conta->convenio(); | ||
$this->variacao = $conta->variacao(); | ||
$this->sequencial_remessa = $conta->sequencialRemessa(); | ||
} | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package remessa | ||
|
||
import "github.com/padmoney/cobranca" | ||
|
||
type Santander struct { | ||
conta cobranca.Conta | ||
params Params | ||
sequential int64 | ||
} | ||
|
||
func NewSantander(conta cobranca.Conta, params Params, sequential int64) Santander { | ||
return Santander{ | ||
conta: conta, | ||
params: params, | ||
sequential: sequential, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package remessa | ||
|
||
/* | ||
func TestMethodName(t *testing.T) { | ||
if err != nil { | ||
t.Errorf("There should not be an error, error: %s", err) | ||
} | ||
if got != expected { | ||
t.Errorf("Expected '%s', got '%s'", expected, got) | ||
} | ||
} | ||
*/ |