mirror of
https://github.com/retailcrm/api-client-go.git
synced 2025-03-23 08:13:51 +03:00
Merge pull request #95 from Neur0toxine/fix-regionId-cityId
fix regionId & cityId unmarshaling error
This commit is contained in:
commit
2859073353
24
.github/workflows/ci.yml
vendored
24
.github/workflows/ci.yml
vendored
@ -20,10 +20,10 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Check out code into the Go module directory
|
- name: Check out code into the Go module directory
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
- name: Set up Go 1.17
|
- name: Set up Go 1.23
|
||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: '1.17'
|
go-version: '1.23'
|
||||||
- name: Get dependencies
|
- name: Get dependencies
|
||||||
run: |
|
run: |
|
||||||
go mod tidy
|
go mod tidy
|
||||||
@ -31,7 +31,7 @@ jobs:
|
|||||||
- name: Lint code with golangci-lint
|
- name: Lint code with golangci-lint
|
||||||
uses: golangci/golangci-lint-action@v3
|
uses: golangci/golangci-lint-action@v3
|
||||||
with:
|
with:
|
||||||
version: v1.50.1
|
version: v1.62.2
|
||||||
only-new-issues: true
|
only-new-issues: true
|
||||||
skip-pkg-cache: true
|
skip-pkg-cache: true
|
||||||
args: --build-tags=testutils
|
args: --build-tags=testutils
|
||||||
@ -40,13 +40,13 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
go-version: ['1.13', '1.14', '1.15', '1.16', '1.17']
|
go-version: ['1.19', '1.20', '1.21', '1.22', '1.23', 'stable']
|
||||||
include:
|
include:
|
||||||
- go-version: '1.17'
|
- go-version: '1.23'
|
||||||
coverage: 1
|
coverage: 1
|
||||||
steps:
|
steps:
|
||||||
- name: Set up Go ${{ matrix.go-version }}
|
- name: Set up Go ${{ matrix.go-version }}
|
||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: ${{ matrix.go-version }}
|
go-version: ${{ matrix.go-version }}
|
||||||
- name: Check out code into the Go module directory
|
- name: Check out code into the Go module directory
|
||||||
@ -59,17 +59,21 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
COVERAGE: ${{ matrix.coverage }}
|
COVERAGE: ${{ matrix.coverage }}
|
||||||
if: env.COVERAGE != 1
|
if: env.COVERAGE != 1
|
||||||
run: go test -tags=testutils ./...
|
run: |
|
||||||
|
go install gotest.tools/gotestsum@latest
|
||||||
|
gotestsum --format testdox ./... -tags=testutils -v -cpu 2 -timeout 60s -race
|
||||||
- name: Tests with coverage
|
- name: Tests with coverage
|
||||||
env:
|
env:
|
||||||
COVERAGE: ${{ matrix.coverage }}
|
COVERAGE: ${{ matrix.coverage }}
|
||||||
if: env.COVERAGE == 1
|
if: env.COVERAGE == 1
|
||||||
run: |
|
run: |
|
||||||
go test -tags=testutils ./... -race -coverprofile=coverage.txt -covermode=atomic "$d"
|
go install gotest.tools/gotestsum@latest
|
||||||
|
gotestsum --format testdox ./... -tags=testutils -v -cpu 2 -timeout 60s -race -cover -coverprofile=coverage.txt -covermode=atomic "$d"
|
||||||
- name: Coverage
|
- name: Coverage
|
||||||
env:
|
env:
|
||||||
COVERAGE: ${{ matrix.coverage }}
|
COVERAGE: ${{ matrix.coverage }}
|
||||||
if: env.COVERAGE == 1
|
if: env.COVERAGE == 1
|
||||||
run: |
|
run: |
|
||||||
|
go install github.com/axw/gocov/gocov@latest
|
||||||
|
gocov convert ./coverage.txt | gocov report
|
||||||
bash <(curl -s https://codecov.io/bash)
|
bash <(curl -s https://codecov.io/bash)
|
||||||
rm coverage.txt
|
|
||||||
|
@ -1,11 +1,37 @@
|
|||||||
run:
|
run:
|
||||||
skip-dirs-use-default: true
|
skip-dirs-use-default: true
|
||||||
allow-parallel-runners: true
|
allow-parallel-runners: true
|
||||||
skip-files:
|
|
||||||
|
issues:
|
||||||
|
exclude-files:
|
||||||
- testutils.go
|
- testutils.go
|
||||||
|
exclude-rules:
|
||||||
|
- path: _test\.go
|
||||||
|
linters:
|
||||||
|
- lll
|
||||||
|
- errcheck
|
||||||
|
- misspell
|
||||||
|
- ineffassign
|
||||||
|
- whitespace
|
||||||
|
- makezero
|
||||||
|
- errcheck
|
||||||
|
- funlen
|
||||||
|
- goconst
|
||||||
|
- gocognit
|
||||||
|
- gocyclo
|
||||||
|
- godot
|
||||||
|
- unused
|
||||||
|
- errchkjson
|
||||||
|
- varnamelen
|
||||||
|
exclude-use-default: true
|
||||||
|
exclude-case-sensitive: false
|
||||||
|
max-issues-per-linter: 0
|
||||||
|
max-same-issues: 0
|
||||||
|
fix: true
|
||||||
|
|
||||||
output:
|
output:
|
||||||
format: colored-line-number
|
formats:
|
||||||
|
- format: colored-line-number
|
||||||
sort-results: true
|
sort-results: true
|
||||||
|
|
||||||
# Linters below do not support go1.18 yet because of generics.
|
# Linters below do not support go1.18 yet because of generics.
|
||||||
@ -38,6 +64,7 @@ linters:
|
|||||||
- errorlint
|
- errorlint
|
||||||
- exhaustive
|
- exhaustive
|
||||||
- exportloopref
|
- exportloopref
|
||||||
|
- copyloopvar
|
||||||
- funlen
|
- funlen
|
||||||
- gocognit
|
- gocognit
|
||||||
- goconst
|
- goconst
|
||||||
@ -53,7 +80,6 @@ linters:
|
|||||||
- nestif
|
- nestif
|
||||||
- prealloc
|
- prealloc
|
||||||
- predeclared
|
- predeclared
|
||||||
- exportloopref
|
|
||||||
- unconvert
|
- unconvert
|
||||||
- whitespace
|
- whitespace
|
||||||
|
|
||||||
@ -178,34 +204,10 @@ linters-settings:
|
|||||||
- t *testing.T
|
- t *testing.T
|
||||||
- e error
|
- e error
|
||||||
- i int
|
- i int
|
||||||
issues:
|
|
||||||
exclude-rules:
|
|
||||||
- path: _test\.go
|
|
||||||
linters:
|
|
||||||
- lll
|
|
||||||
- errcheck
|
|
||||||
- misspell
|
|
||||||
- ineffassign
|
|
||||||
- whitespace
|
|
||||||
- makezero
|
|
||||||
- errcheck
|
|
||||||
- funlen
|
|
||||||
- goconst
|
|
||||||
- gocognit
|
|
||||||
- gocyclo
|
|
||||||
- godot
|
|
||||||
- unused
|
|
||||||
- errchkjson
|
|
||||||
- varnamelen
|
|
||||||
exclude-use-default: true
|
|
||||||
exclude-case-sensitive: false
|
|
||||||
max-issues-per-linter: 0
|
|
||||||
max-same-issues: 0
|
|
||||||
fix: true
|
|
||||||
|
|
||||||
severity:
|
severity:
|
||||||
default-severity: error
|
default-severity: error
|
||||||
case-sensitive: false
|
case-sensitive: false
|
||||||
|
|
||||||
service:
|
service:
|
||||||
golangci-lint-version: 1.50.x
|
golangci-lint-version: 1.62.x
|
||||||
|
@ -3822,7 +3822,95 @@ func TestClient_PriceTypes(t *testing.T) {
|
|||||||
gock.New(crmURL).
|
gock.New(crmURL).
|
||||||
Get("/reference/price-types").
|
Get("/reference/price-types").
|
||||||
Reply(200).
|
Reply(200).
|
||||||
BodyString(`{"success": true}`)
|
BodyString(`
|
||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"priceTypes": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"code": "base",
|
||||||
|
"name": "Base",
|
||||||
|
"active": true,
|
||||||
|
"promo": false,
|
||||||
|
"default": true,
|
||||||
|
"geo": [],
|
||||||
|
"groups": [],
|
||||||
|
"ordering": 1,
|
||||||
|
"currency": "MXN"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 4,
|
||||||
|
"code": "cop",
|
||||||
|
"name": "COP",
|
||||||
|
"active": false,
|
||||||
|
"promo": false,
|
||||||
|
"default": false,
|
||||||
|
"geo": [],
|
||||||
|
"groups": [
|
||||||
|
"manager_1"
|
||||||
|
],
|
||||||
|
"ordering": 990,
|
||||||
|
"currency": "MXN"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2,
|
||||||
|
"code": "promo_test",
|
||||||
|
"name": "Promotional",
|
||||||
|
"active": false,
|
||||||
|
"promo": true,
|
||||||
|
"default": false,
|
||||||
|
"geo": [
|
||||||
|
{
|
||||||
|
"country": "CO",
|
||||||
|
"regionId": "",
|
||||||
|
"region": "Todas las regiones",
|
||||||
|
"cityId": "",
|
||||||
|
"city": "All"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "ES",
|
||||||
|
"regionId": "",
|
||||||
|
"region": "Todas las regiones",
|
||||||
|
"cityId": "",
|
||||||
|
"city": "All"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "MX",
|
||||||
|
"regionId": "",
|
||||||
|
"region": "Todas las regiones",
|
||||||
|
"cityId": "",
|
||||||
|
"city": "All"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"groups": [],
|
||||||
|
"ordering": 990,
|
||||||
|
"currency": "MXN"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3,
|
||||||
|
"code": "wholesale",
|
||||||
|
"name": "Wholesale",
|
||||||
|
"active": false,
|
||||||
|
"promo": true,
|
||||||
|
"default": false,
|
||||||
|
"description": "Solo para ventas al mayoreo con mas de 10 articulos.",
|
||||||
|
"filterExpression": "order.quantity >= 1",
|
||||||
|
"geo": [
|
||||||
|
{
|
||||||
|
"country": "MX",
|
||||||
|
"regionId": "",
|
||||||
|
"region": "Todas las regiones",
|
||||||
|
"cityId": "",
|
||||||
|
"city": "All"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"groups": [],
|
||||||
|
"ordering": 990,
|
||||||
|
"currency": "MXN"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
`)
|
||||||
|
|
||||||
data, st, err := c.PriceTypes()
|
data, st, err := c.PriceTypes()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -23,7 +23,7 @@ func (st SystemTime) MarshalJSON() ([]byte, error) {
|
|||||||
return []byte(st.String()), nil
|
return []byte(st.String()), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// String returns the time in the custom format
|
// String returns the time in the custom format.
|
||||||
func (st *SystemTime) String() string {
|
func (st *SystemTime) String() string {
|
||||||
t := time.Time(*st)
|
t := time.Time(*st)
|
||||||
return fmt.Sprintf("%q", t.Format(systemTimeLayout))
|
return fmt.Sprintf("%q", t.Format(systemTimeLayout))
|
||||||
|
7
types.go
7
types.go
@ -53,13 +53,16 @@ type Address struct {
|
|||||||
Text string `json:"text,omitempty"`
|
Text string `json:"text,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GeoID type. Can be empty string.
|
||||||
|
type GeoID json.Number
|
||||||
|
|
||||||
// GeoHierarchyRow type.
|
// GeoHierarchyRow type.
|
||||||
type GeoHierarchyRow struct {
|
type GeoHierarchyRow struct {
|
||||||
Country string `json:"country,omitempty"`
|
Country string `json:"country,omitempty"`
|
||||||
Region string `json:"region,omitempty"`
|
Region string `json:"region,omitempty"`
|
||||||
RegionID int `json:"regionId,omitempty"`
|
RegionID GeoID `json:"regionId,omitempty"`
|
||||||
City string `json:"city,omitempty"`
|
City string `json:"city,omitempty"`
|
||||||
CityID int `json:"cityId,omitempty"`
|
CityID GeoID `json:"cityId,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Source type.
|
// Source type.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user