{"modulePath":"github.com/weiwolves/pkg","version":"v0.0.0-20200322065615-581c8d33cff6","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package directory\n\nPackage directory provides features for currencies, currency rates, conversion of prices to a specified currency format, countries and regions.\n\n@todo think about: [https://github.com/mledoze/countries](https://github.com/mledoze/countries)\n\n## Variables\n\n```go\nvar TableCollection csdb.TableManager\n```\nTableCollection handles all tables and its columns. init() in generated Go file will set the value.\n\n## Functions\n\n```go\nfunc NewConfigStructure() (config.Sections, error)\n```\nNewConfigStructure global configuration structure for this package. Used in frontend (to display the user all the settings) and in backend (scope checks and default values). See the source code of this function for the overall available sections, groups and fields.\n\n## Types\n\n```go\ntype ConfigCurrency struct {\n\tcfgmodel.Str\n}\n```\nConfigCurrency currency type for the configuration based on text/currency pkg.\n\n```go\nfunc NewConfigCurrency(path string, opts ...cfgmodel.Option) ConfigCurrency\n```\nNewConfigCurrency creates a new currency configuration type.\n\n```go\nfunc (cc ConfigCurrency) Get(sg config.Scoped) (cur Currency, err error)\n```\nGet tries to retrieve a currency considering the scope\n\n```go\nfunc (cc ConfigCurrency) GetDefault(sg config.Getter) (cur Currency, err error)\n```\nGetDefault returns the default currency without considering the scope.\n\n```go\nfunc (cc ConfigCurrency) Write(w config.Setter, v Currency, s scope.Type, id int64) error\n```\nWrites a currency to the configuration storage.\n\n```go\ntype Currency struct {\n\tcurrency.Unit\n}\n```\nCurrency represents a corestore currency type which may add more features.\n\n```go\nfunc MustNewCurrencyISO(iso string) Currency\n```\nMustNewCurrencyISO same as NewCurrencyISO() but panics on error.\n\n```go\nfunc NewCurrencyISO(iso string) (c Currency, err error)\n```\nNewCurrencyISO creates a new Currency by parsing a 3-letter ISO 4217 currency code. It returns an error if s is not well-formed or not a recognized currency code.\n\n```go\ntype PkgBackend struct {\n\tcfgmodel.PkgBackend\n\n\t// CurrencyOptionsBase =\u003e Base Currency.\n\t// Base currency is used for all online payment transactions. If you have more\n\t// than one store view, the base currency scope is defined by the catalog\n\t// price scope (\"Catalog\" \u003e \"Price\" \u003e \"Catalog Price Scope\").\n\t// Path: currency/options/base\n\t// BackendModel: Magento\\Config\\Model\\Config\\Backend\\Currency\\Base\n\t// SourceModel: Magento\\Config\\Model\\Config\\Source\\Locale\\Currency\n\tCurrencyOptionsBase ConfigCurrency\n\n\t// CurrencyOptionsDefault =\u003e Default Display Currency.\n\t// Path: currency/options/default\n\t// BackendModel: Magento\\Config\\Model\\Config\\Backend\\Currency\\DefaultCurrency\n\t// SourceModel: Magento\\Config\\Model\\Config\\Source\\Locale\\Currency\n\tCurrencyOptionsDefault ConfigCurrency\n\n\t// CurrencyOptionsAllow =\u003e Allowed Currencies.\n\t// Path: currency/options/allow\n\t// BackendModel: Magento\\Config\\Model\\Config\\Backend\\Currency\\Allow\n\t// SourceModel: Magento\\Config\\Model\\Config\\Source\\Locale\\Currency\n\tCurrencyOptionsAllow cfgmodel.StringCSV\n\n\t// CurrencyWebservicexTimeout =\u003e Connection Timeout in Seconds.\n\t// Path: currency/webservicex/timeout\n\tCurrencyWebservicexTimeout cfgmodel.Str\n\n\t// CurrencyImportEnabled =\u003e Enabled.\n\t// Path: currency/import/enabled\n\t// SourceModel: Magento\\Config\\Model\\Config\\Source\\Yesno\n\tCurrencyImportEnabled cfgmodel.Bool\n\n\t// CurrencyImportErrorEmail =\u003e Error Email Recipient.\n\t// Path: currency/import/error_email\n\tCurrencyImportErrorEmail cfgmodel.Str\n\n\t// CurrencyImportErrorEmailIdentity =\u003e Error Email Sender.\n\t// Path: currency/import/error_email_identity\n\t// SourceModel: Magento\\Config\\Model\\Config\\Source\\Email\\Identity\n\tCurrencyImportErrorEmailIdentity cfgmodel.Str\n\n\t// CurrencyImportErrorEmailTemplate =\u003e Error Email Template.\n\t// Email template chosen based on theme fallback when \"Default\" option is\n\t// selected.\n\t// Path: currency/import/error_email_template\n\t// SourceModel: Magento\\Config\\Model\\Config\\Source\\Email\\Template\n\tCurrencyImportErrorEmailTemplate cfgmodel.Str\n\n\t// CurrencyImportFrequency =\u003e Frequency.\n\t// Path: currency/import/frequency\n\t// SourceModel: Magento\\Cron\\Model\\Config\\Source\\Frequency\n\tCurrencyImportFrequency cfgmodel.Str\n\n\t// CurrencyImportService =\u003e Service.\n\t// Path: currency/import/service\n\t// BackendModel: Magento\\Config\\Model\\Config\\Backend\\Currency\\Cron\n\t// SourceModel: Magento\\Directory\\Model\\Currency\\Import\\Source\\Service\n\tCurrencyImportService cfgmodel.Str\n\n\t// CurrencyImportTime =\u003e Start Time.\n\t// Path: currency/import/time\n\tCurrencyImportTime cfgmodel.Str\n\n\t// SystemCurrencyInstalled =\u003e Installed Currencies.\n\t// Defines all installed and available currencies.\n\t// Path: system/currency/installed\n\t// BackendModel: Magento\\Config\\Model\\Config\\Backend\\Locale\n\t// SourceModel: Magento\\Config\\Model\\Config\\Source\\Locale\\Currency\\All\n\t//\n\t// TODO:\n\t//\t// SourceCurrencyAll used in Path: `system/currency/installed`,\n\t//func (sca *SourceCurrencyAll) Options() source.Slice {\n\t//\t// Magento\\Framework\\Locale\\Resolver\n\t//\t// 1. get all allowed currencies from the config\n\t//\t// 2. get slice of currency code and currency name and filter out all not-allowed currencies\n\t//\t// grep locale from general/locale/code scope::store for the current store ID\n\t//\t// the store locale greps the currencies from http://php.net/manual/en/class.resourcebundle.php\n\t//\t// in the correct language\n\t//\tstoreLocale, err := sca.mc.Config.String(config.Path(PathDefaultLocale), config.ScopeStore(sca.mc.ScopeStore.StoreID()))\n\t//\treturn nil\n\t//}\n\tSystemCurrencyInstalled cfgmodel.StringCSV\n\n\t// GeneralCountryOptionalZipCountries =\u003e Zip/Postal Code is Optional for.\n\t// Path: general/country/optional_zip_countries\n\t// SourceModel: Magento\\Directory\\Model\\Config\\Source\\Country\n\tGeneralCountryOptionalZipCountries cfgmodel.StringCSV\n\n\t// PathGeneralCountryAllow per store view allowed list of countries\n\t// SourceModel: Magento\\Directory\\Model\\Config\\Source\\Country\n\tGeneralCountryAllow cfgmodel.StringCSV\n\n\t// PathGeneralCountryDefault returns the store view default configured country code.\n\t// SourceModel: Magento\\Directory\\Model\\Config\\Source\\Country\n\tGeneralCountryDefault cfgmodel.Str\n\n\t// PathGeneralCountryEuCountries =\u003e European Union Countries.\n\t// SourceModel: Magento\\Directory\\Model\\Config\\Source\\Country\n\tGeneralCountryEuCountries cfgmodel.StringCSV\n\n\t// PathGeneralCountryDestinations contains codes of the most used countries.\n\t// Such countries can be shown on the top of the country list.\n\t// SourceModel: Magento\\Directory\\Model\\Config\\Source\\Country\n\tGeneralCountryDestinations cfgmodel.StringCSV\n\n\t// PathGeneralLocaleTimezone =\u003e Timezone.\n\t// BackendModel: Magento\\Config\\Model\\Config\\Backend\\Locale\\Timezone\n\t// SourceModel: Magento\\Config\\Model\\Config\\Source\\Locale\\Timezone\n\tGeneralLocaleTimezone cfgmodel.Str\n\n\t// PathGeneralLocaleCode =\u003e Locale.\n\t// SourceModel: Magento\\Config\\Model\\Config\\Source\\Locale\n\tGeneralLocaleCode cfgmodel.Str\n\n\t// PathGeneralLocaleFirstday =\u003e First Day of Week.\n\t// SourceModel: Magento\\Config\\Model\\Config\\Source\\Locale\\Weekdays\n\tGeneralLocaleFirstday cfgmodel.Str\n\n\t// PathGeneralLocaleWeekend =\u003e Weekend Days.\n\t// SourceModel: Magento\\Config\\Model\\Config\\Source\\Locale\\Weekdays\n\tGeneralLocaleWeekend cfgmodel.StringCSV\n\n\t// GeneralRegionStateRequired =\u003e State is Required for.\n\t// Path: general/region/state_required\n\t// SourceModel: Magento\\Directory\\Model\\Config\\Source\\Country\n\tGeneralRegionStateRequired cfgmodel.StringCSV\n\n\t// GeneralRegionDisplayAll =\u003e Allow to Choose State if It is Optional for Country.\n\t// Path: general/region/display_all\n\t// SourceModel: Magento\\Config\\Model\\Config\\Source\\Yesno\n\tGeneralRegionDisplayAll cfgmodel.Bool\n\n\t// GeneralLocaleWeightUnit =\u003e Weight Unit.\n\t// Path: general/locale/weight_unit\n\t// SourceModel: Magento\\Directory\\Model\\Config\\Source\\WeightUnit\n\tGeneralLocaleWeightUnit cfgmodel.Str\n}\n```\nPkgBackend just exported for the sake of documentation. See fields for more information. The PkgBackend handles the reading and writing of configuration values within this package.\n\n```go\nfunc NewBackend(cfgStruct element.Sections) *PkgBackend\n```\nNewBackend initializes the global configuration models containing the cfgpath.Route variable to the appropriate entry. The function Load() will be executed to apply the Sections to all models. See Load() for more details.\n\n```go\nfunc (be *PkgBackend) InitCountry(dbrsess dbr.SessionRunner, o *PkgSource) error\n```\nInitCountry should run every time your service initializes or a value in the database changes.\n\n```go\nfunc (be *PkgBackend) InitCurrency(dbrSess dbr.SessionRunner, o *PkgSource) error\n```\nInitCurrency sets the Options() on all PathCurrency\\* configuration global variables.\n\n```go\nfunc (be *PkgBackend) InitSources(dbrSess dbr.SessionRunner) (*PkgSource, error)\n```\nInitSources initializes the global variable Sources in all models. Changing a cfgsource.Slice here affects all other models.\n\n```go\nfunc (pp *PkgBackend) Load(cfgStruct element.Sections) *PkgBackend\n```\nLoad creates the configuration models for each PkgBackend field. Internal mutex will protect the fields during loading. The argument Sections will be applied to all models.\n\n```go\ntype PkgSource struct {\n\tsync.Mutex\n\t// Currency contains all possible currencies on this planet.\n\tCurrency _cfgsource.Slice\n\t// Country should contain all countries\n\tCountry _cfgsource.Slice\n}\n```\nPkgSource a container for all available cfgsource.Slice within this package. These sources will be applied to the models See fields for more information.\n\n","path":"github.com/weiwolves/pkg/directory","name":"directory","synopsis":"Package directory provides features for currencies, currency rates, conversion of prices to a specified currency format, countries and regions.","isRedistributable":true}
