Skip to content

Commit dc7c064

Browse files
author
sp
committed
Fix: Fix Version, Fix GetList
1 parent 186ce81 commit dc7c064

File tree

4 files changed

+22
-20
lines changed

4 files changed

+22
-20
lines changed

_examples/getExamples.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ import (
44
"bytes"
55
"context"
66
"fmt"
7-
px "github.com/pitwch/go-wrapper-proffix-restapi/proffixrest"
87
"log"
98
"net/url"
9+
10+
px "github.com/pitwch/go-wrapper-proffix-restapi/proffixrest"
1011
)
1112

12-
//Put Client in Function
13+
// Put Client in Function
1314
func Connect() (pxrest *px.Client, err error) {
1415

1516
//Use PROFFIX Demo Logins as Example

proffixrest/client.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414

1515
// Version of Wrapper
1616
const (
17-
Version = "1.13.20"
17+
Version = "1.13.22"
1818
)
1919

2020
// DefaultHTTPTransport is an http.RoundTripper that has DisableKeepAlives set true.
@@ -70,7 +70,7 @@ func NewClient(RestURL string, apiUser string, apiPassword string, apiDatabase s
7070

7171
// Default to v3
7272
if options.Version == "" {
73-
options.Version = "v3"
73+
options.Version = "v4"
7474
}
7575

7676
if options.APIPrefix == "" {

proffixrest/client_test.go

+15-10
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,20 @@ import (
88
"testing"
99
)
1010

11-
//Define struct (AdressNr as string just for convenience)
11+
// Define struct (AdressNr as string just for convenience)
1212
type Adresse struct {
1313
AdressNr string `json:"AdressNr,omitempty"`
1414
Name string `json:"Name,omitempty"`
1515
Ort string `json:"Ort,omitempty"`
1616
PLZ string `json:"PLZ,omitempty"`
17+
Land Land `json:"Land,omitempty"`
1718
}
1819

19-
//Connect function
20+
type Land struct {
21+
LandNr string `json:"LandNr,omitempty"`
22+
}
23+
24+
// Connect function
2025
func ConnectTest(modules []string) (pxrest *Client, err error) {
2126

2227
//Use PROFFIX Public Demo Login as Example (REMOVED - As offical demo often is outdated)
@@ -46,7 +51,7 @@ func ConnectTest(modules []string) (pxrest *Client, err error) {
4651
return pxrest, err
4752
}
4853

49-
//Helper function for checking if is type Options
54+
// Helper function for checking if is type Options
5055
func isOption(t interface{}) bool {
5156
switch t.(type) {
5257
case Options:
@@ -56,7 +61,7 @@ func isOption(t interface{}) bool {
5661
}
5762
}
5863

59-
//Helper function for checking if is type Client
64+
// Helper function for checking if is type Client
6065
func isClient(t interface{}) bool {
6166
switch t.(type) {
6267
case Client:
@@ -66,7 +71,7 @@ func isClient(t interface{}) bool {
6671
}
6772
}
6873

69-
//Test all Requests in one Session
74+
// Test all Requests in one Session
7075
func TestClient_Requests(t *testing.T) {
7176

7277
//New Context
@@ -75,7 +80,7 @@ func TestClient_Requests(t *testing.T) {
7580
//POST TESTs
7681

7782
//Fill struct with Demo Data
78-
var data = Adresse{Name: "Muster GmbH", Ort: "Zürich", PLZ: "8000"}
83+
var data = Adresse{Name: "Muster GmbH", Ort: "Zürich", PLZ: "8000", Land: Land{LandNr: "CH"}}
7984

8085
//Connect
8186
pxrest, _ := ConnectTest([]string{"VOL"})
@@ -206,7 +211,7 @@ func TestClient_Requests(t *testing.T) {
206211

207212
}
208213

209-
//Test all Requests in one Session
214+
// Test all Requests in one Session
210215
func TestClient_AdvancedFilters(t *testing.T) {
211216

212217
//New Context
@@ -277,7 +282,7 @@ func TestClient_AdvancedFilters(t *testing.T) {
277282

278283
}
279284

280-
//Test Get Database with Key from Options
285+
// Test Get Database with Key from Options
281286
func TestGetDatabase(t *testing.T) {
282287

283288
//New Context
@@ -318,7 +323,7 @@ func TestGetDatabase(t *testing.T) {
318323
}
319324
}
320325

321-
//Test Get Info with Key set in Function
326+
// Test Get Info with Key set in Function
322327
func TestGetInfo(t *testing.T) {
323328

324329
//New Context
@@ -352,7 +357,7 @@ func TestGetInfo(t *testing.T) {
352357

353358
}
354359

355-
//Check structs
360+
// Check structs
356361
func TestStructs(t *testing.T) {
357362

358363
//New Context

proffixrest/list.go

+2-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"io"
77
"net/http"
88
"strconv"
9-
"strings"
109
)
1110

1211
func (c *Client) GetList(ctx context.Context, listenr int, body interface{}) (io.ReadCloser, http.Header, int, error) {
@@ -24,17 +23,14 @@ func (c *Client) GetList(ctx context.Context, listenr int, body interface{}) (io
2423
//If Log enabled log URL
2524
logDebug(ctx, c, fmt.Sprintf("Got Download URL from PROFFIX REST-API: %v, PxSession-ID: %v", downloadLocation, PxSessionId))
2625

27-
//Remove Path from Response -> replace with empty string
28-
cleanLocation := strings.Replace(downloadLocation, c.restURL.String(), "", -1)
29-
30-
downloadFile, headersDownload, statusDownload, err := c.Get(ctx, cleanLocation, nil)
26+
downloadFile, headersDownload, statusDownload, err := c.Get(ctx, downloadLocation, nil)
3127

3228
if headersDownload == nil {
3329
headersDownload = http.Header{}
3430
}
3531

3632
//If Log enabled log URL
37-
logDebug(ctx, c, fmt.Sprintf("Downloaded File from '%v' with Content-Length: %v, PxSession-ID: %v", cleanLocation, headersDownload.Get("Content-Length"), PxSessionId))
33+
logDebug(ctx, c, fmt.Sprintf("Downloaded File from '%v' with Content-Length: %v, PxSession-ID: %v", downloadLocation, headersDownload.Get("Content-Length"), PxSessionId))
3834

3935
return downloadFile, headersDownload, statusDownload, err
4036

0 commit comments

Comments
 (0)