Skip to content

Commit

Permalink
Merge pull request #27 from panperla/RE-23
Browse files Browse the repository at this point in the history
Fixing data in models to be interface rather than predefined struct
  • Loading branch information
panperla committed Jan 18, 2024
2 parents 031478a + ef761e1 commit ff07ec6
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 50 deletions.
10 changes: 5 additions & 5 deletions reamaze/contacts_models.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ type CreateContactRequest struct {

type UpdateContactRequest struct {
Contact struct {
Name string `json:"name"`
FriendlyName string `json:"friendly_name"`
ExternalAvatarURL string `json:"external_avatar_url"`
Notes []string `json:"notes"`
Data interface{} `json:"data"`
Name string `json:"name"`
FriendlyName string `json:"friendly_name"`
ExternalAvatarURL string `json:"external_avatar_url"`
Notes []string `json:"notes"`
Data any `json:"data"`
} `json:"contact"`
}

Expand Down
1 change: 0 additions & 1 deletion reamaze/conversations.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ func (c *Client) CreateConversation(req *CreateConversationRequest) (*CreateConv

err = json.Unmarshal(resp, &response)
if err != nil {

return nil, err
}
return response, nil
Expand Down
73 changes: 29 additions & 44 deletions reamaze/conversations_models.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,16 +245,12 @@ type CreateConversationResponse struct {
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Origin int `json:"origin"`
Data struct {
Nda string `json:"NDA"`
Firstname string `json:"Firstname"`
Lastname string `json:"Lastname"`
} `json:"data"`
HoldUntil any `json:"hold_until"`
Data any `json:"data"`
HoldUntil any `json:"hold_until"`
Author struct {
ID int `json:"id"`
Name string `json:"name"`
Data string `json:"data"`
Data any `json:"data"`
Email string `json:"email"`
Twitter string `json:"twitter"`
Facebook string `json:"facebook"`
Expand All @@ -280,19 +276,19 @@ type CreateConversationResponse struct {
CreatedAt time.Time `json:"created_at"`
} `json:"last_customer_message"`
Followers []struct {
ID int `json:"id"`
Name string `json:"name"`
Data interface{} `json:"data"`
Email string `json:"email"`
Twitter string `json:"twitter"`
Facebook string `json:"facebook"`
Instagram string `json:"instagram"`
Mobile string `json:"mobile"`
FriendlyName string `json:"friendly_name"`
DisplayName string `json:"display_name"`
Staff bool `json:"staff?"`
Customer bool `json:"customer?"`
Bot bool `json:"bot?"`
ID int `json:"id"`
Name string `json:"name"`
Data any `json:"data"`
Email string `json:"email"`
Twitter string `json:"twitter"`
Facebook string `json:"facebook"`
Instagram string `json:"instagram"`
Mobile string `json:"mobile"`
FriendlyName string `json:"friendly_name"`
DisplayName string `json:"display_name"`
Staff bool `json:"staff?"`
Customer bool `json:"customer?"`
Bot bool `json:"bot?"`
} `json:"followers"`
Message struct {
Body string `json:"body"`
Expand All @@ -309,24 +305,24 @@ type CreateConversationRequest struct {
Status ReamazeStatus `json:"status,omitempty"`
SupressNotification bool `json:"suppress_notifications,omitempty"` // You can optionally pass in a message[suppress_notifications] boolean attribute with a value of true to prevent Reamaze from sending any email (or integration) notifications related to this message.
SupressAutoresolve bool `json:"suppress_autoresolve,omitempty"` // You can optionally pass in a message[suppress_autoresolve] boolean attribute with a value of true to prevent Reamaze from marking the conversation as resolved when message[user] is a staff user.
Data interface{} `json:"data,omitempty"`
Data any `json:"data,omitempty"`
Message struct {
Body string `json:"body,omitempty"`
Attachment string `json:"attachment,omitempty"`
Attachments []string `json:"attachments,omitempty"`
} `json:"message,omitempty"`
User struct {
Name string `json:"name,omitempty"`
Email string `json:"email,omitempty"`
Data interface{} `json:"data,omitempty"`
Name string `json:"name,omitempty"`
Email string `json:"email,omitempty"`
Data any `json:"data,omitempty"`
} `json:"user,omitempty"`
} `json:"conversation,omitempty"`
}
type UpdateConversationRequest struct {
Conversation struct {
TagList []string `json:"tag_list,omitempty"`
Status ReamazeStatus `json:"status,omitempty"`
Data interface{} `json:"data,omitempty"`
Data any `json:"data,omitempty"`
Assignee string `json:"assignee,omitempty"`
Category string `json:"category,omitempty"`
Brand string `json:"brand,omitempty"`
Expand All @@ -339,19 +335,12 @@ type GetConversationResponse struct {
CreatedAt time.Time `json:"created_at,omitempty"`
UpdatedAt time.Time `json:"updated_at,omitempty"`
Origin int `json:"origin,omitempty"`
Data struct {
LastName string `json:"last_name,omitempty"`
FirstName string `json:"first_name,omitempty"`
} `json:"data,omitempty"`
HoldUntil any `json:"hold_until,omitempty"`
Data any `json:"data,omitempty"`
HoldUntil any `json:"hold_until,omitempty"`
Author struct {
ID int `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Data struct {
LastName string `json:"last_name,omitempty"`
FirstName string `json:"first_name,omitempty"`
JobApplication string `json:"job_application,omitempty"`
} `json:"data"`
ID int `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Data any `json:"data"`
Email string `json:"email,omitempty"`
Twitter string `json:"twitter,omitempty"`
Facebook string `json:"facebook,omitempty"`
Expand All @@ -377,13 +366,9 @@ type GetConversationResponse struct {
CreatedAt time.Time `json:"created_at,omitempty"`
} `json:"last_customer_message,omitempty"`
Followers []struct {
ID int `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Data struct {
LastName string `json:"last_name,omitempty"`
FirstName string `json:"first_name,omitempty"`
JobApplication string `json:"job_application,omitempty"`
} `json:"data"`
ID int `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Data any `json:"data"`
Email string `json:"email,omitempty"`
Twitter string `json:"twitter,omitempty"`
Facebook string `json:"facebook,omitempty"`
Expand Down
16 changes: 16 additions & 0 deletions reamaze/conversations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,22 @@ func TestClient_CreateConversation(t *testing.T) {
correctConversation.Conversation.Category = "test"
correctConversation.Conversation.Message.Body = "test"
correctConversation.Conversation.User.Email = "test"
correctConversation.Conversation.Data = struct {
FirstName string `json:"first_name,omitempty"`
LastName string `json:"last_name,omitempty"`
}{
FirstName: "dummy",
LastName: "dummy",
}
correctConversation.Conversation.User.Data = struct {
JobApplication bool `json:"job_application,omitempty"`
FirstName string `json:"first_name,omitempty"`
LastName string `json:"last_name,omitempty"`
}{
JobApplication: true,
FirstName: "dummy",
LastName: "dummy",
}

type fields struct {
baseURL string
Expand Down

0 comments on commit ff07ec6

Please sign in to comment.