Go client for retailCRM API
Go to file
Alex Lushpai 635e40dab2
Merge pull request #25 from iyzoer/master
Update User struct
2019-03-05 14:49:28 +03:00
errs updated error handling 2019-02-21 11:51:50 +03:00
v5 Update User struct 2019-03-05 14:43:38 +03:00
.env.dist Product units 2019-02-20 10:07:02 +03:00
.gitignore add debug mode, add .env support for local testing 2018-09-28 01:37:56 +03:00
.travis.yml Product units 2019-02-20 10:07:02 +03:00
LICENSE remove pointers from response, update license, minor refactoring 2018-03-21 00:54:37 +03:00
README.md update README.md 2019-02-25 12:02:03 +03:00

Build Status GitHub release GoLang version Godoc reference

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)
}

Documentation