sentdm 0.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.
- checksums.yaml +7 -0
- data/.ignore +2 -0
- data/CHANGELOG.md +11 -0
- data/README.md +240 -0
- data/SECURITY.md +27 -0
- data/lib/sentdm/client.rb +115 -0
- data/lib/sentdm/errors.rb +228 -0
- data/lib/sentdm/file_part.rb +58 -0
- data/lib/sentdm/internal/transport/base_client.rb +573 -0
- data/lib/sentdm/internal/transport/pooled_net_requester.rb +210 -0
- data/lib/sentdm/internal/type/array_of.rb +168 -0
- data/lib/sentdm/internal/type/base_model.rb +531 -0
- data/lib/sentdm/internal/type/base_page.rb +55 -0
- data/lib/sentdm/internal/type/boolean.rb +77 -0
- data/lib/sentdm/internal/type/converter.rb +327 -0
- data/lib/sentdm/internal/type/enum.rb +131 -0
- data/lib/sentdm/internal/type/file_input.rb +111 -0
- data/lib/sentdm/internal/type/hash_of.rb +188 -0
- data/lib/sentdm/internal/type/request_parameters.rb +42 -0
- data/lib/sentdm/internal/type/union.rb +237 -0
- data/lib/sentdm/internal/type/unknown.rb +81 -0
- data/lib/sentdm/internal/util.rb +920 -0
- data/lib/sentdm/internal.rb +20 -0
- data/lib/sentdm/models/contact_list_item.rb +96 -0
- data/lib/sentdm/models/contact_list_params.rb +30 -0
- data/lib/sentdm/models/contact_list_response.rb +40 -0
- data/lib/sentdm/models/contact_retrieve_by_phone_params.rb +22 -0
- data/lib/sentdm/models/contact_retrieve_id_params.rb +22 -0
- data/lib/sentdm/models/message_retrieve_params.rb +14 -0
- data/lib/sentdm/models/message_retrieve_response.rb +227 -0
- data/lib/sentdm/models/message_send_quick_message_params.rb +34 -0
- data/lib/sentdm/models/message_send_to_contact_params.rb +46 -0
- data/lib/sentdm/models/message_send_to_phone_params.rb +47 -0
- data/lib/sentdm/models/number_lookup_retrieve_params.rb +20 -0
- data/lib/sentdm/models/number_lookup_retrieve_response.rb +83 -0
- data/lib/sentdm/models/organization_list_params.rb +14 -0
- data/lib/sentdm/models/organization_list_response.rb +57 -0
- data/lib/sentdm/models/organization_retrieve_profiles_params.rb +14 -0
- data/lib/sentdm/models/organization_retrieve_profiles_response.rb +22 -0
- data/lib/sentdm/models/organizations/customer_user.rb +96 -0
- data/lib/sentdm/models/organizations/user_delete_params.rb +22 -0
- data/lib/sentdm/models/organizations/user_invite_params.rb +40 -0
- data/lib/sentdm/models/organizations/user_list_params.rb +28 -0
- data/lib/sentdm/models/organizations/user_list_response.rb +36 -0
- data/lib/sentdm/models/organizations/user_retrieve_params.rb +22 -0
- data/lib/sentdm/models/organizations/user_update_role_params.rb +28 -0
- data/lib/sentdm/models/profile_summary.rb +45 -0
- data/lib/sentdm/models/template_body_content.rb +27 -0
- data/lib/sentdm/models/template_create_params.rb +53 -0
- data/lib/sentdm/models/template_definition.rb +310 -0
- data/lib/sentdm/models/template_delete_params.rb +14 -0
- data/lib/sentdm/models/template_list_params.rb +54 -0
- data/lib/sentdm/models/template_list_response.rb +40 -0
- data/lib/sentdm/models/template_response.rb +100 -0
- data/lib/sentdm/models/template_retrieve_params.rb +14 -0
- data/lib/sentdm/models/template_variable.rb +74 -0
- data/lib/sentdm/models.rb +83 -0
- data/lib/sentdm/request_options.rb +77 -0
- data/lib/sentdm/resources/contacts.rb +88 -0
- data/lib/sentdm/resources/messages.rb +130 -0
- data/lib/sentdm/resources/number_lookup.rb +37 -0
- data/lib/sentdm/resources/organizations/users.rb +150 -0
- data/lib/sentdm/resources/organizations.rb +58 -0
- data/lib/sentdm/resources/templates.rb +131 -0
- data/lib/sentdm/version.rb +5 -0
- data/lib/sentdm.rb +94 -0
- data/manifest.yaml +17 -0
- data/rbi/sentdm/client.rbi +80 -0
- data/rbi/sentdm/errors.rbi +205 -0
- data/rbi/sentdm/file_part.rbi +37 -0
- data/rbi/sentdm/internal/transport/base_client.rbi +297 -0
- data/rbi/sentdm/internal/transport/pooled_net_requester.rbi +82 -0
- data/rbi/sentdm/internal/type/array_of.rbi +104 -0
- data/rbi/sentdm/internal/type/base_model.rbi +299 -0
- data/rbi/sentdm/internal/type/base_page.rbi +42 -0
- data/rbi/sentdm/internal/type/boolean.rbi +58 -0
- data/rbi/sentdm/internal/type/converter.rbi +204 -0
- data/rbi/sentdm/internal/type/enum.rbi +82 -0
- data/rbi/sentdm/internal/type/file_input.rbi +59 -0
- data/rbi/sentdm/internal/type/hash_of.rbi +104 -0
- data/rbi/sentdm/internal/type/request_parameters.rbi +29 -0
- data/rbi/sentdm/internal/type/union.rbi +126 -0
- data/rbi/sentdm/internal/type/unknown.rbi +58 -0
- data/rbi/sentdm/internal/util.rbi +484 -0
- data/rbi/sentdm/internal.rbi +16 -0
- data/rbi/sentdm/models/contact_list_item.rbi +144 -0
- data/rbi/sentdm/models/contact_list_params.rbi +51 -0
- data/rbi/sentdm/models/contact_list_response.rbi +74 -0
- data/rbi/sentdm/models/contact_retrieve_by_phone_params.rbi +40 -0
- data/rbi/sentdm/models/contact_retrieve_id_params.rbi +40 -0
- data/rbi/sentdm/models/message_retrieve_params.rbi +27 -0
- data/rbi/sentdm/models/message_retrieve_response.rbi +376 -0
- data/rbi/sentdm/models/message_send_quick_message_params.rbi +56 -0
- data/rbi/sentdm/models/message_send_to_contact_params.rbi +63 -0
- data/rbi/sentdm/models/message_send_to_phone_params.rbi +65 -0
- data/rbi/sentdm/models/number_lookup_retrieve_params.rbi +35 -0
- data/rbi/sentdm/models/number_lookup_retrieve_response.rbi +132 -0
- data/rbi/sentdm/models/organization_list_params.rbi +27 -0
- data/rbi/sentdm/models/organization_list_response.rbi +131 -0
- data/rbi/sentdm/models/organization_retrieve_profiles_params.rbi +30 -0
- data/rbi/sentdm/models/organization_retrieve_profiles_response.rbi +47 -0
- data/rbi/sentdm/models/organizations/customer_user.rbi +129 -0
- data/rbi/sentdm/models/organizations/user_delete_params.rbi +40 -0
- data/rbi/sentdm/models/organizations/user_invite_params.rbi +73 -0
- data/rbi/sentdm/models/organizations/user_list_params.rbi +48 -0
- data/rbi/sentdm/models/organizations/user_list_response.rbi +71 -0
- data/rbi/sentdm/models/organizations/user_retrieve_params.rbi +40 -0
- data/rbi/sentdm/models/organizations/user_update_role_params.rbi +51 -0
- data/rbi/sentdm/models/profile_summary.rbi +74 -0
- data/rbi/sentdm/models/template_body_content.rbi +46 -0
- data/rbi/sentdm/models/template_create_params.rbi +81 -0
- data/rbi/sentdm/models/template_definition.rbi +497 -0
- data/rbi/sentdm/models/template_delete_params.rbi +27 -0
- data/rbi/sentdm/models/template_list_params.rbi +75 -0
- data/rbi/sentdm/models/template_list_response.rbi +74 -0
- data/rbi/sentdm/models/template_response.rbi +149 -0
- data/rbi/sentdm/models/template_retrieve_params.rbi +27 -0
- data/rbi/sentdm/models/template_variable.rbi +120 -0
- data/rbi/sentdm/models.rbi +46 -0
- data/rbi/sentdm/request_options.rbi +55 -0
- data/rbi/sentdm/resources/contacts.rbi +63 -0
- data/rbi/sentdm/resources/messages.rbi +97 -0
- data/rbi/sentdm/resources/number_lookup.rbi +24 -0
- data/rbi/sentdm/resources/organizations/users.rbi +95 -0
- data/rbi/sentdm/resources/organizations.rbi +37 -0
- data/rbi/sentdm/resources/templates.rbi +103 -0
- data/rbi/sentdm/version.rbi +5 -0
- data/sig/sentdm/client.rbs +41 -0
- data/sig/sentdm/errors.rbs +117 -0
- data/sig/sentdm/file_part.rbs +21 -0
- data/sig/sentdm/internal/transport/base_client.rbs +133 -0
- data/sig/sentdm/internal/transport/pooled_net_requester.rbs +48 -0
- data/sig/sentdm/internal/type/array_of.rbs +48 -0
- data/sig/sentdm/internal/type/base_model.rbs +102 -0
- data/sig/sentdm/internal/type/base_page.rbs +24 -0
- data/sig/sentdm/internal/type/boolean.rbs +26 -0
- data/sig/sentdm/internal/type/converter.rbs +79 -0
- data/sig/sentdm/internal/type/enum.rbs +32 -0
- data/sig/sentdm/internal/type/file_input.rbs +25 -0
- data/sig/sentdm/internal/type/hash_of.rbs +48 -0
- data/sig/sentdm/internal/type/request_parameters.rbs +17 -0
- data/sig/sentdm/internal/type/union.rbs +52 -0
- data/sig/sentdm/internal/type/unknown.rbs +26 -0
- data/sig/sentdm/internal/util.rbs +185 -0
- data/sig/sentdm/internal.rbs +9 -0
- data/sig/sentdm/models/contact_list_item.rbs +85 -0
- data/sig/sentdm/models/contact_list_params.rbs +28 -0
- data/sig/sentdm/models/contact_list_response.rbs +52 -0
- data/sig/sentdm/models/contact_retrieve_by_phone_params.rbs +23 -0
- data/sig/sentdm/models/contact_retrieve_id_params.rbs +20 -0
- data/sig/sentdm/models/message_retrieve_params.rbs +15 -0
- data/sig/sentdm/models/message_retrieve_response.rbs +188 -0
- data/sig/sentdm/models/message_send_quick_message_params.rbs +28 -0
- data/sig/sentdm/models/message_send_to_contact_params.rbs +36 -0
- data/sig/sentdm/models/message_send_to_phone_params.rbs +36 -0
- data/sig/sentdm/models/number_lookup_retrieve_params.rbs +23 -0
- data/sig/sentdm/models/number_lookup_retrieve_response.rbs +78 -0
- data/sig/sentdm/models/organization_list_params.rbs +15 -0
- data/sig/sentdm/models/organization_list_response.rbs +76 -0
- data/sig/sentdm/models/organization_retrieve_profiles_params.rbs +15 -0
- data/sig/sentdm/models/organization_retrieve_profiles_response.rbs +28 -0
- data/sig/sentdm/models/organizations/customer_user.rbs +91 -0
- data/sig/sentdm/models/organizations/user_delete_params.rbs +25 -0
- data/sig/sentdm/models/organizations/user_invite_params.rbs +44 -0
- data/sig/sentdm/models/organizations/user_list_params.rbs +30 -0
- data/sig/sentdm/models/organizations/user_list_response.rbs +47 -0
- data/sig/sentdm/models/organizations/user_retrieve_params.rbs +25 -0
- data/sig/sentdm/models/organizations/user_update_role_params.rbs +32 -0
- data/sig/sentdm/models/profile_summary.rbs +51 -0
- data/sig/sentdm/models/template_body_content.rbs +32 -0
- data/sig/sentdm/models/template_create_params.rbs +43 -0
- data/sig/sentdm/models/template_definition.rbs +258 -0
- data/sig/sentdm/models/template_delete_params.rbs +15 -0
- data/sig/sentdm/models/template_list_params.rbs +46 -0
- data/sig/sentdm/models/template_list_response.rbs +52 -0
- data/sig/sentdm/models/template_response.rbs +92 -0
- data/sig/sentdm/models/template_retrieve_params.rbs +15 -0
- data/sig/sentdm/models/template_variable.rbs +87 -0
- data/sig/sentdm/models.rbs +43 -0
- data/sig/sentdm/request_options.rbs +34 -0
- data/sig/sentdm/resources/contacts.rbs +23 -0
- data/sig/sentdm/resources/messages.rbs +32 -0
- data/sig/sentdm/resources/number_lookup.rbs +12 -0
- data/sig/sentdm/resources/organizations/users.rbs +44 -0
- data/sig/sentdm/resources/organizations.rbs +18 -0
- data/sig/sentdm/resources/templates.rbs +31 -0
- data/sig/sentdm/version.rbs +3 -0
- metadata +259 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# typed: strong
|
|
2
|
+
|
|
3
|
+
module Sentdm
|
|
4
|
+
module Resources
|
|
5
|
+
class Organizations
|
|
6
|
+
sig { returns(Sentdm::Resources::Organizations::Users) }
|
|
7
|
+
attr_reader :users
|
|
8
|
+
|
|
9
|
+
# Retrieves all organizations that the authenticated user has access to, including
|
|
10
|
+
# the sender profiles within each organization that the user can access. Returns
|
|
11
|
+
# organization details with nested profiles filtered by user permissions.
|
|
12
|
+
sig do
|
|
13
|
+
params(request_options: Sentdm::RequestOptions::OrHash).returns(
|
|
14
|
+
Sentdm::Models::OrganizationListResponse
|
|
15
|
+
)
|
|
16
|
+
end
|
|
17
|
+
def list(request_options: {})
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Retrieves all sender profiles within an organization that the authenticated user
|
|
21
|
+
# has access to. Returns filtered list based on user's permissions.
|
|
22
|
+
sig do
|
|
23
|
+
params(
|
|
24
|
+
org_id: String,
|
|
25
|
+
request_options: Sentdm::RequestOptions::OrHash
|
|
26
|
+
).returns(Sentdm::Models::OrganizationRetrieveProfilesResponse)
|
|
27
|
+
end
|
|
28
|
+
def retrieve_profiles(org_id, request_options: {})
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# @api private
|
|
32
|
+
sig { params(client: Sentdm::Client).returns(T.attached_class) }
|
|
33
|
+
def self.new(client:)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# typed: strong
|
|
2
|
+
|
|
3
|
+
module Sentdm
|
|
4
|
+
module Resources
|
|
5
|
+
class Templates
|
|
6
|
+
# Creates a new message template for the authenticated customer with comprehensive
|
|
7
|
+
# template definitions including headers, body, footer, and interactive buttons.
|
|
8
|
+
# Supports automatic metadata generation using AI (display name, language,
|
|
9
|
+
# category). Optionally submits the template for WhatsApp review. The customer ID
|
|
10
|
+
# is extracted from the authentication token.
|
|
11
|
+
sig do
|
|
12
|
+
params(
|
|
13
|
+
definition: Sentdm::TemplateDefinition::OrHash,
|
|
14
|
+
category: T.nilable(String),
|
|
15
|
+
language: T.nilable(String),
|
|
16
|
+
submit_for_review: T::Boolean,
|
|
17
|
+
request_options: Sentdm::RequestOptions::OrHash
|
|
18
|
+
).returns(Sentdm::TemplateResponse)
|
|
19
|
+
end
|
|
20
|
+
def create(
|
|
21
|
+
# Template definition containing header, body, footer, and buttons
|
|
22
|
+
definition:,
|
|
23
|
+
# The template category (e.g., MARKETING, UTILITY, AUTHENTICATION). Can only be
|
|
24
|
+
# set when creating a new template. If not provided, will be auto-generated using
|
|
25
|
+
# AI.
|
|
26
|
+
category: nil,
|
|
27
|
+
# The template language code (e.g., en_US, es_ES). Can only be set when creating a
|
|
28
|
+
# new template. If not provided, will be auto-detected using AI.
|
|
29
|
+
language: nil,
|
|
30
|
+
# When false, the template will be saved as draft. When true, the template will be
|
|
31
|
+
# submitted for review.
|
|
32
|
+
submit_for_review: nil,
|
|
33
|
+
request_options: {}
|
|
34
|
+
)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Retrieves a specific message template by its unique identifier for the
|
|
38
|
+
# authenticated customer with comprehensive template definitions including
|
|
39
|
+
# headers, body, footer, and interactive buttons. The customer ID is extracted
|
|
40
|
+
# from the authentication token.
|
|
41
|
+
sig do
|
|
42
|
+
params(
|
|
43
|
+
id: String,
|
|
44
|
+
request_options: Sentdm::RequestOptions::OrHash
|
|
45
|
+
).returns(Sentdm::TemplateResponse)
|
|
46
|
+
end
|
|
47
|
+
def retrieve(id, request_options: {})
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# Retrieves all message templates available for the authenticated customer with
|
|
51
|
+
# comprehensive template definitions including headers, body, footer, and
|
|
52
|
+
# interactive buttons. Supports advanced filtering by search term, status, and
|
|
53
|
+
# category, plus pagination. The customer ID is extracted from the authentication
|
|
54
|
+
# token.
|
|
55
|
+
sig do
|
|
56
|
+
params(
|
|
57
|
+
page: Integer,
|
|
58
|
+
page_size: Integer,
|
|
59
|
+
category: T.nilable(String),
|
|
60
|
+
search: T.nilable(String),
|
|
61
|
+
status: T.nilable(String),
|
|
62
|
+
request_options: Sentdm::RequestOptions::OrHash
|
|
63
|
+
).returns(Sentdm::Models::TemplateListResponse)
|
|
64
|
+
end
|
|
65
|
+
def list(
|
|
66
|
+
# The page number (zero-indexed). Default is 0.
|
|
67
|
+
page:,
|
|
68
|
+
# The number of items per page (1-1000). Default is 100.
|
|
69
|
+
page_size:,
|
|
70
|
+
# Optional filter by template category (e.g., MARKETING, UTILITY, AUTHENTICATION)
|
|
71
|
+
category: nil,
|
|
72
|
+
# Optional search term to filter templates by name or content
|
|
73
|
+
search: nil,
|
|
74
|
+
# Optional filter by template status (e.g., APPROVED, PENDING, REJECTED, DRAFT)
|
|
75
|
+
status: nil,
|
|
76
|
+
request_options: {}
|
|
77
|
+
)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# Deletes a specific message template by its unique identifier for the
|
|
81
|
+
# authenticated customer with smart deletion strategy. Deletion behavior: - If
|
|
82
|
+
# template has NO messages: Permanently deleted from database (hard delete). - If
|
|
83
|
+
# template has messages: Marked as deleted but preserved for message history (soft
|
|
84
|
+
# delete with snapshot). The template must exist and belong to the authenticated
|
|
85
|
+
# customer to be deleted successfully. The customer ID is extracted from the
|
|
86
|
+
# authentication token.
|
|
87
|
+
sig do
|
|
88
|
+
params(id: String, request_options: Sentdm::RequestOptions::OrHash).void
|
|
89
|
+
end
|
|
90
|
+
def delete(
|
|
91
|
+
# The unique identifier (GUID) of the resource to retrieve
|
|
92
|
+
id,
|
|
93
|
+
request_options: {}
|
|
94
|
+
)
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
# @api private
|
|
98
|
+
sig { params(client: Sentdm::Client).returns(T.attached_class) }
|
|
99
|
+
def self.new(client:)
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
module Sentdm
|
|
2
|
+
class Client < Sentdm::Internal::Transport::BaseClient
|
|
3
|
+
DEFAULT_MAX_RETRIES: 2
|
|
4
|
+
|
|
5
|
+
DEFAULT_TIMEOUT_IN_SECONDS: Float
|
|
6
|
+
|
|
7
|
+
DEFAULT_INITIAL_RETRY_DELAY: Float
|
|
8
|
+
|
|
9
|
+
DEFAULT_MAX_RETRY_DELAY: Float
|
|
10
|
+
|
|
11
|
+
attr_reader api_key: String
|
|
12
|
+
|
|
13
|
+
attr_reader sender_id: String
|
|
14
|
+
|
|
15
|
+
attr_reader templates: Sentdm::Resources::Templates
|
|
16
|
+
|
|
17
|
+
attr_reader contacts: Sentdm::Resources::Contacts
|
|
18
|
+
|
|
19
|
+
attr_reader messages: Sentdm::Resources::Messages
|
|
20
|
+
|
|
21
|
+
attr_reader number_lookup: Sentdm::Resources::NumberLookup
|
|
22
|
+
|
|
23
|
+
attr_reader organizations: Sentdm::Resources::Organizations
|
|
24
|
+
|
|
25
|
+
private def auth_headers: -> ::Hash[String, String]
|
|
26
|
+
|
|
27
|
+
private def customer_api_key: -> ::Hash[String, String]
|
|
28
|
+
|
|
29
|
+
private def customer_sender_id: -> ::Hash[String, String]
|
|
30
|
+
|
|
31
|
+
def initialize: (
|
|
32
|
+
?api_key: String?,
|
|
33
|
+
?sender_id: String?,
|
|
34
|
+
?base_url: String?,
|
|
35
|
+
?max_retries: Integer,
|
|
36
|
+
?timeout: Float,
|
|
37
|
+
?initial_retry_delay: Float,
|
|
38
|
+
?max_retry_delay: Float
|
|
39
|
+
) -> void
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
module Sentdm
|
|
2
|
+
module Errors
|
|
3
|
+
class Error < StandardError
|
|
4
|
+
attr_accessor cause: StandardError?
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
class ConversionError < Sentdm::Errors::Error
|
|
8
|
+
def cause: -> StandardError?
|
|
9
|
+
|
|
10
|
+
def initialize: (
|
|
11
|
+
on: Class,
|
|
12
|
+
method: Symbol,
|
|
13
|
+
target: top,
|
|
14
|
+
value: top,
|
|
15
|
+
?cause: StandardError?
|
|
16
|
+
) -> void
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
class APIError < Sentdm::Errors::Error
|
|
20
|
+
attr_accessor url: URI::Generic
|
|
21
|
+
|
|
22
|
+
attr_accessor status: Integer?
|
|
23
|
+
|
|
24
|
+
attr_accessor headers: ::Hash[String, String]?
|
|
25
|
+
|
|
26
|
+
attr_accessor body: top?
|
|
27
|
+
|
|
28
|
+
def initialize: (
|
|
29
|
+
url: URI::Generic,
|
|
30
|
+
?status: Integer?,
|
|
31
|
+
?headers: ::Hash[String, String]?,
|
|
32
|
+
?body: Object?,
|
|
33
|
+
?request: nil,
|
|
34
|
+
?response: nil,
|
|
35
|
+
?message: String?
|
|
36
|
+
) -> void
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
class APIConnectionError < Sentdm::Errors::APIError
|
|
40
|
+
def initialize: (
|
|
41
|
+
url: URI::Generic,
|
|
42
|
+
?status: nil,
|
|
43
|
+
?headers: ::Hash[String, String]?,
|
|
44
|
+
?body: nil,
|
|
45
|
+
?request: nil,
|
|
46
|
+
?response: nil,
|
|
47
|
+
?message: String?
|
|
48
|
+
) -> void
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
class APITimeoutError < Sentdm::Errors::APIConnectionError
|
|
52
|
+
def initialize: (
|
|
53
|
+
url: URI::Generic,
|
|
54
|
+
?status: nil,
|
|
55
|
+
?headers: ::Hash[String, String]?,
|
|
56
|
+
?body: nil,
|
|
57
|
+
?request: nil,
|
|
58
|
+
?response: nil,
|
|
59
|
+
?message: String?
|
|
60
|
+
) -> void
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
class APIStatusError < Sentdm::Errors::APIError
|
|
64
|
+
def self.for: (
|
|
65
|
+
url: URI::Generic,
|
|
66
|
+
status: Integer,
|
|
67
|
+
headers: ::Hash[String, String]?,
|
|
68
|
+
body: Object?,
|
|
69
|
+
request: nil,
|
|
70
|
+
response: nil,
|
|
71
|
+
?message: String?
|
|
72
|
+
) -> instance
|
|
73
|
+
|
|
74
|
+
def initialize: (
|
|
75
|
+
url: URI::Generic,
|
|
76
|
+
status: Integer,
|
|
77
|
+
headers: ::Hash[String, String]?,
|
|
78
|
+
body: Object?,
|
|
79
|
+
request: nil,
|
|
80
|
+
response: nil,
|
|
81
|
+
?message: String?
|
|
82
|
+
) -> void
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
class BadRequestError < Sentdm::Errors::APIStatusError
|
|
86
|
+
HTTP_STATUS: 400
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
class AuthenticationError < Sentdm::Errors::APIStatusError
|
|
90
|
+
HTTP_STATUS: 401
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
class PermissionDeniedError < Sentdm::Errors::APIStatusError
|
|
94
|
+
HTTP_STATUS: 403
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
class NotFoundError < Sentdm::Errors::APIStatusError
|
|
98
|
+
HTTP_STATUS: 404
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
class ConflictError < Sentdm::Errors::APIStatusError
|
|
102
|
+
HTTP_STATUS: 409
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
class UnprocessableEntityError < Sentdm::Errors::APIStatusError
|
|
106
|
+
HTTP_STATUS: 422
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
class RateLimitError < Sentdm::Errors::APIStatusError
|
|
110
|
+
HTTP_STATUS: 429
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
class InternalServerError < Sentdm::Errors::APIStatusError
|
|
114
|
+
HTTP_STATUS: Range[Integer]
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Sentdm
|
|
2
|
+
class FilePart
|
|
3
|
+
attr_reader content: Pathname | StringIO | IO | String
|
|
4
|
+
|
|
5
|
+
attr_reader content_type: String?
|
|
6
|
+
|
|
7
|
+
attr_reader filename: String?
|
|
8
|
+
|
|
9
|
+
private def read: -> String
|
|
10
|
+
|
|
11
|
+
def to_json: (*top a) -> String
|
|
12
|
+
|
|
13
|
+
def to_yaml: (*top a) -> String
|
|
14
|
+
|
|
15
|
+
def initialize: (
|
|
16
|
+
Pathname | StringIO | IO | String content,
|
|
17
|
+
?filename: (Pathname | String)?,
|
|
18
|
+
?content_type: String?
|
|
19
|
+
) -> void
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
module Sentdm
|
|
2
|
+
module Internal
|
|
3
|
+
module Transport
|
|
4
|
+
class BaseClient
|
|
5
|
+
extend Sentdm::Internal::Util::SorbetRuntimeSupport
|
|
6
|
+
|
|
7
|
+
type request_components =
|
|
8
|
+
{
|
|
9
|
+
method: Symbol,
|
|
10
|
+
path: String | ::Array[String],
|
|
11
|
+
query: ::Hash[String, (::Array[String] | String)?]?,
|
|
12
|
+
headers: ::Hash[String, (String
|
|
13
|
+
| Integer
|
|
14
|
+
| ::Array[(String | Integer)?])?]?,
|
|
15
|
+
body: top?,
|
|
16
|
+
unwrap: (Symbol
|
|
17
|
+
| Integer
|
|
18
|
+
| ::Array[(Symbol | Integer)]
|
|
19
|
+
| (^(top arg0) -> top))?,
|
|
20
|
+
page: Class?,
|
|
21
|
+
stream: Class?,
|
|
22
|
+
model: Sentdm::Internal::Type::Converter::input?,
|
|
23
|
+
options: Sentdm::request_opts?
|
|
24
|
+
}
|
|
25
|
+
type request_input =
|
|
26
|
+
{
|
|
27
|
+
method: Symbol,
|
|
28
|
+
url: URI::Generic,
|
|
29
|
+
headers: ::Hash[String, String],
|
|
30
|
+
body: top,
|
|
31
|
+
max_retries: Integer,
|
|
32
|
+
timeout: Float
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
MAX_REDIRECTS: 20
|
|
36
|
+
|
|
37
|
+
PLATFORM_HEADERS: ::Hash[String, String]
|
|
38
|
+
|
|
39
|
+
def self.validate!: (
|
|
40
|
+
Sentdm::Internal::Transport::BaseClient::request_components req
|
|
41
|
+
) -> void
|
|
42
|
+
|
|
43
|
+
def self.should_retry?: (
|
|
44
|
+
Integer status,
|
|
45
|
+
headers: ::Hash[String, String]
|
|
46
|
+
) -> bool
|
|
47
|
+
|
|
48
|
+
def self.follow_redirect: (
|
|
49
|
+
Sentdm::Internal::Transport::BaseClient::request_input request,
|
|
50
|
+
status: Integer,
|
|
51
|
+
response_headers: ::Hash[String, String]
|
|
52
|
+
) -> Sentdm::Internal::Transport::BaseClient::request_input
|
|
53
|
+
|
|
54
|
+
def self.reap_connection!: (
|
|
55
|
+
Integer | Sentdm::Errors::APIConnectionError status,
|
|
56
|
+
stream: Enumerable[String]?
|
|
57
|
+
) -> void
|
|
58
|
+
|
|
59
|
+
attr_reader base_url: URI::Generic
|
|
60
|
+
|
|
61
|
+
attr_reader timeout: Float
|
|
62
|
+
|
|
63
|
+
attr_reader max_retries: Integer
|
|
64
|
+
|
|
65
|
+
attr_reader initial_retry_delay: Float
|
|
66
|
+
|
|
67
|
+
attr_reader max_retry_delay: Float
|
|
68
|
+
|
|
69
|
+
attr_reader headers: ::Hash[String, String]
|
|
70
|
+
|
|
71
|
+
attr_reader idempotency_header: String?
|
|
72
|
+
|
|
73
|
+
# @api private
|
|
74
|
+
attr_reader requester: Sentdm::Internal::Transport::PooledNetRequester
|
|
75
|
+
|
|
76
|
+
def initialize: (
|
|
77
|
+
base_url: String,
|
|
78
|
+
?timeout: Float,
|
|
79
|
+
?max_retries: Integer,
|
|
80
|
+
?initial_retry_delay: Float,
|
|
81
|
+
?max_retry_delay: Float,
|
|
82
|
+
?headers: ::Hash[String, (String
|
|
83
|
+
| Integer
|
|
84
|
+
| ::Array[(String | Integer)?])?],
|
|
85
|
+
?idempotency_header: String?
|
|
86
|
+
) -> void
|
|
87
|
+
|
|
88
|
+
private def auth_headers: -> ::Hash[String, String]
|
|
89
|
+
|
|
90
|
+
private def user_agent: -> String
|
|
91
|
+
|
|
92
|
+
private def generate_idempotency_key: -> String
|
|
93
|
+
|
|
94
|
+
private def build_request: (
|
|
95
|
+
Sentdm::Internal::Transport::BaseClient::request_components req,
|
|
96
|
+
Sentdm::request_options opts
|
|
97
|
+
) -> Sentdm::Internal::Transport::BaseClient::request_input
|
|
98
|
+
|
|
99
|
+
private def retry_delay: (
|
|
100
|
+
::Hash[String, String] headers,
|
|
101
|
+
retry_count: Integer
|
|
102
|
+
) -> Float
|
|
103
|
+
|
|
104
|
+
def send_request: (
|
|
105
|
+
Sentdm::Internal::Transport::BaseClient::request_input request,
|
|
106
|
+
redirect_count: Integer,
|
|
107
|
+
retry_count: Integer,
|
|
108
|
+
send_retry_header: bool
|
|
109
|
+
) -> [Integer, top, Enumerable[String]]
|
|
110
|
+
|
|
111
|
+
def request: (
|
|
112
|
+
Symbol method,
|
|
113
|
+
String | ::Array[String] path,
|
|
114
|
+
?query: ::Hash[String, (::Array[String] | String)?]?,
|
|
115
|
+
?headers: ::Hash[String, (String
|
|
116
|
+
| Integer
|
|
117
|
+
| ::Array[(String | Integer)?])?]?,
|
|
118
|
+
?body: top?,
|
|
119
|
+
?unwrap: (Symbol
|
|
120
|
+
| Integer
|
|
121
|
+
| ::Array[(Symbol | Integer)]
|
|
122
|
+
| (^(top arg0) -> top))?,
|
|
123
|
+
?page: Class?,
|
|
124
|
+
?stream: Class?,
|
|
125
|
+
?model: Sentdm::Internal::Type::Converter::input?,
|
|
126
|
+
?options: Sentdm::request_opts?
|
|
127
|
+
) -> top
|
|
128
|
+
|
|
129
|
+
def inspect: -> String
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
module Sentdm
|
|
2
|
+
module Internal
|
|
3
|
+
module Transport
|
|
4
|
+
class PooledNetRequester
|
|
5
|
+
extend Sentdm::Internal::Util::SorbetRuntimeSupport
|
|
6
|
+
|
|
7
|
+
type request =
|
|
8
|
+
{
|
|
9
|
+
method: Symbol,
|
|
10
|
+
url: URI::Generic,
|
|
11
|
+
headers: ::Hash[String, String],
|
|
12
|
+
body: top,
|
|
13
|
+
deadline: Float
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
KEEP_ALIVE_TIMEOUT: 30
|
|
17
|
+
|
|
18
|
+
DEFAULT_MAX_CONNECTIONS: Integer
|
|
19
|
+
|
|
20
|
+
def self.connect: (
|
|
21
|
+
cert_store: OpenSSL::X509::Store,
|
|
22
|
+
url: URI::Generic
|
|
23
|
+
) -> top
|
|
24
|
+
|
|
25
|
+
def self.calibrate_socket_timeout: (top conn, Float deadline) -> void
|
|
26
|
+
|
|
27
|
+
def self.build_request: (
|
|
28
|
+
Sentdm::Internal::Transport::PooledNetRequester::request request
|
|
29
|
+
) {
|
|
30
|
+
(String arg0) -> void
|
|
31
|
+
} -> [top, (^-> void)]
|
|
32
|
+
|
|
33
|
+
private def with_pool: (
|
|
34
|
+
URI::Generic url,
|
|
35
|
+
deadline: Float
|
|
36
|
+
) {
|
|
37
|
+
(top arg0) -> void
|
|
38
|
+
} -> void
|
|
39
|
+
|
|
40
|
+
def execute: (
|
|
41
|
+
Sentdm::Internal::Transport::PooledNetRequester::request request
|
|
42
|
+
) -> [Integer, top, Enumerable[String]]
|
|
43
|
+
|
|
44
|
+
def initialize: (?size: Integer) -> void
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
module Sentdm
|
|
2
|
+
module Internal
|
|
3
|
+
module Type
|
|
4
|
+
class ArrayOf[Elem]
|
|
5
|
+
include Sentdm::Internal::Type::Converter
|
|
6
|
+
include Sentdm::Internal::Util::SorbetRuntimeSupport
|
|
7
|
+
|
|
8
|
+
def self.[]: (
|
|
9
|
+
::Hash[Symbol, top]
|
|
10
|
+
| ^-> Sentdm::Internal::Type::Converter::input
|
|
11
|
+
| Sentdm::Internal::Type::Converter::input type_info,
|
|
12
|
+
?::Hash[Symbol, top] spec
|
|
13
|
+
) -> instance
|
|
14
|
+
|
|
15
|
+
def ===: (top other) -> bool
|
|
16
|
+
|
|
17
|
+
def ==: (top other) -> bool
|
|
18
|
+
|
|
19
|
+
def hash: -> Integer
|
|
20
|
+
|
|
21
|
+
def coerce: (
|
|
22
|
+
::Array[top] | top value,
|
|
23
|
+
state: Sentdm::Internal::Type::Converter::coerce_state
|
|
24
|
+
) -> (::Array[top] | top)
|
|
25
|
+
|
|
26
|
+
def dump: (
|
|
27
|
+
::Array[top] | top value,
|
|
28
|
+
state: Sentdm::Internal::Type::Converter::dump_state
|
|
29
|
+
) -> (::Array[top] | top)
|
|
30
|
+
|
|
31
|
+
def to_sorbet_type: -> top
|
|
32
|
+
|
|
33
|
+
def item_type: -> Elem
|
|
34
|
+
|
|
35
|
+
def nilable?: -> bool
|
|
36
|
+
|
|
37
|
+
def initialize: (
|
|
38
|
+
::Hash[Symbol, top]
|
|
39
|
+
| ^-> Sentdm::Internal::Type::Converter::input
|
|
40
|
+
| Sentdm::Internal::Type::Converter::input type_info,
|
|
41
|
+
?::Hash[Symbol, top] spec
|
|
42
|
+
) -> void
|
|
43
|
+
|
|
44
|
+
def inspect: (?depth: Integer) -> String
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
module Sentdm
|
|
2
|
+
module Internal
|
|
3
|
+
module Type
|
|
4
|
+
class BaseModel
|
|
5
|
+
extend Sentdm::Internal::Type::Converter
|
|
6
|
+
extend Sentdm::Internal::Util::SorbetRuntimeSupport
|
|
7
|
+
|
|
8
|
+
type known_field =
|
|
9
|
+
{ mode: (:coerce | :dump)?, required: bool, nilable: bool }
|
|
10
|
+
|
|
11
|
+
def self.inherited: (self child) -> void
|
|
12
|
+
|
|
13
|
+
def self.known_fields: -> ::Hash[Symbol, (Sentdm::Internal::Type::BaseModel::known_field
|
|
14
|
+
& { type_fn: (^-> Sentdm::Internal::Type::Converter::input) })]
|
|
15
|
+
|
|
16
|
+
def self.fields: -> ::Hash[Symbol, (Sentdm::Internal::Type::BaseModel::known_field
|
|
17
|
+
& { type: Sentdm::Internal::Type::Converter::input })]
|
|
18
|
+
|
|
19
|
+
private def self.add_field: (
|
|
20
|
+
Symbol name_sym,
|
|
21
|
+
required: bool,
|
|
22
|
+
type_info: {
|
|
23
|
+
const: (nil | bool | Integer | Float | Symbol)?,
|
|
24
|
+
enum: ^-> Sentdm::Internal::Type::Converter::input?,
|
|
25
|
+
union: ^-> Sentdm::Internal::Type::Converter::input?,
|
|
26
|
+
api_name: Symbol
|
|
27
|
+
}
|
|
28
|
+
| ^-> Sentdm::Internal::Type::Converter::input
|
|
29
|
+
| Sentdm::Internal::Type::Converter::input,
|
|
30
|
+
spec: ::Hash[Symbol, top]
|
|
31
|
+
) -> void
|
|
32
|
+
|
|
33
|
+
def self.required: (
|
|
34
|
+
Symbol name_sym,
|
|
35
|
+
::Hash[Symbol, top]
|
|
36
|
+
| ^-> Sentdm::Internal::Type::Converter::input
|
|
37
|
+
| Sentdm::Internal::Type::Converter::input type_info,
|
|
38
|
+
?::Hash[Symbol, top] spec
|
|
39
|
+
) -> void
|
|
40
|
+
|
|
41
|
+
def self.optional: (
|
|
42
|
+
Symbol name_sym,
|
|
43
|
+
::Hash[Symbol, top]
|
|
44
|
+
| ^-> Sentdm::Internal::Type::Converter::input
|
|
45
|
+
| Sentdm::Internal::Type::Converter::input type_info,
|
|
46
|
+
?::Hash[Symbol, top] spec
|
|
47
|
+
) -> void
|
|
48
|
+
|
|
49
|
+
private def self.request_only: { -> void } -> void
|
|
50
|
+
|
|
51
|
+
private def self.response_only: { -> void } -> void
|
|
52
|
+
|
|
53
|
+
def self.==: (top other) -> bool
|
|
54
|
+
|
|
55
|
+
def self.hash: -> Integer
|
|
56
|
+
|
|
57
|
+
def ==: (top other) -> bool
|
|
58
|
+
|
|
59
|
+
def hash: -> Integer
|
|
60
|
+
|
|
61
|
+
def self.coerce: (
|
|
62
|
+
Sentdm::Internal::Type::BaseModel | ::Hash[top, top] | top value,
|
|
63
|
+
state: Sentdm::Internal::Type::Converter::coerce_state
|
|
64
|
+
) -> (instance | top)
|
|
65
|
+
|
|
66
|
+
def self.dump: (
|
|
67
|
+
instance | top value,
|
|
68
|
+
state: Sentdm::Internal::Type::Converter::dump_state
|
|
69
|
+
) -> (::Hash[top, top] | top)
|
|
70
|
+
|
|
71
|
+
def self.to_sorbet_type: -> top
|
|
72
|
+
|
|
73
|
+
def self.recursively_to_h: (
|
|
74
|
+
Sentdm::Internal::Type::BaseModel model,
|
|
75
|
+
convert: bool
|
|
76
|
+
) -> ::Hash[Symbol, top]
|
|
77
|
+
|
|
78
|
+
def []: (Symbol key) -> top?
|
|
79
|
+
|
|
80
|
+
def to_h: -> ::Hash[Symbol, top]
|
|
81
|
+
|
|
82
|
+
alias to_hash to_h
|
|
83
|
+
|
|
84
|
+
def deep_to_h: -> ::Hash[Symbol, top]
|
|
85
|
+
|
|
86
|
+
def deconstruct_keys: (::Array[Symbol]? keys) -> ::Hash[Symbol, top]
|
|
87
|
+
|
|
88
|
+
def to_json: (*top a) -> String
|
|
89
|
+
|
|
90
|
+
def to_yaml: (*top a) -> String
|
|
91
|
+
|
|
92
|
+
def initialize: (?::Hash[Symbol, top] | instance data) -> void
|
|
93
|
+
|
|
94
|
+
def self.inspect: (?depth: Integer) -> String
|
|
95
|
+
|
|
96
|
+
def to_s: -> String
|
|
97
|
+
|
|
98
|
+
def inspect: -> String
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module Sentdm
|
|
2
|
+
module Internal
|
|
3
|
+
module Type
|
|
4
|
+
module BasePage[Elem]
|
|
5
|
+
def next_page?: -> bool
|
|
6
|
+
|
|
7
|
+
def next_page: -> instance
|
|
8
|
+
|
|
9
|
+
def auto_paging_each: { (Elem arg0) -> void } -> void
|
|
10
|
+
|
|
11
|
+
def to_enum: -> Enumerable[Elem]
|
|
12
|
+
|
|
13
|
+
alias enum_for to_enum
|
|
14
|
+
|
|
15
|
+
def initialize: (
|
|
16
|
+
client: Sentdm::Internal::Transport::BaseClient,
|
|
17
|
+
req: Sentdm::Internal::Transport::BaseClient::request_components,
|
|
18
|
+
headers: ::Hash[String, String],
|
|
19
|
+
page_data: top
|
|
20
|
+
) -> void
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|