mirror of
https://github.com/retailcrm/api-client-go.git
synced 2024-11-25 06:16:03 +03:00
Merge pull request #29 from Neur0toxine/master
[improvement] corporate customers
This commit is contained in:
commit
e8e8fb526c
2
.gitignore
vendored
2
.gitignore
vendored
@ -21,10 +21,12 @@ _testmain.go
|
||||
*.exe
|
||||
*.test
|
||||
*.prof
|
||||
coverage.txt
|
||||
|
||||
# IDE's files
|
||||
.idea
|
||||
*.iml
|
||||
.env
|
||||
.swp
|
||||
|
||||
# Project ignores
|
||||
|
@ -4,8 +4,12 @@ go:
|
||||
- '1.9'
|
||||
- '1.10'
|
||||
- '1.11'
|
||||
- '1.12'
|
||||
- '1.13'
|
||||
before_install:
|
||||
- go get -v github.com/google/go-querystring/query
|
||||
- go get -v github.com/h2non/gock
|
||||
- cp .env.dist .env
|
||||
script: go test -v ./...
|
||||
script: ./go.test.sh
|
||||
after_success:
|
||||
- bash <(curl -s https://codecov.io/bash)
|
||||
|
@ -1,6 +1,6 @@
|
||||
[![Build Status](https://img.shields.io/travis/retailcrm/api-client-go/master.svg?logo=travis&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/go-1.8%2C%201.9%2C%201.10-blue.svg?style=flat-square)](https://golang.org/dl/)
|
||||
[![GoLang version](https://img.shields.io/badge/go-1.8%20--%201.13-blue?style=flat-square)](https://golang.org/dl/)
|
||||
[![Godoc reference](https://img.shields.io/badge/godoc-reference-blue.svg?style=flat-square)](https://godoc.org/github.com/retailcrm/api-client-go)
|
||||
|
||||
|
||||
|
15
go.test.sh
Executable file
15
go.test.sh
Executable file
@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
export DEVELOPER_NODE=1
|
||||
export RETAILCRM_URL=https://test.retailcrm.pro
|
||||
export RETAILCRM_KEY=key
|
||||
echo "" > coverage.txt
|
||||
|
||||
for d in $(go list ./... | grep -v vendor); do
|
||||
go test -race -coverprofile=profile.out -covermode=atomic "$d"
|
||||
if [ -f profile.out ]; then
|
||||
cat profile.out >> coverage.txt
|
||||
rm profile.out
|
||||
fi
|
||||
done
|
1018
v5/client.go
1018
v5/client.go
File diff suppressed because it is too large
Load Diff
1007
v5/client_test.go
1007
v5/client_test.go
File diff suppressed because it is too large
Load Diff
@ -57,6 +57,73 @@ type CustomersFilter struct {
|
||||
CustomFields map[string]string `url:"customFields,omitempty,brackets"`
|
||||
}
|
||||
|
||||
// CorporateCustomersFilter type
|
||||
type CorporateCustomersFilter struct {
|
||||
ContragentName string `url:"contragentName,omitempty"`
|
||||
ContragentInn string `url:"contragentInn,omitempty"`
|
||||
ContragentKpp string `url:"contragentKpp,omitempty"`
|
||||
ContragentBik string `url:"contragentBik,omitempty"`
|
||||
ContragentCorrAccount string `url:"contragentCorrAccount,omitempty"`
|
||||
ContragentBankAccount string `url:"contragentBankAccount,omitempty"`
|
||||
ContragentTypes []string `url:"contragentTypes,omitempty,brackets"`
|
||||
ExternalIds []string `url:"externalIds,omitempty,brackets"`
|
||||
Name string `url:"name,omitempty"`
|
||||
City string `url:"city,omitempty"`
|
||||
Region string `url:"region,omitempty"`
|
||||
Email string `url:"email,omitempty"`
|
||||
Notes string `url:"notes,omitempty"`
|
||||
MinOrdersCount int `url:"minOrdersCount,omitempty"`
|
||||
MaxOrdersCount int `url:"maxOrdersCount,omitempty"`
|
||||
MinAverageSumm float32 `url:"minAverageSumm,omitempty"`
|
||||
MaxAverageSumm float32 `url:"maxAverageSumm,omitempty"`
|
||||
MinTotalSumm float32 `url:"minTotalSumm,omitempty"`
|
||||
MaxTotalSumm float32 `url:"maxTotalSumm,omitempty"`
|
||||
ClassSegment string `url:"classSegment,omitempty"`
|
||||
DiscountCardNumber string `url:"discountCardNumber,omitempty"`
|
||||
Attachments int `url:"attachments,omitempty"`
|
||||
MinCostSumm float32 `url:"minCostSumm,omitempty"`
|
||||
MaxCostSumm float32 `url:"maxCostSumm,omitempty"`
|
||||
Vip int `url:"vip,omitempty"`
|
||||
Bad int `url:"bad,omitempty"`
|
||||
TasksCount int `url:"tasksCounts,omitempty"`
|
||||
Ids []string `url:"ids,omitempty,brackets"`
|
||||
Sites []string `url:"sites,omitempty,brackets"`
|
||||
Managers []string `url:"managers,omitempty,brackets"`
|
||||
ManagerGroups []string `url:"managerGroups,omitempty,brackets"`
|
||||
DateFrom string `url:"dateFrom,omitempty"`
|
||||
DateTo string `url:"dateTo,omitempty"`
|
||||
FirstOrderFrom string `url:"firstOrderFrom,omitempty"`
|
||||
FirstOrderTo string `url:"firstOrderTo,omitempty"`
|
||||
LastOrderFrom string `url:"lastOrderFrom,omitempty"`
|
||||
LastOrderTo string `url:"lastOrderTo,omitempty"`
|
||||
CustomFields map[string]string `url:"customFields,omitempty,brackets"`
|
||||
}
|
||||
|
||||
// CorporateCustomersNotesFilter type
|
||||
type CorporateCustomersNotesFilter struct {
|
||||
Ids []string `url:"ids,omitempty,brackets"`
|
||||
CustomerIds []string `url:"ids,omitempty,brackets"`
|
||||
CustomerExternalIds []string `url:"customerExternalIds,omitempty,brackets"`
|
||||
ManagerIds []string `url:"managerIds,omitempty,brackets"`
|
||||
Text string `url:"text,omitempty"`
|
||||
CreatedAtFrom string `url:"createdAtFrom,omitempty"`
|
||||
CreatedAtTo string `url:"createdAtTo,omitempty"`
|
||||
}
|
||||
|
||||
// CorporateCustomerAddressesFilter type
|
||||
type CorporateCustomerAddressesFilter struct {
|
||||
Ids []string `url:"ids,omitempty,brackets"`
|
||||
Name string `url:"name,omitempty"`
|
||||
City string `url:"city,omitempty"`
|
||||
Region string `url:"region,omitempty"`
|
||||
}
|
||||
|
||||
// IdentifiersPairFilter type
|
||||
type IdentifiersPairFilter struct {
|
||||
Ids []string `url:"ids,omitempty,brackets"`
|
||||
ExternalIds []string `url:"externalIds,omitempty,brackets"`
|
||||
}
|
||||
|
||||
// CustomersHistoryFilter type
|
||||
type CustomersHistoryFilter struct {
|
||||
CustomerID int `url:"customerId,omitempty"`
|
||||
@ -66,6 +133,16 @@ type CustomersHistoryFilter struct {
|
||||
EndDate string `url:"endDate,omitempty"`
|
||||
}
|
||||
|
||||
// CorporateCustomersHistoryFilter type
|
||||
type CorporateCustomersHistoryFilter struct {
|
||||
CustomerID int `url:"customerId,omitempty"`
|
||||
SinceID int `url:"sinceId,omitempty"`
|
||||
CustomerExternalID string `url:"customerExternalId,omitempty"`
|
||||
ContactIds []string `url:"contactIds,omitempty,brackets"`
|
||||
StartDate string `url:"startDate,omitempty"`
|
||||
EndDate string `url:"endDate,omitempty"`
|
||||
}
|
||||
|
||||
// OrdersFilter type
|
||||
type OrdersFilter struct {
|
||||
Ids []int `url:"ids,omitempty,brackets"`
|
||||
|
@ -13,6 +13,38 @@ type CustomersRequest struct {
|
||||
Page int `url:"page,omitempty"`
|
||||
}
|
||||
|
||||
// CorporateCustomersRequest type
|
||||
type CorporateCustomersRequest struct {
|
||||
Filter CorporateCustomersFilter `url:"filter,omitempty"`
|
||||
Limit int `url:"limit,omitempty"`
|
||||
Page int `url:"page,omitempty"`
|
||||
}
|
||||
|
||||
// CorporateCustomersNotesRequest type
|
||||
type CorporateCustomersNotesRequest struct {
|
||||
Filter CorporateCustomersNotesFilter `url:"filter,omitempty"`
|
||||
Limit int `url:"limit,omitempty"`
|
||||
Page int `url:"page,omitempty"`
|
||||
}
|
||||
|
||||
// CorporateCustomerAddressesRequest type
|
||||
type CorporateCustomerAddressesRequest struct {
|
||||
Filter CorporateCustomerAddressesFilter `url:"filter,omitempty"`
|
||||
By string `url:"by,omitempty"`
|
||||
Site string `url:"site,omitempty"`
|
||||
Limit int `url:"limit,omitempty"`
|
||||
Page int `url:"page,omitempty"`
|
||||
}
|
||||
|
||||
// IdentifiersPairRequest type
|
||||
type IdentifiersPairRequest struct {
|
||||
Filter IdentifiersPairFilter `url:"filter,omitempty"`
|
||||
By string `url:"by,omitempty"`
|
||||
Site string `url:"site,omitempty"`
|
||||
Limit int `url:"limit,omitempty"`
|
||||
Page int `url:"page,omitempty"`
|
||||
}
|
||||
|
||||
// CustomersUploadRequest type
|
||||
type CustomersUploadRequest struct {
|
||||
Customers []Customer `url:"customers,omitempty,brackets"`
|
||||
@ -26,6 +58,13 @@ type CustomersHistoryRequest struct {
|
||||
Page int `url:"page,omitempty"`
|
||||
}
|
||||
|
||||
// CorporateCustomersHistoryRequest type
|
||||
type CorporateCustomersHistoryRequest struct {
|
||||
Filter CorporateCustomersHistoryFilter `url:"filter,omitempty"`
|
||||
Limit int `url:"limit,omitempty"`
|
||||
Page int `url:"page,omitempty"`
|
||||
}
|
||||
|
||||
// OrderRequest type
|
||||
type OrderRequest struct {
|
||||
By string `url:"by,omitempty"`
|
||||
|
@ -37,6 +37,12 @@ type CustomerResponse struct {
|
||||
Customer *Customer `json:"customer,omitempty,brackets"`
|
||||
}
|
||||
|
||||
// CorporateCustomerResponse type
|
||||
type CorporateCustomerResponse struct {
|
||||
Success bool `json:"success"`
|
||||
CorporateCustomer *CorporateCustomer `json:"customerCorporate,omitempty,brackets"`
|
||||
}
|
||||
|
||||
// CustomersResponse type
|
||||
type CustomersResponse struct {
|
||||
Success bool `json:"success"`
|
||||
@ -44,6 +50,38 @@ type CustomersResponse struct {
|
||||
Customers []Customer `json:"customers,omitempty,brackets"`
|
||||
}
|
||||
|
||||
// CorporateCustomersResponse type
|
||||
type CorporateCustomersResponse struct {
|
||||
Success bool `json:"success"`
|
||||
Pagination *Pagination `json:"pagination,omitempty"`
|
||||
CustomersCorporate []CorporateCustomer `json:"customersCorporate,omitempty,brackets"`
|
||||
}
|
||||
|
||||
// CorporateCustomersNotesResponse type
|
||||
type CorporateCustomersNotesResponse struct {
|
||||
Success bool `json:"success"`
|
||||
Pagination *Pagination `json:"pagination,omitempty"`
|
||||
Notes []Note `json:"notes,omitempty,brackets"`
|
||||
}
|
||||
|
||||
// CorporateCustomersAddressesResponse type
|
||||
type CorporateCustomersAddressesResponse struct {
|
||||
Success bool `json:"success"`
|
||||
Addresses []CorporateCustomerAddress `json:"addresses"`
|
||||
}
|
||||
|
||||
// CorporateCustomerCompaniesResponse type
|
||||
type CorporateCustomerCompaniesResponse struct {
|
||||
Success bool `json:"success"`
|
||||
Companies []Company `json:"companies"`
|
||||
}
|
||||
|
||||
// CorporateCustomerContactsResponse type
|
||||
type CorporateCustomerContactsResponse struct {
|
||||
Success bool `json:"success"`
|
||||
Contacts []CorporateCustomerContact `json:"contacts"`
|
||||
}
|
||||
|
||||
// CustomerChangeResponse type
|
||||
type CustomerChangeResponse struct {
|
||||
Success bool `json:"success"`
|
||||
@ -51,12 +89,18 @@ type CustomerChangeResponse struct {
|
||||
State string `json:"state,omitempty"`
|
||||
}
|
||||
|
||||
// CorporateCustomerChangeResponse type
|
||||
type CorporateCustomerChangeResponse CustomerChangeResponse
|
||||
|
||||
// CustomersUploadResponse type
|
||||
type CustomersUploadResponse struct {
|
||||
Success bool `json:"success"`
|
||||
UploadedCustomers []IdentifiersPair `json:"uploadedCustomers,omitempty,brackets"`
|
||||
}
|
||||
|
||||
// CorporateCustomersUploadResponse type
|
||||
type CorporateCustomersUploadResponse CustomersUploadResponse
|
||||
|
||||
// CustomersHistoryResponse type
|
||||
type CustomersHistoryResponse struct {
|
||||
Success bool `json:"success,omitempty"`
|
||||
@ -65,6 +109,14 @@ type CustomersHistoryResponse struct {
|
||||
Pagination *Pagination `json:"pagination,omitempty"`
|
||||
}
|
||||
|
||||
// CorporateCustomersHistoryResponse type
|
||||
type CorporateCustomersHistoryResponse struct {
|
||||
Success bool `json:"success,omitempty"`
|
||||
GeneratedAt string `json:"generatedAt,omitempty"`
|
||||
History []CorporateCustomerHistoryRecord `json:"history,omitempty,brackets"`
|
||||
Pagination *Pagination `json:"pagination,omitempty"`
|
||||
}
|
||||
|
||||
// OrderResponse type
|
||||
type OrderResponse struct {
|
||||
Success bool `json:"success"`
|
||||
|
98
v5/types.go
98
v5/types.go
@ -2,6 +2,12 @@ package v5
|
||||
|
||||
import "net/http"
|
||||
|
||||
// ByID is "id" constant to use as `by` property in methods
|
||||
const ByID = "id"
|
||||
|
||||
// ByExternalId is "externalId" constant to use as `by` property in methods
|
||||
const ByExternalID = "externalId"
|
||||
|
||||
// Client type
|
||||
type Client struct {
|
||||
URL string
|
||||
@ -145,6 +151,85 @@ type Customer struct {
|
||||
CustomFields map[string]string `json:"customFields,omitempty,brackets"`
|
||||
}
|
||||
|
||||
// CorporateCustomer type
|
||||
type CorporateCustomer struct {
|
||||
ID int `json:"id,omitempty"`
|
||||
ExternalID string `json:"externalId,omitempty"`
|
||||
Nickname string `json:"nickName,omitempty"`
|
||||
CreatedAt string `json:"createdAt,omitempty"`
|
||||
Vip bool `json:"vip,omitempty"`
|
||||
Bad bool `json:"bad,omitempty"`
|
||||
CustomFields map[string]string `json:"customFields,omitempty,brackets"`
|
||||
PersonalDiscount float32 `json:"personalDiscount,omitempty"`
|
||||
DiscountCardNumber string `json:"discountCardNumber,omitempty"`
|
||||
ManagerID int `json:"managerId,omitempty"`
|
||||
Source *Source `json:"source,omitempty"`
|
||||
CustomerContacts []CorporateCustomerContact `json:"customerContacts,omitempty"`
|
||||
Companies []Company `json:"companies,omitempty"`
|
||||
Addresses []CorporateCustomerAddress `json:"addresses,omitempty"`
|
||||
}
|
||||
|
||||
type CorporateCustomerContact struct {
|
||||
IsMain bool `json:"isMain,omitempty"`
|
||||
Customer CorporateCustomerContactCustomer `json:"customer,omitempty"`
|
||||
Companies []IdentifiersPair `json:"companies,omitempty"`
|
||||
}
|
||||
|
||||
// CorporateCustomerAddress type. Address didn't inherited in order to simplify declaration.
|
||||
type CorporateCustomerAddress struct {
|
||||
ID int `json:"id,omitempty"`
|
||||
Index string `json:"index,omitempty"`
|
||||
CountryISO string `json:"countryIso,omitempty"`
|
||||
Region string `json:"region,omitempty"`
|
||||
RegionID int `json:"regionId,omitempty"`
|
||||
City string `json:"city,omitempty"`
|
||||
CityID int `json:"cityId,omitempty"`
|
||||
CityType string `json:"cityType,omitempty"`
|
||||
Street string `json:"street,omitempty"`
|
||||
StreetID int `json:"streetId,omitempty"`
|
||||
StreetType string `json:"streetType,omitempty"`
|
||||
Building string `json:"building,omitempty"`
|
||||
Flat string `json:"flat,omitempty"`
|
||||
IntercomCode string `json:"intercomCode,omitempty"`
|
||||
Floor int `json:"floor,omitempty"`
|
||||
Block int `json:"block,omitempty"`
|
||||
House string `json:"house,omitempty"`
|
||||
Housing string `json:"housing,omitempty"`
|
||||
Metro string `json:"metro,omitempty"`
|
||||
Notes string `json:"notes,omitempty"`
|
||||
Text string `json:"text,omitempty"`
|
||||
ExternalID string `json:"externalId,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
}
|
||||
|
||||
type CorporateCustomerContactCustomer struct {
|
||||
ID int `json:"id,omitempty"`
|
||||
ExternalID string `json:"externalId,omitempty"`
|
||||
BrowserID string `json:"browserId,omitempty"`
|
||||
Site string `json:"site,omitempty"`
|
||||
}
|
||||
|
||||
type Company struct {
|
||||
ID int `json:"id,omitempty"`
|
||||
IsMain bool `json:"isMain,omitempty"`
|
||||
ExternalID string `json:"externalId,omitempty"`
|
||||
Active bool `json:"active,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Brand string `json:"brand,omitempty"`
|
||||
Site string `json:"site,omitempty"`
|
||||
CreatedAt string `json:"createdAt,omitempty"`
|
||||
Contragent *Contragent `json:"contragent,omitempty"`
|
||||
Address *IdentifiersPair `json:"address,omitempty"`
|
||||
CustomFields map[string]string `json:"customFields,omitempty,brackets"`
|
||||
}
|
||||
|
||||
// CorporateCustomerNote type
|
||||
type CorporateCustomerNote struct {
|
||||
ManagerID int `json:"managerId,omitempty"`
|
||||
Text string `json:"text,omitempty"`
|
||||
Customer *IdentifiersPair `json:"customer,omitempty"`
|
||||
}
|
||||
|
||||
// Phone type
|
||||
type Phone struct {
|
||||
Number string `json:"number,omitempty"`
|
||||
@ -163,6 +248,19 @@ type CustomerHistoryRecord struct {
|
||||
Customer *Customer `json:"customer,omitempty,brackets"`
|
||||
}
|
||||
|
||||
// CorporateCustomerHistoryRecord type
|
||||
type CorporateCustomerHistoryRecord struct {
|
||||
ID int `json:"id,omitempty"`
|
||||
CreatedAt string `json:"createdAt,omitempty"`
|
||||
Created bool `json:"created,omitempty"`
|
||||
Deleted bool `json:"deleted,omitempty"`
|
||||
Source string `json:"source,omitempty"`
|
||||
Field string `json:"field,omitempty"`
|
||||
User *User `json:"user,omitempty,brackets"`
|
||||
APIKey *APIKey `json:"apiKey,omitempty,brackets"`
|
||||
CorporateCustomer *CorporateCustomer `json:"corporateCustomer,omitempty,brackets"`
|
||||
}
|
||||
|
||||
/**
|
||||
Order related types
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user