qubrics-sending 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +57 -0
- data/LICENSE +21 -0
- data/README.md +112 -0
- data/lib/qubrics/sending/client.rb +71 -0
- data/lib/qubrics/sending/version.rb +7 -0
- data/lib/qubrics/sending.rb +12 -0
- data/lib/qubrics_sending_generated/api/attachments_api.rb +373 -0
- data/lib/qubrics_sending_generated/api/emails_api.rb +172 -0
- data/lib/qubrics_sending_generated/api/meta_api.rb +142 -0
- data/lib/qubrics_sending_generated/api_client.rb +447 -0
- data/lib/qubrics_sending_generated/api_error.rb +58 -0
- data/lib/qubrics_sending_generated/api_model_base.rb +95 -0
- data/lib/qubrics_sending_generated/configuration.rb +413 -0
- data/lib/qubrics_sending_generated/models/address.rb +215 -0
- data/lib/qubrics_sending_generated/models/attachment.rb +103 -0
- data/lib/qubrics_sending_generated/models/attachment_upload_data.rb +284 -0
- data/lib/qubrics_sending_generated/models/attachment_upload_intent_data.rb +337 -0
- data/lib/qubrics_sending_generated/models/attachment_upload_intent_request.rb +279 -0
- data/lib/qubrics_sending_generated/models/attachment_upload_intent_response.rb +223 -0
- data/lib/qubrics_sending_generated/models/attachment_upload_response.rb +223 -0
- data/lib/qubrics_sending_generated/models/batch_result_item.rb +256 -0
- data/lib/qubrics_sending_generated/models/batch_send_request.rb +185 -0
- data/lib/qubrics_sending_generated/models/batch_send_success_data.rb +192 -0
- data/lib/qubrics_sending_generated/models/batch_send_success_response.rb +223 -0
- data/lib/qubrics_sending_generated/models/batch_summary.rb +219 -0
- data/lib/qubrics_sending_generated/models/connection.rb +273 -0
- data/lib/qubrics_sending_generated/models/connection_credential.rb +226 -0
- data/lib/qubrics_sending_generated/models/connection_mailboxes_inner.rb +190 -0
- data/lib/qubrics_sending_generated/models/connection_response.rb +223 -0
- data/lib/qubrics_sending_generated/models/connection_team.rb +190 -0
- data/lib/qubrics_sending_generated/models/email_send_request.rb +474 -0
- data/lib/qubrics_sending_generated/models/email_send_request_delivery_group.rb +105 -0
- data/lib/qubrics_sending_generated/models/error_detail.rb +251 -0
- data/lib/qubrics_sending_generated/models/error_issue.rb +219 -0
- data/lib/qubrics_sending_generated/models/error_response.rb +216 -0
- data/lib/qubrics_sending_generated/models/inline_attachment.rb +274 -0
- data/lib/qubrics_sending_generated/models/meta.rb +165 -0
- data/lib/qubrics_sending_generated/models/recipient.rb +214 -0
- data/lib/qubrics_sending_generated/models/send_success_data.rb +227 -0
- data/lib/qubrics_sending_generated/models/send_success_response.rb +223 -0
- data/lib/qubrics_sending_generated/models/success_envelope.rb +190 -0
- data/lib/qubrics_sending_generated/models/uploaded_attachment_ref.rb +176 -0
- data/lib/qubrics_sending_generated/version.rb +15 -0
- data/lib/qubrics_sending_generated.rb +72 -0
- metadata +168 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: ceb5b81baaac2aaa809d6e1d35833a297ec59cb5239aac7072e6ec6e9f2bc61c
|
|
4
|
+
data.tar.gz: 314c5c3fb5ebb17ae4ca085f2af3b59835ecfcff0dd7a9ae6b4b0ea6d6a44a6f
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 7d33f7fe96a18d5698492e6be6e5a3793789a699970a1507dbece5db0e11505f35713328324cc0af087ffbf25838b46f6c3f0850845198f448156e70d3fb35e7
|
|
7
|
+
data.tar.gz: 944a636319cb1643ca89f063809413ceffffeebfd0e350d1039045591d4905f1749d228150422052cab7ee5d02dde88a16e727beef61886e4c84bb83c0747367
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 2.0.0
|
|
4
|
+
|
|
5
|
+
- Requires `qubrics-core` 2.x and Ruby 3.1 or newer.
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
* Add one delivery group or a list of `delivery_group` IDs to email send requests.
|
|
10
|
+
|
|
11
|
+
## [1.5.0](https://github.com/Sendmux/sendmux-sdk/compare/ruby-sending/v1.4.0...ruby-sending/v1.5.0) (2026-09-19)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* integrate combined provider variables and delivery routing ([81bbf22](https://github.com/Sendmux/sendmux-sdk/commit/81bbf221a357bf5d588eba654184ff34491473df))
|
|
17
|
+
* **sdk:** add provider variables and delivery group routing ([94f52d4](https://github.com/Sendmux/sendmux-sdk/commit/94f52d4e9f6157e197308541cc5987517bac7a4a))
|
|
18
|
+
|
|
19
|
+
## [1.4.0](https://github.com/Sendmux/sendmux-sdk/compare/ruby-sending/v1.3.0...ruby-sending/v1.4.0) (2026-09-10)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Features
|
|
23
|
+
|
|
24
|
+
* add REST OAuth clients and CLI token lifecycle ([cc4a3aa](https://github.com/Sendmux/sendmux-sdk/commit/cc4a3aa6110378641418a94455ed5b9a986e65ff))
|
|
25
|
+
|
|
26
|
+
## [1.3.0](https://github.com/Sendmux/sendmux-sdk/compare/ruby-sending/v1.2.0...ruby-sending/v1.3.0) (2026-09-08)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
### Features
|
|
30
|
+
|
|
31
|
+
* add connection checks across SDKs, CLI and MCP ([77f449e](https://github.com/Sendmux/sendmux-sdk/commit/77f449e2c8cba49bc8bc84c49c35baa61120866a))
|
|
32
|
+
* **sdk:** add connection checks across clients, CLI and MCP ([3e02c67](https://github.com/Sendmux/sendmux-sdk/commit/3e02c67dcab45e37dad7abbdd4c4e1bd0b1fbbe6))
|
|
33
|
+
|
|
34
|
+
## [1.2.0](https://github.com/Sendmux/sendmux-sdk/compare/ruby-sending/v1.1.0...ruby-sending/v1.2.0) (2026-07-08)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
### Features
|
|
38
|
+
|
|
39
|
+
* **sdk:** add sending attachment upload surfaces ([#96](https://github.com/Sendmux/sendmux-sdk/issues/96)) ([b8f9d5f](https://github.com/Sendmux/sendmux-sdk/commit/b8f9d5fe3c1ae510db82ce05c55cbcad92b43b44))
|
|
40
|
+
|
|
41
|
+
## [1.1.0](https://github.com/Sendmux/sendmux-sdk/compare/ruby-sending/v1.0.0...ruby-sending/v1.1.0) (2026-07-01)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
### Features
|
|
45
|
+
|
|
46
|
+
* allow owner-approved agent tokens for sending ([9d1cb7d](https://github.com/Sendmux/sendmux-sdk/commit/9d1cb7df3df5aef1f59a4990dc087178ba3a7b21))
|
|
47
|
+
|
|
48
|
+
## 1.0.0 (2026-06-02)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
### Features
|
|
52
|
+
|
|
53
|
+
* **ruby:** add generated SDK packages ([f097fdf](https://github.com/Sendmux/sendmux-sdk/commit/f097fdf6afcbc2a048d9fdb1c9a669fff2a7ca4f))
|
|
54
|
+
|
|
55
|
+
## 1.0.0
|
|
56
|
+
|
|
57
|
+
- Initial generated Ruby Sending API package.
|
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Sendmux
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# qubrics-sending
|
|
2
|
+
|
|
3
|
+
[](https://rubygems.org/gems/qubrics-sending)
|
|
4
|
+
[](https://github.com/qubrics/qubrics-sdk/actions/workflows/ci.yml)
|
|
5
|
+
[](https://github.com/qubrics/qubrics-sdk/blob/main/LICENSE)
|
|
6
|
+
|
|
7
|
+
Ruby SDK package for the Qubrics Sending API.
|
|
8
|
+
|
|
9
|
+
## Documentation
|
|
10
|
+
|
|
11
|
+
- Ruby SDK guide: https://qubrics.com/docs/sdks/ruby
|
|
12
|
+
- Sending API reference: https://qubrics.com/docs/sending-api
|
|
13
|
+
- Source: https://github.com/qubrics/qubrics-sdk/tree/main/packages/ruby/sending
|
|
14
|
+
- Changelog: https://github.com/qubrics/qubrics-sdk/blob/main/packages/ruby/sending/CHANGELOG.md
|
|
15
|
+
|
|
16
|
+
## Requirements
|
|
17
|
+
|
|
18
|
+
- Ruby 3.1 or newer.
|
|
19
|
+
- A send-capable `smx_mbx_` key or owner-approved Sending-resource `smx_agent_` token.
|
|
20
|
+
|
|
21
|
+
For OAuth, use a REST access token with the scopes and mailbox access required by the operation. See [OAuth for REST APIs](https://qubrics.com/docs/developer-tools/oauth).
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
gem install qubrics-sending
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Or add it to your Gemfile:
|
|
30
|
+
|
|
31
|
+
```ruby
|
|
32
|
+
gem "qubrics-sending", "~> 2.0"
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## OAuth access tokens
|
|
36
|
+
|
|
37
|
+
Pass either `api_key:` or `access_token:`. `access_token:` accepts a bare token string or a callable; the callable is evaluated once per authenticated request. Your application owns token storage, expiry checks and refresh coordination.
|
|
38
|
+
|
|
39
|
+
```ruby
|
|
40
|
+
require "qubrics/sending"
|
|
41
|
+
|
|
42
|
+
client = Qubrics::Sending::Client.new(
|
|
43
|
+
access_token: -> { ENV.fetch("QUBRICS_ACCESS_TOKEN") }
|
|
44
|
+
)
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Usage
|
|
48
|
+
|
|
49
|
+
Create a sending client with a send-capable key for the API-key example below.
|
|
50
|
+
|
|
51
|
+
```ruby
|
|
52
|
+
require "qubrics/sending"
|
|
53
|
+
|
|
54
|
+
client = Qubrics::Sending::Client.new(
|
|
55
|
+
api_key: ENV.fetch("QUBRICS_MAILBOX_KEY")
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
request = Qubrics::Sending::Generated::EmailSendRequest.new(
|
|
59
|
+
from: Qubrics::Sending::Generated::Address.new(email: "sender@example.com"),
|
|
60
|
+
to: Qubrics::Sending::Generated::Address.new(email: "recipient@example.com"),
|
|
61
|
+
subject: "Hello from Qubrics",
|
|
62
|
+
text_body: "This message was sent with the Qubrics Ruby SDK."
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
response = client.emails.sending_send_email(
|
|
66
|
+
request,
|
|
67
|
+
Qubrics::Core::Headers.idempotency_key("send-email-001")
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
puts response.data.message_id
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Client surface
|
|
74
|
+
|
|
75
|
+
`Qubrics::Sending::Client` exposes:
|
|
76
|
+
|
|
77
|
+
- `client.emails` for `sending_send_email` and `sending_send_email_batch`.
|
|
78
|
+
- `client.meta` for `sending_get_open_api_spec`.
|
|
79
|
+
|
|
80
|
+
Pass `base_url:` only when you are targeting an explicitly provided Qubrics endpoint for a controlled environment.
|
|
81
|
+
|
|
82
|
+
### Idempotency and retries
|
|
83
|
+
|
|
84
|
+
Mutating sending operations accept the `:idempotency_key` option. Use `Qubrics::Core::Headers.idempotency_key` so retries are safe when a request is replayable.
|
|
85
|
+
|
|
86
|
+
```ruby
|
|
87
|
+
client.emails.sending_send_email(
|
|
88
|
+
request,
|
|
89
|
+
Qubrics::Core::Headers.idempotency_key("send-email-002")
|
|
90
|
+
)
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Errors
|
|
94
|
+
|
|
95
|
+
Generated API errors are mapped to `Qubrics::Core::ApiError`.
|
|
96
|
+
|
|
97
|
+
```ruby
|
|
98
|
+
begin
|
|
99
|
+
client.emails.sending_send_email(request)
|
|
100
|
+
rescue Qubrics::Core::ApiError => error
|
|
101
|
+
warn "#{error.status} #{error.code}: #{error.message}"
|
|
102
|
+
end
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Support
|
|
106
|
+
|
|
107
|
+
- Documentation: https://qubrics.com/docs
|
|
108
|
+
- Contact: contact@qubrics.com
|
|
109
|
+
|
|
110
|
+
## Licence
|
|
111
|
+
|
|
112
|
+
MIT licence. See https://github.com/qubrics/qubrics-sdk/blob/main/LICENSE.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Qubrics
|
|
4
|
+
module Sending
|
|
5
|
+
DEFAULT_BASE_URL = 'https://smtp.qubrics.com/api/v1'
|
|
6
|
+
|
|
7
|
+
class ApiClient < Generated::ApiClient
|
|
8
|
+
def update_params_for_auth!(header_params, query_params, auth_names)
|
|
9
|
+
auth_names = Array(auth_names)
|
|
10
|
+
if !auth_names.empty? && (auth_names - %w[UploadTokenQubrics UploadTokenSendmux]).empty?
|
|
11
|
+
apply_upload_token_auth!(header_params)
|
|
12
|
+
return
|
|
13
|
+
end
|
|
14
|
+
return super unless config.access_token_getter && !auth_names.empty?
|
|
15
|
+
|
|
16
|
+
header_params['Authorization'] = "Bearer #{config.access_token_with_refresh}"
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def call_api(...)
|
|
20
|
+
super
|
|
21
|
+
rescue Generated::ApiError => e
|
|
22
|
+
raise Qubrics::Core::ErrorMapper.map(e)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
private
|
|
26
|
+
|
|
27
|
+
def apply_upload_token_auth!(header_params)
|
|
28
|
+
upload_headers = %w[X-Qubrics-Upload-Token X-Sendmux-Upload-Token]
|
|
29
|
+
return if upload_headers.any? { |header| header_params[header] || header_params[header.to_sym] }
|
|
30
|
+
|
|
31
|
+
upload_headers.each do |header|
|
|
32
|
+
token = config.api_key_with_prefix(header)
|
|
33
|
+
next if token.nil? || token.empty?
|
|
34
|
+
|
|
35
|
+
header_params[header] = token
|
|
36
|
+
break
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
class Client
|
|
42
|
+
attr_reader :api_client, :configuration
|
|
43
|
+
|
|
44
|
+
def initialize(api_key: nil, access_token: nil, base_url: nil, retry_options: nil)
|
|
45
|
+
qubrics_base_url = ENV.fetch('QUBRICS_BASE_URL', nil)
|
|
46
|
+
qubrics_base_url = nil if qubrics_base_url&.empty?
|
|
47
|
+
@configuration = Qubrics::Core::Auth.configure_bearer(
|
|
48
|
+
Generated::Configuration.new,
|
|
49
|
+
api_key,
|
|
50
|
+
Qubrics::Core::ApiKeySurface::SENDING,
|
|
51
|
+
base_url: base_url || qubrics_base_url || ENV.fetch('SENDMUX_BASE_URL', DEFAULT_BASE_URL),
|
|
52
|
+
access_token: access_token
|
|
53
|
+
)
|
|
54
|
+
Qubrics::Core::Retry.configure(@configuration, retry_options)
|
|
55
|
+
@api_client = ApiClient.new(@configuration)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def attachments
|
|
59
|
+
@attachments ||= Generated::AttachmentsApi.new(@api_client)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def emails
|
|
63
|
+
@emails ||= Generated::EmailsApi.new(@api_client)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def meta
|
|
67
|
+
@meta ||= Generated::MetaApi.new(@api_client)
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#Qubrics Sending API
|
|
3
|
+
|
|
4
|
+
#Send emails programmatically via the Qubrics email infrastructure. Every response carries an `X-Request-Id` header; errors include a `retryable` flag. 429 and 503 responses include `Retry-After`. Mutating endpoints accept an `Idempotency-Key` header for safe retries.
|
|
5
|
+
|
|
6
|
+
The version of the OpenAPI document: 1.0.0
|
|
7
|
+
|
|
8
|
+
Generated by: https://openapi-generator.tech
|
|
9
|
+
Generator version: 7.22.0
|
|
10
|
+
|
|
11
|
+
=end
|
|
12
|
+
|
|
13
|
+
require 'cgi'
|
|
14
|
+
|
|
15
|
+
module Qubrics::Sending::Generated
|
|
16
|
+
class AttachmentsApi
|
|
17
|
+
attr_accessor :api_client
|
|
18
|
+
|
|
19
|
+
def initialize(api_client = ApiClient.default)
|
|
20
|
+
@api_client = api_client
|
|
21
|
+
end
|
|
22
|
+
# Upload bytes to an attachment upload URL
|
|
23
|
+
# Upload the exact binary bytes for a previously-created attachment upload URL. This operation uses the short-lived upload token header returned by POST /emails/attachment-uploads, not a Qubrics API key.
|
|
24
|
+
# @param content_length [Integer] Exact number of bytes in the binary request body.
|
|
25
|
+
# @param upload_id [String] Upload intent ID returned by POST /emails/attachment-uploads.
|
|
26
|
+
# @param body [File]
|
|
27
|
+
# @param [Hash] opts the optional parameters
|
|
28
|
+
# @option opts [String] :x_qubrics_upload_token Short-lived upload token returned by POST /emails/attachment-uploads. Send this header or X-Sendmux-Upload-Token. If both are sent, their values must match.
|
|
29
|
+
# @option opts [String] :x_sendmux_upload_token Compatibility alias for X-Qubrics-Upload-Token, retained indefinitely.
|
|
30
|
+
# @return [AttachmentUploadResponse]
|
|
31
|
+
def sending_complete_attachment_upload(content_length, upload_id, body, opts = {}, legacy_opts = nil)
|
|
32
|
+
data, _status_code, _headers = sending_complete_attachment_upload_with_http_info(content_length, upload_id, body, opts, legacy_opts)
|
|
33
|
+
data
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Upload bytes to an attachment upload URL
|
|
37
|
+
# Upload the exact binary bytes for a previously-created attachment upload URL. This operation uses the short-lived upload token header returned by POST /emails/attachment-uploads, not a Qubrics API key.
|
|
38
|
+
# @param content_length [Integer] Exact number of bytes in the binary request body.
|
|
39
|
+
# @param upload_id [String] Upload intent ID returned by POST /emails/attachment-uploads.
|
|
40
|
+
# @param body [File]
|
|
41
|
+
# @param [Hash] opts the optional parameters
|
|
42
|
+
# @option opts [String] :x_qubrics_upload_token Short-lived upload token returned by POST /emails/attachment-uploads. Send this header or X-Sendmux-Upload-Token. If both are sent, their values must match.
|
|
43
|
+
# @option opts [String] :x_sendmux_upload_token Compatibility alias for X-Qubrics-Upload-Token, retained indefinitely.
|
|
44
|
+
# @return [Array<(AttachmentUploadResponse, Integer, Hash)>] AttachmentUploadResponse data, response status code and response headers
|
|
45
|
+
def sending_complete_attachment_upload_with_http_info(content_length, upload_id, body, opts = {}, legacy_opts = nil)
|
|
46
|
+
if !opts.is_a?(Hash) || !legacy_opts.nil?
|
|
47
|
+
content_length, upload_id, body, opts = upload_id, body, opts,
|
|
48
|
+
(legacy_opts || {}).merge(x_sendmux_upload_token: content_length)
|
|
49
|
+
end
|
|
50
|
+
if @api_client.config.debugging
|
|
51
|
+
@api_client.config.logger.debug 'Calling API: AttachmentsApi.sending_complete_attachment_upload ...'
|
|
52
|
+
end
|
|
53
|
+
# verify the required parameter 'content_length' is set
|
|
54
|
+
if @api_client.config.client_side_validation && content_length.nil?
|
|
55
|
+
fail ArgumentError, "Missing the required parameter 'content_length' when calling AttachmentsApi.sending_complete_attachment_upload"
|
|
56
|
+
end
|
|
57
|
+
if @api_client.config.client_side_validation && content_length < 1
|
|
58
|
+
fail ArgumentError, 'invalid value for "content_length" when calling AttachmentsApi.sending_complete_attachment_upload, must be greater than or equal to 1.'
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# verify the required parameter 'upload_id' is set
|
|
62
|
+
if @api_client.config.client_side_validation && upload_id.nil?
|
|
63
|
+
fail ArgumentError, "Missing the required parameter 'upload_id' when calling AttachmentsApi.sending_complete_attachment_upload"
|
|
64
|
+
end
|
|
65
|
+
pattern = Regexp.new(/^upl_[a-z0-9]{24}$/)
|
|
66
|
+
if @api_client.config.client_side_validation && upload_id !~ pattern
|
|
67
|
+
fail ArgumentError, "invalid value for 'upload_id' when calling AttachmentsApi.sending_complete_attachment_upload, must conform to the pattern #{pattern}."
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# verify the required parameter 'body' is set
|
|
71
|
+
if @api_client.config.client_side_validation && body.nil?
|
|
72
|
+
fail ArgumentError, "Missing the required parameter 'body' when calling AttachmentsApi.sending_complete_attachment_upload"
|
|
73
|
+
end
|
|
74
|
+
# resource path
|
|
75
|
+
local_var_path = '/emails/attachment-uploads/{upload_id}'.sub('{upload_id}', CGI.escape(upload_id.to_s))
|
|
76
|
+
|
|
77
|
+
# query parameters
|
|
78
|
+
query_params = opts[:query_params] || {}
|
|
79
|
+
|
|
80
|
+
# header parameters
|
|
81
|
+
header_params = opts[:header_params] || {}
|
|
82
|
+
# HTTP header 'Accept' (if needed)
|
|
83
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
|
|
84
|
+
# HTTP header 'Content-Type'
|
|
85
|
+
content_type = @api_client.select_header_content_type(['application/octet-stream'])
|
|
86
|
+
if !content_type.nil?
|
|
87
|
+
header_params['Content-Type'] = content_type
|
|
88
|
+
end
|
|
89
|
+
header_params[:'Content-Length'] = content_length
|
|
90
|
+
header_params[:'X-Qubrics-Upload-Token'] = opts[:'x_qubrics_upload_token'] if !opts[:'x_qubrics_upload_token'].nil?
|
|
91
|
+
header_params[:'X-Sendmux-Upload-Token'] = opts[:'x_sendmux_upload_token'] if !opts[:'x_sendmux_upload_token'].nil?
|
|
92
|
+
|
|
93
|
+
# form parameters
|
|
94
|
+
form_params = opts[:form_params] || {}
|
|
95
|
+
|
|
96
|
+
# http body (model)
|
|
97
|
+
post_body = opts[:debug_body] || @api_client.object_to_http_body(body)
|
|
98
|
+
|
|
99
|
+
# return_type
|
|
100
|
+
return_type = opts[:debug_return_type] || 'AttachmentUploadResponse'
|
|
101
|
+
|
|
102
|
+
# auth_names
|
|
103
|
+
auth_names = opts[:debug_auth_names] || ['UploadTokenSendmux', 'UploadTokenQubrics']
|
|
104
|
+
|
|
105
|
+
new_options = opts.merge(
|
|
106
|
+
:operation => :"AttachmentsApi.sending_complete_attachment_upload",
|
|
107
|
+
:header_params => header_params,
|
|
108
|
+
:query_params => query_params,
|
|
109
|
+
:form_params => form_params,
|
|
110
|
+
:body => post_body,
|
|
111
|
+
:auth_names => auth_names,
|
|
112
|
+
:return_type => return_type
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)
|
|
116
|
+
if @api_client.config.debugging
|
|
117
|
+
@api_client.config.logger.debug "API called: AttachmentsApi#sending_complete_attachment_upload\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
|
118
|
+
end
|
|
119
|
+
return data, status_code, headers
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
# Create an attachment upload URL
|
|
123
|
+
# Create a short-lived upload URL and token that lets a remote client PUT one binary attachment without exposing the API key on the upload request. Requires `email.send` permission.
|
|
124
|
+
# @param attachment_upload_intent_request [AttachmentUploadIntentRequest]
|
|
125
|
+
# @param [Hash] opts the optional parameters
|
|
126
|
+
# @option opts [String] :idempotency_key Optional client-generated key to make the request idempotent for 24 hours. Replays under the same key return the cached response; a reused key with a different body returns 409 idempotency_conflict.
|
|
127
|
+
# @return [AttachmentUploadIntentResponse]
|
|
128
|
+
def sending_create_attachment_upload(attachment_upload_intent_request, opts = {})
|
|
129
|
+
data, _status_code, _headers = sending_create_attachment_upload_with_http_info(attachment_upload_intent_request, opts)
|
|
130
|
+
data
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
# Create an attachment upload URL
|
|
134
|
+
# Create a short-lived upload URL and token that lets a remote client PUT one binary attachment without exposing the API key on the upload request. Requires `email.send` permission.
|
|
135
|
+
# @param attachment_upload_intent_request [AttachmentUploadIntentRequest]
|
|
136
|
+
# @param [Hash] opts the optional parameters
|
|
137
|
+
# @option opts [String] :idempotency_key Optional client-generated key to make the request idempotent for 24 hours. Replays under the same key return the cached response; a reused key with a different body returns 409 idempotency_conflict.
|
|
138
|
+
# @return [Array<(AttachmentUploadIntentResponse, Integer, Hash)>] AttachmentUploadIntentResponse data, response status code and response headers
|
|
139
|
+
def sending_create_attachment_upload_with_http_info(attachment_upload_intent_request, opts = {})
|
|
140
|
+
if @api_client.config.debugging
|
|
141
|
+
@api_client.config.logger.debug 'Calling API: AttachmentsApi.sending_create_attachment_upload ...'
|
|
142
|
+
end
|
|
143
|
+
# verify the required parameter 'attachment_upload_intent_request' is set
|
|
144
|
+
if @api_client.config.client_side_validation && attachment_upload_intent_request.nil?
|
|
145
|
+
fail ArgumentError, "Missing the required parameter 'attachment_upload_intent_request' when calling AttachmentsApi.sending_create_attachment_upload"
|
|
146
|
+
end
|
|
147
|
+
if @api_client.config.client_side_validation && !opts[:'idempotency_key'].nil? && opts[:'idempotency_key'].to_s.length > 255
|
|
148
|
+
fail ArgumentError, 'invalid value for "opts[:"idempotency_key"]" when calling AttachmentsApi.sending_create_attachment_upload, the character length must be smaller than or equal to 255.'
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
# resource path
|
|
152
|
+
local_var_path = '/emails/attachment-uploads'
|
|
153
|
+
|
|
154
|
+
# query parameters
|
|
155
|
+
query_params = opts[:query_params] || {}
|
|
156
|
+
|
|
157
|
+
# header parameters
|
|
158
|
+
header_params = opts[:header_params] || {}
|
|
159
|
+
# HTTP header 'Accept' (if needed)
|
|
160
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
|
|
161
|
+
# HTTP header 'Content-Type'
|
|
162
|
+
content_type = @api_client.select_header_content_type(['application/json'])
|
|
163
|
+
if !content_type.nil?
|
|
164
|
+
header_params['Content-Type'] = content_type
|
|
165
|
+
end
|
|
166
|
+
header_params[:'Idempotency-Key'] = opts[:'idempotency_key'] if !opts[:'idempotency_key'].nil?
|
|
167
|
+
|
|
168
|
+
# form parameters
|
|
169
|
+
form_params = opts[:form_params] || {}
|
|
170
|
+
|
|
171
|
+
# http body (model)
|
|
172
|
+
post_body = opts[:debug_body] || @api_client.object_to_http_body(attachment_upload_intent_request)
|
|
173
|
+
|
|
174
|
+
# return_type
|
|
175
|
+
return_type = opts[:debug_return_type] || 'AttachmentUploadIntentResponse'
|
|
176
|
+
|
|
177
|
+
# auth_names
|
|
178
|
+
auth_names = opts[:debug_auth_names] || ['OAuth2', 'BearerAuth']
|
|
179
|
+
|
|
180
|
+
new_options = opts.merge(
|
|
181
|
+
:operation => :"AttachmentsApi.sending_create_attachment_upload",
|
|
182
|
+
:header_params => header_params,
|
|
183
|
+
:query_params => query_params,
|
|
184
|
+
:form_params => form_params,
|
|
185
|
+
:body => post_body,
|
|
186
|
+
:auth_names => auth_names,
|
|
187
|
+
:return_type => return_type
|
|
188
|
+
)
|
|
189
|
+
|
|
190
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
|
|
191
|
+
if @api_client.config.debugging
|
|
192
|
+
@api_client.config.logger.debug "API called: AttachmentsApi#sending_create_attachment_upload\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
|
193
|
+
end
|
|
194
|
+
return data, status_code, headers
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
# Get attachment metadata
|
|
198
|
+
# Return metadata for a temporary uploaded attachment owned by the authenticated team. File bytes are not returned.
|
|
199
|
+
# @param attachment_id [String] Temporary attachment ID returned by an upload endpoint.
|
|
200
|
+
# @param [Hash] opts the optional parameters
|
|
201
|
+
# @return [AttachmentUploadResponse]
|
|
202
|
+
def sending_get_attachment(attachment_id, opts = {})
|
|
203
|
+
data, _status_code, _headers = sending_get_attachment_with_http_info(attachment_id, opts)
|
|
204
|
+
data
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
# Get attachment metadata
|
|
208
|
+
# Return metadata for a temporary uploaded attachment owned by the authenticated team. File bytes are not returned.
|
|
209
|
+
# @param attachment_id [String] Temporary attachment ID returned by an upload endpoint.
|
|
210
|
+
# @param [Hash] opts the optional parameters
|
|
211
|
+
# @return [Array<(AttachmentUploadResponse, Integer, Hash)>] AttachmentUploadResponse data, response status code and response headers
|
|
212
|
+
def sending_get_attachment_with_http_info(attachment_id, opts = {})
|
|
213
|
+
if @api_client.config.debugging
|
|
214
|
+
@api_client.config.logger.debug 'Calling API: AttachmentsApi.sending_get_attachment ...'
|
|
215
|
+
end
|
|
216
|
+
# verify the required parameter 'attachment_id' is set
|
|
217
|
+
if @api_client.config.client_side_validation && attachment_id.nil?
|
|
218
|
+
fail ArgumentError, "Missing the required parameter 'attachment_id' when calling AttachmentsApi.sending_get_attachment"
|
|
219
|
+
end
|
|
220
|
+
pattern = Regexp.new(/^att_[a-z0-9]{24}$/)
|
|
221
|
+
if @api_client.config.client_side_validation && attachment_id !~ pattern
|
|
222
|
+
fail ArgumentError, "invalid value for 'attachment_id' when calling AttachmentsApi.sending_get_attachment, must conform to the pattern #{pattern}."
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
# resource path
|
|
226
|
+
local_var_path = '/emails/attachments/{attachment_id}'.sub('{attachment_id}', CGI.escape(attachment_id.to_s))
|
|
227
|
+
|
|
228
|
+
# query parameters
|
|
229
|
+
query_params = opts[:query_params] || {}
|
|
230
|
+
|
|
231
|
+
# header parameters
|
|
232
|
+
header_params = opts[:header_params] || {}
|
|
233
|
+
# HTTP header 'Accept' (if needed)
|
|
234
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
|
|
235
|
+
|
|
236
|
+
# form parameters
|
|
237
|
+
form_params = opts[:form_params] || {}
|
|
238
|
+
|
|
239
|
+
# http body (model)
|
|
240
|
+
post_body = opts[:debug_body]
|
|
241
|
+
|
|
242
|
+
# return_type
|
|
243
|
+
return_type = opts[:debug_return_type] || 'AttachmentUploadResponse'
|
|
244
|
+
|
|
245
|
+
# auth_names
|
|
246
|
+
auth_names = opts[:debug_auth_names] || ['OAuth2', 'BearerAuth']
|
|
247
|
+
|
|
248
|
+
new_options = opts.merge(
|
|
249
|
+
:operation => :"AttachmentsApi.sending_get_attachment",
|
|
250
|
+
:header_params => header_params,
|
|
251
|
+
:query_params => query_params,
|
|
252
|
+
:form_params => form_params,
|
|
253
|
+
:body => post_body,
|
|
254
|
+
:auth_names => auth_names,
|
|
255
|
+
:return_type => return_type
|
|
256
|
+
)
|
|
257
|
+
|
|
258
|
+
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
|
|
259
|
+
if @api_client.config.debugging
|
|
260
|
+
@api_client.config.logger.debug "API called: AttachmentsApi#sending_get_attachment\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
|
261
|
+
end
|
|
262
|
+
return data, status_code, headers
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
# Upload an attachment
|
|
266
|
+
# Upload binary attachment bytes and receive a temporary attachment_id for use in attachments[]. Requires `email.send` permission.
|
|
267
|
+
# @param content_length [Integer] Exact number of bytes in the binary request body.
|
|
268
|
+
# @param filename [String] Filename to associate with the uploaded attachment.
|
|
269
|
+
# @param body [File]
|
|
270
|
+
# @param [Hash] opts the optional parameters
|
|
271
|
+
# @option opts [String] :idempotency_key Optional client-generated key to make the request idempotent for 24 hours. Replays under the same key return the cached response; a reused key with a different body returns 409 idempotency_conflict.
|
|
272
|
+
# @option opts [String] :content_type MIME type override for the uploaded attachment.
|
|
273
|
+
# @return [AttachmentUploadResponse]
|
|
274
|
+
def sending_upload_attachment(content_length, filename, body, opts = {})
|
|
275
|
+
data, _status_code, _headers = sending_upload_attachment_with_http_info(content_length, filename, body, opts)
|
|
276
|
+
data
|
|
277
|
+
end
|
|
278
|
+
|
|
279
|
+
# Upload an attachment
|
|
280
|
+
# Upload binary attachment bytes and receive a temporary attachment_id for use in attachments[]. Requires `email.send` permission.
|
|
281
|
+
# @param content_length [Integer] Exact number of bytes in the binary request body.
|
|
282
|
+
# @param filename [String] Filename to associate with the uploaded attachment.
|
|
283
|
+
# @param body [File]
|
|
284
|
+
# @param [Hash] opts the optional parameters
|
|
285
|
+
# @option opts [String] :idempotency_key Optional client-generated key to make the request idempotent for 24 hours. Replays under the same key return the cached response; a reused key with a different body returns 409 idempotency_conflict.
|
|
286
|
+
# @option opts [String] :content_type MIME type override for the uploaded attachment.
|
|
287
|
+
# @return [Array<(AttachmentUploadResponse, Integer, Hash)>] AttachmentUploadResponse data, response status code and response headers
|
|
288
|
+
def sending_upload_attachment_with_http_info(content_length, filename, body, opts = {})
|
|
289
|
+
if @api_client.config.debugging
|
|
290
|
+
@api_client.config.logger.debug 'Calling API: AttachmentsApi.sending_upload_attachment ...'
|
|
291
|
+
end
|
|
292
|
+
# verify the required parameter 'content_length' is set
|
|
293
|
+
if @api_client.config.client_side_validation && content_length.nil?
|
|
294
|
+
fail ArgumentError, "Missing the required parameter 'content_length' when calling AttachmentsApi.sending_upload_attachment"
|
|
295
|
+
end
|
|
296
|
+
if @api_client.config.client_side_validation && content_length < 1
|
|
297
|
+
fail ArgumentError, 'invalid value for "content_length" when calling AttachmentsApi.sending_upload_attachment, must be greater than or equal to 1.'
|
|
298
|
+
end
|
|
299
|
+
|
|
300
|
+
# verify the required parameter 'filename' is set
|
|
301
|
+
if @api_client.config.client_side_validation && filename.nil?
|
|
302
|
+
fail ArgumentError, "Missing the required parameter 'filename' when calling AttachmentsApi.sending_upload_attachment"
|
|
303
|
+
end
|
|
304
|
+
if @api_client.config.client_side_validation && filename.to_s.length > 255
|
|
305
|
+
fail ArgumentError, 'invalid value for "filename" when calling AttachmentsApi.sending_upload_attachment, the character length must be smaller than or equal to 255.'
|
|
306
|
+
end
|
|
307
|
+
|
|
308
|
+
if @api_client.config.client_side_validation && filename.to_s.length < 1
|
|
309
|
+
fail ArgumentError, 'invalid value for "filename" when calling AttachmentsApi.sending_upload_attachment, the character length must be greater than or equal to 1.'
|
|
310
|
+
end
|
|
311
|
+
|
|
312
|
+
# verify the required parameter 'body' is set
|
|
313
|
+
if @api_client.config.client_side_validation && body.nil?
|
|
314
|
+
fail ArgumentError, "Missing the required parameter 'body' when calling AttachmentsApi.sending_upload_attachment"
|
|
315
|
+
end
|
|
316
|
+
if @api_client.config.client_side_validation && !opts[:'idempotency_key'].nil? && opts[:'idempotency_key'].to_s.length > 255
|
|
317
|
+
fail ArgumentError, 'invalid value for "opts[:"idempotency_key"]" when calling AttachmentsApi.sending_upload_attachment, the character length must be smaller than or equal to 255.'
|
|
318
|
+
end
|
|
319
|
+
|
|
320
|
+
if @api_client.config.client_side_validation && !opts[:'content_type'].nil? && opts[:'content_type'].to_s.length > 255
|
|
321
|
+
fail ArgumentError, 'invalid value for "opts[:"content_type"]" when calling AttachmentsApi.sending_upload_attachment, the character length must be smaller than or equal to 255.'
|
|
322
|
+
end
|
|
323
|
+
|
|
324
|
+
# resource path
|
|
325
|
+
local_var_path = '/emails/attachments'
|
|
326
|
+
|
|
327
|
+
# query parameters
|
|
328
|
+
query_params = opts[:query_params] || {}
|
|
329
|
+
query_params[:'filename'] = filename
|
|
330
|
+
query_params[:'content_type'] = opts[:'content_type'] if !opts[:'content_type'].nil?
|
|
331
|
+
|
|
332
|
+
# header parameters
|
|
333
|
+
header_params = opts[:header_params] || {}
|
|
334
|
+
# HTTP header 'Accept' (if needed)
|
|
335
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
|
|
336
|
+
# HTTP header 'Content-Type'
|
|
337
|
+
content_type = @api_client.select_header_content_type(['application/octet-stream'])
|
|
338
|
+
if !content_type.nil?
|
|
339
|
+
header_params['Content-Type'] = content_type
|
|
340
|
+
end
|
|
341
|
+
header_params[:'Content-Length'] = content_length
|
|
342
|
+
header_params[:'Idempotency-Key'] = opts[:'idempotency_key'] if !opts[:'idempotency_key'].nil?
|
|
343
|
+
|
|
344
|
+
# form parameters
|
|
345
|
+
form_params = opts[:form_params] || {}
|
|
346
|
+
|
|
347
|
+
# http body (model)
|
|
348
|
+
post_body = opts[:debug_body] || @api_client.object_to_http_body(body)
|
|
349
|
+
|
|
350
|
+
# return_type
|
|
351
|
+
return_type = opts[:debug_return_type] || 'AttachmentUploadResponse'
|
|
352
|
+
|
|
353
|
+
# auth_names
|
|
354
|
+
auth_names = opts[:debug_auth_names] || ['OAuth2', 'BearerAuth']
|
|
355
|
+
|
|
356
|
+
new_options = opts.merge(
|
|
357
|
+
:operation => :"AttachmentsApi.sending_upload_attachment",
|
|
358
|
+
:header_params => header_params,
|
|
359
|
+
:query_params => query_params,
|
|
360
|
+
:form_params => form_params,
|
|
361
|
+
:body => post_body,
|
|
362
|
+
:auth_names => auth_names,
|
|
363
|
+
:return_type => return_type
|
|
364
|
+
)
|
|
365
|
+
|
|
366
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
|
|
367
|
+
if @api_client.config.debugging
|
|
368
|
+
@api_client.config.logger.debug "API called: AttachmentsApi#sending_upload_attachment\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
|
369
|
+
end
|
|
370
|
+
return data, status_code, headers
|
|
371
|
+
end
|
|
372
|
+
end
|
|
373
|
+
end
|