53 lines
1.1 KiB
Go
53 lines
1.1 KiB
Go
package pricing
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/paulmach/orb/geojson"
|
|
)
|
|
|
|
type PricingService interface {
|
|
Prices(params PricingParams) (map[string]Price, error)
|
|
}
|
|
|
|
func NewPricingService(implementation string) (PricingService, error) {
|
|
switch implementation {
|
|
case "mms43":
|
|
return NewMMS43PricingService()
|
|
case "pfm63":
|
|
return NewPFM63PricingService()
|
|
default:
|
|
return nil, fmt.Errorf("pricing implementation %v is not supported", implementation)
|
|
|
|
}
|
|
}
|
|
|
|
type PricingParams struct {
|
|
MobilityType string
|
|
SharedMobility SharedMobilityParams
|
|
Beneficiary BeneficiaryParams
|
|
Data map[string]any // other data (specific)
|
|
}
|
|
|
|
type SharedMobilityParams struct {
|
|
DriverDistance int64
|
|
PassengerDistance int64
|
|
Departure GeographyParams
|
|
Destination GeographyParams
|
|
OutwardOnly bool
|
|
}
|
|
|
|
type BeneficiaryParams struct {
|
|
Address GeographyParams
|
|
Priority bool
|
|
History int
|
|
}
|
|
|
|
type GeographyParams struct {
|
|
Location *geojson.Feature
|
|
CityCode string // INSEE code
|
|
IntercommunalityCode string // SIRENnumber
|
|
RegionCode string
|
|
DepartmentCode string
|
|
}
|