2020-02-19 12:21:26 +03:00
|
|
|
[![Build Status](https://img.shields.io/travis/retailcrm/api-client-go/master.svg?style=flat-square)](https://travis-ci.org/retailcrm/api-client-go)
|
|
|
|
[![codecov](https://codecov.io/gh/retailcrm/api-client-go/branch/master/graph/badge.svg)](https://codecov.io/gh/retailcrm/api-client-go)
|
2018-03-21 00:54:37 +03:00
|
|
|
[![GitHub release](https://img.shields.io/github/release/retailcrm/api-client-go.svg?style=flat-square)](https://github.com/retailcrm/api-client-go/releases)
|
2020-02-19 12:21:26 +03:00
|
|
|
[![GoLang version](https://img.shields.io/badge/go->=1.8-blue?style=flat-square)](https://golang.org/dl/)
|
2018-08-30 16:38:42 +03:00
|
|
|
[![Godoc reference](https://img.shields.io/badge/godoc-reference-blue.svg?style=flat-square)](https://godoc.org/github.com/retailcrm/api-client-go)
|
2018-03-21 00:54:37 +03:00
|
|
|
|
2018-02-27 13:51:19 +03:00
|
|
|
|
2018-01-16 17:37:55 +03:00
|
|
|
# retailCRM API Go client
|
|
|
|
|
2018-03-21 00:54:37 +03:00
|
|
|
This is golang retailCRM API client.
|
2018-02-27 11:37:15 +03:00
|
|
|
|
2018-03-21 00:54:37 +03:00
|
|
|
## Install
|
2018-02-27 11:37:15 +03:00
|
|
|
|
|
|
|
```bash
|
|
|
|
go get -x github.com/retailcrm/api-client-go
|
|
|
|
```
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
```golang
|
|
|
|
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,
|
2018-03-21 01:30:55 +03:00
|
|
|
},)
|
2019-02-25 12:02:03 +03:00
|
|
|
if err != nil {
|
2018-04-22 20:47:17 +03:00
|
|
|
fmt.Printf("%v", err.Error())
|
2018-02-27 11:37:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if status >= http.StatusBadRequest {
|
2018-04-22 20:44:53 +03:00
|
|
|
fmt.Printf("%v", err.ApiError())
|
2018-02-27 11:37:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
for _, value := range data.Orders {
|
|
|
|
fmt.Printf("%v\n", value.Email)
|
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Println(data.Orders[1].FirstName)
|
|
|
|
|
|
|
|
idata, status, err := c.InventoriesUpload(
|
2018-04-23 16:28:54 +03:00
|
|
|
[]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,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
)
|
2019-02-25 12:02:03 +03:00
|
|
|
if err != nil {
|
2018-04-23 16:28:54 +03:00
|
|
|
fmt.Printf("%v", err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
if status >= http.StatusBadRequest {
|
|
|
|
fmt.Printf("%v", err.ApiError())
|
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Println(idata.processedOffersCount)
|
2018-02-27 11:37:15 +03:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2018-03-21 00:54:37 +03:00
|
|
|
## Documentation
|
2018-02-27 11:37:15 +03:00
|
|
|
|
2018-03-21 00:54:37 +03:00
|
|
|
* [English](http://www.retailcrm.pro/docs/Developers/Index)
|
|
|
|
* [Russian](http://www.retailcrm.ru/docs/Developers/Index)
|