-
Notifications
You must be signed in to change notification settings - Fork 12
/
journeygeolocation.go
159 lines (104 loc) · 3.58 KB
/
journeygeolocation.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
package platformclientv2
import (
"github.com/leekchan/timeutil"
"encoding/json"
"strconv"
"strings"
)
// Journeygeolocation
type Journeygeolocation struct {
// Country - Geolocation's ISO 3166-1 alpha-2 country code.
Country *string `json:"country,omitempty"`
// CountryName - Geolocation's country name.
CountryName *string `json:"countryName,omitempty"`
// Latitude - Geolocation's latitude.
Latitude *float64 `json:"latitude,omitempty"`
// Longitude - Geolocation's longitude.
Longitude *float64 `json:"longitude,omitempty"`
// Locality - Geolocation's locality or city.
Locality *string `json:"locality,omitempty"`
// PostalCode - Geolocation's postal code or ZIP code.
PostalCode *string `json:"postalCode,omitempty"`
// Region - Geolocation's ISO-3166-2 region code.
Region *string `json:"region,omitempty"`
// RegionName - Geolocation's region name.
RegionName *string `json:"regionName,omitempty"`
// Source - The source that was used to determine the geolocation information.
Source *string `json:"source,omitempty"`
// Timezone - Geolocation's timezone.
Timezone *string `json:"timezone,omitempty"`
}
func (o *Journeygeolocation) MarshalJSON() ([]byte, error) {
// Redundant initialization to avoid unused import errors for models with no Time values
_ = timeutil.Timedelta{}
type Alias Journeygeolocation
return json.Marshal(&struct {
Country *string `json:"country,omitempty"`
CountryName *string `json:"countryName,omitempty"`
Latitude *float64 `json:"latitude,omitempty"`
Longitude *float64 `json:"longitude,omitempty"`
Locality *string `json:"locality,omitempty"`
PostalCode *string `json:"postalCode,omitempty"`
Region *string `json:"region,omitempty"`
RegionName *string `json:"regionName,omitempty"`
Source *string `json:"source,omitempty"`
Timezone *string `json:"timezone,omitempty"`
*Alias
}{
Country: o.Country,
CountryName: o.CountryName,
Latitude: o.Latitude,
Longitude: o.Longitude,
Locality: o.Locality,
PostalCode: o.PostalCode,
Region: o.Region,
RegionName: o.RegionName,
Source: o.Source,
Timezone: o.Timezone,
Alias: (*Alias)(o),
})
}
func (o *Journeygeolocation) UnmarshalJSON(b []byte) error {
var JourneygeolocationMap map[string]interface{}
err := json.Unmarshal(b, &JourneygeolocationMap)
if err != nil {
return err
}
if Country, ok := JourneygeolocationMap["country"].(string); ok {
o.Country = &Country
}
if CountryName, ok := JourneygeolocationMap["countryName"].(string); ok {
o.CountryName = &CountryName
}
if Latitude, ok := JourneygeolocationMap["latitude"].(float64); ok {
o.Latitude = &Latitude
}
if Longitude, ok := JourneygeolocationMap["longitude"].(float64); ok {
o.Longitude = &Longitude
}
if Locality, ok := JourneygeolocationMap["locality"].(string); ok {
o.Locality = &Locality
}
if PostalCode, ok := JourneygeolocationMap["postalCode"].(string); ok {
o.PostalCode = &PostalCode
}
if Region, ok := JourneygeolocationMap["region"].(string); ok {
o.Region = &Region
}
if RegionName, ok := JourneygeolocationMap["regionName"].(string); ok {
o.RegionName = &RegionName
}
if Source, ok := JourneygeolocationMap["source"].(string); ok {
o.Source = &Source
}
if Timezone, ok := JourneygeolocationMap["timezone"].(string); ok {
o.Timezone = &Timezone
}
return nil
}
// String returns a JSON representation of the model
func (o *Journeygeolocation) String() string {
j, _ := json.Marshal(o)
str, _ := strconv.Unquote(strings.Replace(strconv.Quote(string(j)), `\\u`, `\u`, -1))
return str
}