remove pointers from response, update license, minor refactoring

This commit is contained in:
Alex Lushpai 2018-03-21 00:54:37 +03:00
parent 3bbf0f2c3a
commit e7c3cc4815
5 changed files with 964 additions and 937 deletions

21
LICENSE Normal file
View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2015-2018 RetailDriver LLC
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@ -1,10 +1,13 @@
[![Build Status](https://img.shields.io/travis/retailcrm/api-client-go/master.svg?style=flat-square)](https://travis-ci.org/retailcrm/api-client-go)
[![GitHub release](https://img.shields.io/github/release/retailcrm/api-client-go.svg?style=flat-square)](https://github.com/retailcrm/api-client-go/releases)
[![GoLang version](https://img.shields.io/badge/GoLang-1.8%2C%201.9%2C%201.10-blue.svg?style=flat-square)](https://golang.org/dl/)
# retailCRM API Go client
Go client for [retailCRM API](http://www.retailcrm.pro/docs/Developers/ApiVersion5).
This is golang retailCRM API client.
## Installation
## Install
```bash
go get -x github.com/retailcrm/api-client-go
@ -76,15 +79,8 @@ func main() {
}
```
## Testing
## Documentation
```bash
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 ./...
```
* [English](http://www.retailcrm.pro/docs/Developers/Index)
* [Russian](http://www.retailcrm.ru/docs/Developers/Index)
* [GoDoc](https://godoc.org/github.com/retailcrm/api-client-go)

File diff suppressed because it is too large Load Diff

View File

@ -57,14 +57,17 @@ func TestClient_ApiVersionsVersions(t *testing.T) {
data, status, err := c.APIVersions()
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if status >= http.StatusBadRequest {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
if data.Success != true {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
}
}
@ -378,7 +381,7 @@ func TestClient_CustomersHistory(t *testing.T) {
func TestClient_NotesNotes(t *testing.T) {
c := client()
data, status, err := c.Notes(NotesRequest{Page: 1})
data, status, err := c.CustomerNotes(NotesRequest{Page: 1})
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
@ -420,7 +423,7 @@ func TestClient_NotesCreateDelete(t *testing.T) {
t.Fail()
}
noteCreateResponse, noteCreateStatus, err := c.NoteCreate(Note{
noteCreateResponse, noteCreateStatus, err := c.CustomerNoteCreate(Note{
Text: "some text",
ManagerID: user,
Customer: &Customer{
@ -442,7 +445,7 @@ func TestClient_NotesCreateDelete(t *testing.T) {
t.Fail()
}
noteDeleteResponse, noteDeleteStatus, err := c.NoteDelete(noteCreateResponse.ID)
noteDeleteResponse, noteDeleteStatus, err := c.CustomerNoteDelete(noteCreateResponse.ID)
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
@ -748,7 +751,7 @@ func TestClient_PaymentCreateEditDelete(t *testing.T) {
Type: "cash",
}
paymentCreateResponse, status, err := c.PaymentCreate(f)
paymentCreateResponse, status, err := c.OrderPaymentCreate(f)
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
@ -769,7 +772,7 @@ func TestClient_PaymentCreateEditDelete(t *testing.T) {
Amount: 500,
}
paymentEditResponse, status, err := c.PaymentEdit(k, "id")
paymentEditResponse, status, err := c.OrderPaymentEdit(k, "id")
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
@ -785,7 +788,7 @@ func TestClient_PaymentCreateEditDelete(t *testing.T) {
t.Fail()
}
paymentDeleteResponse, status, err := c.PaymentDelete(paymentCreateResponse.ID)
paymentDeleteResponse, status, err := c.OrderPaymentDelete(paymentCreateResponse.ID)
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()
@ -969,10 +972,10 @@ func TestClient_UsersUpdate(t *testing.T) {
}
}
func TestClient_StaticticUpdate(t *testing.T) {
func TestClient_StaticticsUpdate(t *testing.T) {
c := client()
data, st, err := c.StaticticUpdate()
data, st, err := c.StaticticsUpdate()
if err.ErrorMsg != "" {
t.Errorf("%v", err.ErrorMsg)
t.Fail()

View File

@ -16,8 +16,8 @@ func (c *Client) ErrorResponse(data []byte) (ErrorResponse, error) {
return resp, err
}
// SucessfulResponse type
type SucessfulResponse struct {
// SuccessfulResponse type
type SuccessfulResponse struct {
Success bool `json:"success,omitempty"`
}