apologist 1.1.0 → 1.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 76803053a1ad437bb60fa57feb7a40ae4b94f951f8045ff06af98f95f36bc783
4
- data.tar.gz: '09b14123c5775032a9d6ad4aa93cef811bf9e713c5abbddf773a23e60ce189eb'
3
+ metadata.gz: b1054cde9bf35ff84eb9672032b3bc21a3a2d93c111138167b108f7f4e219b7b
4
+ data.tar.gz: 7262128610497fd136753b775897bad16ff01b12efb110f4d10d202960c65aea
5
5
  SHA512:
6
- metadata.gz: 022d955a4414294dae0aacafd2e9a6f1f123c2b998c6fd584e6e100e7aa19aff871e5a799448d521aa510c35d4493bf6eb3f8356592e0b091fa0b652c0114f92
7
- data.tar.gz: 293d9d182ba7c19f626a07c7416a926e86524886313ce74f75d7f779eeaac85ec3c702cdbe359c92832825bc920601ea97d0dad542405485da0c2916d2eb682a
6
+ metadata.gz: 2b3d743543ab94eeded1ba0399c818ce58e08eed41c390516e4a17a1dd5a4ada418f8c488fc96f1592b9bf1e6cde25fe5065ea8e228884829c79596bebe9a639
7
+ data.tar.gz: bb9a18913196ec863ef888a65ed601c52629cd4d2b2acc011d26e64547b7cf144f94c3f371a1e996c2e1f731542d382fe0651676295af6e70dcdd1a15a4005c3
data/.fern/metadata.json CHANGED
@@ -6,9 +6,9 @@
6
6
  "moduleName": "Apologist",
7
7
  "clientModuleName": "AgentClient"
8
8
  },
9
- "originGitCommit": "b34e9073b4d563508b6a9eab41f15e10ab60fb15",
9
+ "originGitCommit": "b939d4f55706b529800e2b0a7cb51582fd764206",
10
10
  "originGitCommitIsDirty": false,
11
11
  "invokedBy": "ci",
12
12
  "ciProvider": "github",
13
- "sdkVersion": "1.0.5"
13
+ "sdkVersion": "1.1.1"
14
14
  }
@@ -0,0 +1,84 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Apologist
4
+ module Agent
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
+ # Pauses the agent globally and fans out pause transition messages to open conversations. Requires an API key.
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
+ #
23
+ # @example
24
+ # client.agent.pause_agent
25
+ #
26
+ # @return [Apologist::Agent::Types::PauseAgentResponse]
27
+ def pause_agent(request_options: {}, **_params)
28
+ request = Apologist::Internal::JSON::Request.new(
29
+ base_url: request_options[:base_url],
30
+ method: "POST",
31
+ path: "pause",
32
+ request_options: request_options
33
+ )
34
+ begin
35
+ response = @client.send(request)
36
+ rescue Net::HTTPRequestTimeout
37
+ raise Apologist::Errors::TimeoutError
38
+ end
39
+ code = response.code.to_i
40
+ if code.between?(200, 299)
41
+ Apologist::Agent::Types::PauseAgentResponse.load(response.body)
42
+ else
43
+ error_class = Apologist::Errors::ResponseError.subclass_for_code(code)
44
+ raise error_class.new(response.body, code: code)
45
+ end
46
+ end
47
+
48
+ # Resumes the agent globally and fans out resume transition messages to open conversations. Requires an API key.
49
+ #
50
+ # @param request_options [Hash]
51
+ # @param _params [Hash]
52
+ # @option request_options [String] :base_url
53
+ # @option request_options [Hash{String => Object}] :additional_headers
54
+ # @option request_options [Hash{String => Object}] :additional_query_parameters
55
+ # @option request_options [Hash{String => Object}] :additional_body_parameters
56
+ # @option request_options [Integer] :timeout_in_seconds
57
+ #
58
+ # @example
59
+ # client.agent.resume_agent
60
+ #
61
+ # @return [Apologist::Agent::Types::ResumeAgentResponse]
62
+ def resume_agent(request_options: {}, **_params)
63
+ request = Apologist::Internal::JSON::Request.new(
64
+ base_url: request_options[:base_url],
65
+ method: "POST",
66
+ path: "resume",
67
+ request_options: request_options
68
+ )
69
+ begin
70
+ response = @client.send(request)
71
+ rescue Net::HTTPRequestTimeout
72
+ raise Apologist::Errors::TimeoutError
73
+ end
74
+ code = response.code.to_i
75
+ if code.between?(200, 299)
76
+ Apologist::Agent::Types::ResumeAgentResponse.load(response.body)
77
+ else
78
+ error_class = Apologist::Errors::ResponseError.subclass_for_code(code)
79
+ raise error_class.new(response.body, code: code)
80
+ end
81
+ end
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Apologist
4
+ module Agent
5
+ module Types
6
+ class PauseAgentResponse < Internal::Types::Model
7
+ field :data, -> { Apologist::Types::AgentPauseState }, optional: true, nullable: false
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Apologist
4
+ module Agent
5
+ module Types
6
+ class ResumeAgentResponse < Internal::Types::Model
7
+ field :data, -> { Apologist::Types::AgentPauseState }, optional: true, nullable: false
8
+ end
9
+ end
10
+ end
11
+ end
@@ -402,6 +402,106 @@ module Apologist
402
402
  error_class = Apologist::Errors::ResponseError.subclass_for_code(code)
403
403
  raise error_class.new(response.body, code: code)
404
404
  end
