apologist 1.0.2

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 (137) hide show
  1. checksums.yaml +7 -0
  2. data/.fern/metadata.json +13 -0
  3. data/.fernignore +2 -0
  4. data/.rubocop.yml +108 -0
  5. data/CONTRIBUTING.md +120 -0
  6. data/README.md +169 -0
  7. data/Rakefile +20 -0
  8. data/custom.gemspec.rb +17 -0
  9. data/lib/Apologist/benchmarks/client.rb +160 -0
  10. data/lib/Apologist/benchmarks/types/benchmark_run_request.rb +39 -0
  11. data/lib/Apologist/benchmarks/types/benchmark_run_request_content.rb +16 -0
  12. data/lib/Apologist/benchmarks/types/benchmark_run_request_reasoning_effort.rb +15 -0
  13. data/lib/Apologist/benchmarks/types/benchmark_run_request_verbosity.rb +16 -0
  14. data/lib/Apologist/benchmarks/types/get_benchmark_run_request.rb +13 -0
  15. data/lib/Apologist/benchmarks/types/get_benchmark_run_response.rb +11 -0
  16. data/lib/Apologist/benchmarks/types/list_benchmark_runs_request.rb +33 -0
  17. data/lib/Apologist/benchmarks/types/list_benchmark_runs_response.rb +17 -0
  18. data/lib/Apologist/channels/client.rb +319 -0
  19. data/lib/Apologist/channels/types/get_discord_channel_status_request.rb +11 -0
  20. data/lib/Apologist/channels/types/get_discord_channel_status_response.rb +15 -0
  21. data/lib/Apologist/channels/types/get_instagram_privacy_policy_request.rb +11 -0
  22. data/lib/Apologist/channels/types/receive_discord_interaction_request.rb +17 -0
  23. data/lib/Apologist/channels/types/receive_facebook_message_request.rb +13 -0
  24. data/lib/Apologist/channels/types/receive_telegram_update_request.rb +13 -0
  25. data/lib/Apologist/channels/types/receive_twilio_message_request.rb +15 -0
  26. data/lib/Apologist/channels/types/verify_facebook_webhook_request.rb +17 -0
  27. data/lib/Apologist/channels/types/verify_facebook_webhook_request_hub_mode.rb +13 -0
  28. data/lib/Apologist/chat/client.rb +345 -0
  29. data/lib/Apologist/chat/types/feedback_request.rb +13 -0
  30. data/lib/Apologist/chat/types/flag_request.rb +13 -0
  31. data/lib/Apologist/chat/types/get_chat_completion_request.rb +11 -0
  32. data/lib/Apologist/chat/types/get_chat_completion_response.rb +11 -0
  33. data/lib/Apologist/chat/types/like_request.rb +13 -0
  34. data/lib/Apologist/chat/types/list_chat_completions_request.rb +45 -0
  35. data/lib/Apologist/chat/types/list_chat_completions_response.rb +17 -0
  36. data/lib/Apologist/chat/types/share_request.rb +17 -0
  37. data/lib/Apologist/client.rb +71 -0
  38. data/lib/Apologist/corpus/client.rb +244 -0
  39. data/lib/Apologist/corpus/types/corpus_search_request.rb +17 -0
  40. data/lib/Apologist/corpus/types/corpus_search_request_filters.rb +25 -0
  41. data/lib/Apologist/corpus/types/impression_request.rb +17 -0
  42. data/lib/Apologist/corpus/types/log_corpus_referral_redirect_request.rb +19 -0
  43. data/lib/Apologist/corpus/types/referral_request.rb +17 -0
  44. data/lib/Apologist/corpus/types/search_corpus_response.rb +11 -0
  45. data/lib/Apologist/corpus/types/view_request.rb +17 -0
  46. data/lib/Apologist/ct_as/client.rb +98 -0
  47. data/lib/Apologist/ct_as/types/cta_click_request.rb +13 -0
  48. data/lib/Apologist/ct_as/types/match_ctas_response.rb +11 -0
  49. data/lib/Apologist/environment.rb +7 -0
  50. data/lib/Apologist/errors/api_error.rb +8 -0
  51. data/lib/Apologist/errors/client_error.rb +17 -0
  52. data/lib/Apologist/errors/redirect_error.rb +8 -0
  53. data/lib/Apologist/errors/response_error.rb +42 -0
  54. data/lib/Apologist/errors/server_error.rb +11 -0
  55. data/lib/Apologist/errors/timeout_error.rb +8 -0
  56. data/lib/Apologist/evaluators/client.rb +164 -0
  57. data/lib/Apologist/evaluators/types/evaluate_content_response.rb +11 -0
  58. data/lib/Apologist/evaluators/types/evaluator_request.rb +31 -0
  59. data/lib/Apologist/evaluators/types/evaluator_request_content.rb +15 -0
  60. data/lib/Apologist/evaluators/types/evaluator_request_reasoning_effort.rb +15 -0
  61. data/lib/Apologist/evaluators/types/evaluator_request_verbosity.rb +16 -0
  62. data/lib/Apologist/evaluators/types/get_evaluation_request.rb +13 -0
  63. data/lib/Apologist/evaluators/types/get_evaluation_response.rb +11 -0
  64. data/lib/Apologist/evaluators/types/list_evaluations_request.rb +35 -0
  65. data/lib/Apologist/evaluators/types/list_evaluations_response.rb +17 -0
  66. data/lib/Apologist/internal/errors/constraint_error.rb +10 -0
  67. data/lib/Apologist/internal/errors/type_error.rb +10 -0
  68. data/lib/Apologist/internal/http/base_request.rb +51 -0
  69. data/lib/Apologist/internal/http/raw_client.rb +252 -0
  70. data/lib/Apologist/internal/iterators/cursor_item_iterator.rb +28 -0
  71. data/lib/Apologist/internal/iterators/cursor_page_iterator.rb +63 -0
  72. data/lib/Apologist/internal/iterators/item_iterator.rb +65 -0
  73. data/lib/Apologist/internal/iterators/offset_item_iterator.rb +30 -0
  74. data/lib/Apologist/internal/iterators/offset_page_iterator.rb +103 -0
  75. data/lib/Apologist/internal/json/request.rb +41 -0
  76. data/lib/Apologist/internal/json/serializable.rb +25 -0
  77. data/lib/Apologist/internal/multipart/multipart_encoder.rb +141 -0
  78. data/lib/Apologist/internal/multipart/multipart_form_data.rb +78 -0
  79. data/lib/Apologist/internal/multipart/multipart_form_data_part.rb +51 -0
  80. data/lib/Apologist/internal/multipart/multipart_request.rb +40 -0
  81. data/lib/Apologist/internal/types/array.rb +47 -0
  82. data/lib/Apologist/internal/types/boolean.rb +34 -0
  83. data/lib/Apologist/internal/types/enum.rb +56 -0
  84. data/lib/Apologist/internal/types/hash.rb +36 -0
  85. data/lib/Apologist/internal/types/model/field.rb +38 -0
  86. data/lib/Apologist/internal/types/model.rb +208 -0
  87. data/lib/Apologist/internal/types/type.rb +35 -0
  88. data/lib/Apologist/internal/types/union.rb +161 -0
  89. data/lib/Apologist/internal/types/unknown.rb +15 -0
  90. data/lib/Apologist/internal/types/utils.rb +116 -0
  91. data/lib/Apologist/internal/url_encoded/request.rb +41 -0
  92. data/lib/Apologist/shares/client.rb +52 -0
  93. data/lib/Apologist/shares/types/get_shared_messages_request.rb +11 -0
  94. data/lib/Apologist/shares/types/get_shared_messages_response.rb +11 -0
  95. data/lib/Apologist/types/chat_completion_request.rb +11 -0
  96. data/lib/Apologist/types/chat_completion_request_logprobs.rb +13 -0
  97. data/lib/Apologist/types/chat_completion_request_metadata.rb +29 -0
  98. data/lib/Apologist/types/chat_completion_request_reasoning_effort.rb +13 -0
  99. data/lib/Apologist/types/chat_completion_request_response_format.rb +11 -0
  100. data/lib/Apologist/types/chat_completion_request_response_format_json_schema.rb +17 -0
  101. data/lib/Apologist/types/chat_completion_request_response_format_type.rb +15 -0
  102. data/lib/Apologist/types/chat_completion_request_tool_choice.rb +13 -0
  103. data/lib/Apologist/types/chat_completion_request_tool_choice_zero.rb +13 -0
  104. data/lib/Apologist/types/chat_completion_request_verbosity.rb +14 -0
  105. data/lib/Apologist/types/chat_completion_response.rb +21 -0
  106. data/lib/Apologist/types/chat_completion_response_choices_item.rb +15 -0
  107. data/lib/Apologist/types/chat_completion_response_usage.rb +13 -0
  108. data/lib/Apologist/types/chat_message.rb +11 -0
  109. data/lib/Apologist/types/chat_message_role.rb +13 -0
  110. data/lib/Apologist/types/cta_match_request.rb +11 -0
  111. data/lib/Apologist/types/error.rb +11 -0
  112. data/lib/Apologist/types/success_response.rb +11 -0
  113. data/lib/Apologist/types/tag_ref.rb +11 -0
  114. data/lib/Apologist/types/user.rb +23 -0
  115. data/lib/Apologist/types/user_flag.rb +18 -0
  116. data/lib/Apologist/types/webhook_agent_ref.rb +11 -0
  117. data/lib/Apologist/types/webhook_cta.rb +13 -0
  118. data/lib/Apologist/types/webhook_evaluation.rb +14 -0
  119. data/lib/Apologist/types/webhook_event_info.rb +13 -0
  120. data/lib/Apologist/types/webhook_event_info_key.rb +28 -0
  121. data/lib/Apologist/types/webhook_named_ref.rb +11 -0
  122. data/lib/Apologist/types/webhook_notification_ref.rb +12 -0
  123. data/lib/Apologist/types/webhook_payload.rb +30 -0
  124. data/lib/Apologist/users/client.rb +193 -0
  125. data/lib/Apologist/users/types/get_user_request.rb +11 -0
  126. data/lib/Apologist/users/types/get_user_response.rb +11 -0
  127. data/lib/Apologist/users/types/list_user_flags_request.rb +13 -0
  128. data/lib/Apologist/users/types/list_user_flags_response.rb +17 -0
  129. data/lib/Apologist/users/types/list_users_request.rb +23 -0
  130. data/lib/Apologist/users/types/list_users_response.rb +17 -0
  131. data/lib/Apologist/users/types/update_user_response.rb +11 -0
  132. data/lib/Apologist/users/types/user_update_request.rb +17 -0
  133. data/lib/Apologist/users/types/user_update_request_tags_item.rb +15 -0
  134. data/lib/Apologist/version.rb +5 -0
  135. data/lib/Apologist.rb +131 -0
  136. data/reference.md +2927 -0
  137. metadata +183 -0
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Apologist
4
+ module Benchmarks
5
+ module Types
6
+ module BenchmarkRunRequestReasoningEffort
7
+ extend Apologist::Internal::Types::Enum
8
+
9
+ LOW = "low"
10
+ MEDIUM = "medium"
11
+ HIGH = "high"
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Apologist
4
+ module Benchmarks
5
+ module Types
6
+ module BenchmarkRunRequestVerbosity
7
+ extend Apologist::Internal::Types::Enum
8
+
9
+ MINIMAL = "minimal"
10
+ LOW = "low"
11
+ MEDIUM = "medium"
12
+ HIGH = "high"
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Apologist
4
+ module Benchmarks
5
+ module Types
6
+ class GetBenchmarkRunRequest < Internal::Types::Model
7
+ field :id, -> { String }, optional: false, nullable: false
8
+
9
+ field :run_id, -> { String }, optional: false, nullable: false, api_name: "runId"
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Apologist
4
+ module Benchmarks
5
+ module Types
6
+ class GetBenchmarkRunResponse < Internal::Types::Model
7
+ field :data, -> { Internal::Types::Hash[String, Object] }, optional: true, nullable: false
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Apologist
4
+ module Benchmarks
5
+ module Types
6
+ class ListBenchmarkRunsRequest < Internal::Types::Model
7
+ field :id, -> { String }, optional: false, nullable: false
8
+
9
+ field :page, -> { Integer }, optional: true, nullable: false
10
+
11
+ field :per_page, -> { Integer }, optional: true, nullable: false
12
+
13
+ field :min_timestamp, -> { String }, optional: true, nullable: false
14
+
15
+ field :max_timestamp, -> { String }, optional: true, nullable: false
16
+
17
+ field :min_duration, -> { String }, optional: true, nullable: false
18
+
19
+ field :max_duration, -> { String }, optional: true, nullable: false
20
+
21
+ field :min_score, -> { String }, optional: true, nullable: false
22
+
23
+ field :max_score, -> { String }, optional: true, nullable: false
24
+
25
+ field :passed, -> { String }, optional: true, nullable: false
26
+
27
+ field :min_responses, -> { String }, optional: true, nullable: false
28
+
29
+ field :max_responses, -> { String }, optional: true, nullable: false
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Apologist
4
+ module Benchmarks
5
+ module Types
6
+ class ListBenchmarkRunsResponse < Internal::Types::Model
7
+ field :data, -> { Internal::Types::Array[Internal::Types::Hash[String, Object]] }, optional: true, nullable: false
8
+
9
+ field :total, -> { Integer }, optional: true, nullable: false
10
+
11
+ field :page, -> { Integer }, optional: true, nullable: false
12
+
13
+ field :per_page, -> { Integer }, optional: true, nullable: false
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,319 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Apologist
4
+ module Channels
5
+ class Client
6
+ # @param client [Apologist::Internal::Http::RawClient]
7
+ #
8
+ # @return [void]
9
+ def initialize(client:)
10
+ @client = client
11
+ end
12
+
13
+ # Returns the status of the Discord channel. Used as a lightweight health/verification endpoint.
14
+ #
15
+ # @param request_options [Hash]
16
+ # @param params [Hash]
17
+ # @option request_options [String] :base_url
18
+ # @option request_options [Hash{String => Object}] :additional_headers
19
+ # @option request_options [Hash{String => Object}] :additional_query_parameters
20
+ # @option request_options [Hash{String => Object}] :additional_body_parameters
21
+ # @option request_options [Integer] :timeout_in_seconds
22
+ # @option params [String] :id
23
+ #
24
+ # @example
25
+ # client.channels.get_discord_channel_status(id: "id")
26
+ #
27
+ # @return [Apologist::Channels::Types::GetDiscordChannelStatusResponse]
28
+ def get_discord_channel_status(request_options: {}, **params)
29
+ params = Apologist::Internal::Types::Utils.normalize_keys(params)
30
+ request = Apologist::Internal::JSON::Request.new(
31
+ base_url: request_options[:base_url],
32
+ method: "GET",
33
+ path: "channels/#{URI.encode_uri_component(params[:id].to_s)}/discord",
34
+ request_options: request_options
35
+ )
36
+ begin
37
+ response = @client.send(request)
38
+ rescue Net::HTTPRequestTimeout
39
+ raise Apologist::Errors::TimeoutError
40
+ end
41
+ code = response.code.to_i
42
+ if code.between?(200, 299)
43
+ Apologist::Channels::Types::GetDiscordChannelStatusResponse.load(response.body)
44
+ else
45
+ error_class = Apologist::Errors::ResponseError.subclass_for_code(code)
46
+ raise error_class.new(response.body, code: code)
47
+ end
48
+ end
49
+
50
+ # Receives Discord interaction callbacks for the channel. Requests are verified via Ed25519 signature headers;
51
+ # unsigned or invalid requests are rejected. Payload shape is defined by Discord.
52
+ #
53
+ # @param request_options [Hash]
54
+ # @param params [Hash]
55
+ # @option request_options [String] :base_url
56
+ # @option request_options [Hash{String => Object}] :additional_headers
57
+ # @option request_options [Hash{String => Object}] :additional_query_parameters
58
+ # @option request_options [Hash{String => Object}] :additional_body_parameters
59
+ # @option request_options [Integer] :timeout_in_seconds
60
+ # @option params [String] :id
61
+ # @option params [String] :signature_ed25519
62
+ # @option params [String] :signature_timestamp
63
+ #
64
+ # @example
65
+ # client.channels.receive_discord_interaction(
66
+ # id: "id",
67
+ # signature_ed25519: "x-signature-ed25519",
68
+ # signature_timestamp: "x-signature-timestamp",
69
+ # body: {
70
+ # key: "value"
71
+ # }
72
+ # )
73
+ #
74
+ # @return [untyped]
75
+ def receive_discord_interaction(request_options: {}, **params)
76
+ params = Apologist::Internal::Types::Utils.normalize_keys(params)
77
+ path_param_names = %i[id]
78
+ body_params = params.except(*path_param_names)
79
+
80
+ headers = {}
81
+ headers["x-signature-ed25519"] = params[:signature_ed25519] if params[:signature_ed25519]
82
+ headers["x-signature-timestamp"] = params[:signature_timestamp] if params[:signature_timestamp]
83
+
84
+ request = Apologist::Internal::JSON::Request.new(
85
+ base_url: request_options[:base_url],
86
+ method: "POST",
87
+ path: "channels/#{URI.encode_uri_component(params[:id].to_s)}/discord",
88
+ headers: headers,
89
+ body: body_params,
90
+ request_options: request_options
91
+ )
92
+ begin
93
+ response = @client.send(request)
94
+ rescue Net::HTTPRequestTimeout
95
+ raise Apologist::Errors::TimeoutError
96
+ end
97
+ code = response.code.to_i
98
+ return if code.between?(200, 299)
99
+
100
+ error_class = Apologist::Errors::ResponseError.subclass_for_code(code)
101
+ raise error_class.new(response.body, code: code)
102
+ end
103
+
104
+ # Handles the Meta webhook verification handshake, echoing `hub.challenge` when `hub.verify_token` matches the
105
+ # channel's configured token.
106
+ #
107
+ # @param request_options [Hash]
108
+ # @param params [Hash]
109
+ # @option request_options [String] :base_url
110
+ # @option request_options [Hash{String => Object}] :additional_headers
111
+ # @option request_options [Hash{String => Object}] :additional_query_parameters
112
+ # @option request_options [Hash{String => Object}] :additional_body_parameters
113
+ # @option request_options [Integer] :timeout_in_seconds
114
+ # @option params [String] :id
115
+ # @option params [Apologist::Channels::Types::VerifyFacebookWebhookRequestHubMode] :hub_mode
116
+ # @option params [String] :hub_verify_token
117
+ # @option params [String, nil] :hub_challenge
118
+ #
119
+ # @example
120
+ # client.channels.verify_facebook_webhook(
121
+ # id: "id",
122
+ # hub_mode: "subscribe",
123
+ # hub_verify_token: "hub.verify_token"
124
+ # )
125
+ #
126
+ # @return [String]
127
+ def verify_facebook_webhook(request_options: {}, **params)
128
+ params = Apologist::Internal::Types::Utils.normalize_keys(params)
129
+ query_params = {}
130
+ query_params["hub.mode"] = params[:hub_mode] if params.key?(:hub_mode)
131
+ query_params["hub.verify_token"] = params[:hub_verify_token] if params.key?(:hub_verify_token)
132
+ query_params["hub.challenge"] = params[:hub_challenge] if params.key?(:hub_challenge)
133
+
134
+ request = Apologist::Internal::JSON::Request.new(
135
+ base_url: request_options[:base_url],
136
+ method: "GET",
137
+ path: "channels/#{URI.encode_uri_component(params[:id].to_s)}/facebook",
138
+ query: query_params,
139
+ request_options: request_options
140
+ )
141
+ begin
142
+ response = @client.send(request)
143
+ rescue Net::HTTPRequestTimeout
144
+ raise Apologist::Errors::TimeoutError
145
+ end
146
+ code = response.code.to_i
147
+ return if code.between?(200, 299)
148
+
149
+ error_class = Apologist::Errors::ResponseError.subclass_for_code(code)
150
+ raise error_class.new(response.body, code: code)
151
+ end
152
+
153
+ # Receives Facebook/Messenger (and Instagram-style) message events for the channel. Payload shape is defined by
154
+ # Meta.
155
+ #
156
+ # @param request_options [Hash]
157
+ # @param params [Hash]
158
+ # @option request_options [String] :base_url
159
+ # @option request_options [Hash{String => Object}] :additional_headers
160
+ # @option request_options [Hash{String => Object}] :additional_query_parameters
161
+ # @option request_options [Hash{String => Object}] :additional_body_parameters
162
+ # @option request_options [Integer] :timeout_in_seconds
163
+ # @option params [String] :id
164
+ #
165
+ # @example
166
+ # client.channels.receive_facebook_message(
167
+ # id: "id",
168
+ # body: {
169
+ # key: "value"
170
+ # }
171
+ # )
172
+ #
173
+ # @return [untyped]
174
+ def receive_facebook_message(request_options: {}, **params)
175
+ params = Apologist::Internal::Types::Utils.normalize_keys(params)
176
+ path_param_names = %i[id]
177
+ body_params = params.except(*path_param_names)
178
+
179
+ request = Apologist::Internal::JSON::Request.new(
180
+ base_url: request_options[:base_url],
181
+ method: "POST",
182
+ path: "channels/#{URI.encode_uri_component(params[:id].to_s)}/facebook",
183
+ body: body_params,
184
+ request_options: request_options
185
+ )
186
+ begin
187
+ response = @client.send(request)
188
+ rescue Net::HTTPRequestTimeout
189
+ raise Apologist::Errors::TimeoutError
190
+ end
191
+ code = response.code.to_i
192
+ return if code.between?(200, 299)
193
+
194
+ error_class = Apologist::Errors::ResponseError.subclass_for_code(code)
195
+ raise error_class.new(response.body, code: code)
196
+ end
197
+
198
+ # Returns a static HTML privacy policy page for the Instagram integration.
199
+ #
200
+ # @param request_options [Hash]
201
+ # @param params [Hash]
202
+ # @option request_options [String] :base_url
203
+ # @option request_options [Hash{String => Object}] :additional_headers
204
+ # @option request_options [Hash{String => Object}] :additional_query_parameters
205
+ # @option request_options [Hash{String => Object}] :additional_body_parameters
206
+ # @option request_options [Integer] :timeout_in_seconds
207
+ # @option params [String] :id
208
+ #
209
+ # @example
210
+ # client.channels.get_instagram_privacy_policy(id: "id")
211
+ #
212
+ # @return [String]
213
+ def get_instagram_privacy_policy(request_options: {}, **params)
214
+ params = Apologist::Internal::Types::Utils.normalize_keys(params)
215
+ request = Apologist::Internal::JSON::Request.new(
216
+ base_url: request_options[:base_url],
217
+ method: "GET",
218
+ path: "channels/#{URI.encode_uri_component(params[:id].to_s)}/instagram/privacy",
219
+ request_options: request_options
220
+ )
221
+ begin
222
+ response = @client.send(request)
223
+ rescue Net::HTTPRequestTimeout
224
+ raise Apologist::Errors::TimeoutError
225
+ end
226
+ code = response.code.to_i
227
+ return if code.between?(200, 299)
228
+
229
+ error_class = Apologist::Errors::ResponseError.subclass_for_code(code)
230
+ raise error_class.new(response.body, code: code)
231
+ end
232
+
233
+ # Receives Telegram bot update events for the channel. Non-message updates are acknowledged and ignored. Payload
234
+ # shape is defined by Telegram.
235
+ #
236
+ # @param request_options [Hash]
237
+ # @param params [Hash]
238
+ # @option request_options [String] :base_url
239
+ # @option request_options [Hash{String => Object}] :additional_headers
240
+ # @option request_options [Hash{String => Object}] :additional_query_parameters
241
+ # @option request_options [Hash{String => Object}] :additional_body_parameters
242
+ # @option request_options [Integer] :timeout_in_seconds
243
+ # @option params [String] :id
244
+ #
245
+ # @example
246
+ # client.channels.receive_telegram_update(
247
+ # id: "id",
248
+ # body: {
249
+ # key: "value"
250
+ # }
251
+ # )
252
+ #
253
+ # @return [untyped]
254
+ def receive_telegram_update(request_options: {}, **params)
255
+ params = Apologist::Internal::Types::Utils.normalize_keys(params)
256
+ path_param_names = %i[id]
257
+ body_params = params.except(*path_param_names)
258
+
259
+ request = Apologist::Internal::JSON::Request.new(
260
+ base_url: request_options[:base_url],
261
+ method: "POST",
262
+ path: "channels/#{URI.encode_uri_component(params[:id].to_s)}/telegram",
263
+ body: body_params,
264
+ request_options: request_options
265
+ )
266
+ begin
267
+ response = @client.send(request)
268
+ rescue Net::HTTPRequestTimeout
269
+ raise Apologist::Errors::TimeoutError
270
+ end
271
+ code = response.code.to_i
272
+ return if code.between?(200, 299)
273
+
274
+ error_class = Apologist::Errors::ResponseError.subclass_for_code(code)
275
+ raise error_class.new(response.body, code: code)
276
+ end
277
+
278
+ # Receives inbound Twilio messages for the channel as form-encoded data. Payload fields are defined by Twilio.
279
+ #
280
+ # @param request_options [Hash]
281
+ # @param params [Apologist::Channels::Types::ReceiveTwilioMessageRequest]
282
+ # @option request_options [String] :base_url
283
+ # @option request_options [Hash{String => Object}] :additional_headers
284
+ # @option request_options [Hash{String => Object}] :additional_query_parameters
285
+ # @option request_options [Hash{String => Object}] :additional_body_parameters
286
+ # @option request_options [Integer] :timeout_in_seconds
287
+ # @option params [String] :id
288
+ #
289
+ # @example
290
+ # client.channels.receive_twilio_message(id: "id")
291
+ #
292
+ # @return [untyped]
293
+ def receive_twilio_message(request_options: {}, **params)
294
+ params = Apologist::Internal::Types::Utils.normalize_keys(params)
295
+ request_data = Apologist::Channels::Types::ReceiveTwilioMessageRequest.new(params).to_h
296
+ non_body_param_names = %w[id]
297
+ body = request_data.except(*non_body_param_names)
298
+
299
+ request = Apologist::Internal::UrlEncoded::Request.new(
300
+ base_url: request_options[:base_url],
301
+ method: "POST",
302
+ path: "channels/#{URI.encode_uri_component(params[:id].to_s)}/twilio",
303
+ body: body,
304
+ request_options: request_options
305
+ )
306
+ begin
307
+ response = @client.send(request)
308
+ rescue Net::HTTPRequestTimeout
309
+ raise Apologist::Errors::TimeoutError
310
+ end
311
+ code = response.code.to_i
312
+ return if code.between?(200, 299)
313
+
314
+ error_class = Apologist::Errors::ResponseError.subclass_for_code(code)
315
+ raise error_class.new(response.body, code: code)
316
+ end
317
+ end
318
+ end
319
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Apologist
4
+ module Channels
5
+ module Types
6
+ class GetDiscordChannelStatusRequest < Internal::Types::Model
7
+ field :id, -> { String }, optional: false, nullable: false
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Apologist
4
+ module Channels
5
+ module Types
6
+ class GetDiscordChannelStatusResponse < Internal::Types::Model
7
+ field :status, -> { String }, optional: true, nullable: false
8
+
9
+ field :channel, -> { String }, optional: true, nullable: false
10
+
11
+ field :active, -> { Internal::Types::Boolean }, optional: true, nullable: false
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Apologist
4
+ module Channels
5
+ module Types
6
+ class GetInstagramPrivacyPolicyRequest < Internal::Types::Model
7
+ field :id, -> { String }, optional: false, nullable: false
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Apologist
4
+ module Channels
5
+ module Types
6
+ class ReceiveDiscordInteractionRequest < Internal::Types::Model
7
+ field :id, -> { String }, optional: false, nullable: false
8
+
9
+ field :signature_ed25519, -> { String }, optional: false, nullable: false, api_name: "x-signature-ed25519"
10
+
11
+ field :signature_timestamp, -> { String }, optional: false, nullable: false, api_name: "x-signature-timestamp"
12
+
13
+ field :body, -> { Internal::Types::Hash[String, Object] }, optional: false, nullable: false
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Apologist
4
+ module Channels
5
+ module Types
6
+ class ReceiveFacebookMessageRequest < Internal::Types::Model
7
+ field :id, -> { String }, optional: false, nullable: false
8
+
9
+ field :body, -> { Internal::Types::Hash[String, Object] }, optional: false, nullable: false
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Apologist
4
+ module Channels
5
+ module Types
6
+ class ReceiveTelegramUpdateRequest < Internal::Types::Model
7
+ field :id, -> { String }, optional: false, nullable: false
8
+
9
+ field :body, -> { Internal::Types::Hash[String, Object] }, optional: false, nullable: false
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Apologist
4
+ module Channels
5
+ module Types
6
+ class ReceiveTwilioMessageRequest < Internal::Types::Model
7
+ field :id, -> { String }, optional: false, nullable: false
8
+
9
+ field :from, -> { String }, optional: true, nullable: false, api_name: "From"
10
+
11
+ field :body, -> { String }, optional: true, nullable: false, api_name: "Body"
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Apologist
4
+ module Channels
5
+ module Types
6
+ class VerifyFacebookWebhookRequest < Internal::Types::Model
7
+ field :id, -> { String }, optional: false, nullable: false
8
+
9
+ field :hub_mode, -> { Apologist::Channels::Types::VerifyFacebookWebhookRequestHubMode }, optional: false, nullable: false, api_name: "hub.mode"
10
+
11
+ field :hub_verify_token, -> { String }, optional: false, nullable: false, api_name: "hub.verify_token"
12
+
13
+ field :hub_challenge, -> { String }, optional: true, nullable: false, api_name: "hub.challenge"
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Apologist
4
+ module Channels
5
+ module Types
6
+ module VerifyFacebookWebhookRequestHubMode
7
+ extend Apologist::Internal::Types::Enum
8
+
9
+ SUBSCRIBE = "subscribe"
10
+ end
11
+ end
12
+ end
13
+ end