bot_framework 0.1.0beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +10 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +5 -0
  5. data/CODE_OF_CONDUCT.md +49 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +60 -0
  9. data/Rakefile +6 -0
  10. data/bin/console +14 -0
  11. data/bin/setup +8 -0
  12. data/bot_framework.gemspec +31 -0
  13. data/examples/echo/bot.rb +8 -0
  14. data/examples/echo/config.ru +5 -0
  15. data/examples/stock/bot.rb +38 -0
  16. data/examples/stock/config.ru +5 -0
  17. data/lib/bot_framework.rb +48 -0
  18. data/lib/bot_framework/api_base.rb +31 -0
  19. data/lib/bot_framework/bot.rb +48 -0
  20. data/lib/bot_framework/bot_state.rb +89 -0
  21. data/lib/bot_framework/connector.rb +34 -0
  22. data/lib/bot_framework/conversation.rb +33 -0
  23. data/lib/bot_framework/errors.rb +4 -0
  24. data/lib/bot_framework/models/activity.rb +106 -0
  25. data/lib/bot_framework/models/api_response.rb +23 -0
  26. data/lib/bot_framework/models/attachment.rb +52 -0
  27. data/lib/bot_framework/models/attachment_data.rb +26 -0
  28. data/lib/bot_framework/models/attachment_info.rb +41 -0
  29. data/lib/bot_framework/models/attachment_view.rb +31 -0
  30. data/lib/bot_framework/models/base.rb +187 -0
  31. data/lib/bot_framework/models/bot_data.rb +15 -0
  32. data/lib/bot_framework/models/card_action.rb +43 -0
  33. data/lib/bot_framework/models/card_image.rb +36 -0
  34. data/lib/bot_framework/models/channel_account.rb +18 -0
  35. data/lib/bot_framework/models/conversation_account.rb +22 -0
  36. data/lib/bot_framework/models/conversation_parameters.rb +46 -0
  37. data/lib/bot_framework/models/entity.rb +26 -0
  38. data/lib/bot_framework/models/fact.rb +29 -0
  39. data/lib/bot_framework/models/geo_coordinates.rb +49 -0
  40. data/lib/bot_framework/models/hero_card.rb +62 -0
  41. data/lib/bot_framework/models/object.rb +19 -0
  42. data/lib/bot_framework/models/place.rb +56 -0
  43. data/lib/bot_framework/models/receipt_card.rb +78 -0
  44. data/lib/bot_framework/models/receipt_item.rb +60 -0
  45. data/lib/bot_framework/models/resource_response.rb +13 -0
  46. data/lib/bot_framework/models/signin_card.rb +35 -0
  47. data/lib/bot_framework/models/thumbnail_card.rb +62 -0
  48. data/lib/bot_framework/server.rb +56 -0
  49. data/lib/bot_framework/token_validator.rb +87 -0
  50. data/lib/bot_framework/util.rb +19 -0
  51. data/lib/bot_framework/version.rb +3 -0
  52. metadata +206 -0
