github.com/mundipagg/boleto-api@v0.0.0-20230620145841-3f9ec742599f/bank/services/jpmorgan/stub.go (about)

     1  package jpmorgan
     2  
     3  import (
     4  	"time"
     5  
     6  	"github.com/mundipagg/boleto-api/models"
     7  	"github.com/mundipagg/boleto-api/test"
     8  )
     9  
    10  const day = time.Hour * 24
    11  
    12  type stubBoletoRequestJPMorgan struct {
    13  	test.StubBoletoRequest
    14  }
    15  
    16  func newStubBoletoRequestJPMorgan() *stubBoletoRequestJPMorgan {
    17  	expirationDate := time.Now().Add(5 * day)
    18  
    19  	base := test.NewStubBoletoRequest(models.JPMorgan)
    20  	s := &stubBoletoRequestJPMorgan{
    21  		StubBoletoRequest: *base,
    22  	}
    23  
    24  	s.Title = models.Title{
    25  		ExpireDateTime: expirationDate,
    26  		ExpireDate:     expirationDate.Format("2006-01-02"),
    27  		AmountInCents:  200,
    28  		Instructions:   "Sr. Caixa, favor não receber após vencimento",
    29  		DocumentNumber: "999999999999999",
    30  	}
    31  
    32  	s.Recipient = models.Recipient{
    33  		Document: models.Document{
    34  			Type:   "CNPJ",
    35  			Number: "33172537000198",
    36  		},
    37  	}
    38  
    39  	s.Buyer = models.Buyer{
    40  		Name:  "Nome do Comprador (Cliente)",
    41  		Email: "",
    42  		Document: models.Document{
    43  			Type:   "CPF",
    44  			Number: "37303489819",
    45  		},
    46  		Address: models.Address{
    47  			Street:     "Logradouro do Comprador",
    48  			Number:     "1000",
    49  			Complement: "Sala 01",
    50  			ZipCode:    "00000000",
    51  			City:       "Cidade do Comprador",
    52  			District:   "Bairro do Comprador",
    53  			StateCode:  "SP",
    54  		},
    55  	}
    56  
    57  	return s
    58  }
    59  
    60  func (s *stubBoletoRequestJPMorgan) WithBoletoType(bt string) *stubBoletoRequestJPMorgan {
    61  	switch bt {
    62  	case "DM":
    63  		s.Title.BoletoType, s.Title.BoletoTypeCode = bt, "02"
    64  	default:
    65  		s.Title.BoletoType = bt
    66  	}
    67  	return s
    68  }
    69  
    70  func (s *stubBoletoRequestJPMorgan) WithDocument(number string, doctype string) *stubBoletoRequestJPMorgan {
    71  	s.Buyer.Document.Type = doctype
    72  	s.Buyer.Document.Number = number
    73  	return s
    74  }
    75  
    76  func (s *stubBoletoRequestJPMorgan) WithAccessKey(key string) *stubBoletoRequestJPMorgan {
    77  	s.Authentication.AccessKey = key
    78  	return s
    79  }