-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
56 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package zendesk | ||
|
||
// CustomFieldOption is struct for value of `custom_field_options` | ||
type CustomFieldOption struct { | ||
ID int64 `json:"id,omitempty"` | ||
Name string `json:"name"` | ||
Position int64 `json:"position,omitempty"` | ||
RawName string `json:"raw_name,omitempty"` | ||
URL string `json:"url,omitempty"` | ||
Value string `json:"value"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package zendesk | ||
|
||
import ( | ||
"encoding/json" | ||
"time" | ||
) | ||
|
||
// UserField is struct for user_field payload | ||
type UserField struct { | ||
ID int64 `json:"id,omitempty"` | ||
URL string `json:"url,omitempty"` | ||
Key string `json:"key,omitempty"` | ||
Type string `json:"type"` | ||
Title string `json:"title"` | ||
RawTitle string `json:"raw_title,omitempty"` | ||
Description string `json:"description,omitempty"` | ||
RawDescription string `json:"raw_description,omitempty"` | ||
Position int64 `json:"position,omitempty"` | ||
Active bool `json:"active,omitempty"` | ||
System bool `json:"system,omitempty"` | ||
RegexpForValidation string `json:"regexp_for_validation,omitempty"` | ||
Tag string `json:"tag,omitempty"` | ||
CustomFieldOptions []CustomFieldOption `json:"custom_field_options"` | ||
CreatedAt time.Time `json:"created_at,omitempty"` | ||
UpdatedAt time.Time `json:"updated_at,omitempty"` | ||
} | ||
|
||
// GetUserFields fetch trigger list | ||
func (z *Client) GetUserFields() ([]UserField, Page, error) { | ||
var data struct { | ||
UserFields []UserField `json:"user_fields"` | ||
Page | ||
} | ||
body, err := z.Get("/user_fields.json") | ||
if err != nil { | ||
return nil, Page{}, err | ||
} | ||
|
||
err = json.Unmarshal(body, &data) | ||
if err != nil { | ||
return nil, Page{}, err | ||
} | ||
return data.UserFields, data.Page, nil | ||
} |