mirror of
https://github.com/retailcrm/api-client-go.git
synced 2024-11-25 06:16:03 +03:00
Merge pull request #6 from gwinn/master
remove pointers from response, update license, minor refactoring
This commit is contained in:
commit
a9c16a0e26
21
LICENSE
Normal file
21
LICENSE
Normal 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.
|
22
README.md
22
README.md
@ -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)
|
||||
|
1835
v5/client.go
1835
v5/client.go
File diff suppressed because it is too large
Load Diff
@ -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()
|
||||
|
@ -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"`
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user