Skip to content

Commit

Permalink
bug fixes change i/o
Browse files Browse the repository at this point in the history
  • Loading branch information
Kdheeru12 committed Nov 29, 2021
1 parent 41fa013 commit 346ad51
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 29 deletions.
2 changes: 1 addition & 1 deletion client/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type errorResponse struct {
type Error struct {
ErrorResponse *Response
Code int `json:"code,omitempty"`
Errors interface{} `json:"errors,omitempty"`
Errors interface{} `json:"error,omitempty"`
Message string `json:"message,omitempty"`
}

Expand Down
9 changes: 8 additions & 1 deletion client/integrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ type ApplicationReference struct {
Categories string `json:"categories"`
Documentation_Link string `json:"documentation_link"`
}

type IntegrationCreate struct {
Name string `json:"name"`
Summary string `json:"summary"`
Application string `json:"application"`
}

type Integration struct {
Name string `json:"name"`
Creation_Date string `json:"creation_date"`
Expand All @@ -37,7 +44,7 @@ type Integration struct {
Default_Urgency int `json:"default_urggency"`
}

func (c *IntegrationServerice) CreateIntegration(team string, service_id string, integration *Integration) (*Integration, error) {
func (c *IntegrationServerice) CreateIntegration(team string, service_id string, integration *IntegrationCreate) (*Integration, error) {
path := fmt.Sprintf("/api/account/teams/%s/services/%s/integrations/", team, service_id)

body, err := c.client.newRequestDo("POST", path, integration)
Expand Down
17 changes: 8 additions & 9 deletions client/members.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ import (
type MemberService service

type Member struct {
Unique_Id string `json:"unique_id"`
Team string `json:"team"`
User string `json:"user"`
Joining_Date string `json:"joining_date"`
Role int `json:"role"`
Unique_Id string `json:"unique_id",omitempty`
Team string `json:"team",omitempty`
User string `json:"user",omitempty`
Role int `json:"role",omitempty`
}

type MemberResponse struct {
Expand All @@ -23,28 +22,28 @@ type MemberResponse struct {
Role int `json:"role"`
}

func (c *MemberService) CreateTeamMember(team string, member *Member) (*Member, error) {
func (c *MemberService) CreateTeamMember(team string, member *Member) (*MemberResponse, error) {
path := fmt.Sprintf("/api/account/teams/%s/members/", team)

body, err := c.client.newRequestDo("POST", path, member)
if err != nil {
return nil, err
}
var s Member
var s MemberResponse
err = json.Unmarshal(body.BodyBytes, &s)
if err != nil {
return nil, err
}
return &s, nil
}

func (c *MemberService) UpdateTeamMember(member *Member) (*Member, error) {
func (c *MemberService) UpdateTeamMember(member *Member) (*MemberResponse, error) {
path := fmt.Sprintf("/api/account/teams/%s/members/%s/", member.Team, member.Unique_Id)
body, err := c.client.newRequestDo("PATCH", path, member)
if err != nil {
return nil, err
}
var s Member
var s MemberResponse
err = json.Unmarshal(body.BodyBytes, &s)
if err != nil {
return nil, err
Expand Down
8 changes: 4 additions & 4 deletions client/roles.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import (
type RoleService service

type Roles struct {
Team string `json:"team"`
Unique_Id string `json:"unique_id"`
Team string `json:"team",omitempty`
Unique_Id string `json:"unique_id",omitempty`
Title string `json:"title"`
Description string `json:"description"`
Creation_Date string `json:"creation_date"`
Rank int `json:"rank"`
Creation_Date string `json:"creation_date",omitempty`
Rank int `json:"rank",omitempty`
}

func (c *RoleService) CreateRole(team string, role *Roles) (*Roles, error) {
Expand Down
12 changes: 6 additions & 6 deletions client/schedules.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ type Restrictions struct {
Duration int `json:"duration"`
StartDayOfWeek int `json:"start_day_of_week"`
StartTimeOfDay string `json:"start_time_of_day"`
Unique_Id string `json:"unique_id"`
Unique_Id string `json:"unique_id",omitempty`
}
type Users struct {
User string `json:"user"`
Position int `json:"position"`
Unique_Id string `json:"unique_id"`
Unique_Id string `json:"unique_id",omitempty`
}

type Overrides struct {
Name string `json:"name"`
User string `json:"user"`
StartTime string `json:"start_time"`
EndTime string `json:"end_time"`
Unique_Id string `json:"unique_id"`
Unique_Id string `json:"unique_id",omitempty`
}
type Layers struct {
ShiftLength int `json:"shift_length"`
Expand All @@ -33,8 +33,8 @@ type Layers struct {
RotationEndTime string `json:"rotation_end_time"`
UniqueId string `json:"unique_id"`
LastEdited string `json:"last_edited"`
RestrictionType int `json:"restriction_type"`
IsActive bool `json:"is_active"`
RestrictionType int `json:"restriction_type",omitempty`
IsActive bool `json:"is_active",omitempty`
Restrictions []Restrictions `json:"restrictions"`
Users []Users `json:"users"`
}
Expand All @@ -45,7 +45,7 @@ type Schedules struct {
Summary string `json:"summary"`
Time_zone string `json:"time_zone"`
Team string `json:"team"`
Unique_Id string `json:"unique_id"`
Unique_Id string `json:"unique_id",omitempty`
Layers []Layers `json:"layers"`
Overrides []Overrides `json:"overrides"`
}
Expand Down
12 changes: 6 additions & 6 deletions client/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ type Services struct {
Creation_Date string `json:"creation_date"`
Summary string `json:"summary"`
Description string `json:"description"`
Unique_Id string `json:"unique_id"`
Auto_Resolve_Timeout int `json:"auto_resolve_timeout"`
Created_By string `json:"created_by"`
Unique_Id string `json:"unique_id",omitempty`
Auto_Resolve_Timeout int `json:"auto_resolve_timeout",omitempty`
Created_By string `json:"created_by",omitempty`
Team_Priority string `json:"team_priority"`
Task_Template string `json:"task_template"`
Acknowledgment_Timeout int `json:"acknowledge_timeout"`
Status int `json:"status"`
Acknowledgment_Timeout int `json:"acknowledge_timeout",omitempty`
Status int `json:"status",omitempty`
Escalation_Policy string `json:"escalation_policy"`
Team string `json:"team"`
Sla string `json:"sla"`
Collation_Time int `json:"collation_time"`
Collation int `json:"collation"`
Under_Maintenance bool `json:"under_maintenance"`
Under_Maintenance bool `json:"under_maintenance",omitempty`
}

func (c *Service) CreateService(team string, service *Services) (*Services, error) {
Expand Down
9 changes: 7 additions & 2 deletions client/team.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ type members struct {
Joining_Date string `json:"joining_date"`
Role int `json:"role"`
}

type CreateTeams struct {
Name string `json:"name"`
Unique_Id string `json:"unique_id",omitempty`
}
type Team struct {
Unique_Id string `json:"unique_id"`
Name string `json:"name"`
Expand All @@ -31,7 +36,7 @@ type Team struct {
Members []members `json:"members"`
}

func (c *TeamService) CreateTeam(team *Team) (*Team, error) {
func (c *TeamService) CreateTeam(team *CreateTeams) (*Team, error) {
path := "/api/account/teams/"
body, err := c.client.newRequestDo("POST", path, team)
if err != nil {
Expand All @@ -45,7 +50,7 @@ func (c *TeamService) CreateTeam(team *Team) (*Team, error) {
return &t, nil
}

func (c *TeamService) UpdateTeam(id string, team *Team) (*Team, error) {
func (c *TeamService) UpdateTeam(id string, team *CreateTeams) (*Team, error) {

path := fmt.Sprintf("/api/account/teams/%s/", id)
res, err := c.client.newRequestDo("PATCH", path, team)
Expand Down

0 comments on commit 346ad51

Please sign in to comment.