github.com/mundipagg/boleto-api@v0.0.0-20230620145841-3f9ec742599f/test/builder.go (about)

     1  package test
     2  
     3  import (
     4  	"github.com/google/uuid"
     5  	"github.com/mundipagg/boleto-api/models"
     6  )
     7  
     8  type BuilderBoletoRequest struct {
     9  	authentication models.Authentication
    10  	agreement      models.Agreement
    11  	title          models.Title
    12  	recipient      models.Recipient
    13  	PayeeGuarantor *models.PayeeGuarantor
    14  	buyer          models.Buyer
    15  	bank           models.BankNumber
    16  }
    17  
    18  func NewBuilderBoletoRequest() BuilderBoletoRequest {
    19  	return BuilderBoletoRequest{}
    20  }
    21  
    22  func (b *BuilderBoletoRequest) SetBank(bank models.BankNumber) {
    23  	b.bank = bank
    24  }
    25  
    26  func (b *BuilderBoletoRequest) SetAuthentication(authentication models.Authentication) {
    27  	b.authentication = authentication
    28  }
    29  
    30  func (b *BuilderBoletoRequest) SetAgreement(agreement models.Agreement) {
    31  	b.agreement = agreement
    32  }
    33  
    34  func (b *BuilderBoletoRequest) SetTitle(title models.Title) {
    35  	b.title = title
    36  }
    37  
    38  func (b *BuilderBoletoRequest) SetRecipient(recipient models.Recipient) {
    39  	b.recipient = recipient
    40  }
    41  
    42  func (b *BuilderBoletoRequest) SetPayeeGuarantor(PayeeGuarantor *models.PayeeGuarantor) {
    43  	b.PayeeGuarantor = PayeeGuarantor
    44  }
    45  
    46  func (b *BuilderBoletoRequest) SetBuyer(buyer models.Buyer) {
    47  	b.buyer = buyer
    48  }
    49  
    50  func (b *BuilderBoletoRequest) BoletoRequest() *models.BoletoRequest {
    51  	guid, _ := uuid.NewUUID()
    52  	return &models.BoletoRequest{
    53  		BankNumber:     b.bank,
    54  		Authentication: b.authentication,
    55  		Agreement:      b.agreement,
    56  		Title:          b.title,
    57  		Recipient:      b.recipient,
    58  		PayeeGuarantor: b.PayeeGuarantor,
    59  		Buyer:          b.buyer,
    60  		RequestKey:     guid.String(),
    61  	}
    62  }