lib/app/coordinate-helpers.go

54 lines
1.6 KiB
Go
Raw Permalink Normal View History

2021-01-14 06:36:35 +00:00
package app
import "code.tnxs.net/taxnexus/lib/api/geo/geo_models"
// Coordinate is never ingested, hence no UnMarshal method
// MarshalToSwagger encodes a first class object to swagger
func (obj *Coordinate) MarshalToSwagger() *geo_models.Coordinate {
theTaxTypes := []*geo_models.TaxType{}
if obj.TaxTypes != nil {
for _, itm := range obj.TaxTypes {
theTaxTypes = append(theTaxTypes, itm.MarshalToSwagger())
}
}
var taxRate geo_models.TaxRate
if obj.TaxRate != nil {
taxRate = geo_models.TaxRate{
CombinedRate: obj.TaxRate.CombinedRate,
County: obj.TaxRate.County,
CountyID: obj.TaxRate.CountyID,
CountyRate: obj.TaxRate.CountyRate,
Date: obj.TaxRate.Date,
}
}
return &geo_models.Coordinate{
ID: obj.ID,
Country: obj.Country,
CountryID: obj.CountryID,
County: obj.County,
CountyID: obj.CountyID,
Focus: obj.Focus,
FormattedAddress: obj.FormattedAddress,
IsDistrict: obj.IsDistrict,
Latitude: obj.Latitude,
Longitude: obj.Longitude,
Map: obj.Map,
Name: obj.Name,
Neighborhood: obj.Neighborhood,
Place: obj.Place,
PlaceGeocode: obj.Geocode,
PlaceID: obj.PlaceID,
PostalCode: obj.PostalCode,
Ref: obj.Ref,
State: obj.State,
StateID: obj.StateID,
Status: obj.Status,
Street: obj.Street,
StreetNumber: obj.StreetNumber,
StreetView: obj.StreetView,
TaxTypes: theTaxTypes,
TaxRate: &taxRate,
}
}