Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
vvatanabe committed May 2, 2018
1 parent e576a89 commit cc2fd30
Show file tree
Hide file tree
Showing 7 changed files with 435 additions and 5 deletions.
110 changes: 110 additions & 0 deletions testdata/v2/get-likes-discover.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
{
"likedPosts": [
{
"post": {
"id": 309,
"topicId": 203,
"topic": {
"id": 203,
"name": "Techies",
"description": "",
"suggestion": "Techies",
"isDirectMessage": false,
"lastPostedAt": "2014-06-30T02:32:29Z",
"createdAt": "2014-06-05T02:32:29Z",
"updatedAt": "2014-06-05T02:32:29Z"
},
"replyTo": null,
"message": "@jessica Help me!",
"account": {
"id": 102,
"name": "moss",
"fullName": "Moss",
"suggestion": "Moss",
"imageUrl": "https://typetalk.com/accounts/102/profile_image.png?t=1403749949000",
"isBot": false,
"createdAt": "2014-06-26T02:32:29Z",
"updatedAt": "2014-06-26T02:32:29Z"
},
"attachments": [],
"links": [],
"directMessage": null,
"createdAt": "2014-07-02T03:32:29Z",
"updatedAt": "2014-07-02T03:32:29Z"
},
"likes": [
{
"id": 605,
"postId": 309,
"topicId": 203,
"comment": "",
"account": {
"id": 100,
"name": "jessica",
"fullName": "Jessica Fitzherbert",
"suggestion": "Jessica Fitzherbert",
"imageUrl": "https://typetalk.com/accounts/100/profile_image.png?t=1403577149000",
"isBot": false,
"createdAt": "2014-06-24T02:32:29Z",
"updatedAt": "2014-06-24T02:32:29Z"
},
"createdAt": "2016-12-21T10:12:06Z"
}
],
"directMessage": null
},
{
"post": {
"id": 308,
"topicId": 202,
"topic": {
"id": 202,
"name": "Arts & Crafts Club",
"description": "",
"suggestion": "Arts & Crafts Club",
"isDirectMessage": false,
"lastPostedAt": "2014-06-30T02:32:29Z",
"createdAt": "2014-06-04T02:32:29Z",
"updatedAt": "2014-06-04T02:32:29Z"
},
"replyTo": null,
"message": "@jessica What do you think about this?",
"account": {
"id": 101,
"name": "ahorowitz",
"fullName": "AHorowitz",
"suggestion": "AHorowitz",
"imageUrl": "https://typetalk.com/accounts/101/profile_image.png?t=1403663549000",
"isBot": false,
"createdAt": "2014-06-25T02:32:29Z",
"updatedAt": "2014-06-25T02:32:29Z"
},
"attachments": [],
"links": [],
"directMessage": null,
"createdAt": "2014-07-01T03:32:29Z",
"updatedAt": "2014-07-01T03:32:29Z"
},
"likes": [
{
"id": 604,
"postId": 308,
"topicId": 202,
"comment": "",
"account": {
"id": 100,
"name": "jessica",
"fullName": "Jessica Fitzherbert",
"suggestion": "Jessica Fitzherbert",
"imageUrl": "https://typetalk.com/accounts/100/profile_image.png?t=1403577149000",
"isBot": false,
"createdAt": "2014-06-24T02:32:29Z",
"updatedAt": "2014-06-24T02:32:29Z"
},
"createdAt": "2016-12-21T10:12:06Z"
}
],
"directMessage": null
}
]
}
82 changes: 82 additions & 0 deletions testdata/v2/get-likes-give.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{
"likedPosts": [
{
"post": {
"id": 309,
"topicId": 203,
"topic": {
"id": 203,
"name": "Techies",
"description": "",
"suggestion": "Techies",
"isDirectMessage": false,
"lastPostedAt": "2014-06-30T02:32:29Z",
"createdAt": "2014-06-05T02:32:29Z",
"updatedAt": "2014-06-05T02:32:29Z"
},
"replyTo": null,
"message": "@jessica Help me!",
"account": {
"id": 102,
"name": "moss",
"fullName": "Moss",
"suggestion": "Moss",
"imageUrl": "https://typetalk.com/accounts/102/profile_image.png?t=1403749949000",
"isBot": false,
"createdAt": "2014-06-26T02:32:29Z",
"updatedAt": "2014-06-26T02:32:29Z"
},
"attachments": [],
"links": [],
"directMessage": null,
"createdAt": "2014-07-02T03:32:29Z",
"updatedAt": "2014-07-02T03:32:29Z"
},
"myLike": {
"id": 605,
"comment": "",
"createdAt": "2016-12-21T10:12:06Z"
},
"directMessage": null
},
{
"post": {
"id": 308,
"topicId": 202,
"topic": {
"id": 202,
"name": "Arts & Crafts Club",
"description": "",
"suggestion": "Arts & Crafts Club",
"isDirectMessage": false,
"lastPostedAt": "2014-06-30T02:32:29Z",
"createdAt": "2014-06-04T02:32:29Z",
"updatedAt": "2014-06-04T02:32:29Z"
},
"replyTo": null,
"message": "@jessica What do you think about this?",
"account": {
"id": 101,
"name": "ahorowitz",
"fullName": "AHorowitz",
"suggestion": "AHorowitz",
"imageUrl": "https://typetalk.com/accounts/101/profile_image.png?t=1403663549000",
"isBot": false,
"createdAt": "2014-06-25T02:32:29Z",
"updatedAt": "2014-06-25T02:32:29Z"
},
"attachments": [],
"links": [],
"directMessage": null,
"createdAt": "2014-07-01T03:32:29Z",
"updatedAt": "2014-07-01T03:32:29Z"
},
"myLike": {
"id": 604,
"comment": "",
"createdAt": "2016-12-21T10:12:06Z"
},
"directMessage": null
}
]
}
110 changes: 110 additions & 0 deletions testdata/v2/get-likes-receive.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
{
"likedPosts": [
{
"post": {
"id": 309,
"topicId": 203,
"topic": {
"id": 203,
"name": "Techies",
"description": "",
"suggestion": "Techies",
"isDirectMessage": false,
"lastPostedAt": "2014-06-30T02:32:29Z",
"createdAt": "2014-06-05T02:32:29Z",
"updatedAt": "2014-06-05T02:32:29Z"
},
"replyTo": null,
"message": "@jessica Help me!",
"account": {
"id": 102,
"name": "moss",
"fullName": "Moss",
"suggestion": "Moss",
"imageUrl": "https://typetalk.com/accounts/102/profile_image.png?t=1403749949000",
"isBot": false,
"createdAt": "2014-06-26T02:32:29Z",
"updatedAt": "2014-06-26T02:32:29Z"
},
"attachments": [],
"links": [],
"directMessage": null,
"createdAt": "2014-07-02T03:32:29Z",
"updatedAt": "2014-07-02T03:32:29Z"
},
"likes": [
{
"id": 605,
"postId": 309,
"topicId": 203,
"comment": "",
"account": {
"id": 100,
"name": "jessica",
"fullName": "Jessica Fitzherbert",
"suggestion": "Jessica Fitzherbert",
"imageUrl": "https://typetalk.com/accounts/100/profile_image.png?t=1403577149000",
"isBot": false,
"createdAt": "2014-06-24T02:32:29Z",
"updatedAt": "2014-06-24T02:32:29Z"
},
"createdAt": "2016-12-21T10:12:06Z"
}
],
"directMessage": null
},
{
"post": {
"id": 308,
"topicId": 202,
"topic": {
"id": 202,
"name": "Arts & Crafts Club",
"description": "",
"suggestion": "Arts & Crafts Club",
"isDirectMessage": false,
"lastPostedAt": "2014-06-30T02:32:29Z",
"createdAt": "2014-06-04T02:32:29Z",
"updatedAt": "2014-06-04T02:32:29Z"
},
"replyTo": null,
"message": "@jessica What do you think about this?",
"account": {
"id": 101,
"name": "ahorowitz",
"fullName": "AHorowitz",
"suggestion": "AHorowitz",
"imageUrl": "https://typetalk.com/accounts/101/profile_image.png?t=1403663549000",
"isBot": false,
"createdAt": "2014-06-25T02:32:29Z",
"updatedAt": "2014-06-25T02:32:29Z"
},
"attachments": [],
"links": [],
"directMessage": null,
"createdAt": "2014-07-01T03:32:29Z",
"updatedAt": "2014-07-01T03:32:29Z"
},
"likes": [
{
"id": 604,
"postId": 308,
"topicId": 202,
"comment": "",
"account": {
"id": 100,
"name": "jessica",
"fullName": "Jessica Fitzherbert",
"suggestion": "Jessica Fitzherbert",
"imageUrl": "https://typetalk.com/accounts/100/profile_image.png?t=1403577149000",
"isBot": false,
"createdAt": "2014-06-24T02:32:29Z",
"updatedAt": "2014-06-24T02:32:29Z"
},
"createdAt": "2016-12-21T10:12:06Z"
}
],
"directMessage": null
}
]
}
8 changes: 8 additions & 0 deletions testdata/v2/read-received-likes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"like": {
"receive": {
"hasUnread": false,
"readLikeId": 605
}
}
}
9 changes: 5 additions & 4 deletions typetalk/v2/likes.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ type MyLike struct {
}

