[feature] "/customers-corporate" methods

This commit is contained in:
Pavel 2019-10-16 16:32:31 +03:00
parent a3a642d631
commit b4cceb213e
7 changed files with 2187 additions and 27 deletions

1
.gitignore vendored
View File

@ -26,5 +26,6 @@ _testmain.go
.idea .idea
*.iml *.iml
.env .env
.swp
# Project ignores # Project ignores

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -57,6 +57,73 @@ type CustomersFilter struct {
CustomFields map[string]string `url:"customFields,omitempty,brackets"` 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 // CustomersHistoryFilter type
type CustomersHistoryFilter struct { type CustomersHistoryFilter struct {
CustomerID int `url:"customerId,omitempty"` CustomerID int `url:"customerId,omitempty"`

View File

@ -13,6 +13,38 @@ type CustomersRequest struct {
Page int `url:"page,omitempty"` 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 // CustomersUploadRequest type
type CustomersUploadRequest struct { type CustomersUploadRequest struct {
Customers []Customer `url:"customers,omitempty,brackets"` Customers []Customer `url:"customers,omitempty,brackets"`

View File

@ -37,6 +37,12 @@ type CustomerResponse struct {
Customer *Customer `json:"customer,omitempty,brackets"` Customer *Customer `json:"customer,omitempty,brackets"`
} }
// CorporateCustomerResponse type
type CorporateCustomerResponse struct {
Success bool `json:"success"`
CorporateCustomer *CorporateCustomer `json:"customerCorporate,omitempty,brackets"`
}
// CustomersResponse type // CustomersResponse type
type CustomersResponse struct { type CustomersResponse struct {
Success bool `json:"success"` Success bool `json:"success"`
@ -44,6 +50,38 @@ type CustomersResponse struct {
Customers []Customer `json:"customers,omitempty,brackets"` 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 // CustomerChangeResponse type
type CustomerChangeResponse struct { type CustomerChangeResponse struct {
Success bool `json:"success"` Success bool `json:"success"`
@ -51,12 +89,18 @@ type CustomerChangeResponse struct {
State string `json:"state,omitempty"` State string `json:"state,omitempty"`
} }
// CorporateCustomerChangeResponse type
type CorporateCustomerChangeResponse CustomerChangeResponse
// CustomersUploadResponse type // CustomersUploadResponse type
type CustomersUploadResponse struct { type CustomersUploadResponse struct {
Success bool `json:"success"` Success bool `json:"success"`
UploadedCustomers []IdentifiersPair `json:"uploadedCustomers,omitempty,brackets"` UploadedCustomers []IdentifiersPair `json:"uploadedCustomers,omitempty,brackets"`
} }
// CorporateCustomersUploadResponse type
type CorporateCustomersUploadResponse CustomersUploadResponse
// CustomersHistoryResponse type // CustomersHistoryResponse type
type CustomersHistoryResponse struct { type CustomersHistoryResponse struct {
Success bool `json:"success,omitempty"` Success bool `json:"success,omitempty"`
@ -65,6 +109,15 @@ type CustomersHistoryResponse struct {
Pagination *Pagination `json:"pagination,omitempty"` Pagination *Pagination `json:"pagination,omitempty"`
} }
// CorporateCustomersHistoryResponse type
// TODO: Update history format in case of changes
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 // OrderResponse type
type OrderResponse struct { type OrderResponse struct {
Success bool `json:"success"` Success bool `json:"success"`

View File

@ -2,6 +2,12 @@ package v5
import "net/http" 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 // Client type
type Client struct { type Client struct {
URL string URL string
@ -145,6 +151,85 @@ type Customer struct {
CustomFields map[string]string `json:"customFields,omitempty,brackets"` 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 // Phone type
type Phone struct { type Phone struct {
Number string `json:"number,omitempty"` Number string `json:"number,omitempty"`
@ -163,6 +248,19 @@ type CustomerHistoryRecord struct {
Customer *Customer `json:"customer,omitempty,brackets"` 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 Order related types
*/ */