/
ext_profile.go
98 lines (84 loc) · 2.5 KB
/
ext_profile.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package web
import (
"context"
"encoding/json"
"net/http"
)
type profileClient struct {
c *Client
}
type Profile struct {
Npwp string `json:"npwp"`
Nama string `json:"nama"`
NoFax string `json:"noFax"`
NoHP string `json:"noHp"`
NoTelepon string `json:"noTelepon"`
Alamat string `json:"alamat"`
// KodePos any `json:"kodePos"`
KLU string `json:"klu"`
KppAdm string `json:"kppAdm"`
// IDCabangWp int64 `json:"idCabangWp"`
MasaBuku1 string `json:"masaBuku1"`
MasaBuku2 string `json:"masaBuku2"`
JabatanSpt string `json:"jabatanSpt"`
PenandatanganFaktur string `json:"penandatanganFaktur"`
PenandatanganSpt string `json:"penandatanganSpt"`
TempatPenandatangan string `json:"tempatPenandatangan"`
}
type ProfileGetResponse struct {
// Status int `json:"status"`
// Message string `json:"message"`
Data []*Profile `json:"data"`
}
func (p *ProfileGetResponse) GetOne() *Profile {
if len(p.Data) <= 0 {
return nil
}
return p.Data[0]
}
// Get profile PKP
func (c *profileClient) Get(ctx context.Context) (response ProfileGetResponse, err error) {
var req *http.Request
if req, err = http.NewRequestWithContext(ctx, http.MethodGet, EndpointProfilePkpGet, nil); err != nil {
return
}
var resp *http.Response
if resp, err = c.c.do(req, prepareReqOptMainView); err != nil {
return
}
defer resp.Body.Close()
if err = json.NewDecoder(resp.Body).Decode(&response); err != nil {
return
}
return
}
type ProfileUpdated struct {
JabatanSpt string `json:"jabatanSpt"`
Npwp string `json:"npwp"`
PenandatanganFaktur string `json:"penandatanganFaktur"`
PenandatanganSpt string `json:"penandatanganSpt"`
// IDCabangWp int `json:"idCabangWp"`
}
type ProfileSaveOrUpdateRequest struct {
PenandatanganFaktur string `json:"penandatanganFaktur"`
PenandatanganSpt string `json:"penandatanganSpt"`
JabatanSpt string `json:"jabatanSpt"`
}
type ProfileSaveOrUpdateResponse struct {
Data []*ProfileUpdated
}
// SaveOrUpdate save or update profile PKP
func (c *profileClient) SaveOrUpdate(ctx context.Context, request ProfileSaveOrUpdateRequest) (response ProfileSaveOrUpdateResponse, err error) {
response, err = restInvoke(c.c, restInvokeArgs[ProfileSaveOrUpdateRequest, ProfileSaveOrUpdateResponse]{
Ctx: ctx,
Method: http.MethodPost,
Url: EndpointProfileSaveOrUpdate,
Request: request,
ValidateResponse: validateResponse(
vr_checkIfRedirect,
"",
),
BodyDecoder: bodyDecoderJSON,
})
return
}