apps 0.2.1 → 0.3.0
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.
- checksums.yaml +4 -4
- data/.gitignore +4 -0
- data/README.md +103 -19
- data/bin/setup +1 -2
- data/exe/apps +0 -0
- data/lib/apps/common/schema.rb +8 -0
- data/lib/apps/common/schema/base.rb +91 -0
- data/lib/apps/common/schema/concerns.rb +10 -0
- data/lib/apps/common/schema/concerns/potential_action.rb +35 -0
- data/lib/apps/gmail/markup.rb +158 -0
- data/lib/apps/gmail/schema.rb +21 -0
- data/lib/apps/gmail/schema/action.rb +19 -0
- data/lib/apps/gmail/schema/confirm_action.rb +21 -0
- data/lib/apps/gmail/schema/email_message.rb +15 -0
- data/lib/apps/gmail/schema/event.rb +41 -0
- data/lib/apps/gmail/schema/parcel_delivery.rb +43 -0
- data/lib/apps/gmail/schema/place.rb +24 -0
- data/lib/apps/gmail/schema/postal_address.rb +22 -0
- data/lib/apps/gmail/schema/rsvp_action.rb +25 -0
- data/lib/apps/gmail/schema/save_action.rb +20 -0
- data/lib/apps/gmail/schema/track_action.rb +20 -0
- data/lib/apps/gmail/schema/view_action.rb +20 -0
- data/lib/apps/outlook/actionable_messages.rb +13 -0
- data/lib/apps/outlook/schema.rb +20 -0
- data/lib/apps/outlook/schema/action.rb +14 -0
- data/lib/apps/outlook/schema/action_card.rb +42 -0
- data/lib/apps/outlook/schema/concerns.rb +14 -0
- data/lib/apps/outlook/schema/concerns/sections.rb +27 -0
- data/lib/apps/outlook/schema/concerns/sorted_potential_action.rb +17 -0
- data/lib/apps/outlook/schema/date_input.rb +17 -0
- data/lib/apps/outlook/schema/http_post.rb +44 -0
- data/lib/apps/outlook/schema/input.rb +23 -0
- data/lib/apps/outlook/schema/invoke_add_in_command.rb +33 -0
- data/lib/apps/outlook/schema/message_card.rb +39 -0
- data/lib/apps/outlook/schema/multichoice_input.rb +32 -0
- data/lib/apps/outlook/schema/open_uri.rb +24 -0
- data/lib/apps/outlook/schema/section.rb +52 -0
- data/lib/apps/outlook/schema/text_input.rb +20 -0
- data/lib/apps/version.rb +4 -1
- data/lib/examples.rb +121 -0
- data/package.json +12 -0
- metadata +37 -16
- data/lib/apps/adapters/gmail/markup.rb +0 -42
- data/lib/apps/adapters/gmail/markup/action.rb +0 -23
- data/lib/apps/adapters/gmail/markup/base.rb +0 -37
- data/lib/apps/adapters/gmail/markup/base_context.rb +0 -23
- data/lib/apps/adapters/gmail/markup/confirm_action.rb +0 -23
- data/lib/apps/adapters/gmail/markup/email_message.rb +0 -22
- data/lib/apps/adapters/gmail/markup/event.rb +0 -40
- data/lib/apps/adapters/gmail/markup/parcel_delivery.rb +0 -47
- data/lib/apps/adapters/gmail/markup/place.rb +0 -27
- data/lib/apps/adapters/gmail/markup/postal_address.rb +0 -26
- data/lib/apps/adapters/gmail/markup/rsvp_action.rb +0 -27
- data/lib/apps/adapters/gmail/markup/save_action.rb +0 -22
- data/lib/apps/adapters/gmail/markup/track_action.rb +0 -24
- data/lib/apps/adapters/gmail/markup/view_action.rb +0 -24
@@ -0,0 +1,21 @@
|
|
1
|
+
require_relative '../common/schema'
|
2
|
+
require_relative '../common/schema/concerns'
|
3
|
+
|
4
|
+
module Apps
|
5
|
+
module Gmail
|
6
|
+
module Schema
|
7
|
+
include ::Apps::Common::Schema
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
require_relative 'schema/confirm_action'
|
13
|
+
require_relative 'schema/email_message'
|
14
|
+
require_relative 'schema/event'
|
15
|
+
require_relative 'schema/parcel_delivery'
|
16
|
+
require_relative 'schema/place'
|
17
|
+
require_relative 'schema/postal_address'
|
18
|
+
require_relative 'schema/rsvp_action'
|
19
|
+
require_relative 'schema/save_action'
|
20
|
+
require_relative 'schema/track_action'
|
21
|
+
require_relative 'schema/view_action'
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require_relative 'action'
|
2
|
+
|
3
|
+
module Apps
|
4
|
+
module Gmail
|
5
|
+
module Schema
|
6
|
+
# See: https://developers.google.com/gmail/markup/reference/one-click-action
|
7
|
+
# See: https://developers.google.com/gmail/markup/reference/types/ConfirmAction
|
8
|
+
class ConfirmAction < Action
|
9
|
+
|
10
|
+
attr_accessor :name, :confirmed
|
11
|
+
|
12
|
+
def serialize
|
13
|
+
super.merge(
|
14
|
+
"name" => name,
|
15
|
+
"confirmed" => confirmed&.serialize # Thing
|
16
|
+
)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Apps
|
2
|
+
module Gmail
|
3
|
+
module Schema
|
4
|
+
class EmailMessage < Base
|
5
|
+
include Schema::Concerns::PotentialAction
|
6
|
+
|
7
|
+
attr_accessor :description, :publisher
|
8
|
+
|
9
|
+
def serialize
|
10
|
+
super.merge("publisher" => publisher&.serialize) # Organization
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require_relative 'rsvp_action'
|
2
|
+
require_relative 'place'
|
3
|
+
|
4
|
+
module Apps
|
5
|
+
module Gmail
|
6
|
+
module Schema
|
7
|
+
class Event < Base
|
8
|
+
include Schema::Concerns::PotentialAction
|
9
|
+
|
10
|
+
attr_accessor :name, :start_date, :end_date, :location
|
11
|
+
|
12
|
+
def serialize
|
13
|
+
super.merge(
|
14
|
+
"name" => name,
|
15
|
+
"startDate" => start_date,
|
16
|
+
"endDate" => end_date,
|
17
|
+
"location" => location&.serialize
|
18
|
+
)
|
19
|
+
end
|
20
|
+
|
21
|
+
def build_location(**attrs)
|
22
|
+
self.location = Place.new(**attrs).tap do |place|
|
23
|
+
place.build_address unless place.address
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def build_rsvp_actions
|
28
|
+
actions.clear
|
29
|
+
|
30
|
+
%w[Yes No Maybe].map { |response| add_action_for(response) }
|
31
|
+
end
|
32
|
+
|
33
|
+
def add_action_for(response, **attrs)
|
34
|
+
RsvpAction.new(response: response, **attrs).tap do |action|
|
35
|
+
actions << action
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require_relative 'postal_address'
|
2
|
+
|
3
|
+
module Apps
|
4
|
+
module Gmail
|
5
|
+
module Schema
|
6
|
+
class ParcelDelivery < Base
|
7
|
+
include Schema::Concerns::PotentialAction
|
8
|
+
|
9
|
+
attr_accessor :delivery_address, :expected_arrival_until, :carrier_name
|
10
|
+
attr_accessor :product_name, :order_number, :merchant_name
|
11
|
+
attr_accessor :tracking_url
|
12
|
+
|
13
|
+
def serialize
|
14
|
+
super.merge(
|
15
|
+
"deliveryAddress" => delivery_address&.serialize,
|
16
|
+
"expectedArrivalUntil" => expected_arrival_until,
|
17
|
+
"carrier" => {
|
18
|
+
"@type" => "Organization",
|
19
|
+
"name" => carrier_name
|
20
|
+
},
|
21
|
+
"itemShipped" => {
|
22
|
+
"@type" => "Product",
|
23
|
+
"name" => product_name
|
24
|
+
},
|
25
|
+
"partOfOrder" => {
|
26
|
+
"@type" => "Order",
|
27
|
+
"orderNumber" => order_number,
|
28
|
+
"merchant" => {
|
29
|
+
"@type" => "Organization",
|
30
|
+
"name" => merchant_name
|
31
|
+
}
|
32
|
+
},
|
33
|
+
"trackingUrl" => tracking_url
|
34
|
+
)
|
35
|
+
end
|
36
|
+
|
37
|
+
def build_delivery_address(**attrs)
|
38
|
+
self.delivery_address = PostalAddress.new(**attrs)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require_relative 'postal_address'
|
2
|
+
|
3
|
+
module Apps
|
4
|
+
module Gmail
|
5
|
+
module Schema
|
6
|
+
class Place < Base
|
7
|
+
|
8
|
+
attr_accessor :name, :same_as, :address
|
9
|
+
|
10
|
+
def serialize
|
11
|
+
super.merge(
|
12
|
+
"sameAs" => same_as,
|
13
|
+
"name" => name,
|
14
|
+
"address" => address&.serialize
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
def build_address(**attrs)
|
19
|
+
self.address = PostalAddress.new(**attrs)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Apps
|
2
|
+
module Gmail
|
3
|
+
module Schema
|
4
|
+
class PostalAddress < Base
|
5
|
+
|
6
|
+
attr_accessor :name, :street, :locality, :region, :po_box, :postal_code, :country
|
7
|
+
|
8
|
+
def serialize
|
9
|
+
super.merge(
|
10
|
+
"name" => name,
|
11
|
+
"streetAddress" => street, # street address
|
12
|
+
"addressLocality" => locality, # city
|
13
|
+
"addressRegion" => region, # state (abbr)
|
14
|
+
"postOfficeBoxNumber" => po_box,
|
15
|
+
"postalCode" => postal_code, # zip code
|
16
|
+
"addressCountry" => country
|
17
|
+
)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require_relative 'action'
|
2
|
+
|
3
|
+
module Apps
|
4
|
+
module Gmail
|
5
|
+
module Schema
|
6
|
+
# See: https://developers.google.com/gmail/markup/reference/rsvp-action
|
7
|
+
class RsvpAction < Action
|
8
|
+
|
9
|
+
attr_accessor :response, :additional_number_of_guests, :bringing_kids, :bringing_other_people
|
10
|
+
|
11
|
+
def serialize
|
12
|
+
super.merge(
|
13
|
+
"rsvpResponse" => response.downcase,
|
14
|
+
"additionalNumberOfGuests" => additional_number_of_guests&.to_i,
|
15
|
+
"bringingKids" => bringing_kids&.to_i,
|
16
|
+
"bringingOtherPeople" => bringing_other_people&.to_i,
|
17
|
+
# "comment" => {},
|
18
|
+
# "event" => {},
|
19
|
+
"attendance" => "http://schema.org/RsvpAttendance/#{response.capitalize}"
|
20
|
+
)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require_relative 'action'
|
2
|
+
|
3
|
+
module Apps
|
4
|
+
module Gmail
|
5
|
+
module Schema
|
6
|
+
# See: https://developers.google.com/gmail/markup/reference/one-click-action
|
7
|
+
# See: https://developers.google.com/gmail/markup/reference/types/SaveAction
|
8
|
+
class SaveAction < Action
|
9
|
+
|
10
|
+
attr_accessor :name
|
11
|
+
|
12
|
+
def serialize
|
13
|
+
super.merge(
|
14
|
+
"name" => name
|
15
|
+
)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Apps
|
2
|
+
module Gmail
|
3
|
+
module Schema
|
4
|
+
# See: https://developers.google.com/gmail/markup/reference/go-to-action
|
5
|
+
# See: https://developers.google.com/gmail/markup/reference/types/TrackAction
|
6
|
+
class TrackAction < Base
|
7
|
+
|
8
|
+
attr_accessor :name, :target, :delivery_method
|
9
|
+
|
10
|
+
def serialize
|
11
|
+
super.merge(
|
12
|
+
"name" => name,
|
13
|
+
"target" => target,
|
14
|
+
"deliveryMethod" => delivery_method&.serialize # DeliveryMethod
|
15
|
+
)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Apps
|
2
|
+
module Gmail
|
3
|
+
module Schema
|
4
|
+
# See: https://developers.google.com/gmail/markup/reference/go-to-action
|
5
|
+
# See: https://developers.google.com/gmail/markup/reference/types/ViewAction
|
6
|
+
class ViewAction < Base
|
7
|
+
|
8
|
+
attr_accessor :name, :target, :viewed
|
9
|
+
|
10
|
+
def serialize
|
11
|
+
super.merge(
|
12
|
+
"name" => name,
|
13
|
+
"target" => target,
|
14
|
+
"viewed" => viewed&.serialize # Thing
|
15
|
+
)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require_relative '../common/schema'
|
2
|
+
|
3
|
+
module Apps
|
4
|
+
module Outlook
|
5
|
+
module Schema
|
6
|
+
include ::Apps::Common::Schema
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
require_relative 'schema/concerns'
|
12
|
+
require_relative 'schema/action_card'
|
13
|
+
require_relative 'schema/date_input'
|
14
|
+
require_relative 'schema/http_post'
|
15
|
+
require_relative 'schema/invoke_add_in_command'
|
16
|
+
require_relative 'schema/message_card'
|
17
|
+
require_relative 'schema/multichoice_input'
|
18
|
+
require_relative 'schema/open_uri'
|
19
|
+
require_relative 'schema/section'
|
20
|
+
require_relative 'schema/text_input'
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Apps
|
2
|
+
module Outlook
|
3
|
+
module Schema
|
4
|
+
# See: https://docs.microsoft.com/en-us/outlook/actionable-messages/card-reference#actions
|
5
|
+
class Action < Base
|
6
|
+
attr_accessor :name # Button text
|
7
|
+
|
8
|
+
def serialize
|
9
|
+
super.merge("name" => name)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require_relative 'action'
|
2
|
+
require_relative 'http_post'
|
3
|
+
require_relative 'open_uri'
|
4
|
+
|
5
|
+
module Apps
|
6
|
+
module Outlook
|
7
|
+
module Schema
|
8
|
+
# See: https://docs.microsoft.com/en-us/outlook/actionable-messages/card-reference#actioncard-action
|
9
|
+
class ActionCard < Action
|
10
|
+
ACTIONS = [
|
11
|
+
Schema::OpenUri,
|
12
|
+
Schema::HttpPOST
|
13
|
+
].freeze
|
14
|
+
|
15
|
+
def inputs
|
16
|
+
@inputs ||= []
|
17
|
+
end
|
18
|
+
|
19
|
+
# OpenUriAction and HttpPostAction allowed
|
20
|
+
def actions
|
21
|
+
@actions ||= []
|
22
|
+
end
|
23
|
+
|
24
|
+
def serialize
|
25
|
+
super.merge(
|
26
|
+
"inputs" => inputs.map(&:serialize),
|
27
|
+
"actions" => actions.select { |action| ACTIONS.include?(action.class) }.map(&:serialize)
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
31
|
+
# See: https://docs.microsoft.com/en-us/outlook/actionable-messages/card-reference#input-value-substitution
|
32
|
+
def input_value_substitutions(formatted: true)
|
33
|
+
inputs.map do |input|
|
34
|
+
key = "#{input.id}.value"
|
35
|
+
|
36
|
+
formatted ? "{{#{key}}}" : key
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require_relative '../../common/schema/concerns'
|
2
|
+
|
3
|
+
module Apps
|
4
|
+
module Outlook
|
5
|
+
module Schema
|
6
|
+
module Concerns
|
7
|
+
include ::Apps::Common::Schema::Concerns
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
require_relative 'concerns/sections'
|
14
|
+
require_relative 'concerns/sorted_potential_action'
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Apps
|
2
|
+
module Outlook
|
3
|
+
module Schema
|
4
|
+
module Concerns
|
5
|
+
module Sections
|
6
|
+
def sections
|
7
|
+
@sections ||= []
|
8
|
+
end
|
9
|
+
|
10
|
+
def serialize
|
11
|
+
if sections.any?
|
12
|
+
super.merge("sections" => sections.map(&:serialize))
|
13
|
+
else
|
14
|
+
super
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def add_section(title, **attrs)
|
19
|
+
Section.new(title: title, **attrs).tap do |section|
|
20
|
+
sections << section
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|