unione 1.2.3 → 1.2.4

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: 905c25d5be2c9eb7f499e528962a173bd5852d40ed4239d07d9484d830227900
4
- data.tar.gz: 2b0bc8aa4a2149a3e663ed7da251174ceeb180671e3f90ee932814ad791cbfc9
3
+ metadata.gz: 1d86bd592e33bc40ed8d53bcff63702b395ef838be66048185f0bb7f2aa81dc9
4
+ data.tar.gz: 1c07d213b80dd4b7d10d773d0467d9134c5e1cf741cdb96ee8b2f3d531cc3ff1
5
5
  SHA512:
6
- metadata.gz: a0916665cc508953defe333e3517a0b72b0000a6dde8ffce70753e1cf01a5b9772fd78a26a118c188481f55c41bc40601345c86574399afab16a296e96323c06
7
- data.tar.gz: 92a7e623a9c261c4577cbeb3cbce612dfa21742bdad0a48c30628f844f2f4d0fb5bacf0755d9eaec37d5c6588da303398b60cfb07c412276416e04a32d20f00f
6
+ metadata.gz: f7c1bbac87f18795fc82876ca75fc5385e81cdfb9881bc1d6e095e5c0284474e4334d74da72c8382390da3ad0b01c133545653ccadf8397ab86bc03f9bd45ad7
7
+ data.tar.gz: 7156691b8ece43855f73ab61d7273c854c84748b08a931b7eae75b1d01cb3fa2cccfd20f00946b7f58fd835cb8ae0431261e6a796050e2f87593ae1b7137c616
data/AGENTS.md CHANGED
@@ -1,83 +1,59 @@
1
1
  # AGENTS.md
2
2
 
3
- UniOne Ruby SDK — client for the UniOne transactional email Web API (Web API 1.90).
3
+ UniOne Ruby SDK — client for the UniOne transactional email Web API (Web API 1.90). How to integrate UniOne into an application comes first; the last section is about changing this package.
4
4
 
