forked from pagarme/pagarme-golang-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
getLocationResponse.go
45 lines (38 loc) · 1001 Bytes
/
getLocationResponse.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
package models
import (
"encoding/json"
"github.com/apimatic/go-core-runtime/types"
)
// Response object for geetting an order location request
type GetLocationResponse struct {
Latitude types.Optional[string] `json:"latitude"`
Longitude types.Optional[string] `json:"longitude"`
}
func (g *GetLocationResponse) MarshalJSON() (
[]byte,
error) {
return json.Marshal(g.toMap())
}
func (g *GetLocationResponse) toMap() map[string]any {
structMap := make(map[string]any)
if g.Latitude.IsValueSet() {
structMap["latitude"] = g.Latitude.Value()
}
if g.Longitude.IsValueSet() {
structMap["longitude"] = g.Longitude.Value()
}
return structMap
}
func (g *GetLocationResponse) UnmarshalJSON(input []byte) error {
temp := &struct {
Latitude types.Optional[string] `json:"latitude"`
Longitude types.Optional[string] `json:"longitude"`
}{}
err := json.Unmarshal(input, &temp)
if err != nil {
return err
}
g.Latitude = temp.Latitude
g.Longitude = temp.Longitude
return nil
}