Go client for retailCRM API
Go to file
2021-10-26 13:16:58 +03:00
.github/workflows add go 1.17 to test matrix 2021-09-06 16:39:14 +03:00
v5 add scopes to credentials method response 2021-10-26 13:16:58 +03:00
.env.dist Product units 2019-02-20 10:07:02 +03:00
.gitignore [improvement] coverage 2019-11-25 10:28:35 +03:00
.golangci.yml Switch to go modules & update linter config (#49) 2021-04-16 14:25:25 +03:00
go.mod Remove errs package, change logic for error processing (#48) 2021-04-26 12:09:21 +03:00
go.sum Switch to go modules & update linter config (#49) 2021-04-16 14:25:25 +03:00
LICENSE Update product name, cleanup annotations (#43) 2020-12-15 13:33:24 +03:00
README.md Update product name, cleanup annotations (#43) 2020-12-15 13:33:24 +03:00

Build Status Covarage GitHub release Go Report Card GoLang version pkg.go.dev

RetailCRM API Go client

This is golang RetailCRM API client.

Install

go get -x github.com/retailcrm/api-client-go

Usage

package main

import (
	"fmt"
	"net/http"

	"github.com/retailcrm/api-client-go/v5"
)

func main() {
	var client = v5.New("https://demo.retailcrm.pro", "09jIJ09j0JKhgyfvyuUIKhiugF")

	data, status, err := client.Orders(v5.OrdersRequest{
		Filter: v5.OrdersFilter{},
		Limit: 20,
		Page: 1,
	},)
	if err != nil {
		fmt.Printf("%v", err.Error())
	}

	if status >= http.StatusBadRequest {
		fmt.Printf("%v", err.ApiError())
	}

	for _, value := range data.Orders {
		fmt.Printf("%v\n", value.Email)
	}

	fmt.Println(data.Orders[1].FirstName)

	idata, status, err := c.InventoriesUpload(
		[]InventoryUpload{
			{
				XMLID: "pTKIKAeghYzX21HTdzFCe1",
				Stores: []InventoryUploadStore{
					{
						Code: "test-store-v5",
						Available: 10,
						PurchasePrice: 1500,
					},
					{
						Code: "test-store-v4",
						Available: 20,
						PurchasePrice: 1530,
					},
					{
						Code: "test-store",
						Available: 30,
						PurchasePrice: 1510,
					},
				},
			},
			{
				XMLID: "JQIvcrCtiSpOV3AAfMiQB3",
				Stores: []InventoryUploadStore{
					{
						Code: "test-store-v5",
						Available: 45,
						PurchasePrice: 1500,
					},
					{
						Code: "test-store-v4",
						Available: 32,
						PurchasePrice: 1530,
					},
					{
						Code: "test-store",
						Available: 46,
						PurchasePrice: 1510,
					},
				},
			},
		},
	)
	if err != nil {
		fmt.Printf("%v", err.Error())
	}

	if status >= http.StatusBadRequest {
		fmt.Printf("%v", err.ApiError())
	}

	fmt.Println(idata.processedOffersCount)
}