telegram-bot-ruby 2.4.0 → 2.5.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.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +19 -0
  3. data/CHANGELOG.md +7 -0
  4. data/lib/telegram/bot/api/endpoints.rb +102 -62
  5. data/lib/telegram/bot/types/accepted_gift_types.rb +14 -0
  6. data/lib/telegram/bot/types/business_bot_rights.rb +24 -0
  7. data/lib/telegram/bot/types/business_connection.rb +1 -1
  8. data/lib/telegram/bot/types/chat.rb +1 -0
  9. data/lib/telegram/bot/types/chat_administrator_rights.rb +1 -0
  10. data/lib/telegram/bot/types/chat_full_info.rb +3 -1
  11. data/lib/telegram/bot/types/chat_member_administrator.rb +1 -0
  12. data/lib/telegram/bot/types/checklist.rb +15 -0
  13. data/lib/telegram/bot/types/checklist_task.rb +15 -0
  14. data/lib/telegram/bot/types/checklist_tasks_added.rb +12 -0
  15. data/lib/telegram/bot/types/checklist_tasks_done.rb +13 -0
  16. data/lib/telegram/bot/types/direct_message_price_changed.rb +12 -0
  17. data/lib/telegram/bot/types/direct_messages_topic.rb +12 -0
  18. data/lib/telegram/bot/types/external_reply_info.rb +1 -0
  19. data/lib/telegram/bot/types/gift.rb +1 -0
  20. data/lib/telegram/bot/types/gift_info.rb +18 -0
  21. data/lib/telegram/bot/types/input_checklist.rb +16 -0
  22. data/lib/telegram/bot/types/input_checklist_task.rb +14 -0
  23. data/lib/telegram/bot/types/input_file.rb +10 -0
  24. data/lib/telegram/bot/types/input_profile_photo.rb +15 -0
  25. data/lib/telegram/bot/types/input_profile_photo_animated.rb +13 -0
  26. data/lib/telegram/bot/types/input_profile_photo_static.rb +12 -0
  27. data/lib/telegram/bot/types/input_story_content.rb +15 -0
  28. data/lib/telegram/bot/types/input_story_content_photo.rb +12 -0
  29. data/lib/telegram/bot/types/input_story_content_video.rb +15 -0
  30. data/lib/telegram/bot/types/location_address.rb +14 -0
  31. data/lib/telegram/bot/types/message.rb +17 -0
  32. data/lib/telegram/bot/types/owned_gift.rb +15 -0
  33. data/lib/telegram/bot/types/owned_gift_regular.rb +23 -0
  34. data/lib/telegram/bot/types/owned_gift_unique.rb +19 -0
  35. data/lib/telegram/bot/types/owned_gifts.rb +13 -0
  36. data/lib/telegram/bot/types/paid_message_price_changed.rb +11 -0
  37. data/lib/telegram/bot/types/reply_parameters.rb +1 -0
  38. data/lib/telegram/bot/types/star_amount.rb +12 -0
  39. data/lib/telegram/bot/types/story_area.rb +12 -0
  40. data/lib/telegram/bot/types/story_area_position.rb +16 -0
  41. data/lib/telegram/bot/types/story_area_type.rb +18 -0
  42. data/lib/telegram/bot/types/story_area_type_link.rb +12 -0
  43. data/lib/telegram/bot/types/story_area_type_location.rb +14 -0
  44. data/lib/telegram/bot/types/story_area_type_suggested_reaction.rb +14 -0
  45. data/lib/telegram/bot/types/story_area_type_unique_gift.rb +12 -0
  46. data/lib/telegram/bot/types/story_area_type_weather.rb +14 -0
  47. data/lib/telegram/bot/types/suggested_post_approval_failed.rb +12 -0
  48. data/lib/telegram/bot/types/suggested_post_approved.rb +13 -0
  49. data/lib/telegram/bot/types/suggested_post_declined.rb +12 -0
  50. data/lib/telegram/bot/types/suggested_post_info.rb +13 -0
  51. data/lib/telegram/bot/types/suggested_post_paid.rb +14 -0
  52. data/lib/telegram/bot/types/suggested_post_parameters.rb +12 -0
  53. data/lib/telegram/bot/types/suggested_post_price.rb +12 -0
  54. data/lib/telegram/bot/types/suggested_post_refunded.rb +12 -0
  55. data/lib/telegram/bot/types/transaction_partner_user.rb +2 -0
  56. data/lib/telegram/bot/types/unique_gift.rb +17 -0
  57. data/lib/telegram/bot/types/unique_gift_backdrop.rb +13 -0
  58. data/lib/telegram/bot/types/unique_gift_backdrop_colors.rb +14 -0
  59. data/lib/telegram/bot/types/unique_gift_info.rb +16 -0
  60. data/lib/telegram/bot/types/unique_gift_model.rb +13 -0
  61. data/lib/telegram/bot/types/unique_gift_symbol.rb +13 -0
  62. data/lib/telegram/bot/version.rb +1 -1
  63. data/rakelib/builders/endpoints_builder.rb +51 -0
  64. data/rakelib/builders/type_builder.rb +140 -0
  65. data/rakelib/parse.rake +31 -0
  66. data/rakelib/parsers/methods_parser.rb +115 -0
  67. data/rakelib/parsers/types_parser.rb +273 -0
  68. data/rakelib/rebuild.rake +30 -0
  69. data/rakelib/templates/endpoints.erb +13 -0
  70. metadata +57 -9
  71. data/rakelib/parse_schema.rake +0 -73
  72. data/rakelib/rebuild_types.rake +0 -90
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telegram
4
+ module Bot
5
+ module Types
6
+ class LocationAddress < Base
7
+ attribute :country_code, Types::String
8
+ attribute? :state, Types::String
9
+ attribute? :city, Types::String
10
+ attribute? :street, Types::String
11
+ end
12
+ end
13
+ end
14
+ end
@@ -6,6 +6,7 @@ module Telegram
6
6
  class Message < Base
