misarmail 1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 7fb5ef6ef30c000df0e5737eac0e056e77db86562b67199aa0c53f4097846ba6
4
+ data.tar.gz: 37092f3124bab5b9fedad156bac2199e99c4c4115121f7277ee1103363a013b4
5
+ SHA512:
6
+ metadata.gz: 88f14c434908fe0f189680689f173de703ae22903c46cbe1377ebdcffa294b60e2e99ed10fbd909d8ac07967149db4f77e1b8e29c7de8651ff0e860d75908d2d
7
+ data.tar.gz: dad272747a6a1d4a9d492ef25f6d2e28a218a14bc3a937d7aff2b87367c47b6f3b486c2a592bdcaff828b32a7f1a1c1fa7ee441c8d3a4c1d7ff59bc29b25f346
data/CHANGELOG.md ADDED
@@ -0,0 +1,35 @@
1
+ # Changelog
2
+
3
+ All notable changes to this SDK are documented here. The format follows
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project uses
5
+ [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [1.0.0] — 2026-08-17
8
+
9
+ First release.
10
+
11
+ ### Added
12
+
13
+ - Full coverage of the MisarMail REST API, authenticated with a `msk_` developer
14
+ key sent as `Authorization: Bearer msk_…`.
15
+ - Server-Sent Events for `POST /api/ai/generate-email/stream` and
16
+ `GET /api/campaigns/{id}/send-stream`. Unnamed frames terminated by
17
+ `data: [DONE]`, which the SDK consumes rather than handing on.
18
+ - `GET /plan` for reading the subscription's allowances and per-feature usage,
19
+ so an expensive call can be checked before it is attempted rather than after
20
+ it is refused.
21
+ - Retries with exponential back-off on genuinely transient statuses
22
+ (429 rate limits, 500, 502, 503, 504).
23
+
24
+ ### Notes
25
+
26
+ - Plan limits are enforced server-side against the subscription attached to the
27
+ API key. Both a spent allowance and a locked feature answer 403 carrying
28
+ `code: "plan_limit_exceeded"`. The client keys on that code rather than the
29
+ status — 403 is otherwise an authorization failure — and surfaces a distinct
30
+ error type that is never retried, since retrying cannot help until the
31
+ allowance resets or the plan changes.
32
+ - Streams are never retried: replaying one that failed mid-flight would
33
+ duplicate whatever the caller had already consumed.
34
+
35
+ [1.0.0]: https://misarmail.com/docs
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Misar AI Technology Private Limited
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 all
13
+ 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 THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,95 @@
1
+ # MisarMail Ruby SDK
2
+
3
+ Official Ruby SDK for the [MisarMail](https://misarmail.com) API — transactional
4
+ send, campaigns, contacts, templates, automations, deliverability, warmup,
5
+ monetization and the two AI streams.
6
+
7
+ Full reference: [`misarmail.com/docs`](https://misarmail.com/docs).
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ gem install misarmail
13
+ ```
14
+
15
+ ## Auth
16
+
17
+ Use a MisarMail developer key (`msk_…`), created at
18
+ [misarmail.com/developers](https://misarmail.com/developers). It is sent as
19
+ `Authorization: Bearer msk_…`.
20
+
21
+ Every call is metered against the subscription attached to that key. There is no
22
+ client-side limit checking — the server decides, and the SDK surfaces its answer.
23
+
24
+ ## Quick start
25
+
26
+ ```ruby
27
+ require "misar_mail"
28
+
29
+ mail = MisarMail::Client.new(api_key: "msk_your_key")
30
+
31
+ mail.email.send(
32
+ from: { email: "you@yourdomain.com" },
33
+ to: [{ email: "someone@example.com" }],
34
+ subject: "Hello",
35
+ html: "<p>Hi there</p>"
36
+ )
37
+
38
+ contacts = mail.contacts.list(page: 1, limit: 50)
39
+ ```
40
+
41
+ ## Plan limits
42
+
43
+ Both a spent allowance and a feature that is not on the plan answer **`403`**,
44
+ carrying `code: "plan_limit_exceeded"`. The SDK keys on that code rather than
45
+ the status, which is why a refusal is typed correctly even though 403 is
46
+ otherwise an authorization failure. The SDK raises
47
+ `PlanLimitError` for either, and **does not retry** it — retrying cannot
48
+ help until the allowance resets or the plan changes. Read ``upgrade_url`` to
49
+ send the user somewhere useful.
50
+
51
+ `GET /plan` returns `plan`, `sending` (the per-day and per-month email caps),
52
+ `usage` — an array with one entry per metered feature, each carrying `used`,
53
+ `limit` and `remaining` — and `upgrade`, which is null until a quota is tight.
54
+ A null `limit` means unlimited, and `remaining` is null alongside it rather than
55
+ 0. Read it before an expensive call rather than discovering the ceiling through
56
+ a refusal.
57
+
58
+ The key needs the `read` or `subscription` scope.
59
+
60
+ ```ruby
61
+ plan = mail.plan.get
62
+
63
+ begin
64
+ mail.campaigns.create(
65
+ name: "Blast", subject: "We just shipped",
66
+ fromName: "Your Name", fromEmail: "you@yourdomain.com"
67
+ )
68
+ rescue MisarMail::PlanLimitError => e
69
+ warn "#{e.feature} exhausted on #{e.plan}: #{e.upgrade_url}"
70
+ end
71
+ ```
72
+
73
+ ## Streaming
74
+
75
+ Two endpoints stream Server-Sent Events. Both sit **outside** `/v1`, which the
76
+ SDK handles for you:
77
+
78
+ | Method | Route |
79
+ | --- | --- |
80
+ | `streaming.generateEmail` | `POST /api/ai/generate-email/stream` |
81
+ | `streaming.campaignSend` | `GET /api/campaigns/{id}/send-stream` |
82
+
83
+ Frames are unnamed (`data: {…}`) and the stream ends with `data: [DONE]`, which
84
+ the SDK consumes rather than handing on. A stream is never retried: replaying one
85
+ that failed mid-flight would duplicate whatever you had already read.
86
+
87
+ ```ruby
88
+ mail.streaming.generate_email(prompt: "a launch email") do |event|
89
+ print event.data["delta"]
90
+ end
91
+ ```
92
+
93
+ ## License
94
+
95
+ MIT — see [LICENSE](LICENSE).