type GetLikesOptions struct {
SpaceKey string `json:"spaceKey,omitempty"`
SpaceKey string `json:"spaceKey"`
From int `json:"from,omitempty"`
}

Expand Down Expand Up @@ -140,7 +140,8 @@ func (s *LikesService) GetLikesDiscover(ctx context.Context, opt *GetLikesOption
}
}

type readReceivedLikesOptions struct {
type ReadReceivedLikesOptions struct {
SpaceKey string `json:"spaceKey"`
LikeId int `json:"likeId,omitempty"`
}

Expand All @@ -154,11 +155,11 @@ type ReadReceivedLikesResult struct {
}

// Typetalk API docs: https://developer.nulab-inc.com/docs/typetalk/api/2/save-read-likes/
func (s *LikesService) ReadReceivedLikes(ctx context.Context, likeId int) (*ReadReceivedLikesResult, *Response, error) {
func (s *LikesService) ReadReceivedLikes(ctx context.Context, opt *ReadReceivedLikesOptions) (*ReadReceivedLikesResult, *Response, error) {
u := "likes/receive/bookmark/save"

var result *ReadReceivedLikesResult
if resp, err := s.client.Post(ctx, u, &readReceivedLikesOptions{likeId}, result); err != nil {
if resp, err := s.client.Post(ctx, u, opt, result); err != nil {
return nil, resp, err
} else {
return result, resp, nil
Expand Down

0 comments on commit cc2fd30

Please sign in to comment.