7
7
  attribute :message_id, Types::Integer
8
8
  attribute? :message_thread_id, Types::Integer
9
+ attribute? :direct_messages_topic, DirectMessagesTopic
9
10
  attribute? :from, User
10
11
  attribute? :sender_chat, Chat
11
12
  attribute? :sender_boost_count, Types::Integer
@@ -20,15 +21,19 @@ module Telegram
20
21
  attribute? :external_reply, ExternalReplyInfo
21
22
  attribute? :quote, TextQuote
22
23
  attribute? :reply_to_story, Story
24
+ attribute? :reply_to_checklist_task_id, Types::Integer
23
25
  attribute? :via_bot, User
24
26
  attribute? :edit_date, Types::Integer
25
27
  attribute? :has_protected_content, Types::True
26
28
  attribute? :is_from_offline, Types::True
29
+ attribute? :is_paid_post, Types::True
27
30
  attribute? :media_group_id, Types::String
28
31
  attribute? :author_signature, Types::String
32
+ attribute? :paid_star_count, Types::Integer
29
33
  attribute? :text, Types::String
30
34
  attribute? :entities, Types::Array.of(MessageEntity)
31
35
  attribute? :link_preview_options, LinkPreviewOptions
36
+ attribute? :suggested_post_info, SuggestedPostInfo
32
37
  attribute? :effect_id, Types::String
33
38
  attribute? :animation, Animation
34
39
  attribute? :audio, Audio
@@ -44,6 +49,7 @@ module Telegram
44
49
  attribute? :caption_entities, Types::Array.of(MessageEntity)
45
50
  attribute? :show_caption_above_media, Types::True
46
51
  attribute? :has_media_spoiler, Types::True
52
+ attribute? :checklist, Checklist
47
53
  attribute? :contact, Contact
48
54
  attribute? :dice, Dice
49
55
  attribute? :game, Game
@@ -67,12 +73,17 @@ module Telegram
67
73
  attribute? :refunded_payment, RefundedPayment
68
74
  attribute? :users_shared, UsersShared
69
75
  attribute? :chat_shared, ChatShared
76
+ attribute? :gift, GiftInfo
77
+ attribute? :unique_gift, UniqueGiftInfo
70
78
  attribute? :connected_website, Types::String
71
79
  attribute? :write_access_allowed, WriteAccessAllowed
72
80
  attribute? :passport_data, PassportData
73
81
  attribute? :proximity_alert_triggered, ProximityAlertTriggered
74
82
  attribute? :boost_added, ChatBoostAdded
75
83
  attribute? :chat_background_set, ChatBackground
