This repository was archived by the owner on Aug 21, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdealmap.go
156 lines (141 loc) · 4.92 KB
/
dealmap.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
package dealmap
import "time"
// Centered activity Values
const (
Kids = 1
Group = 8
Romantic = 16
Casual = 64
Fun = 512
LateNight = 16384
Outdoor = 32768
)
// Unknown value
const (
Unknown = 0
)
// Deal types
const (
GiftCertificate = 1
BOGO = 2
PrintableCoupon = 4
GroupBuy = 8
DailyDeal = 16
FreeDeal = 32
)
// Deal capability values
const (
Favorite = 1 // Favorited by The Dealmap Deal Editors
HasTransaction = 2 // Involves some kind of purchase
Featured = 4 // This deal is featured on The Dealmap
Exclusive = 8 // This deal is exclusively available only at The Dealmap
FiftyPercentOrMore = 16 // This deal has 50 or more % savings
CanBePrinted = 32 // This is a printable coupon
Affiliate = 64 // Affiliate
)
// Deal units
const (
Price = 1
Percentage = 2
)
// Deal currency
const (
USD = 1
GBP = 2
EUR = 3
)
// Deals is an API response containing a list of deals and an API message
type Deals struct {
Message string // Message from API, usually indicating a problem of some kind
Results []Deal `xml:"Results>Deal"` // List of Deal objects
TotalResults int // Total number of results
}
// A Deal contains all the details of a single deal. See TheDealMap API documentation for details.
type Deal struct {
Activity int
AddedBy string
AdditionalDiscountCouponCode string
AdditionalDiscountCouponEffectiveTime string
AdditionalDiscountCouponExpirationTime string
AdditionalDiscountDealUnit int
AdditionalDiscountedValue int
AddressLine string
Affiliation string
BDescription string
BusinessID string
BusinessName string
Capability int
Category string
City string
Country string
Currency int
DealSource string
DealType int
DealUnit int
Description string
DiscountedValue float64
EffectiveTime string
ExpirationTime string
FaceValue float64
ID string
IconUrl string
ImageUrl string
IsSoldOut bool
Keywords string
Latitude float64
Longitude float64
MoreInfoLink string
Phone string
Ratings float64
ReviewCount int
SoldCount int
State string
Tags string
Terms string
Title string
TrackingUrl string
TransactionUrl string
YouSave string
ZipCode string
}
// Attempts to parse the additional discount coupon's effective time
func (d *Deal) ParseAdditionalDiscountCouponEffectiveTime() (time.Time, error) {
return time.Parse(time.RFC3339, d.AdditionalDiscountCouponEffectiveTime)
}
// Attempts to parse the additional discount coupon's expiration time
func (d *Deal) ParseAdditionalDiscountCouponExpirationTime() (time.Time, error) {
return time.Parse(time.RFC3339, d.AdditionalDiscountCouponExpirationTime)
}
// Attempts to parse the deal's effective time
func (d *Deal) ParseEffectiveTime() (time.Time, error) {
return time.Parse(time.RFC3339, d.EffectiveTime)
}
// Attempts to parse the deal's expiration time
func (d *Deal) ParseExpirationTime() (time.Time, error) {
return time.Parse(time.RFC3339, d.ExpirationTime)
}
// Businesses is an API response containing a list of Business objects and a response message
type Businesses struct {
Message string // Message from API, usually indicating a problem of some kind
Results []Business `xml:"Results>Business"` // List of Business objects
TotalResults int // Total number of results
}
// Business contains the details of a business in TheDealMap. See the API documentation for details.
type Business struct {
Activity int
AddressLine string
Capability int
Category string
City string
Country string
Franchise string
ID string
Latitude float64
Longitude float64
MoreInfoLink string
Phone string
Ratings float64
Reviews int
State string
Title string
}