Skip to content
This repository has been archived by the owner on Dec 9, 2021. It is now read-only.

Commit

Permalink
api,client: marshal null returnCode, not zero-value model
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdecaf committed Aug 14, 2020
1 parent c2aeb50 commit 8a02212
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 10 deletions.
1 change: 1 addition & 0 deletions api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,7 @@ components:
type: string
description: Long form explanation of return code
example: Previously active account has been closed by customer or RDFI
nullable: true
required:
- code
- reason
Expand Down
2 changes: 1 addition & 1 deletion pkg/client/docs/MicroDeposits.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Name | Type | Description | Notes
**Destination** | [**Destination**](Destination.md) | |
**Amounts** | **[]string** | |
**Status** | [**TransferStatus**](TransferStatus.md) | |
**ReturnCode** | [**ReturnCode**](ReturnCode.md) | | [optional]
**ReturnCode** | Pointer to [**ReturnCode**](ReturnCode.md) | | [optional]
**ProcessedAt** | Pointer to [**time.Time**](time.Time.md) | | [optional]
**Created** | [**time.Time**](time.Time.md) | |

Expand Down
2 changes: 1 addition & 1 deletion pkg/client/docs/Transfer.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Name | Type | Description | Notes
**Description** | **string** | Brief description of the transaction, that may appear on the receiving entity’s financial statement. This field is put into the Entry Detail's DiscretionaryData. |
**Status** | [**TransferStatus**](TransferStatus.md) | |
**SameDay** | **bool** | When set to true this indicates the transfer should be processed the same day if possible. | [default to false]
**ReturnCode** | [**ReturnCode**](ReturnCode.md) | | [optional]
**ReturnCode** | Pointer to [**ReturnCode**](ReturnCode.md) | | [optional]
**ProcessedAt** | Pointer to [**time.Time**](time.Time.md) | | [optional]
**Created** | [**time.Time**](time.Time.md) | |

Expand Down
2 changes: 1 addition & 1 deletion pkg/client/model_micro_deposits.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type MicroDeposits struct {
Destination Destination `json:"destination"`
Amounts []string `json:"amounts"`
Status TransferStatus `json:"status"`
ReturnCode ReturnCode `json:"returnCode,omitempty"`
ReturnCode *ReturnCode `json:"returnCode,omitempty"`
ProcessedAt *time.Time `json:"processedAt,omitempty"`
Created time.Time `json:"created"`
}
8 changes: 4 additions & 4 deletions pkg/client/model_transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ type Transfer struct {
Description string `json:"description"`
Status TransferStatus `json:"status"`
// When set to true this indicates the transfer should be processed the same day if possible.
SameDay bool `json:"sameDay"`
ReturnCode ReturnCode `json:"returnCode,omitempty"`
ProcessedAt *time.Time `json:"processedAt,omitempty"`
Created time.Time `json:"created"`
SameDay bool `json:"sameDay"`
ReturnCode *ReturnCode `json:"returnCode,omitempty"`
ProcessedAt *time.Time `json:"processedAt,omitempty"`
Created time.Time `json:"created"`
}
2 changes: 1 addition & 1 deletion pkg/transfers/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ limit 1`
}
if returnCode != nil {
if rc := ach.LookupReturnCode(*returnCode); rc != nil {
transfer.ReturnCode = client.ReturnCode{
transfer.ReturnCode = &client.ReturnCode{
Code: rc.Code,
Reason: rc.Reason,
Description: rc.Description,
Expand Down
9 changes: 7 additions & 2 deletions pkg/validation/microdeposits/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ where micro_deposit_id = ? and deleted_at is null limit 1;`
micro.Amounts = strings.Split(amounts, "|")
if returnCode != nil {
if rc := ach.LookupReturnCode(*returnCode); rc != nil {
micro.ReturnCode = client.ReturnCode{
micro.ReturnCode = &client.ReturnCode{
Code: rc.Code,
Reason: rc.Reason,
Description: rc.Description,
Expand Down Expand Up @@ -136,13 +136,18 @@ func (r *sqlRepo) writeMicroDeposits(micro *client.MicroDeposits) error {
}
defer stmt.Close()

var returnCode *string
if micro.ReturnCode != nil {
returnCode = &micro.ReturnCode.Code
}

_, err = stmt.Exec(
micro.MicroDepositID,
micro.Destination.CustomerID,
micro.Destination.AccountID,
strings.Join(micro.Amounts, "|"),
micro.Status,
micro.ReturnCode.Code,
returnCode,
micro.Created,
)
if err != nil {
Expand Down

0 comments on commit 8a02212

Please sign in to comment.