84
+ attribute? :checklist_tasks_done, ChecklistTasksDone
85
+ attribute? :checklist_tasks_added, ChecklistTasksAdded
86
+ attribute? :direct_message_price_changed, DirectMessagePriceChanged
76
87
  attribute? :forum_topic_created, ForumTopicCreated
77
88
  attribute? :forum_topic_edited, ForumTopicEdited
78
89
  attribute? :forum_topic_closed, ForumTopicClosed
@@ -83,6 +94,12 @@ module Telegram
83
94
  attribute? :giveaway, Giveaway
84
95
  attribute? :giveaway_winners, GiveawayWinners
85
96
  attribute? :giveaway_completed, GiveawayCompleted
97
+ attribute? :paid_message_price_changed, PaidMessagePriceChanged
98
+ attribute? :suggested_post_approved, SuggestedPostApproved
99
+ attribute? :suggested_post_approval_failed, SuggestedPostApprovalFailed
100
+ attribute? :suggested_post_declined, SuggestedPostDeclined
101
+ attribute? :suggested_post_paid, SuggestedPostPaid
102
+ attribute? :suggested_post_refunded, SuggestedPostRefunded
86
103
  attribute? :video_chat_scheduled, VideoChatScheduled
87
104
  attribute? :video_chat_started, VideoChatStarted
88
105
  attribute? :video_chat_ended, VideoChatEnded
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telegram
4
+ module Bot
5
+ module Types
6
+ ## Just for classes consistency
7
+ # rubocop:disable Naming/ConstantName
8
+ OwnedGift = (
9
+ OwnedGiftRegular |
10
+ OwnedGiftUnique
11
+ )
12
+ # rubocop:enable Naming/ConstantName
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telegram
4
+ module Bot
5
+ module Types
6
+ class OwnedGiftRegular < Base
7
+ attribute :type, Types::String.constrained(eql: 'regular').default('regular')
8
+ attribute :gift, Gift
9
+ attribute? :owned_gift_id, Types::String
10
+ attribute? :sender_user, User
11
+ attribute :send_date, Types::Integer
12
+ attribute? :text, Types::String
13
+ attribute? :entities, Types::Array.of(MessageEntity)
14
+ attribute? :is_private, Types::True
15
+ attribute? :is_saved, Types::True
16
+ attribute? :can_be_upgraded, Types::True
17
+ attribute? :was_refunded, Types::True
18
+ attribute? :convert_star_count, Types::Integer
19
+ attribute? :prepaid_upgrade_star_count, Types::Integer
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telegram
4
+ module Bot
5
+ module Types
6
+ class OwnedGiftUnique < Base
7
+ attribute :type, Types::String.constrained(eql: 'unique').default('unique')
8
+ attribute :gift, UniqueGift
9
+ attribute? :owned_gift_id, Types::String
10
+ attribute? :sender_user, User
11
+ attribute :send_date, Types::Integer
12
+ attribute? :is_saved, Types::True
13
+ attribute? :can_be_transferred, Types::True
14
+ attribute? :transfer_star_count, Types::Integer
15
+ attribute? :next_transfer_date, Types::Integer
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telegram
4
+ module Bot
5
+ module Types
6
+ class OwnedGifts < Base
7
+ attribute :total_count, Types::Integer
8
+ attribute :gifts, Types::Array.of(OwnedGift)
9
+ attribute? :next_offset, Types::String
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telegram
4
+ module Bot
5
+ module Types
6
+ class PaidMessagePriceChanged < Base
7
+ attribute :paid_message_star_count, Types::Integer
8
+ end
9
+ end
10
+ end
11
+ end
@@ -11,6 +11,7 @@ module Telegram
11
11
  attribute? :quote_parse_mode, Types::String
12
12
  attribute? :quote_entities, Types::Array.of(MessageEntity)
13
13
  attribute? :quote_position, Types::Integer
14
+ attribute? :checklist_task_id, Types::Integer
14
15
  end
15
16
  end
16
17
  end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telegram