5
- ## Working on this repository
6
-
7
- - **Generated code.** The whole package is generated by the UniOne team from the UniOne Web API OpenAPI spec (Web API 1.90): sources, docs, README.md and this file. Do not hand-edit it: the next release replaces the content of this repository. Report problems and requests in the issues of this repository (https://github.com/unione-repo/unione-ruby-sdk).
8
- - **Build and check:**
9
-
10
- ```bash
11
- gem build *.gemspec
12
- ```
5
+ ## Integrating UniOne
13
6
 
14
- - **Source label.** Every request carries the query parameter `platform=ruby-sdk.1.2.3`, added in one place, the shared request client (`ApiClient`); a package built on this SDK puts its own label in front: `<package>.<version>,ruby-sdk.1.2.3`.
15
- - **Tests.** Before a release the generator builds and lints the package and runs every example of docs/ and of this file against a mock of the API: no real API key, no real sends.
16
- - **Release.** The version (1.2.3 in the gemspec) and the tag `v1.2.3` come from the generator; README.md states the Web API version the release was generated from.
17
- - **Secrets.** Never commit API keys; the examples read `UNIONE_API_KEY` from the environment.
7
+ **On one of these frameworks, install its package instead of this SDK:** it brings the SDK and plugs it into the framework (configuration, client in the container, mailer, webhooks).
18
8
 
19
- ## Integrating UniOne with this SDK
9
+ | Framework | Package | Guide |
10
+ |---|---|---|
11
+ | Ruby on Rails | `unione-rails` | [AGENTS.md](https://github.com/unione-repo/unione-rails/blob/HEAD/AGENTS.md) |
20
12
 
21
- Full quickstart: [README.md](README.md). Install:
13
+ ### Install
22
14
 
23
15
  ```bash
24
16
  gem install unione
25
17
  ```
26
18
 
27
- Requirements: Ruby 2.7+.
28
-
29
- If the project is built on one of these frameworks, install its package instead: it brings this SDK and plugs it into the framework (configuration, client in the container, mailer, webhooks).
30
-
31
- | Framework | Package | Guide |
32
- |---|---|---|
33
- | Ruby on Rails | `unione-rails` | [AGENTS.md](https://github.com/unione-repo/unione-rails/blob/HEAD/AGENTS.md) |
34
-
35
- Rules that generated code must follow:
36
-
37
- - Server-side only. Read the API key from `UNIONE_API_KEY`; never put it in browser or mobile code, never commit it.
38
- - Base URL `https://api.unione.io/en/transactional/api/v1` (an account registered on another host uses that one: `eu1.unione.io`, `us1.unione.io`); every method is POST with a JSON body; auth header `X-API-KEY`. The SDK does all of it.
39
- - First email without DNS: `domain/get-sandbox-domain` → `confirmed-email/create` (the user clicks the link within 48 hours) → `email/send` from `noreply@<sandbox-domain>` to the confirmed address. Account API key only; up to 10 confirmed addresses, 100 emails a day; the domain expires after 31 days.
40
- - Never ship a sandbox domain as the production sender (it is not in `domain/list`); read `from_email` from config. Production needs a verified domain: `domain/get-dns-records` → DNS records → `domain/validate-verification-record`, `domain/validate-dkim` → `domain/list`.
41
- - Set `message.idempotence_key` on retryable sends; retry network errors, `429` and `5xx` with backoff, not other errors unchanged. Up to 500 recipients and 10 MB per request with the attachments in base64 (a third larger than the files); always `body.html` or `body.plaintext`.
42
- - Delivery events via webhook (`webhook/set`) with a fast, idempotent HTTPS handler, not polling; check the `auth` field of every notification: the MD5 of the request body with the `auth` value replaced by the API key.
43
- - Keep the default unsubscribe and tracking behaviour; changes go through UniOne support.
44
- - Do not invent methods or fields. Check [docs/](docs/) of this package, the [API reference](https://docs.unione.io/en/web-api-ref) or [llms.txt](https://docs.unione.io/llms.txt).
19
+ Requirements: Ruby 2.7+. The API key goes to `UNIONE_API_KEY`.
45
20
 
46
21
  ### Send an email
47
22
 
48
- The client reads the API key from `UNIONE_API_KEY`:
49
-
50
23
  ```ruby
51
24
  require 'unione'
52
25
 
53
- Common = UniOne::Common::Model
26
+ Body = UniOne::Common::Model::BodyObject
54
27
  Email = UniOne::Api::Email::Model
28
+ Recipient = UniOne::Api::Email::Model::MessageObjectRecipientsItem
55
29
 
56
30
  client = UniOne.client(ENV.fetch('UNIONE_API_KEY'))
57
31
 
58
- response = client.email.send_email(Email::EmailSendRequest.new(
59
- message: Email::MessageObject.new(
60
- recipients: [
61
- Email::MessageObjectRecipientsItem.new(
62
- email: 'user@example.com',
63
- substitutions: {
64
- 'CustomerId' => '12452',
65
- 'to_name' => 'John Smith',
66
- }
67
- )
68
- ],
69
- body: Common::BodyObject.new(
70
- html: '<b>Hello, {{to_name}}</b>',
71
- plaintext: 'Hello, {{to_name}}'
72
- ),
73
- subject: 'UniOne test email ',
74
- from_email: 'email@example.com',
75
- from_name: 'John Smith'
76
- )
77
- ))
78
- p response.job_id
32
+ message = Email::MessageObject.new(
33
+ recipients: [Recipient.from_address('Alex <alex@example.com>')],
34
+ body: Body.html('<p>Hello, {{to_name}}! Your order has shipped.</p>'),
35
+ subject: 'Your order',
36
+ from_email: 'shop@example.com',
37
+ from_name: 'Shop'
38
+ )
39
+ response = client.email.send_email(Email::EmailSendRequest.new(message: message))
40
+ puts response.job_id
79
41
  ```
80
42
 
43
+ Personalization, attachments, CC/BCC, scheduling, safe retries, error handling, the webhook handler and the sandbox flow: the recipes of [README.md](README.md#recipes).
44
+
45
+ ### Rules for generated code
46
+
47
+ - Server-side only. Read the API key from `UNIONE_API_KEY`; never put it in browser or mobile code, never commit it.
48
+ - Build the recipients and the body with the short forms of the SDK (the recipient from `"Name <email>"`, the name goes to `to_name`; per-recipient metadata; the HTML / text body), as in "Send an email" and the README recipes, not with hand-built nested objects.
49
+ - Base URL `https://api.unione.io/en/transactional/api/v1` (an account registered on another host uses that one: `eu1.unione.io`, `us1.unione.io`); every method is POST with a JSON body; auth header `X-API-KEY`. The SDK does all of it.
50
+ - First email without DNS: `domain/get-sandbox-domain` → `confirmed-email/create` (the user clicks the link within 48 hours) → `email/send` from `noreply@<sandbox-domain>` to the confirmed address. Account API key only; up to 10 confirmed addresses, 100 emails a day. The domain is deleted 31 days after it was created: the next `domain/get-sandbox-domain` call creates a new one with another name, so read the name from the response, never hardcode it.
51
+ - Never ship a sandbox domain as the production sender (it is not in `domain/list`); read `from_email` from config. Production needs a verified domain: `domain/get-dns-records` → DNS records (verification TXT as is, DKIM TXT `v=DKIM1; k=rsa; p=<dkim>` on `<selector>._domainkey`, CNAME `_dmarc` → the `dmarc` field; SPF `include:spf.unione.io` is not in the response) → `domain/validate-verification-record`, `domain/validate-dkim` → `domain/list`.
52
+ - Set `message.idempotence_key` on retryable sends; retry network errors, `429` and `5xx` with backoff, not other errors unchanged. Up to 500 recipients and 10 MB per request with the attachments in base64 (a third larger than the files); always `body.html` or `body.plaintext`.
53
+ - Delivery events via webhook (`webhook/set`), not polling. Check the `auth` field of every notification (MD5 of the raw request body with the `auth` value replaced by the API key) and answer 401 to a wrong one. Answer 200 within 3 seconds and process the events from a queue, otherwise the request is repeated every 10 minutes for 24 hours; take at least 5 parallel requests of up to 100 events each; deduplicate.
54
+ - Keep the default unsubscribe and tracking behaviour; changes go through UniOne support.
55
+ - Do not invent methods or fields. Check [docs/](docs/) of this package, the [API reference](https://docs.unione.io/en/web-api-ref) or [llms.txt](https://docs.unione.io/llms.txt).
56
+
81
57
  ### Errors
82
58
 
83
59
  Every method throws `ApiError` when the request fails: the HTTP status (0 for a network error or a timeout), the [API error code](https://docs.unione.io/en/web-api-ref#api-errors) and the message.
@@ -97,3 +73,17 @@ end
97
73
  - Methods and models of every section: [Email](docs/Email.md), [EmailValidation](docs/EmailValidation.md), [ConfirmedEmail](docs/ConfirmedEmail.md), [Template](docs/Template.md), [Webhook](docs/Webhook.md), [Suppression](docs/Suppression.md), [Domain](docs/Domain.md), [EventDump](docs/EventDump.md), [Tag](docs/Tag.md), [Project](docs/Project.md), [System](docs/System.md), [Obsolete](docs/Obsolete.md)
98
74
  - [API reference](https://docs.unione.io/en/web-api-ref)
99
75
  - [Full API reference for LLMs](https://docs.unione.io/llms-full.txt)
76
+
77
+ ## Working on this repository
78
+
79
+ - **Generated code.** The whole package is generated by the UniOne team from the UniOne Web API OpenAPI spec (Web API 1.90): sources, docs, README.md and this file. Do not hand-edit it: the next release replaces the content of this repository. Report problems and requests in the issues of this repository (https://github.com/unione-repo/unione-ruby-sdk).
80
+ - **Build and check:**
81
+
82
+ ```bash
83
+ gem build *.gemspec
84
+ ```
85
+
86
+ - **Source label.** Every request carries the query parameter `platform=ruby-sdk.1.2.4`, added in one place, the shared request client (`ApiClient`); a package built on this SDK puts its own label in front: `<package>.<version>,ruby-sdk.1.2.4`.
87
+ - **Tests.** Before a release the generator builds and lints the package and runs every example of docs/ and of this file against a mock of the API: no real API key, no real sends.
88
+ - **Release.** The version (1.2.4 in the gemspec) and the tag `v1.2.4` come from the generator; README.md states the Web API version the release was generated from.
89
+ - **Secrets.** Never commit API keys; the examples read `UNIONE_API_KEY` from the environment.
@@ -7,7 +7,7 @@ require 'uri'
7
7
  module UniOne
8
8
  module Client
9
9
  # The SDK and its version in the "platform" query parameter of every request.
10
- PLATFORM = 'ruby-sdk.1.2.3'
10
+ PLATFORM = 'ruby-sdk.1.2.4'
11
11
 
12
12
  # Default transport (HTTP layer of ApiClient): Net::HTTP of the standard library.
13
13
  #
@@ -36,7 +36,7 @@ module UniOne
36
36
  # default ones of the same name
37
37
  attr_accessor :headers
38
38
 
39
- def initialize(api_key, base_url: DEFAULT_BASE_URL, timeout: 30, user_agent: 'unione-ruby-sdk/1.2.3', platform: nil, headers: {})
39
+ def initialize(api_key, base_url: DEFAULT_BASE_URL, timeout: 30, user_agent: 'unione-ruby-sdk/1.2.4', platform: nil, headers: {})
40
40
  @api_key = api_key
41
41
  @base_url = base_url.sub(%r{/+\z}, '')
42
42
  @timeout = timeout
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module UniOne
4
- VERSION = '1.2.3'
4
+ VERSION = '1.2.4'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unione
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
4
+ version: 1.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - UniOne