Skip to content

Commit

Permalink
ADD: appchat API
Browse files Browse the repository at this point in the history
  • Loading branch information
seandong committed Nov 7, 2018
1 parent b6d5412 commit 56bedb7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 23 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ values = JSON.parse data

[Wework::Api::Methods::Message](https://github.com/mycolorway/wework/blob/master/lib/wework/api/methods/message.rb)

[Wework::Api::Methods::Appchat](https://github.com/mycolorway/wework/blob/master/lib/wework/api/methods/appchat.rb)

[Wework::Api::Methods::Media](https://github.com/mycolorway/wework/blob/master/lib/wework/api/methods/media.rb)

[Wework::Api::Methods::Menu](https://github.com/mycolorway/wework/blob/master/lib/wework/api/methods/menu.rb)
Expand Down
40 changes: 18 additions & 22 deletions lib/wework/api/methods/appchat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,58 +5,54 @@ module Api
module Methods
module Appchat

def create_group group_name, owner_id, group_user_ids, chat_id
def appchat_create group_name, owner_id, group_user_ids, chat_id
post 'appchat/create',
name: group_name,
owner: owner_id,
userlist: group_user_ids,
chatid: chat_id
end

# name: group_name
# owner: owner_id
# add_user_list: add_user_list
# del_user_list: del_user_list
def update_group chat_id, payload={}
def appchat_update chat_id, payload={}
payload.merge! chatid: chat_id
post 'appchat/update', payload
end

def get_group chat_id
def appchat_get chat_id
get 'appchat/get', { params: { chatid: chat_id } }
end

def group_text_message_send chat_id, content
message_send chat_id, {text: {content: content}, msgtype: 'text'}
def text_appchat_send chat_id, content
appchat_send chat_id, {text: {content: content}, msgtype: 'text'}
end

def group_image_message_send chat_id, media_id
message_send chat_id, {image: {media_id: media_id}, msgtype: 'image'}
def image_appchat_send chat_id, media_id
appchat_send chat_id, {image: {media_id: media_id}, msgtype: 'image'}
end

def group_voice_message_send chat_id, media_id
message_send chat_id, {voice: {media_id: media_id}, msgtype: 'voice'}
def voice_appchat_send chat_id, media_id
appchat_send chat_id, {voice: {media_id: media_id}, msgtype: 'voice'}
end

def group_file_message_send chat_id, media_id
message_send chat_id, {file: {media_id: media_id}, msgtype: 'file'}
def file_appchat_send chat_id, media_id
appchat_send chat_id, {file: {media_id: media_id}, msgtype: 'file'}
end

def group_video_message_send chat_id, video={}
message_send chat_id, {video: video, msgtype: 'video'}
def video_appchat_send chat_id, video={}
appchat_send chat_id, {video: video, msgtype: 'video'}
end

def group_textcard_message_send chat_id, textcard={}
message_send chat_id, {textcard: textcard, msgtype: 'textcard'}
def textcard_appchat_send chat_id, textcard={}
appchat_send chat_id, {textcard: textcard, msgtype: 'textcard'}
end

def group_news_message_send chat_id, news=[]
message_send chat_id, {news: {articles: news}, msgtype: 'news'}
def news_appchat_send chat_id, news=[]
appchat_send chat_id, {news: {articles: news}, msgtype: 'news'}
end

private

def message_send chat_id, payload={}
def appchat_send chat_id, payload={}
payload.merge!(chatid: chat_id)
post 'appchat/send', payload
end
Expand Down
2 changes: 1 addition & 1 deletion lib/wework/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Wework
VERSION = '1.2.2'.freeze
VERSION = '1.2.3'.freeze
end

0 comments on commit 56bedb7

Please sign in to comment.