Skip to content

Commit

Permalink
Merge pull request #145 from zymiboxpay/master
Browse files Browse the repository at this point in the history
since bin/wechat cmd line using custom_message_send, so should also add it in enterprise account.
  • Loading branch information
Eric-Guo authored Aug 25, 2016
2 parents 791154b + 73303ee commit 0bdf37a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/wechat/corp_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,5 +164,9 @@ def material_delete(media_id)
def message_send(userid, message)
post 'message/send', Message.to(userid).text(message).agent_id(agentid).to_json, content_type: :json
end

def custom_message_send(message)
post 'message/send', message.agent_id(agentid).to_json, content_type: :json
end
end
end
18 changes: 18 additions & 0 deletions spec/lib/wechat/corp_api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -471,4 +471,22 @@
expect(subject.message_send 'userid', 'message content').to be true
end
end

describe '#custom_message_send' do
specify 'will post message/send with access_token, and json payload' do
payload = {
touser: 'openid',
msgtype: 'text',
agentid: '1',
text: { content: 'message content' }
}

expect(subject.client).to receive(:post)
.with('message/send', payload.to_json,
params: { access_token: 'access_token' }, content_type: :json).and_return(true)

expect(subject.custom_message_send Wechat::Message.to('openid').text('message content')).to be true
end
end

end

0 comments on commit 0bdf37a

Please sign in to comment.