-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7e4bc5b
commit 7e2951a
Showing
6 changed files
with
333 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package transform | ||
|
||
import ( | ||
"github.com/stellar/stellar-etl/internal/utils" | ||
) | ||
|
||
func TransformRetoolEntityData(entityData utils.RetoolEntityDataTransformInput) (EntityDataTransformOutput, error) { | ||
transformedRetoolEntityData := EntityDataTransformOutput{ | ||
ID: entityData.ID, | ||
Name: entityData.Name, | ||
HomeDomain: entityData.HomeDomain.HomeDomain, | ||
Status: entityData.Status, | ||
CreatedAt: entityData.CreatedAt, | ||
UpdatedAt: entityData.UpdatedAt, | ||
Custodial: entityData.Custodial, | ||
NonCustodial: entityData.NonCustodial, | ||
HomeDomainsID: entityData.HomeDomainsID, | ||
Description: entityData.Description, | ||
WebsiteURL: entityData.WebsiteURL, | ||
SdpEnabled: entityData.SdpEnabled, | ||
SorobanEnabled: entityData.SorobanEnabled, | ||
Notes: entityData.Notes, | ||
Verified: entityData.Verified, | ||
FeeSponsor: entityData.FeeSponsor, | ||
AccountSponsor: entityData.AccountSponsor, | ||
Live: entityData.Live, | ||
AppGeographies: mapGeographies(entityData.AppGeographiesDetails), | ||
Ramps: mapRamps(entityData.AppToRampsIntegrations), | ||
} | ||
|
||
return transformedRetoolEntityData, nil | ||
} | ||
|
||
func mapGeographies(appGeographies []utils.AppGeographyDetail) []string { | ||
var geographies []string | ||
for _, geoDetail := range appGeographies { | ||
for _, geo := range geoDetail.GeographiesID { | ||
geographies = append(geographies, geo.Name) | ||
} | ||
} | ||
return geographies | ||
} | ||
|
||
func mapRamps(appRamps []utils.AppToRampIntegration) []string { | ||
var ramps []string | ||
for _, ramp := range appRamps { | ||
ramps = append(ramps, ramp.Anchor.Name) | ||
} | ||
return ramps | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
package transform | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stellar/stellar-etl/internal/utils" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestTransformRetoolEntityData(t *testing.T) { | ||
output, _ := TransformRetoolEntityData(utils.RetoolEntityDataTransformInput{ | ||
ID: 16, | ||
Name: "El Dorado", | ||
Status: "live", | ||
CreatedAt: 1706749912776, | ||
UpdatedAt: nil, | ||
Custodial: true, | ||
NonCustodial: true, | ||
HomeDomainsID: 240, | ||
Description: "", | ||
WebsiteURL: "", | ||
SdpEnabled: false, | ||
SorobanEnabled: false, | ||
Notes: "", | ||
Verified: false, | ||
FeeSponsor: false, | ||
AccountSponsor: false, | ||
Live: true, | ||
HomeDomain: utils.HomeDomain{ | ||
ID: 240, | ||
CreatedAt: 1706749903897, | ||
UpdatedAt: 1706749903897, | ||
HomeDomain: "eldorado.io", | ||
}, | ||
AppGeographiesDetails: []utils.AppGeographyDetail{ | ||
{ | ||
ID: 39, | ||
AppsID: 16, | ||
CreatedAt: 1707887845605, | ||
GeographiesID: []utils.Geography{ | ||
{ | ||
ID: 176, | ||
CreatedAt: 1691020699576, | ||
UpdatedAt: 1706650713745, | ||
Name: "Argentina", | ||
OfficialName: "The Argentine Republic", | ||
}, | ||
{ | ||
ID: 273, | ||
CreatedAt: 1691020699834, | ||
UpdatedAt: 1706650708355, | ||
Name: "Brazil", | ||
OfficialName: "The Federative Republic of Brazil", | ||
}, | ||
}, | ||
Retail: false, | ||
Enterprise: false, | ||
}, | ||
}, | ||
AppToRampsIntegrations: []utils.AppToRampIntegration{ | ||
{ | ||
ID: 18, | ||
CreatedAt: 1707617027154, | ||
AnchorsID: 28, | ||
AppsID: 16, | ||
Anchor: utils.Anchor{ | ||
ID: 28, | ||
CreatedAt: 1705423531705, | ||
UpdatedAt: 1706596979487, | ||
Name: "MoneyGram", | ||
}, | ||
}, | ||
}, | ||
}, | ||
) | ||
expectedOutput := EntityDataTransformOutput{ | ||
ID: 16, | ||
Name: "El Dorado", | ||
Status: "live", | ||
CreatedAt: 1706749912776, | ||
UpdatedAt: nil, | ||
Custodial: true, | ||
NonCustodial: true, | ||
HomeDomainsID: 240, | ||
Description: "", | ||
WebsiteURL: "", | ||
SdpEnabled: false, | ||
SorobanEnabled: false, | ||
Notes: "", | ||
Verified: false, | ||
FeeSponsor: false, | ||
AccountSponsor: false, | ||
Live: true, | ||
HomeDomain: "eldorado.io", | ||
AppGeographies: []string{"Argentina", "Brazil"}, | ||
Ramps: []string{"MoneyGram"}, | ||
} | ||
assert.Equal(t, expectedOutput, output) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.