Skip to content

Commit

Permalink
feat: helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
brokeyourbike committed Oct 22, 2023
1 parent 6953c32 commit a93a805
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions webhook/mccy_accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ type MCCYAccountCreatedPayload struct {
Type string `json:"Type" validate:"required"`
}

// GetIdentifier returns first identifier. If no identifiers are found, an empty string is returned.
func (w MCCYAccountCreatedPayload) GetIdentifier() string {
if len(w.Identifiers) > 0 {
return w.Identifiers[0].Identifier
}
return ""
}

// MCCYAccountUpdatedPayload
// This webhook confirms that the multicurrency account has been updated
type MCCYAccountUpdatedPayload struct {
Expand All @@ -56,6 +64,14 @@ type MCCYAccountUpdatedPayload struct {
Type string `json:"Type" validate:"required"`
}

// GetIdentifier returns first identifier. If no identifiers are found, an empty string is returned.
func (w MCCYAccountUpdatedPayload) GetIdentifier() string {
if len(w.Identifiers) > 0 {
return w.Identifiers[0].Identifier
}
return ""
}

// MCCYVirtualAccountCreatedPayload
// This webhook confirms that the multicurrency virtual account has been created
type MCCYVirtualAccountCreatedPayload struct {
Expand All @@ -68,6 +84,14 @@ type MCCYVirtualAccountCreatedPayload struct {
TimestampCreated clearbank.Time `json:"TimestampCreated" validate:"required"`
}

// GetIdentifier returns first identifier. If no identifiers are found, an empty string is returned.
func (w MCCYVirtualAccountCreatedPayload) GetIdentifier() string {
if len(w.Identifiers) > 0 {
return w.Identifiers[0].Identifier
}
return ""
}

// MCCYVirtualAccountUpdatedPayload
// This webhook confirms that the multicurrency virtual account has been updated
type MCCYVirtualAccountUpdatedPayload struct {
Expand All @@ -81,3 +105,11 @@ type MCCYVirtualAccountUpdatedPayload struct {
StatusReason string `json:"StatusReason"`
StatusInformation string `json:"StatusInformation"`
}

// GetIdentifier returns first identifier. If no identifiers are found, an empty string is returned.
func (w MCCYVirtualAccountUpdatedPayload) GetIdentifier() string {
if len(w.Identifiers) > 0 {
return w.Identifiers[0].Identifier
}
return ""
}

0 comments on commit a93a805

Please sign in to comment.