@@ -0,0 +1,15 @@
1
+ module BotFramework
2
+ class BotData < Base
3
+ attr_accessor :data
4
+
5
+ attr_accessor :e_tag
6
+
7
+ # Attribute type mapping.
8
+ def self.swagger_types
9
+ {
10
+ data: :Object,
11
+ e_tag: :String
12
+ }
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,43 @@
1
+ module BotFramework
2
+ class CardAction < Base
3
+ # Defines the type of action implemented by this button.
4
+ attr_accessor :type
5
+
6
+ # Text description which appear on the button.
7
+ attr_accessor :title
8
+
9
+ # URL Picture which will appear on the button, next to text label.
10
+ attr_accessor :image
11
+
12
+ # Supplementary parameter for action. Content of this property depends on the ActionType
13
+ attr_accessor :value
14
+
15
+ # Attribute mapping from ruby-style variable name to JSON key.
16
+ # Attribute type mapping.
17
+ def self.swagger_types
18
+ {
19
+ type: :String,
20
+ title: :String,
21
+ image: :String,
22
+ value: :String
23
+ }
24
+ end
25
+
26
+ # Initializes the object
27
+ # @param [Hash] attributes Model attributes in the form of hash
28
+ def initialize(attributes = {})
29
+ return unless attributes.is_a?(Hash)
30
+
31
+ # convert string to symbol for hash key
32
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
33
+
34
+ self.type = attributes[:type] if attributes.key?(:type)
35
+
36
+ self.title = attributes[:title] if attributes.key?(:title)
37
+
38
+ self.image = attributes[:image] if attributes.key?(:image)
39
+
40
+ self.value = attributes[:value] if attributes.key?(:value)
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,36 @@
1
+ module BotFramework
2
+ class CardImage < Base
3
+ # URL Thumbnail image for major content property.
4
+ attr_accessor :url
5
+
6
+ # Image description intended for screen readers
7
+ attr_accessor :alt
8
+
9
+ # Action assigned to specific Attachment.E.g.navigate to specific URL or play/open media content
10
+ attr_accessor :tap
11
+
12
+ # Attribute type mapping.
13
+ def self.swagger_types
14
+ {
15
+ url: :String,
16
+ alt: :String,
17
+ tap: :CardAction
18
+ }
19
+ end
20
+
21
+ # Initializes the object
22
+ # @param [Hash] attributes Model attributes in the form of hash
23
+ def initialize(attributes = {})
24
+ return unless attributes.is_a?(Hash)
25
+
26
+ # convert string to symbol for hash key
27
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
28
+
29
+ self.url = attributes[:url] if attributes.key?(:url)
30
+
31
+ self.alt = attributes[:alt] if attributes.key?(:alt)
32
+
33
+ self.tap = attributes[:tap] if attributes.key?(:tap)
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,18 @@
1
+ module BotFramework
2
+ # Channel account information needed to route a message
3
+ class ChannelAccount < Base
4
+ # Channel id for the user or bot on this channel (Example: joe@smith.com, or @joesmith or 123456)
5
+ attr_accessor :id
6
+
7
+ # Display friendly name
8
+ attr_accessor :name
9
+
10
+ # Attribute type mapping.
11
+ def self.swagger_types
12
+ {
13
+ id: :String,
14
+ name: :String
15
+ }
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,22 @@
1
+ module BotFramework
2
+ # Channel account information for a conversation
3
+ class ConversationAccount < Base
4
+ # Is this a reference to a group
5
+ attr_accessor :is_group
6
+
7
+ # Channel id for the user or bot on this channel (Example: joe@smith.com, or @joesmith or 123456)
8
+ attr_accessor :id
9
+
10
+ # Display friendly name
11
+ attr_accessor :name
12
+
13
+ # Attribute type mapping.
14
+ def self.swagger_types
15
+ {
16
+ is_group: :BOOLEAN,
17
+ id: :String,
18
+ name: :String
19
+ }
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,46 @@
1
+ module BotFramework
2
+ class ConversationParameters < Base
3
+ # IsGroup
4
+ attr_accessor :is_group
5
+
6
+ # The bot address for this conversation
7
+ attr_accessor :bot
8
+
9
+ # Members to add to the conversation
10
+ attr_accessor :members
11
+
12
+ # (Optional) Topic of the conversation (if supported by the channel)
13
+ attr_accessor :topic_name
14
+
15
+ # Attribute type mapping.
16
+ def self.swagger_types
17
+ {
18
+ is_group: :BOOLEAN,
19
+ bot: :ChannelAccount,
20
+ members: :'Array<ChannelAccount>',
21
+ topic_name: :String
22
+ }
23
+ end
24
+
25
+ # Initializes the object
26
+ # @param [Hash] attributes Model attributes in the form of hash
27
+ def initialize(attributes = {})
28
+ return unless attributes.is_a?(Hash)
29
+
30
+ # convert string to symbol for hash key
31
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
32
+
33
+ self.is_group = attributes[:isGroup] if attributes.key?(:isGroup)
34
+
35
+ self.bot = attributes[:bot] if attributes.key?(:bot)
36
+
37
+ if attributes.key?(:members)
38
+ if (value = attributes[:members]).is_a?(Array)
39
+ self.members = value
40
+ end
41
+ end
42
+
43
+ self.topic_name = attributes[:topicName] if attributes.key?(:topicName)
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,26 @@
1
+
2
+ module BotFramework
3
+ # Object of schema.org types
4
+ class Entity < Base
5
+ # Entity Type (typically from schema.org types)
6
+ attr_accessor :type
7
+
8
+ # Attribute type mapping.
9
+ def self.swagger_types
10
+ {
11
+ type: :String
12
+ }
13
+ end
14
+
15
+ # Initializes the object
16
+ # @param [Hash] attributes Model attributes in the form of hash
17
+ def initialize(attributes = {})
18
+ return unless attributes.is_a?(Hash)
19
+
20
+ # convert string to symbol for hash key
21
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
22
+
23
+ self.type = attributes[:type] if attributes.key?(:type)
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,29 @@
1
+ module BotFramework
2
+ # Set of key-value pairs. Advantage of this section is that key and value properties will be rendered with default style information with some delimiter between them. So there is no need for developer to specify style information.
3
+ class Fact < Base
4
+ attr_accessor :key
5
+
6
+ attr_accessor :value
7
+
8
+ # Attribute type mapping.
9
+ def self.swagger_types
10
+ {
11
+ key: :String,
12
+ value: :String
13
+ }
14
+ end
15
+
16
+ # Initializes the object
17
+ # @param [Hash] attributes Model attributes in the form of hash
18
+ def initialize(attributes = {})
19
+ return unless attributes.is_a?(Hash)
20
+
21
+ # convert string to symbol for hash key
22
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
23
+
24
+ self.key = attributes[:key] if attributes.key?(:key)
25
+
26
+ self.value = attributes[:value] if attributes.key?(:value)
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,49 @@
1
+ module BotFramework
2
+ # GeoCoordinates (entity type: \"https://schema.org/GeoCoordinates\")
3
+ class GeoCoordinates < Base
4
+ # Elevation of the location [WGS 84](https://en.wikipedia.org/wiki/World_Geodetic_System)
5
+ attr_accessor :elevation
6
+
7
+ # Latitude of the location [WGS 84](https://en.wikipedia.org/wiki/World_Geodetic_System)
8
+ attr_accessor :latitude
9
+
10
+ # Longitude of the location [WGS 84](https://en.wikipedia.org/wiki/World_Geodetic_System)
11
+ attr_accessor :longitude
12
+
13
+ # The type of the thing
14
+ attr_accessor :type
15
+
16
+ # The name of the thing
17
+ attr_accessor :name
18
+
19
+ # Attribute type mapping.
20
+ def self.swagger_types
21
+ {
22
+ elevation: :Float,
23
+ latitude: :Float,
24
+ longitude: :Float,
25
+ type: :String,
26
+ name: :String
27
+ }
28
+ end
29
+
30
+ # Initializes the object
31
+ # @param [Hash] attributes Model attributes in the form of hash
32
+ def initialize(attributes = {})
33
+ return unless attributes.is_a?(Hash)
34
+
35
+ # convert string to symbol for hash key
36
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
37
+
38
+ self.elevation = attributes[:elevation] if attributes.key?(:elevation)
39
+
40
+ self.latitude = attributes[:latitude] if attributes.key?(:latitude)
41
+
42
+ self.longitude = attributes[:longitude] if attributes.key?(:longitude)
43
+
44
+ self.type = attributes[:type] if attributes.key?(:type)
45
+
46
+ self.name = attributes[:name] if attributes.key?(:name)
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,62 @@
1
+ module BotFramework
2
+ class HeroCard < Base
3
+ # Title of the card
4
+ attr_accessor :title
5
+
6
+ # Subtitle of the card
7
+ attr_accessor :subtitle
8
+
9
+ # Text for the card
10
+ attr_accessor :text
11
+
12
+ # Array of i
13
+ attr_accessor :images
14
+
15
+ # Set of actions applicable to the current card
16
+ attr_accessor :buttons
17
+
18
+ # This action will be activated when user taps on the card itself
19
+ attr_accessor :tap
20
+
21
+ # Attribute type mapping.
22
+ def self.swagger_types
23
+ {
24
+ title: :String,
25
+ subtitle: :String,
26
+ text: :String,
27
+ images: :'Array<CardImage>',
28
+ buttons: :'Array<CardAction>',
29
+ tap: :CardAction
30
+ }
31
+ end
32
+
33
+ # Initializes the object
34
+ # @param [Hash] attributes Model attributes in the form of hash
35
+ def initialize(attributes = {})
36
+ return unless attributes.is_a?(Hash)
37
+
38
+ # convert string to symbol for hash key
39
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
40
+
41
+ self.title = attributes[:title] if attributes.key?(:title)
42
+
43
+ self.subtitle = attributes[:subtitle] if attributes.key?(:subtitle)
44
+
45
+ self.text = attributes[:text] if attributes.key?(:text)
46
+
47
+ if attributes.key?(:images)
48
+ if (value = attributes[:images]).is_a?(Array)
49
+ self.images = value
50
+ end
51
+ end
52
+
53
+ if attributes.key?(:buttons)
54
+ if (value = attributes[:buttons]).is_a?(Array)
55
+ self.buttons = value
56
+ end
57
+ end
58
+
59
+ self.tap = attributes[:tap] if attributes.key?(:tap)
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,19 @@
1
+ module BotFramework
2
+ class Object < Base
3
+
4
+ # Attribute type mapping.
5
+ def self.swagger_types
6
+ {
7
+ }
8
+ end
9
+
10
+ # Initializes the object
11
+ # @param [Hash] attributes Model attributes in the form of hash
12
+ def initialize(attributes = {})
13
+ return unless attributes.is_a?(Hash)
14
+
15
+ # convert string to symbol for hash key
16
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,56 @@
1
+ module BotFramework
2
+ # Place (entity type: \"https://schema.org/Place\")
3
+ class Place < Base
4
+ # Address of the place (may be `string` or complex object of type `PostalAddress`)
5
+ attr_accessor :address
6
+
7
+ # Geo coordinates of the place (may be complex object of type `GeoCoordinates` or `GeoShape`)
8
+ attr_accessor :geo
9
+
10
+ # Map to the place (may be `string` (URL) or complex object of type `Map`)
11
+ attr_accessor :has_map
12
+
13
+ # The type of the thing
14
+ attr_accessor :type
15
+
16
+ # The name of the thing
17
+ attr_accessor :name
18
+
19
+ # Attribute type mapping.
20
+ def self.swagger_types
21
+ {
22
+ address: :Object,
23
+ geo: :Object,
24
+ has_map: :Object,
25
+ type: :String,
26
+ name: :String
27
+ }
28
+ end
29
+
30
+ # Initializes the object
31
+ # @param [Hash] attributes Model attributes in the form of hash
32
+ def initialize(attributes = {})
33
+ return unless attributes.is_a?(Hash)
34
+
35
+ # convert string to symbol for hash key
36
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
37
+
38
+ self.address = attributes[:address] if attributes.key?(:address)
39
+
40
+ self.geo = attributes[:geo] if attributes.key?(:geo)
41
+
42
+ self.has_map = attributes[:hasMap] if attributes.key?(:hasMap)
43
+
44
+ self.type = attributes[:type] if attributes.key?(:type)
45
+
46
+ self.name = attributes[:name] if attributes.key?(:name)
47
+ end
48
+
49
+ # Show invalid properties with the reasons. Usually used together with valid?
50
+ # @return Array for valid properies with the reasons
51
+ def list_invalid_properties
52
+ invalid_properties = []
53
+ invalid_properties
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,78 @@
1
+ module BotFramework
2
+ class ReceiptCard < Base
3
+ # Title of the card
4
+ attr_accessor :title
5
+
6
+ # Array of Receipt Items
7
+ attr_accessor :items
8
+
9
+ # Array of Fact Objects Array of key-value pairs.
10
+ attr_accessor :facts
11
+
12
+ # This action will be activated when user taps on the card
13
+ attr_accessor :tap
14
+
15
+ # Total amount of money paid (or should be paid)
16
+ attr_accessor :total
17
+
18
+ # Total amount of TAX paid(or should be paid)
19
+ attr_accessor :tax
20
+
21
+ # Total amount of VAT paid(or should be paid)
22
+ attr_accessor :vat
23
+
24
+ # Set of actions applicable to the current card
25
+ attr_accessor :buttons
26
+
27
+ # Attribute type mapping.
28
+ def self.swagger_types
29
+ {
30
+ title: :String,
31
+ items: :'Array<ReceiptItem>',
32
+ facts: :'Array<Fact>',
33
+ tap: :CardAction,
34
+ total: :String,
35
+ tax: :String,
36
+ vat: :String,
37
+ buttons: :'Array<CardAction>'
38
+ }
39
+ end
40
+
41
+ # Initializes the object
42
+ # @param [Hash] attributes Model attributes in the form of hash
43
+ def initialize(attributes = {})
44
+ return unless attributes.is_a?(Hash)
45
+
46
+ # convert string to symbol for hash key
47
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
48
+
49
+ self.title = attributes[:title] if attributes.key?(:title)
50
+
51
+ if attributes.key?(:items)
52
+ if (value = attributes[:items]).is_a?(Array)
53
+ self.items = value
54
+ end
55
+ end
56
+
57
+ if attributes.key?(:facts)
58
+ if (value = attributes[:facts]).is_a?(Array)
59
+ self.facts = value
60
+ end
61
+ end
62
+
63
+ self.tap = attributes[:tap] if attributes.key?(:tap)
64
+
65
+ self.total = attributes[:total] if attributes.key?(:total)
66
+
67
+ self.tax = attributes[:tax] if attributes.key?(:tax)
68
+
69
+ self.vat = attributes[:vat] if attributes.key?(:vat)
70
+
71
+ if attributes.key?(:buttons)
72
+ if (value = attributes[:buttons]).is_a?(Array)
73
+ self.buttons = value
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end