github.com/schmorrison/Zoho@v1.1.4/recruit/types.go (about) 1 package recruit 2 3 import ( 4 "encoding/json" 5 6 zoho "github.com/schmorrison/Zoho" 7 ) 8 9 type Error struct { 10 Code string `json:"code,omitempty"` 11 Details struct{} `json:"details,omitempty"` 12 Message string `json:"message,omitempty"` 13 Status string `json:"status,omitempty"` 14 } 15 16 type PageInfo struct { 17 PerPage int `json:"per_page,omitempty"` 18 Count int `json:"count,omitempty"` 19 Page int `json:"page,omitempty"` 20 MoreRecords bool `json:"more_records,omitempty"` 21 } 22 23 type MultiSelect []string 24 type Date = zoho.Date 25 type Time = zoho.Time 26 type Number int 27 type Currency float64 28 type Decimal float64 29 type Percent float64 30 type Long int64 31 type Checkbox bool 32 type URL string 33 type Lookup struct { 34 Name string `json:"name,omitempty"` 35 ID string `json:"id,omitempty"` 36 } 37 type Owner struct { 38 Name string `json:"name,omitempty"` 39 ID string `json:"id,omitempty"` 40 } 41 type Layout struct { 42 Name string `json:"name,omitempty"` 43 ID string `json:"id,omitempty"` 44 } 45 type AutoNumber string 46 47 // SingleLine is the field type in Zoho that defines a single line input field 48 type SingleLine string 49 50 func (s *SingleLine) UnmarshalJSON(data []byte) error { 51 if string(data) == "null" { 52 t := SingleLine("") 53 *s = t 54 return nil 55 } 56 57 var t string 58 if err := json.Unmarshal(data, &t); err != nil { 59 return err 60 } 61 62 tp := SingleLine(t) 63 *s = tp 64 return nil 65 } 66 67 func (s SingleLine) MarshalJSON() ([]byte, error) { 68 if string(s) == "" { 69 return []byte{}, nil 70 } 71 return []byte(s), nil 72 } 73 74 // MultiLine is the field type in Zoho that defines a multiline input field, like text area in HTML 75 type MultiLine string 76 77 func (s *MultiLine) UnmarshalJSON(data []byte) error { 78 if string(data) == "null" { 79 t := MultiLine("") 80 *s = t 81 return nil 82 } 83 84 var t string 85 if err := json.Unmarshal(data, &t); err != nil { 86 return err 87 } 88 89 tp := MultiLine(t) 90 *s = tp 91 return nil 92 } 93 94 func (s MultiLine) MarshalJSON() ([]byte, error) { 95 if string(s) == "" { 96 return []byte{}, nil 97 } 98 return []byte(s), nil 99 } 100 101 // Email is the field type in Zoho that defines an email address field 102 type Email string 103 104 func (s *Email) UnmarshalJSON(data []byte) error { 105 if string(data) == "null" { 106 t := Email("") 107 *s = t 108 return nil 109 } 110 111 var t string 112 if err := json.Unmarshal(data, &t); err != nil { 113 return err 114 } 115 116 tp := Email(t) 117 *s = tp 118 return nil 119 } 120 121 func (s Email) MarshalJSON() ([]byte, error) { 122 if string(s) == "" { 123 return []byte{}, nil 124 } 125 return []byte(s), nil 126 } 127 128 // Phone is the field type in Zoho that defines a phone number field 129 type Phone string 130 131 func (s *Phone) UnmarshalJSON(data []byte) error { 132 if string(data) == "null" { 133 t := Phone("") 134 *s = t 135 return nil 136 } 137 138 var t string 139 if err := json.Unmarshal(data, &t); err != nil { 140 return err 141 } 142 143 tp := Phone(t) 144 *s = tp 145 return nil 146 } 147 148 func (s Phone) MarshalJSON() ([]byte, error) { 149 if string(s) == "" { 150 return []byte{}, nil 151 } 152 return []byte(s), nil 153 } 154 155 // PickList is the field type in Zoho that defines a dropdown that has been selected 156 type PickList string 157 158 func (s *PickList) UnmarshalJSON(data []byte) error { 159 if string(data) == "null" { 160 t := PickList("") 161 *s = t 162 return nil 163 } 164 165 var t string 166 if err := json.Unmarshal(data, &t); err != nil { 167 return err 168 } 169 170 tp := PickList(t) 171 *s = tp 172 return nil 173 } 174 175 func (s PickList) MarshalJSON() ([]byte, error) { 176 if string(s) == "" { 177 return []byte{}, nil 178 } 179 return []byte(s), nil 180 }