mirror of
https://github.com/retailcrm/api-client-go.git
synced 2024-11-25 14:26:04 +03:00
Neur0toxine
97b1abf470
* refactor library and upgrade version * remove useless environment variable * remove unsupported versions from go.mod * fixes for error handling & data types * different improvements for errors * fixes for types and tests * better coverage, fix error with the unmarshalers
1.2 KiB
1.2 KiB
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.