4
+ module Bot
5
+ module Types
6
+ class StarAmount < Base
7
+ attribute :amount, Types::Integer
8
+ attribute? :nanostar_amount, Types::Integer
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telegram
4
+ module Bot
5
+ module Types
6
+ class StoryArea < Base
7
+ attribute :position, StoryAreaPosition
8
+ attribute :type, StoryAreaType
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telegram
4
+ module Bot
5
+ module Types
6
+ class StoryAreaPosition < Base
7
+ attribute :x_percentage, Types::Float
8
+ attribute :y_percentage, Types::Float
9
+ attribute :width_percentage, Types::Float
10
+ attribute :height_percentage, Types::Float
11
+ attribute :rotation_angle, Types::Float
12
+ attribute :corner_radius_percentage, Types::Float
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telegram
4
+ module Bot
5
+ module Types
6
+ ## Just for classes consistency
7
+ # rubocop:disable Naming/ConstantName
8
+ StoryAreaType = (
9
+ StoryAreaTypeLocation |
10
+ StoryAreaTypeSuggestedReaction |
11
+ StoryAreaTypeLink |
12
+ StoryAreaTypeWeather |
13
+ StoryAreaTypeUniqueGift
14
+ )
15
+ # rubocop:enable Naming/ConstantName
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telegram
4
+ module Bot
5
+ module Types
6
+ class StoryAreaTypeLink < Base
7
+ attribute :type, Types::String.constrained(eql: 'link').default('link')
8
+ attribute :url, Types::String
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telegram
4
+ module Bot
5
+ module Types
6
+ class StoryAreaTypeLocation < Base
7
+ attribute :type, Types::String.constrained(eql: 'location').default('location')
8
+ attribute :latitude, Types::Float
9
+ attribute :longitude, Types::Float
10
+ attribute? :address, LocationAddress
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telegram
4
+ module Bot
5
+ module Types
6
+ class StoryAreaTypeSuggestedReaction < Base
7
+ attribute :type, Types::String.constrained(eql: 'suggested_reaction').default('suggested_reaction')
8
+ attribute :reaction_type, ReactionType
9
+ attribute? :is_dark, Types::Bool
10
+ attribute? :is_flipped, Types::Bool
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telegram
4
+ module Bot
5
+ module Types
6
+ class StoryAreaTypeUniqueGift < Base
7
+ attribute :type, Types::String.constrained(eql: 'unique_gift').default('unique_gift')
8
+ attribute :name, Types::String
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telegram
4
+ module Bot
5
+ module Types
6
+ class StoryAreaTypeWeather < Base
7
+ attribute :type, Types::String.constrained(eql: 'weather').default('weather')
8
+ attribute :temperature, Types::Float
9
+ attribute :emoji, Types::String
10
+ attribute :background_color, Types::Integer
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telegram
4
+ module Bot
5
+ module Types
6
+ class SuggestedPostApprovalFailed < Base
7
+ attribute? :suggested_post_message, Message
8
+ attribute :price, SuggestedPostPrice
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telegram
4
+ module Bot
5
+ module Types
6
+ class SuggestedPostApproved < Base
7
+ attribute? :suggested_post_message, Message
8
+ attribute? :price, SuggestedPostPrice
9
+ attribute :send_date, Types::Integer
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telegram
4
+ module Bot
5
+ module Types
6
+ class SuggestedPostDeclined < Base
7
+ attribute? :suggested_post_message, Message
8
+ attribute? :comment, Types::String
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telegram
4
+ module Bot
5
+ module Types
6
+ class SuggestedPostInfo < Base
7
+ attribute :state, Types::String
8
+ attribute? :price, SuggestedPostPrice
9
+ attribute? :send_date, Types::Integer
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telegram
4
+ module Bot
5
+ module Types
6
+ class SuggestedPostPaid < Base
7
+ attribute? :suggested_post_message, Message
8
+ attribute :currency, Types::String
9
+ attribute? :amount, Types::Integer
10
+ attribute? :star_amount, StarAmount
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telegram
4
+ module Bot
5
+ module Types
6
+ class SuggestedPostParameters < Base
7
+ attribute? :price, SuggestedPostPrice
8
+ attribute? :send_date, Types::Integer
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telegram
4
+ module Bot
5
+ module Types
6
+ class SuggestedPostPrice < Base
7
+ attribute :currency, Types::String
8
+ attribute :amount, Types::Integer.constrained(min_size: 5, max_size: 100_000)
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telegram
4
+ module Bot
5
+ module Types
6
+ class SuggestedPostRefunded < Base
7
+ attribute? :suggested_post_message, Message
8
+ attribute :reason, Types::String
9
+ end
10
+ end
11
+ end
12
+ end
@@ -5,6 +5,7 @@ module Telegram
5
5
  module Types
6
6
  class TransactionPartnerUser < Base