405
+
406
+ # Handles the Meta WhatsApp Cloud API webhook verification handshake, echoing `hub.challenge` when
407
+ # `hub.verify_token` matches the channel's configured token.
408
+ #
409
+ # @param request_options [Hash]
410
+ # @param params [Hash]
411
+ # @option request_options [String] :base_url
412
+ # @option request_options [Hash{String => Object}] :additional_headers
413
+ # @option request_options [Hash{String => Object}] :additional_query_parameters
414
+ # @option request_options [Hash{String => Object}] :additional_body_parameters
415
+ # @option request_options [Integer] :timeout_in_seconds
416
+ # @option params [String] :id
417
+ # @option params [Apologist::Channels::Types::VerifyWhatsAppWebhookRequestHubMode] :hub_mode
418
+ # @option params [String] :hub_verify_token
419
+ # @option params [String, nil] :hub_challenge
420
+ #
421
+ # @example
422
+ # client.channels.verify_whats_app_webhook(
423
+ # id: "id",
424
+ # hub_mode: "subscribe",
425
+ # hub_verify_token: "hub.verify_token"
426
+ # )
427
+ #
428
+ # @return [String]
429
+ def verify_whats_app_webhook(request_options: {}, **params)
430
+ params = Apologist::Internal::Types::Utils.normalize_keys(params)
431
+ query_params = {}
432
+ query_params["hub.mode"] = params[:hub_mode] if params.key?(:hub_mode)
433
+ query_params["hub.verify_token"] = params[:hub_verify_token] if params.key?(:hub_verify_token)
434
+ query_params["hub.challenge"] = params[:hub_challenge] if params.key?(:hub_challenge)
435
+
436
+ request = Apologist::Internal::JSON::Request.new(
437
+ base_url: request_options[:base_url],
438
+ method: "GET",
439
+ path: "channels/#{URI.encode_uri_component(params[:id].to_s)}/whatsapp",
440
+ query: query_params,
441
+ request_options: request_options
442
+ )
443
+ begin
444
+ response = @client.send(request)
445
+ rescue Net::HTTPRequestTimeout
446
+ raise Apologist::Errors::TimeoutError
447
+ end
448
+ code = response.code.to_i
449
+ return if code.between?(200, 299)
450
+
451
+ error_class = Apologist::Errors::ResponseError.subclass_for_code(code)
452
+ raise error_class.new(response.body, code: code)
453
+ end
454
+
455
+ # Receives WhatsApp Cloud API message events for the channel. Payload shape is defined by Meta. Signature
456
+ # verification via `x-hub-signature-256` is used when the channel has an App Secret configured; otherwise the
457
+ # webhook relies on URL secrecy and/or an `api_key` query parameter.
458
+ #
459
+ # @param request_options [Hash]
460
+ # @param params [Hash]
461
+ # @option request_options [String] :base_url
462
+ # @option request_options [Hash{String => Object}] :additional_headers
463
+ # @option request_options [Hash{String => Object}] :additional_query_parameters
464
+ # @option request_options [Hash{String => Object}] :additional_body_parameters
465
+ # @option request_options [Integer] :timeout_in_seconds
466
+ # @option params [String] :id
467
+ # @option params [String, nil] :hub_signature256
468
+ #
469
+ # @example
470
+ # client.channels.receive_whats_app_message(
471
+ # id: "id",
472
+ # body: {
473
+ # key: "value"
474
+ # }
475
+ # )
476
+ #
477
+ # @return [untyped]
478
+ def receive_whats_app_message(request_options: {}, **params)
479
+ params = Apologist::Internal::Types::Utils.normalize_keys(params)
480
+ path_param_names = %i[id]
481
+ body_params = params.except(*path_param_names)
482
+
483
+ headers = {}
484
+ headers["x-hub-signature-256"] = params[:hub_signature256] if params[:hub_signature256]
485
+
486
+ request = Apologist::Internal::JSON::Request.new(
487
+ base_url: request_options[:base_url],
488
+ method: "POST",
489
+ path: "channels/#{URI.encode_uri_component(params[:id].to_s)}/whatsapp",
490
+ headers: headers,
491
+ body: body_params,
492
+ request_options: request_options
493
+ )
494
+ begin
495
+ response = @client.send(request)
496
+ rescue Net::HTTPRequestTimeout
497
+ raise Apologist::Errors::TimeoutError
498
+ end
499
+ code = response.code.to_i
500
+ return if code.between?(200, 299)
501
+
502
+ error_class = Apologist::Errors::ResponseError.subclass_for_code(code)
503
+ raise error_class.new(response.body, code: code)
504
+ end
405
505
  end
406
506
  end
407
507
  end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Apologist
