Skip to content

Latest commit

 

History

History
70 lines (51 loc) · 1.18 KB

UPGRADING.md

File metadata and controls

70 lines (51 loc) · 1.18 KB

Upgrading to the v2

Install the new version

go get -u github.com/retailcrm/api-client-go/v2

Update all imports

Before:

package main

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

After:

package main

import "github.com/retailcrm/api-client-go/v2"

You can use package alias v5 to skip the second step.

Replace package name for all imported symbols

Before:

package main

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

func main() {
    client := v5.New("https://test.retailcrm.pro", "key")
	data, status, err := client.Orders(v5.OrdersRequest{
		Filter: v5.OrdersFilter{
			City: "Moscow",
		},
		Page: 1,
	})
	...
}

After:

package main

import "github.com/retailcrm/api-client-go/v2"

func main() {
    client := retailcrm.New("https://test.retailcrm.pro", "key")
	data, status, err := client.Orders(retailcrm.OrdersRequest{
		Filter: retailcrm.OrdersFilter{
			City: "Moscow",
		},
		Page: 1,
	})
	...
}

Upgrade client usages

This major release contains some breaking changes regarding field names and fully redesigned error handling. Use the second example from the readme to learn how to process errors correctly.