Esempio n. 1
0
// MatchIndex ...
func MatchIndex(w http.ResponseWriter, r *http.Request) {

	// Temporary dry-run until a web interface accomodates this.
	var force, matchSKU bool
	var tz string
	flag.BoolVar(&force, "f", false, "Default is to dry run, this forces the real thing.")
	flag.BoolVar(&matchSKU, "s", false, "Default is to match based on ID, this uses SKU.")
	flag.StringVar(&tz, "z", "Local", "Timezone in zoneinfo format (default is system time)")
	flag.Parse()

	// Grab environment variables for authentication.
	// Store names.
	vendDomainPrefix = os.Getenv("VEND_DOMAIN_PREFIX")
	shopifyStoreName = os.Getenv("SHOPIFY_STORE_NAME")
	// Auth tokens.
	vendToken = os.Getenv("VEND_TOKEN")
	shopifyKey = os.Getenv("SHOPIFY_KEY")
	shopifyPassword = os.Getenv("SHOPIFY_PASSWORD")

	// Check for empty variables.
	if vendDomainPrefix == "" || vendToken == "" {
		fmt.Printf("Please specify a Domain Prefix and API Access Token.")
		os.Exit(0)
	}

	// To save people who write DomainPrefix.vendhq.com.
	// Split DomainPrefix on the "." period character then grab the first part.
	parts := strings.Split(vendDomainPrefix, ".")
	vendDomainPrefix = parts[0]

	v := vend.NewClient(vendToken, vendDomainPrefix, tz)
	s := shopify.NewClient(shopifyKey, shopifyPassword, shopifyStoreName)

	manager := manager.NewManager(s, v)

	manager.Run(force, matchSKU)

	w.Header().Set("Content-Type", "application/json; charset=UTF-8")
	w.WriteHeader(http.StatusOK)
}
Esempio n. 2
0
func main() {
	vend.NewClient(token, domainPrefix, tz)
}
Esempio n. 3
0
func main() {
	v := vend.NewClient(token, domainPrefix, tz)
	manager := manager.NewManager(v)

	manager.Run()
}