Go client for retailCRM API
Go to file
Alex Lushpai b8862f3d58
Merge pull request #4 from gwinn/master
Cleaning up redundant code
2018-02-27 15:34:16 +03:00
v5 godoc ApiCredentials 2018-02-27 15:22:52 +03:00
.gitignore Travis CI configuration (#2) 2018-02-27 13:51:19 +03:00
.travis.yml Travis CI configuration (#2) 2018-02-27 13:51:19 +03:00
README.md cleanup 2018-02-27 15:31:55 +03:00
retailcrm.go Initial set of methods & tests (#1) 2018-02-27 11:37:15 +03:00

Build Status

retailCRM API Go client

Go client for retailCRM API.

Installation

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.ErrorMsg != "" {
		fmt.Printf("%v", err.ErrorMsg)
	}

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

	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.ErrorMsg != "" {
        fmt.Printf("%v", err.ErrorMsg)
    }

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

    fmt.Println(idata.processedOffersCount)
}

Testing

export RETAILCRM_URL="https://demo.retailcrm.pro"
export RETAILCRM_KEY="09jIJ09j0JKhgyfvyuUIKhiugF"
export RETAILCRM_USER="1"

cd $GOPATH/src/github.com/retailcrm/api-client-go

go test -v ./...