-
Notifications
You must be signed in to change notification settings - Fork 37
/
defs.go
109 lines (90 loc) · 3.08 KB
/
defs.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
// Copyright (c) 2018, Randy Westlund. All rights reserved.
// This code is under the BSD-2-Clause license.
package quickbooks
import "time"
type CustomField struct {
DefinitionId string `json:"DefinitionId,omitempty"`
StringValue string `json:"StringValue,omitempty"`
Type string `json:"Type,omitempty"`
Name string `json:"Name,omitempty"`
}
// Date represents a Quickbooks date
type Date struct {
time.Time `json:",omitempty"`
}
// UnmarshalJSON removes time from parsed date
func (d *Date) UnmarshalJSON(b []byte) (err error) {
if b[0] == '"' && b[len(b)-1] == '"' {
b = b[1 : len(b)-1]
}
d.Time, err = time.Parse(format, string(b))
if err != nil {
d.Time, err = time.Parse(secondFormat, string(b))
}
return err
}
func (d Date) String() string {
return d.Format(format)
}
// EmailAddress represents a QuickBooks email address.
type EmailAddress struct {
Address string `json:",omitempty"`
}
// EndpointUrl specifies the endpoint to connect to
type EndpointUrl string
const (
// DiscoveryProductionEndpoint is for live apps.
DiscoveryProductionEndpoint EndpointUrl = "https://developer.api.intuit.com/.well-known/openid_configuration"
// DiscoverySandboxEndpoint is for testing.
DiscoverySandboxEndpoint EndpointUrl = "https://developer.api.intuit.com/.well-known/openid_sandbox_configuration"
// ProductionEndpoint is for live apps.
ProductionEndpoint EndpointUrl = "https://quickbooks.api.intuit.com"
// SandboxEndpoint is for testing.
SandboxEndpoint EndpointUrl = "https://sandbox-quickbooks.api.intuit.com"
format = "2006-01-02T15:04:05-07:00"
queryPageSize = 1000
secondFormat = "2006-01-02"
)
func (u EndpointUrl) String() string {
return string(u)
}
// MemoRef represents a QuickBooks MemoRef object.
type MemoRef struct {
Value string `json:"value,omitempty"`
}
// MetaData is a timestamp of genesis and last change of a Quickbooks object
type MetaData struct {
CreateTime Date `json:",omitempty"`
LastUpdatedTime Date `json:",omitempty"`
}
// PhysicalAddress represents a QuickBooks address.
type PhysicalAddress struct {
Id string `json:"Id,omitempty"`
// These lines are context-dependent! Read the QuickBooks API carefully.
Line1 string `json:",omitempty"`
Line2 string `json:",omitempty"`
Line3 string `json:",omitempty"`
Line4 string `json:",omitempty"`
Line5 string `json:",omitempty"`
City string `json:",omitempty"`
Country string `json:",omitempty"`
// A.K.A. State.
CountrySubDivisionCode string `json:",omitempty"`
PostalCode string `json:",omitempty"`
Lat string `json:",omitempty"`
Long string `json:",omitempty"`
}
// ReferenceType represents a QuickBooks reference to another object.
type ReferenceType struct {
Value string `json:"value,omitempty"`
Name string `json:"name,omitempty"`
Type string `json:"type,omitempty"`
}
// TelephoneNumber represents a QuickBooks phone number.
type TelephoneNumber struct {
FreeFormNumber string `json:",omitempty"`
}
// WebSiteAddress represents a Quickbooks Website
type WebSiteAddress struct {
URI string `json:",omitempty"`
}