4
+ module Channels
5
+ module Types
6
+ class ReceiveWhatsAppMessageRequest < Internal::Types::Model
7
+ field :id, -> { String }, optional: false, nullable: false
8
+
9
+ field :hub_signature256, -> { String }, optional: true, nullable: false, api_name: "x-hub-signature-256"
10
+
11
+ field :body, -> { Internal::Types::Hash[String, Object] }, optional: false, nullable: false
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 VerifyWhatsAppWebhookRequest < Internal::Types::Model
7
+ field :id, -> { String }, optional: false, nullable: false
8
+
9
+ field :hub_mode, -> { Apologist::Channels::Types::VerifyWhatsAppWebhookRequestHubMode }, 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 VerifyWhatsAppWebhookRequestHubMode
7
+ extend Apologist::Internal::Types::Enum
8
+
9
+ SUBSCRIBE = "subscribe"
10
+ end
11
+ end
12
+ end
13
+ end
@@ -20,7 +20,7 @@ module Apologist
20
20
  @raw_client = Apologist::Internal::Http::RawClient.new(
21
21
  base_url: base_url || Apologist::Environment::DEFAULT,
22
22
  headers: {
23
- "User-Agent" => "apologist/1.0.5",
23
+ "User-Agent" => "apologist/1.1.1",
24
24
  "X-Fern-Language" => "Ruby",
25
25
  "x-api-key" => api_key.to_s
26
26
  },
@@ -58,6 +58,16 @@ module Apologist
58
58
  @benchmarks ||= Apologist::Benchmarks::Client.new(client: @raw_client)
59
59
  end
60
60
 
61
+ # @return [Apologist::Agent::Client]
62
+ def agent
63
+ @agent ||= Apologist::Agent::Client.new(client: @raw_client)
64
+ end
65
+
66
+ # @return [Apologist::Conversations::Client]
67
+ def conversations
68
+ @conversations ||= Apologist::Conversations::Client.new(client: @raw_client)
69
+ end
70
+
61
71
  # @return [Apologist::Channels::Client]
62
72
  def channels
63
73
  @channels ||= Apologist::Channels::Client.new(client: @raw_client)
@@ -0,0 +1,168 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Apologist
4
+ module Conversations
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 a paginated list of conversations for the requesting agent, newest first.
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 [Integer, nil] :page
23
+ # @option params [Integer, nil] :per_page
24
+ #
25
+ # @example
26
+ # client.conversations.list_conversations
27
+ #
28
+ # @return [Apologist::Conversations::Types::ListConversationsResponse]
29
+ def list_conversations(request_options: {}, **params)
30
+ params = Apologist::Internal::Types::Utils.normalize_keys(params)
31
+ query_params = {}
32
+ query_params["page"] = params[:page] if params.key?(:page)
33
+ query_params["per_page"] = params[:per_page] if params.key?(:per_page)
34
+
35
+ request = Apologist::Internal::JSON::Request.new(
36
+ base_url: request_options[:base_url],
37
+ method: "GET",
38
+ path: "conversations",
39
+ query: query_params,
40
+ request_options: request_options
41
+ )
42
+ begin
43
+ response = @client.send(request)
44
+ rescue Net::HTTPRequestTimeout
45
+ raise Apologist::Errors::TimeoutError
46
+ end
47
+ code = response.code.to_i
48
+ if code.between?(200, 299)
49
+ Apologist::Conversations::Types::ListConversationsResponse.load(response.body)
50
+ else
51
+ error_class = Apologist::Errors::ResponseError.subclass_for_code(code)
52
+ raise error_class.new(response.body, code: code)
53
+ end
54
+ end
55
+
56
+ # Returns a single conversation by internal UUID or team-scoped external id.
57
+ #
58
+ # @param request_options [Hash]
59
+ # @param params [Hash]
60
+ # @option request_options [String] :base_url
61
+ # @option request_options [Hash{String => Object}] :additional_headers
62
+ # @option request_options [Hash{String => Object}] :additional_query_parameters
63
+ # @option request_options [Hash{String => Object}] :additional_body_parameters
64
+ # @option request_options [Integer] :timeout_in_seconds
65
+ # @option params [String] :id
66
+ #
67
+ # @example
68
+ # client.conversations.get_conversation(id: "id")
69
+ #
70
+ # @return [Apologist::Conversations::Types::GetConversationResponse]
71
+ def get_conversation(request_options: {}, **params)
72
+ params = Apologist::Internal::Types::Utils.normalize_keys(params)
73
+ request = Apologist::Internal::JSON::Request.new(
74
+ base_url: request_options[:base_url],
75
+ method: "GET",
76
+ path: "conversations/#{URI.encode_uri_component(params[:id].to_s)}",
77
+ request_options: request_options
78
+ )
79
+ begin
80
+ response = @client.send(request)
81
+ rescue Net::HTTPRequestTimeout
82
+ raise Apologist::Errors::TimeoutError
83
+ end
84
+ code = response.code.to_i
85
+ if code.between?(200, 299)
86
+ Apologist::Conversations::Types::GetConversationResponse.load(response.body)
87
+ else
88
+ error_class = Apologist::Errors::ResponseError.subclass_for_code(code)
89
+ raise error_class.new(response.body, code: code)
90
+ end
91
+ end
92
+
93
+ # Pauses the agent on a conversation identified by internal UUID or team-scoped external id. Requires an API key.
94
+ #
95
+ # @param request_options [Hash]
96
+ # @param params [Hash]
97
+ # @option request_options [String] :base_url
98
+ # @option request_options [Hash{String => Object}] :additional_headers
99
+ # @option request_options [Hash{String => Object}] :additional_query_parameters
100
+ # @option request_options [Hash{String => Object}] :additional_body_parameters
101
+ # @option request_options [Integer] :timeout_in_seconds
102
+ # @option params [String] :id
103
+ #
104
+ # @example
105
+ # client.conversations.pause_conversation(id: "id")
106
+ #
107
+ # @return [Apologist::Conversations::Types::PauseConversationResponse]
108
+ def pause_conversation(request_options: {}, **params)
109
+ params = Apologist::Internal::Types::Utils.normalize_keys(params)
110
+ request = Apologist::Internal::JSON::Request.new(
111
+ base_url: request_options[:base_url],
112
+ method: "POST",
113
+ path: "conversations/#{URI.encode_uri_component(params[:id].to_s)}/pause",
114
+ request_options: request_options
115
+ )
116
+ begin
117
+ response = @client.send(request)
118
+ rescue Net::HTTPRequestTimeout
119
+ raise Apologist::Errors::TimeoutError
120
+ end
121
+ code = response.code.to_i
122
+ if code.between?(200, 299)
123
+ Apologist::Conversations::Types::PauseConversationResponse.load(response.body)
124
+ else
125
+ error_class = Apologist::Errors::ResponseError.subclass_for_code(code)
126
+ raise error_class.new(response.body, code: code)
127
+ end
128
+ end
129
+
130
+ # Resumes the agent on a conversation identified by internal UUID or team-scoped external id. Requires an API key.
131
+ #
132
+ # @param request_options [Hash]
133
+ # @param params [Hash]
134
+ # @option request_options [String] :base_url
135
+ # @option request_options [Hash{String => Object}] :additional_headers
136
+ # @option request_options [Hash{String => Object}] :additional_query_parameters
137
+ # @option request_options [Hash{String => Object}] :additional_body_parameters
138
+ # @option request_options [Integer] :timeout_in_seconds
139
+ # @option params [String] :id
140
+ #
141
+ # @example
142
+ # client.conversations.resume_conversation(id: "id")
143
+ #
144
+ # @return [Apologist::Conversations::Types::ResumeConversationResponse]
145
+ def resume_conversation(request_options: {}, **params)
146
+ params = Apologist::Internal::Types::Utils.normalize_keys(params)
147
+ request = Apologist::Internal::JSON::Request.new(
148
+ base_url: request_options[:base_url],
149
+ method: "POST",
150
+ path: "conversations/#{URI.encode_uri_component(params[:id].to_s)}/resume",
151
+ request_options: request_options
152
+ )
153
+ begin
154
+ response = @client.send(request)
155
+ rescue Net::HTTPRequestTimeout
156
+ raise Apologist::Errors::TimeoutError
157
+ end
158
+ code = response.code.to_i
159
+ if code.between?(200, 299)
160
+ Apologist::Conversations::Types::ResumeConversationResponse.load(response.body)
161
+ else
162
+ error_class = Apologist::Errors::ResponseError.subclass_for_code(code)
163
+ raise error_class.new(response.body, code: code)
164
+ end
165
+ end
166
+ end
167
+ end
168
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Apologist
4
+ module Conversations
5
+ module Types
6
+ class GetConversationRequest < Internal::Types::Model
7
+ field :id, -> { String }, optional: false, nullable: false
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Apologist
4
+ module Conversations
5
+ module Types
6
+ class GetConversationResponse < Internal::Types::Model
7
+ field :data, -> { Apologist::Types::Conversation }, optional: true, nullable: false
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Apologist
4
+ module Conversations
5
+ module Types
6
+ class ListConversationsRequest < Internal::Types::Model
7
+ field :page, -> { Integer }, optional: true, nullable: false
8
+
9
+ field :per_page, -> { Integer }, optional: true, nullable: false
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Apologist
4
+ module Conversations
5
+ module Types
6
+ class ListConversationsResponse < Internal::Types::Model
7
+ field :data, -> { Internal::Types::Array[Apologist::Types::Conversation] }, 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,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Apologist
4
+ module Conversations
5
+ module Types
6
+ class PauseConversationRequest < Internal::Types::Model
7
+ field :id, -> { String }, optional: false, nullable: false
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Apologist
4
+ module Conversations
5
+ module Types
6
+ class PauseConversationResponse < Internal::Types::Model
7
+ field :data, -> { Apologist::Types::Conversation }, optional: true, nullable: false
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Apologist
4
+ module Conversations
5
+ module Types
6
+ class ResumeConversationRequest < Internal::Types::Model
7
+ field :id, -> { String }, optional: false, nullable: false
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Apologist
4
+ module Conversations
5
+ module Types
6
+ class ResumeConversationResponse < Internal::Types::Model
7
+ field :data, -> { Apologist::Types::Conversation }, optional: true, nullable: false
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Apologist
4
+ module Types
5
+ # Agent-wide pause or resume result, including fan-out counts.
6
+ class AgentPauseState < Internal::Types::Model
7
+ field :is_paused, -> { Internal::Types::Boolean }, optional: true, nullable: false
8
+
9
+ field :paused_at, -> { String }, optional: true, nullable: false
10
+
11
+ field :resumed_at, -> { String }, optional: true, nullable: false
12
+
13
+ field :emitted, -> { Integer }, optional: true, nullable: false
14
+
15
+ field :skipped, -> { Integer }, optional: true, nullable: false
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Apologist
4
+ module Types
5
+ # A conversation scoped to the requesting agent.
6
+ class Conversation < Internal::Types::Model
7
+ field :id, -> { String }, optional: true, nullable: false
8
+
9
+ field :external_id, -> { String }, optional: true, nullable: false
10
+
11
+ field :agent_id, -> { Integer }, optional: true, nullable: false
12
+
13
+ field :team_id, -> { Integer }, optional: true, nullable: false
14
+
15
+ field :tags, -> { Internal::Types::Hash[String, Object] }, optional: true, nullable: false
16
+
17
+ field :started_at, -> { String }, optional: true, nullable: false
18
+
19
+ field :ended_at, -> { String }, optional: true, nullable: false
20
+
21
+ field :agent_paused, -> { Internal::Types::Boolean }, optional: true, nullable: false
22
+
23
+ field :agent_paused_at, -> { String }, optional: true, nullable: false
24
+
25
+ field :agent_resumed_at, -> { String }, optional: true, nullable: false
26
+ end
27
+ end
28
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Apologist
4
- VERSION = "1.1.0"
4
+ VERSION = "1.1.1"
5
5
  end
data/lib/Apologist.rb CHANGED
@@ -60,9 +60,18 @@ require_relative "Apologist/benchmarks/types/benchmark_run_request_content"
60
60
  require_relative "Apologist/benchmarks/types/benchmark_run_request_reasoning_effort"
61
61
  require_relative "Apologist/benchmarks/types/benchmark_run_request_verbosity"
62
62
  require_relative "Apologist/benchmarks/types/get_benchmark_run_response"
63
+ require_relative "Apologist/types/agent_pause_state"
64
+ require_relative "Apologist/agent/types/pause_agent_response"
65
+ require_relative "Apologist/agent/types/resume_agent_response"
66
+ require_relative "Apologist/types/conversation"
67
+ require_relative "Apologist/conversations/types/list_conversations_response"
68
+ require_relative "Apologist/conversations/types/get_conversation_response"
69
+ require_relative "Apologist/conversations/types/pause_conversation_response"
70
+ require_relative "Apologist/conversations/types/resume_conversation_response"
63
71
  require_relative "Apologist/channels/types/get_discord_channel_status_response"
64
72
  require_relative "Apologist/channels/types/get_line_channel_status_response"
65
73
  require_relative "Apologist/channels/types/verify_facebook_webhook_request_hub_mode"
74
+ require_relative "Apologist/channels/types/verify_whats_app_webhook_request_hub_mode"
66
75
  require_relative "Apologist/shares/types/get_shared_messages_response"
67
76
  require_relative "Apologist/types/error"
68
77
  require_relative "Apologist/types/success_response"
@@ -119,6 +128,12 @@ require_relative "Apologist/benchmarks/client"
119
128
  require_relative "Apologist/benchmarks/types/list_benchmark_runs_request"
120
129
  require_relative "Apologist/benchmarks/types/benchmark_run_request"
121
130
  require_relative "Apologist/benchmarks/types/get_benchmark_run_request"
131
+ require_relative "Apologist/agent/client"
132
+ require_relative "Apologist/conversations/client"
133
+ require_relative "Apologist/conversations/types/list_conversations_request"
134
+ require_relative "Apologist/conversations/types/get_conversation_request"
135
+ require_relative "Apologist/conversations/types/pause_conversation_request"
136
+ require_relative "Apologist/conversations/types/resume_conversation_request"
122
137
  require_relative "Apologist/channels/client"
123
138
  require_relative "Apologist/channels/types/get_discord_channel_status_request"
124
139
  require_relative "Apologist/channels/types/receive_discord_interaction_request"
@@ -129,6 +144,8 @@ require_relative "Apologist/channels/types/receive_facebook_message_request"
129
144
  require_relative "Apologist/channels/types/get_instagram_privacy_policy_request"
130
145
  require_relative "Apologist/channels/types/receive_telegram_update_request"
131
146
  require_relative "Apologist/channels/types/receive_twilio_message_request"
147
+ require_relative "Apologist/channels/types/verify_whats_app_webhook_request"
148
+ require_relative "Apologist/channels/types/receive_whats_app_message_request"
132
149
  require_relative "Apologist/shares/client"
133
150
  require_relative "Apologist/shares/types/get_shared_messages_request"
134
151
  require_relative "Apologist/environment"
data/reference.md CHANGED
@@ -2322,6 +2322,372 @@ client.benchmarks.get_benchmark_run(
2322
2322
  </dl>
2323
2323
 
2324
2324
 
2325
+ </dd>
2326
+ </dl>
2327
+ </details>
2328
+
2329
+ ## Agent
2330
+ <details><summary><code>client.agent.<a href="/lib/Apologist/agent/client.rb">pause_agent</a>() -> Apologist::Agent::Types::PauseAgentResponse</code></summary>
2331
+ <dl>
2332
+ <dd>
2333
+
2334
+ #### 📝 Description
2335
+
2336
+ <dl>
2337
+ <dd>
2338
+
2339
+ <dl>
2340
+ <dd>
2341
+
2342
+ Pauses the agent globally and fans out pause transition messages to open conversations. Requires an API key.
2343
+ </dd>
2344
+ </dl>
2345
+ </dd>
2346
+ </dl>
2347
+
2348
+ #### 🔌 Usage
2349
+
2350
+ <dl>
2351
+ <dd>
2352
+
2353
+ <dl>
2354
+ <dd>
2355
+
2356
+ ```ruby
2357
+ client.agent.pause_agent
2358
+ ```
2359
+ </dd>
2360
+ </dl>
2361
+ </dd>
2362
+ </dl>
2363
+
2364
+ #### ⚙️ Parameters
2365
+
2366
+ <dl>
2367
+ <dd>
2368
+
2369
+ <dl>
2370
+ <dd>
2371
+
2372
+ **request_options:** `Apologist::Agent::RequestOptions`
2373
+
2374
+ </dd>
2375
+ </dl>
2376
+ </dd>
2377
+ </dl>
2378
+
2379
+
2380
+ </dd>
2381
+ </dl>
2382
+ </details>
2383
+
2384
+ <details><summary><code>client.agent.<a href="/lib/Apologist/agent/client.rb">resume_agent</a>() -> Apologist::Agent::Types::ResumeAgentResponse</code></summary>
2385
+ <dl>
2386
+ <dd>
2387
+
2388
+ #### 📝 Description
2389
+
2390
+ <dl>
2391
+ <dd>
2392
+
2393
+ <dl>
2394
+ <dd>
2395
+
2396
+ Resumes the agent globally and fans out resume transition messages to open conversations. Requires an API key.
2397
+ </dd>
2398
+ </dl>
2399
+ </dd>
2400
+ </dl>
2401
+
2402
+ #### 🔌 Usage
2403
+
2404
+ <dl>
2405
+ <dd>
2406
+
2407
+ <dl>
2408
+ <dd>
2409
+
2410
+ ```ruby
2411
+ client.agent.resume_agent
2412
+ ```
2413
+ </dd>
2414
+ </dl>
2415
+ </dd>
2416
+ </dl>
2417
+
2418
+ #### ⚙️ Parameters
2419
+
2420
+ <dl>
2421
+ <dd>
2422
+
2423
+ <dl>
2424
+ <dd>
2425
+
2426
+ **request_options:** `Apologist::Agent::RequestOptions`
2427
+
2428
+ </dd>
2429
+ </dl>
2430
+ </dd>
2431
+ </dl>
2432
+
2433
+
2434
+ </dd>
2435
+ </dl>
2436
+ </details>
2437
+
2438
+ ## Conversations
2439
+ <details><summary><code>client.conversations.<a href="/lib/Apologist/conversations/client.rb">list_conversations</a>() -> Apologist::Conversations::Types::ListConversationsResponse</code></summary>
2440
+ <dl>
2441
+ <dd>
2442
+
2443
+ #### 📝 Description
2444
+
2445
+ <dl>
2446
+ <dd>
2447
+
2448
+ <dl>
2449
+ <dd>
2450
+
2451
+ Returns a paginated list of conversations for the requesting agent, newest first.
2452
+ </dd>
2453
+ </dl>
2454
+ </dd>
2455
+ </dl>
2456
+
2457
+ #### 🔌 Usage
2458
+
2459
+ <dl>
2460
+ <dd>
2461
+
2462
+ <dl>
2463
+ <dd>
2464
+
2465
+ ```ruby
2466
+ client.conversations.list_conversations
2467
+ ```
2468
+ </dd>
2469
+ </dl>
2470
+ </dd>
2471
+ </dl>
2472
+
2473
+ #### ⚙️ Parameters
2474
+
2475
+ <dl>
2476
+ <dd>
2477
+
2478
+ <dl>
2479
+ <dd>
2480
+
2481
+ **page:** `Integer`
2482
+
2483
+ </dd>
2484
+ </dl>
2485
+
2486
+ <dl>
2487
+ <dd>
2488
+
2489
+ **per_page:** `Integer` — Results per page (clamped to 100).
2490
+
2491
+ </dd>
2492
+ </dl>
2493
+
2494
+ <dl>
2495
+ <dd>
2496
+
2497
+ **request_options:** `Apologist::Conversations::RequestOptions`
2498
+
2499
+ </dd>
2500
+ </dl>
2501
+ </dd>
2502
+ </dl>
2503
+
2504
+
2505
+ </dd>
2506
+ </dl>
2507
+ </details>
2508
+
2509
+ <details><summary><code>client.conversations.<a href="/lib/Apologist/conversations/client.rb">get_conversation</a>(id:) -> Apologist::Conversations::Types::GetConversationResponse</code></summary>
2510
+ <dl>
2511
+ <dd>
2512
+
2513
+ #### 📝 Description
2514
+
2515
+ <dl>
2516
+ <dd>
2517
+
2518
+ <dl>
2519
+ <dd>
2520
+
2521
+ Returns a single conversation by internal UUID or team-scoped external id.
2522
+ </dd>
2523
+ </dl>
2524
+ </dd>
2525
+ </dl>
2526
+
2527
+ #### 🔌 Usage
2528
+
2529
+ <dl>
2530
+ <dd>
2531
+
2532
+ <dl>
2533
+ <dd>
2534
+
2535
+ ```ruby
2536
+ client.conversations.get_conversation(id: "id")
2537
+ ```
2538
+ </dd>
2539
+ </dl>
2540
+ </dd>
2541
+ </dl>
2542
+
2543
+ #### ⚙️ Parameters
2544
+
2545
+ <dl>
2546
+ <dd>
2547
+
2548
+ <dl>
2549
+ <dd>
2550
+
2551
+ **id:** `String` — The conversation UUID or team-scoped external id
2552
+
2553
+ </dd>
2554
+ </dl>
2555
+
2556
+ <dl>
2557
+ <dd>
2558
+
2559
+ **request_options:** `Apologist::Conversations::RequestOptions`
2560
+
2561
+ </dd>
2562
+ </dl>
2563
+ </dd>
2564
+ </dl>
2565
+
2566
+
2567
+ </dd>
2568
+ </dl>
2569
+ </details>
2570
+
2571
+ <details><summary><code>client.conversations.<a href="/lib/Apologist/conversations/client.rb">pause_conversation</a>(id:) -> Apologist::Conversations::Types::PauseConversationResponse</code></summary>
2572
+ <dl>
2573
+ <dd>
2574
+
2575
+ #### 📝 Description
2576
+
2577
+ <dl>
2578
+ <dd>
2579
+
2580
+ <dl>
2581
+ <dd>
2582
+
2583
+ Pauses the agent on a conversation identified by internal UUID or team-scoped external id. Requires an API key.
2584
+ </dd>
2585
+ </dl>
2586
+ </dd>
2587
+ </dl>
2588
+
2589
+ #### 🔌 Usage
2590
+
2591
+ <dl>
2592
+ <dd>
2593
+
2594
+ <dl>
2595
+ <dd>
2596
+
2597
+ ```ruby
2598
+ client.conversations.pause_conversation(id: "id")
2599
+ ```
2600
+ </dd>
2601
+ </dl>
2602
+ </dd>
2603
+ </dl>
2604
+
2605
+ #### ⚙️ Parameters
2606
+
2607
+ <dl>
2608
+ <dd>
2609
+
2610
+ <dl>
2611
+ <dd>
2612
+
2613
+ **id:** `String` — The conversation UUID or team-scoped external id
2614
+
2615
+ </dd>
2616
+ </dl>
2617
+
2618
+ <dl>
2619
+ <dd>
2620
+
2621
+ **request_options:** `Apologist::Conversations::RequestOptions`
2622
+
2623
+ </dd>
2624
+ </dl>
2625
+ </dd>
2626
+ </dl>
2627
+
2628
+
2629
+ </dd>
2630
+ </dl>
2631
+ </details>
2632
+
2633
+ <details><summary><code>client.conversations.<a href="/lib/Apologist/conversations/client.rb">resume_conversation</a>(id:) -> Apologist::Conversations::Types::ResumeConversationResponse</code></summary>
2634
+ <dl>
2635
+ <dd>
2636
+
2637
+ #### 📝 Description
2638
+
2639
+ <dl>
2640
+ <dd>
2641
+
2642
+ <dl>
2643
+ <dd>
2644
+
2645
+ Resumes the agent on a conversation identified by internal UUID or team-scoped external id. Requires an API key.
2646
+ </dd>
2647
+ </dl>
2648
+ </dd>
2649
+ </dl>
2650
+
2651
+ #### 🔌 Usage
2652
+
2653
+ <dl>
2654
+ <dd>
2655
+
2656
+ <dl>
2657
+ <dd>
2658
+
2659
+ ```ruby
2660
+ client.conversations.resume_conversation(id: "id")
2661
+ ```
2662
+ </dd>
2663
+ </dl>
2664
+ </dd>
2665
+ </dl>
2666
+
2667
+ #### ⚙️ Parameters
2668
+
2669
+ <dl>
2670
+ <dd>
2671
+
2672
+ <dl>
2673
+ <dd>
2674
+
2675
+ **id:** `String` — The conversation UUID or team-scoped external id
2676
+
2677
+ </dd>
2678
+ </dl>
2679
+
2680
+ <dl>
2681
+ <dd>
2682
+
2683
+ **request_options:** `Apologist::Conversations::RequestOptions`
2684
+
2685
+ </dd>
2686
+ </dl>
2687
+ </dd>
2688
+ </dl>
2689
+
2690
+
2325
2691
  </dd>
2326
2692
  </dl>
2327
2693
  </details>
@@ -3003,6 +3369,179 @@ client.channels.receive_twilio_message(id: "id")
3003
3369
  </dl>
3004
3370
 
3005
3371
 
3372
+ </dd>
3373
+ </dl>
3374
+ </details>
3375
+
3376
+ <details><summary><code>client.channels.<a href="/lib/Apologist/channels/client.rb">verify_whats_app_webhook</a>(id:) -> String</code></summary>
3377
+ <dl>
3378
+ <dd>
3379
+
3380
+ #### 📝 Description
3381
+
3382
+ <dl>
3383
+ <dd>
3384
+
3385
+ <dl>
3386
+ <dd>
3387
+
3388
+ Handles the Meta WhatsApp Cloud API webhook verification handshake, echoing `hub.challenge` when `hub.verify_token` matches the channel's configured token.
3389
+ </dd>
3390
+ </dl>
3391
+ </dd>
3392
+ </dl>
3393
+
3394
+ #### 🔌 Usage
3395
+
3396
+ <dl>
3397
+ <dd>
3398
+
3399
+ <dl>
3400
+ <dd>
3401
+
3402
+ ```ruby
3403
+ client.channels.verify_whats_app_webhook(
3404
+ id: "id",
3405
+ hub_mode: "subscribe",
3406
+ hub_verify_token: "hub.verify_token"
3407
+ )
3408
+ ```
3409
+ </dd>
3410
+ </dl>
3411
+ </dd>
3412
+ </dl>
3413
+
3414
+ #### ⚙️ Parameters
3415
+
3416
+ <dl>
3417
+ <dd>
3418
+
3419
+ <dl>
3420
+ <dd>
3421
+
3422
+ **id:** `String` — The channel id
3423
+
3424
+ </dd>
3425
+ </dl>
3426
+
3427
+ <dl>
3428
+ <dd>
3429
+
3430
+ **hub_mode:** `Apologist::Channels::Types::VerifyWhatsAppWebhookRequestHubMode`
3431
+
3432
+ </dd>
3433
+ </dl>
3434
+
3435
+ <dl>
3436
+ <dd>
3437
+
3438
+ **hub_verify_token:** `String`
3439
+
3440
+ </dd>
3441
+ </dl>
3442
+
3443
+ <dl>
3444
+ <dd>
3445
+
3446
+ **hub_challenge:** `String`
3447
+
3448
+ </dd>
3449
+ </dl>
3450
+
3451
+ <dl>
3452
+ <dd>
3453
+
3454
+ **request_options:** `Apologist::Channels::RequestOptions`
3455
+
3456
+ </dd>
3457
+ </dl>
3458
+ </dd>
3459
+ </dl>
3460
+
3461
+
3462
+ </dd>
3463
+ </dl>
3464
+ </details>
3465
+
3466
+ <details><summary><code>client.channels.<a href="/lib/Apologist/channels/client.rb">receive_whats_app_message</a>(id:, request) -> </code></summary>
3467
+ <dl>
3468
+ <dd>
3469
+
3470
+ #### 📝 Description
3471
+
3472
+ <dl>
3473
+ <dd>
3474
+
3475
+ <dl>
3476
+ <dd>
3477
+
3478
+ Receives WhatsApp Cloud API message events for the channel. Payload shape is defined by Meta. Signature verification via `x-hub-signature-256` is used when the channel has an App Secret configured; otherwise the webhook relies on URL secrecy and/or an `api_key` query parameter.
3479
+ </dd>
3480
+ </dl>
3481
+ </dd>
3482
+ </dl>
3483
+
3484
+ #### 🔌 Usage
3485
+
3486
+ <dl>
3487
+ <dd>
3488
+
3489
+ <dl>
3490
+ <dd>
3491
+
3492
+ ```ruby
3493
+ client.channels.receive_whats_app_message(
3494
+ id: "id",
3495
+ body: {
3496
+ key: "value"
3497
+ }
3498
+ )
3499
+ ```
3500
+ </dd>
3501
+ </dl>
3502
+ </dd>
3503
+ </dl>
3504
+
3505
+ #### ⚙️ Parameters
3506
+
3507
+ <dl>
3508
+ <dd>
3509
+
3510
+ <dl>
3511
+ <dd>
3512
+
3513
+ **id:** `String` — The channel id
3514
+
3515
+ </dd>
3516
+ </dl>
3517
+
3518
+ <dl>
3519
+ <dd>
3520
+
3521
+ **hub_signature256:** `String` — Meta `sha256=<hex>` HMAC of the raw body keyed with the WhatsApp App Secret. Required when the channel has an App Secret configured and the webhook URL does not include an api_key.
3522
+
3523
+ </dd>
3524
+ </dl>
3525
+
3526
+ <dl>
3527
+ <dd>
3528
+
3529
+ **request:** `Internal::Types::Hash[String, Object]` — WhatsApp Cloud API webhook payload (`entry` + `changes`).
3530
+
3531
+ </dd>
3532
+ </dl>
3533
+
3534
+ <dl>
3535
+ <dd>
3536
+
3537
+ **request_options:** `Apologist::Channels::RequestOptions`
3538
+
3539
+ </dd>
3540
+ </dl>
3541
+ </dd>
3542
+ </dl>
3543
+
3544
+
3006
3545
  </dd>
3007
3546
  </dl>
3008
3547
  </details>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apologist
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Apologist
@@ -27,6 +27,9 @@ files:
27
27
  - Rakefile
28
28
  - custom.gemspec.rb
29
29
  - lib/Apologist.rb
30
+ - lib/Apologist/agent/client.rb
31
+ - lib/Apologist/agent/types/pause_agent_response.rb
32
+ - lib/Apologist/agent/types/resume_agent_response.rb
30
33
  - lib/Apologist/benchmarks/client.rb
31
34
  - lib/Apologist/benchmarks/types/benchmark_run_request.rb
32
35
  - lib/Apologist/benchmarks/types/benchmark_run_request_content.rb
@@ -47,8 +50,11 @@ files:
47
50
  - lib/Apologist/channels/types/receive_line_webhook_request.rb
48
51
  - lib/Apologist/channels/types/receive_telegram_update_request.rb
49
52
  - lib/Apologist/channels/types/receive_twilio_message_request.rb
53
+ - lib/Apologist/channels/types/receive_whats_app_message_request.rb
50
54
  - lib/Apologist/channels/types/verify_facebook_webhook_request.rb
51
55
  - lib/Apologist/channels/types/verify_facebook_webhook_request_hub_mode.rb
56
+ - lib/Apologist/channels/types/verify_whats_app_webhook_request.rb
57
+ - lib/Apologist/channels/types/verify_whats_app_webhook_request_hub_mode.rb
52
58
  - lib/Apologist/chat/client.rb
53
59
  - lib/Apologist/chat/types/feedback_request.rb
54
60
  - lib/Apologist/chat/types/flag_request.rb
@@ -59,6 +65,15 @@ files:
59
65
  - lib/Apologist/chat/types/list_chat_completions_response.rb
60
66
  - lib/Apologist/chat/types/share_request.rb
61
67
  - lib/Apologist/client.rb
68
+ - lib/Apologist/conversations/client.rb
69
+ - lib/Apologist/conversations/types/get_conversation_request.rb
70
+ - lib/Apologist/conversations/types/get_conversation_response.rb
71
+ - lib/Apologist/conversations/types/list_conversations_request.rb
72
+ - lib/Apologist/conversations/types/list_conversations_response.rb
73
+ - lib/Apologist/conversations/types/pause_conversation_request.rb
74
+ - lib/Apologist/conversations/types/pause_conversation_response.rb
75
+ - lib/Apologist/conversations/types/resume_conversation_request.rb
76
+ - lib/Apologist/conversations/types/resume_conversation_response.rb
62
77
  - lib/Apologist/corpus/client.rb
63
78
  - lib/Apologist/corpus/types/corpus_search_request.rb
64
79
  - lib/Apologist/corpus/types/corpus_search_request_filters.rb
@@ -116,6 +131,7 @@ files:
116
131
  - lib/Apologist/shares/client.rb
117
132
  - lib/Apologist/shares/types/get_shared_messages_request.rb
118
133
  - lib/Apologist/shares/types/get_shared_messages_response.rb
134
+ - lib/Apologist/types/agent_pause_state.rb
119
135
  - lib/Apologist/types/chat_completion_request.rb
120
136
  - lib/Apologist/types/chat_completion_request_logprobs.rb
121
137
  - lib/Apologist/types/chat_completion_request_metadata.rb
@@ -131,6 +147,7 @@ files:
131
147
  - lib/Apologist/types/chat_completion_response_usage.rb
132
148
  - lib/Apologist/types/chat_message.rb
133
149
  - lib/Apologist/types/chat_message_role.rb
150
+ - lib/Apologist/types/conversation.rb
134
151
  - lib/Apologist/types/cta_match_request.rb
135
152
  - lib/Apologist/types/error.rb
136
153
  - lib/Apologist/types/success_response.rb