github.com/mundipagg/boleto-api@v0.0.0-20230620145841-3f9ec742599f/bradescoNetEmpresa/request.go (about) 1 package bradescoNetEmpresa 2 3 const registerBradescoNetEmpresa = ` 4 ## Content-Type:application/json 5 { 6 {{if (eq .Recipient.Document.Type "CNPJ")}} 7 "nuCPFCNPJ": "{{splitValues (extractNumbers .Recipient.Document.Number) 0 8}}", 8 {{else}} 9 "nuCPFCNPJ": "{{splitValues (extractNumbers .Recipient.Document.Number) 0 9}}", 10 {{end}} 11 12 {{if (eq .Recipient.Document.Type "CNPJ")}} 13 "filialCPFCNPJ": "{{splitValues (extractNumbers .Recipient.Document.Number) 8 12}}", 14 {{else}} 15 "filialCPFCNPJ": "0", 16 {{end}} 17 18 {{if (eq .Recipient.Document.Type "CNPJ")}} 19 "ctrlCPFCNPJ": "{{splitValues (extractNumbers .Recipient.Document.Number) 12 14}}", 20 {{else}} 21 "ctrlCPFCNPJ": "{{splitValues (extractNumbers .Recipient.Document.Number) 9 11}}", 22 {{end}} 23 "cdTipoAcesso": "2", 24 "clubBanco": "2269651", 25 "cdTipoContrato": "48", 26 "idProduto": "{{padLeft (toString16 .Agreement.Wallet) "0" 2}}", 27 "nuNegociacao": "{{.Agreement.Agency}}0000000{{.Agreement.Account}}", 28 "cdBanco": "237", 29 "tpRegistro": "1", 30 "nuTitulo": "{{.Title.OurNumber}}", 31 "nuCliente": "{{.Title.DocumentNumber}}", 32 "dtEmissaoTitulo": "{{brDateDelimiterTime .Title.CreateDate "."}}", 33 "dtVencimentoTitulo": "{{brDateDelimiter .Title.ExpireDate "."}}", 34 "tpVencimento": "0", 35 "vlNominalTitulo": "{{.Title.AmountInCents}}", 36 "cdEspecieTitulo": "{{ .Title.BoletoTypeCode}}", 37 "nomePagador": "{{truncate .Buyer.Name 70}}", 38 "logradouroPagador": "{{truncate .Buyer.Address.Street 40}}", 39 "nuLogradouroPagador": "{{truncate .Buyer.Address.Number 10}}", 40 "complementoLogradouroPagador": "{{truncate .Buyer.Address.Complement 15}}", 41 {{ $length := len (extractNumbers .Buyer.Address.ZipCode)}} 42 {{ $zipCode := (extractNumbers .Buyer.Address.ZipCode)}} 43 {{ if ge $length 5}} 44 "cepPagador": "{{splitValues $zipCode 0 5}}", 45 {{ end }} 46 47 {{ if ge $length 8}} 48 "complementoCepPagador": "{{splitValues $zipCode 5 8}}", 49 {{ end }} 50 51 "bairroPagador": "{{truncate .Buyer.Address.District 40}}", 52 "municipioPagador": "{{truncate .Buyer.Address.City 30}}", 53 "ufPagador": "{{truncate .Buyer.Address.StateCode 2}}", 54 {{if (eq .Buyer.Document.Type "CPF")}} 55 "cdIndCpfcnpjPagador": "1", 56 {{else}} 57 "cdIndCpfcnpjPagador": "2", 58 {{end}} 59 "nuCpfcnpjPagador": "{{extractNumbers .Buyer.Document.Number}}", 60 "endEletronicoPagador": "{{truncate .Buyer.Email 70}}", 61 } 62 ` 63 64 const reponseBradescoNetEmpresaXml = `<?xml version="1.0" encoding="UTF-8"?> 65 <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> 66 <soapenv:Body> 67 <ns2:registrarTituloResponse xmlns:ns2="http://ws.registrotitulo.ibpj.web.bradesco.com.br/"> 68 <return>{{contentJson}}</return> 69 </ns2:registrarTituloResponse> 70 </soapenv:Body> 71 </soapenv:Envelope> 72 ` 73 74 const responseBradescoNetEmpresaJson = `{{.contentJson}}` 75 76 const reponseBradescoNetEmpresa = ` 77 { 78 "cdErro": "{{returnCode}}", 79 "msgErro": "{{returnMessage}}", 80 "linhaDigitavel": "{{digitableLine}}" 81 } 82 ` 83 84 func getRequestBradescoNetEmpresa() string { 85 return registerBradescoNetEmpresa 86 } 87 88 func getResponseBradescoNetEmpresaXml() string { 89 return reponseBradescoNetEmpresaXml 90 } 91 92 func getResponseBradescoNetEmpresaJson() string { 93 return responseBradescoNetEmpresaJson 94 } 95 96 func getResponseBradescoNetEmpresa() string { 97 return reponseBradescoNetEmpresa 98 }