github.com/mundipagg/boleto-api@v0.0.0-20230620145841-3f9ec742599f/bank/services/jpmorgan/contracts.go (about) 1 package jpmorgan 2 3 type arrayDataError struct { 4 Error []errorResponse `json:"errors"` 5 } 6 7 type errorResponse struct { 8 Code string `json:"errorCode,omitempty"` 9 Message string `json:"errorMsg,omitempty"` 10 } 11 12 type ServiceMessageError struct { 13 Status string `xml:"Status"` 14 Reason string `xml:"Reason"` 15 } 16 17 const templateRequest = ` 18 { 19 "clienteBeneficiario": { 20 "cnpjCpfBenfcrioOr": {{toUint .Recipient.Document.Number}}, 21 "codAgencia": {{toUint .Agreement.Agency}}, 22 "codBanco": {{.BankNumber}}, 23 "codCartTit": 1, 24 "codContaCorrente": {{toUint .Agreement.Account}}, 25 "tpPessoaBenfcrioOr": {{docType .Recipient.Document}}, 26 "txtInfCliCed": "{{truncateOnly (onlyAlphanumerics (onlyOneSpace .Recipient.Name)) 80}}" 27 }, 28 "sacadoOuPagador": { 29 "bairroPagdr": "{{truncateOnly (onlyAlphanumerics (onlyOneSpace .Buyer.Address.District)) 15}}", 30 "cepPagdr": {{toUint .Buyer.Address.ZipCode}}, 31 "cidPagdr": "{{truncateOnly (onlyAlphanumerics (onlyOneSpace .Buyer.Address.City)) 15}}", 32 "cnpjCpfPagdr": {{toUint .Buyer.Document.Number}}, 33 "logradPagdr": "{{truncateOnly (onlyAlphanumerics (onlyOneSpace (joinSpace (.Buyer.Address.Street) (.Buyer.Address.Number) (.Buyer.Address.Complement)))) 40}}", 34 "nomRzSocPagdr": "{{truncateOnly (onlyAlphanumerics (onlyOneSpace .Buyer.Name)) 40}}", 35 "tpPessoaPagdr": {{docType .Buyer.Document}}, 36 "ufPagdr": "{{truncateOnly (onlyAlphabetics (removeAllSpaces .Buyer.Address.StateCode)) 2}}" 37 }, 38 "titulo": { 39 "numDocTit": "{{.Title.DocumentNumber}}", 40 "dtVencTit": "{{.Title.ExpireDate}}", 41 "vlrTit": {{strToFloat (toFloatStr .Title.AmountInCents)}}, 42 "codEspTit": {{toUint .Title.BoletoTypeCode}}, 43 "dtEmsTit": "{{enDate (today) "-"}}", 44 "vlrAbattTit": 0, 45 "tpCodPrott": 3, 46 "qtdDiaPrott": 0, 47 "codMoedaCnab": 9 48 }, 49 "juros": { 50 "codJurosTit": 3 51 }, 52 "descontos": { 53 "codDesctTit": 0 54 } 55 }` 56 57 const templateAPI = ` 58 { 59 {{if (hasErrorTags . "errorCode") | (hasErrorTags . "messageError")}} 60 "Errors": [ 61 { 62 {{if (hasErrorTags . "errorCode")}} 63 "Code": "{{trim .errorCode}}", 64 {{end}} 65 {{if (eq .messageError "{}") | (eq .messageError "Error")}} 66 "Message": "{{trim .errorCode}}" 67 {{else}} 68 {{if (eq .messageDetails "{}")}} 69 "Message": "{{joinSpace (trim .messageError)}}" 70 {{else}} 71 "Message": "{{joinSpace (trim .messageError) ":" (trim .messageDetails)}}" 72 {{end}} 73 {{end}} 74 } 75 ] 76 {{else}} 77 "DigitableLine": "{{fmtDigitableLine (trim .digitableLine)}}", 78 "BarCodeNumber": "{{trim .barCodeNumber}}", 79 "OurNumber": "{{padLeft .ourNumber "0" 12}}" 80 {{end}} 81 } 82 ` 83 84 const templateResponse = ` 85 { 86 "resposta":{ 87 "numCodBarras": "{{barCodeNumber}}", 88 "identdNossoNum": "{{ourNumber}}", 89 "linhaDigitavel": "{{digitableLine}}" 90 } 91 } 92 ` 93 94 var templateErrorXmltoJson = ` 95 { 96 "Status" : "{{messageError}}", 97 "Reason" : "{{errorCode}}" 98 } 99 ` 100 101 const templateErrorJson = ` 102 { 103 "errorCode": "{{errorCode}}", 104 "errorMsg": "{{messageError}}", 105 "resposta": "{{messageDetails}}" 106 } 107 ` 108 109 const templateErrorBoletoJson = ` 110 { 111 "numCodRetorno": "{{errorCode}}", 112 "mensagem": "{{messageError}}", 113 "resposta": "{{messageDetails}}" 114 } 115 `