7
7
  attribute :type, Types::String.constrained(eql: 'user').default('user')
8
+ attribute :transaction_type, Types::String
8
9
  attribute :user, User
9
10
  attribute? :affiliate, AffiliateInfo
10
11
  attribute? :invoice_payload, Types::String
@@ -12,6 +13,7 @@ module Telegram
12
13
  attribute? :paid_media, Types::Array.of(PaidMedia)
13
14
  attribute? :paid_media_payload, Types::String
14
15
  attribute? :gift, Gift
16
+ attribute? :premium_subscription_duration, Types::Integer
15
17
  end
16
18
  end
17
19
  end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telegram
4
+ module Bot
5
+ module Types
6
+ class UniqueGift < Base
7
+ attribute :base_name, Types::String
8
+ attribute :name, Types::String
9
+ attribute :number, Types::Integer
10
+ attribute :model, UniqueGiftModel
11
+ attribute :symbol, UniqueGiftSymbol
12
+ attribute :backdrop, UniqueGiftBackdrop
13
+ attribute? :publisher_chat, Chat
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telegram
4
+ module Bot
5
+ module Types
6
+ class UniqueGiftBackdrop < Base
7
+ attribute :name, Types::String
8
+ attribute :colors, UniqueGiftBackdropColors
9
+ attribute :rarity_per_mille, Types::Integer
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telegram
4
+ module Bot
5
+ module Types
6
+ class UniqueGiftBackdropColors < Base
7
+ attribute :center_color, Types::Integer
8
+ attribute :edge_color, Types::Integer
9
+ attribute :symbol_color, Types::Integer
10
+ attribute :text_color, Types::Integer
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telegram
4
+ module Bot
5
+ module Types
6
+ class UniqueGiftInfo < Base
7
+ attribute :gift, UniqueGift
8
+ attribute :origin, Types::String
9
+ attribute? :last_resale_star_count, Types::Integer
10
+ attribute? :owned_gift_id, Types::String
11
+ attribute? :transfer_star_count, Types::Integer
12
+ attribute? :next_transfer_date, Types::Integer
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telegram
4
+ module Bot
5
+ module Types
6
+ class UniqueGiftModel < Base
7
+ attribute :name, Types::String
8
+ attribute :sticker, Sticker
9
+ attribute :rarity_per_mille, Types::Integer
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telegram
4
+ module Bot
5
+ module Types
6
+ class UniqueGiftSymbol < Base
7
+ attribute :name, Types::String
8
+ attribute :sticker, Sticker
9
+ attribute :rarity_per_mille, Types::Integer
10
+ end
11
+ end
12
+ end
13
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Telegram
4
4
  module Bot
5
- VERSION = '2.4.0'
5
+ VERSION = '2.5.0'
6
6
  end
7
7
  end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'erb'
4
+
5
+ module Builders
6
+ class EndpointsBuilder
7
+ attr_reader :methods, :templates_dir
8
+
9
+ def initialize(methods, templates_dir:)
10
+ @methods = methods.transform_values { |type| convert_to_types_format(type) }
11
+ @templates_dir = templates_dir
12
+ end
13
+
14
+ def build
15
+ template_path = File.join(templates_dir, 'endpoints.erb')
16
+ template = ERB.new(File.read(template_path), trim_mode: '-')
17
+
18
+ b = binding
19
+ b.local_variable_set(:methods, methods)
20
+
21
+ template.result(b)
22
+ end
23
+
24
+ private
25
+
26
+ def convert_to_types_format(type)
27
+ return convert_union_type(type) if type.include?(' | ')
28
+
29
+ convert_single_type(type)
30
+ end
31
+
32
+ def convert_union_type(type)
33
+ type.split(' | ').map { |t| convert_to_types_format(t.strip) }.join(' | ')
34
+ end
35
+
36
+ def convert_single_type(type)
37
+ return convert_array_type(type) if type.start_with?('Array<')
38
+
39
+ convert_primitive_type(type)
40
+ end
41
+
42
+ def convert_array_type(type)
43
+ inner_type = type.match(/Array<(.+)>/)[1]
44
+ "Types::Array.of(#{convert_to_types_format(inner_type)})"
45
+ end
46
+
47
+ def convert_primitive_type(type)
48
+ type == 'Boolean' ? 'Types::Bool' : "Types::#{type}"
49
+ end
50
+ end
51
+ end