Class: DingBot::Message::ActionCard

Inherits:
Base
  • Object
show all
Defined in:
lib/dingbot/message/action_card.rb

Overview

ActionCard基类

{
  "msgtype": "actionCard",
  "actionCard": {
    "title": "乔布斯 20 年前想打造一间苹果咖啡厅,而它正是 Apple Store 的前身",
    "text": "![screenshot](https://img.alicdn.com/tfs/TB1NwmBEL9TBuNjy1zbXXXpepXa-2400-1218.png) \n\n #### 乔布斯 20 年前想打造的苹果咖啡厅 \n\n Apple Store 的设计正从原来满满的科技感走向生活化,而其生活化的走向其实可以追溯到 20 年前苹果一个建立咖啡馆的计划", 
    "btnOrientation": "0",
    "btns": [
        {
            "title": "内容不错",
            "actionURL": "https://www.dingtalk.com/"
        },
        {
            "title": "不感兴趣",
            "actionURL": "https://www.dingtalk.com/"
        }
    ]
  }
  "at":{
     "atMobiles":["137188xxxxx"]
   }

}

Direct Known Subclasses

IndependentActionCard, WholeActionCard

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#to_json

Constructor Details

#initialize(title = '', text = '', btn_orientation = '0', at_mobiles = []) ⇒ ActionCard

Returns a new instance of ActionCard.



29
30
31
32
33
34
# File 'lib/dingbot/message/action_card.rb', line 29

def initialize(title='', text='', btn_orientation='0', at_mobiles=[])
  @title = title
  @text = text
  @btn_orientation = btn_orientation
  @at_mobiles = at_mobiles
end

Instance Attribute Details

#at_mobilesObject

Returns the value of attribute at_mobiles.



27
28
29
# File 'lib/dingbot/message/action_card.rb', line 27

def at_mobiles
  @at_mobiles
end

#btn_orientationObject

Returns the value of attribute btn_orientation.



27
28
29
# File 'lib/dingbot/message/action_card.rb', line 27

def btn_orientation
  @btn_orientation
end

#textObject

Returns the value of attribute text.



27
28
29
# File 'lib/dingbot/message/action_card.rb', line 27

def text
  @text
end

#titleObject

Returns the value of attribute title.



27
28
29
# File 'lib/dingbot/message/action_card.rb', line 27

def title
  @title
end

Instance Method Details

#body_paramsObject



40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/dingbot/message/action_card.rb', line 40

def body_params
  super.merge({
      actionCard: {
          title: @title,
          text: @text,
          btnOrientation: @btn_orientation,
      },
      at: {
        atMobiles: @at_mobiles,
      }
    }
  )
end

#msg_typeObject



36
37
38
# File 'lib/dingbot/message/action_card.rb', line 36

def msg_type
  TYPE::ACTION_CARD
end