openemail 0.0.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 +7 -0
- data/README.md +183 -0
- data/lib/openemail/api_paths.rb +249 -0
- data/lib/openemail/client.rb +69 -0
- data/lib/openemail/constants.rb +851 -0
- data/lib/openemail/credentials.rb +53 -0
- data/lib/openemail/decode.rb +34 -0
- data/lib/openemail/defaults.rb +111 -0
- data/lib/openemail/endpoint.rb +144 -0
- data/lib/openemail/errors.rb +121 -0
- data/lib/openemail/http.rb +172 -0
- data/lib/openemail/languages.rb +42 -0
- data/lib/openemail/pagination.rb +63 -0
- data/lib/openemail/protocol.rb +169 -0
- data/lib/openemail/raw_body.rb +83 -0
- data/lib/openemail/request_path.rb +50 -0
- data/lib/openemail/resource.rb +70 -0
- data/lib/openemail/resources/account.rb +64 -0
- data/lib/openemail/resources/addresses.rb +38 -0
- data/lib/openemail/resources/analytics.rb +17 -0
- data/lib/openemail/resources/app_host.rb +23 -0
- data/lib/openemail/resources/audiences.rb +90 -0
- data/lib/openemail/resources/billing.rb +64 -0
- data/lib/openemail/resources/branding.rb +24 -0
- data/lib/openemail/resources/broadcasts.rb +65 -0
- data/lib/openemail/resources/calendar.rb +59 -0
- data/lib/openemail/resources/chats.rb +31 -0
- data/lib/openemail/resources/contacts.rb +111 -0
- data/lib/openemail/resources/dns_connections.rb +19 -0
- data/lib/openemail/resources/domains.rb +153 -0
- data/lib/openemail/resources/drafts.rb +35 -0
- data/lib/openemail/resources/emails.rb +100 -0
- data/lib/openemail/resources/encryption.rb +19 -0
- data/lib/openemail/resources/exports.rb +27 -0
- data/lib/openemail/resources/files.rb +95 -0
- data/lib/openemail/resources/forms.rb +111 -0
- data/lib/openemail/resources/imports.rb +86 -0
- data/lib/openemail/resources/keys.rb +127 -0
- data/lib/openemail/resources/labels.rb +39 -0
- data/lib/openemail/resources/languages.rb +11 -0
- data/lib/openemail/resources/me.rb +19 -0
- data/lib/openemail/resources/members.rb +74 -0
- data/lib/openemail/resources/provider_imports.rb +40 -0
- data/lib/openemail/resources/roles.rb +39 -0
- data/lib/openemail/resources/rules.rb +57 -0
- data/lib/openemail/resources/security.rb +19 -0
- data/lib/openemail/resources/senders.rb +15 -0
- data/lib/openemail/resources/settings.rb +16 -0
- data/lib/openemail/resources/subscriptions.rb +30 -0
- data/lib/openemail/resources/support.rb +11 -0
- data/lib/openemail/resources/suppressions.rb +31 -0
- data/lib/openemail/resources/temp_mail.rb +67 -0
- data/lib/openemail/resources/templates.rb +151 -0
- data/lib/openemail/resources/threads.rb +104 -0
- data/lib/openemail/resources/tools.rb +19 -0
- data/lib/openemail/resources/tracking.rb +63 -0
- data/lib/openemail/resources/webhooks.rb +142 -0
- data/lib/openemail/resources/workspaces.rb +28 -0
- data/lib/openemail/results.rb +33 -0
- data/lib/openemail/transport.rb +272 -0
- data/lib/openemail/update_notice.rb +69 -0
- data/lib/openemail/version.rb +5 -0
- data/lib/openemail/webhook.rb +82 -0
- data/lib/openemail/wire.rb +95 -0
- data/lib/openemail.rb +125 -0
- metadata +109 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OpenEmail
|
|
4
|
+
module Resources
|
|
5
|
+
class Rules < Resource
|
|
6
|
+
def list(enabled: nil, limit: nil, cursor: nil, api_key: nil)
|
|
7
|
+
fetch_page(ApiPaths::RULES, query_params(enabled: flag(enabled)), limit:, cursor:, api_key:)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def list_all(enabled: nil, limit: nil, cursor: nil, api_key: nil)
|
|
11
|
+
collect_all(ApiPaths::RULES, query_params(enabled: flag(enabled)), limit:, cursor:, api_key:)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def iterate(enabled: nil, limit: nil, cursor: nil, api_key: nil, &)
|
|
15
|
+
iterate_pages(ApiPaths::RULES, query_params(enabled: flag(enabled)), limit:, cursor:, api_key:, &)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def get(id, api_key: nil)
|
|
19
|
+
request(fill(ApiPaths::RULE, id:), api_key:)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def create(body = nil, api_key: nil, **fields)
|
|
23
|
+
request(ApiPaths::RULES, method: :post, body: payload(body, fields), api_key:)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def update(id, patch = nil, api_key: nil, **fields)
|
|
27
|
+
request(fill(ApiPaths::RULE, id:), method: :patch, body: payload(patch, fields), api_key:)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def delete(id, api_key: nil)
|
|
31
|
+
request(fill(ApiPaths::RULE, id:), method: :delete, api_key:)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def reorder(rule_ids, api_key: nil)
|
|
35
|
+
envelope = request(ApiPaths::RULES_REORDER, method: :post, body: {"ruleIds" => rule_ids}, repeatable: true,
|
|
36
|
+
api_key:)
|
|
37
|
+
Pagination.items_of(envelope.is_a?(Hash) ? envelope : {})
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def test(id, body = nil, api_key: nil, **fields)
|
|
41
|
+
request(fill(ApiPaths::RULE_TEST, id:), method: :post, body: payload(body, fields), repeatable: true, api_key:)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def list_runs(rule_id: nil, thread_id: nil, limit: nil, cursor: nil, api_key: nil)
|
|
45
|
+
fetch_page(ApiPaths::RULE_RUNS, query_params(rule_id:, thread_id:), limit:, cursor:, api_key:)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def list_all_runs(rule_id: nil, thread_id: nil, limit: nil, cursor: nil, api_key: nil)
|
|
49
|
+
collect_all(ApiPaths::RULE_RUNS, query_params(rule_id:, thread_id:), limit:, cursor:, api_key:)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def iterate_runs(rule_id: nil, thread_id: nil, limit: nil, cursor: nil, api_key: nil, &)
|
|
53
|
+
iterate_pages(ApiPaths::RULE_RUNS, query_params(rule_id:, thread_id:), limit:, cursor:, api_key:, &)
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OpenEmail
|
|
4
|
+
module Resources
|
|
5
|
+
class Security < Resource
|
|
6
|
+
def step_up_status(api_key: nil)
|
|
7
|
+
request(ApiPaths::SECURITY_STEP_UP, api_key:)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def begin_step_up(body = nil, api_key: nil, **fields)
|
|
11
|
+
request(ApiPaths::SECURITY_STEP_UP, method: :post, body: payload(body, fields), api_key:)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def verify_step_up(body = nil, api_key: nil, **fields)
|
|
15
|
+
request(ApiPaths::SECURITY_STEP_UP_VERIFY, method: :post, body: payload(body, fields), api_key:)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OpenEmail
|
|
4
|
+
module Resources
|
|
5
|
+
class Senders < Resource
|
|
6
|
+
def get(email, api_key: nil)
|
|
7
|
+
request(fill(ApiPaths::SENDER, email:), api_key:)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def research(email, api_key: nil)
|
|
11
|
+
request(fill(ApiPaths::SENDER_RESEARCH, email:), method: :post, repeatable: true, api_key:)
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OpenEmail
|
|
4
|
+
module Resources
|
|
5
|
+
class Settings < Resource
|
|
6
|
+
def get(address: nil, api_key: nil)
|
|
7
|
+
request(ApiPaths::SETTINGS, query: query_params(address:), api_key:)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def update(patch = nil, address: nil, api_key: nil, **fields)
|
|
11
|
+
request(ApiPaths::SETTINGS, method: :patch, query: query_params(address:), body: payload(patch, fields),
|
|
12
|
+
repeatable: true, api_key:)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OpenEmail
|
|
4
|
+
module Resources
|
|
5
|
+
class Subscriptions < Resource
|
|
6
|
+
def list(status: nil, q: nil, sort: nil, limit: nil, offset: nil, address: nil, api_key: nil)
|
|
7
|
+
request(ApiPaths::SUBSCRIPTIONS, query: query_params(status:, q:, sort:, limit:, offset:, address:), api_key:)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def list_domains(status: nil, q: nil, sort: nil, limit: nil, offset: nil, address: nil, api_key: nil)
|
|
11
|
+
request(ApiPaths::SUBSCRIPTION_DOMAINS, query: query_params(status:, q:, sort:, limit:, offset:, address:),
|
|
12
|
+
api_key:)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def unsubscribe(id, body = nil, api_key: nil, **fields)
|
|
16
|
+
request(fill(ApiPaths::SUBSCRIPTION_UNSUBSCRIBE, id:), method: :post, body: payload(body, fields), api_key:)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def unsubscribe_domain(domain, body = nil, api_key: nil, **fields)
|
|
20
|
+
request(fill(ApiPaths::SUBSCRIPTION_DOMAIN_UNSUBSCRIBE, domain:), method: :post, body: payload(body, fields),
|
|
21
|
+
api_key:)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def move(id, body = nil, api_key: nil, **fields)
|
|
25
|
+
request(fill(ApiPaths::SUBSCRIPTION_MOVE, id:), method: :post, body: payload(body, fields), repeatable: true,
|
|
26
|
+
api_key:)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OpenEmail
|
|
4
|
+
module Resources
|
|
5
|
+
class Suppressions < Resource
|
|
6
|
+
def list(q: nil, reason: nil, limit: nil, cursor: nil, api_key: nil)
|
|
7
|
+
fetch_page(ApiPaths::SUPPRESSIONS, query_params(q:, reason:), limit:, cursor:, api_key:)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def list_all(q: nil, reason: nil, limit: nil, cursor: nil, api_key: nil)
|
|
11
|
+
collect_all(ApiPaths::SUPPRESSIONS, query_params(q:, reason:), limit:, cursor:, api_key:)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def iterate(q: nil, reason: nil, limit: nil, cursor: nil, api_key: nil, &)
|
|
15
|
+
iterate_pages(ApiPaths::SUPPRESSIONS, query_params(q:, reason:), limit:, cursor:, api_key:, &)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def get(id, api_key: nil)
|
|
19
|
+
request(fill(ApiPaths::SUPPRESSION, id:), api_key:)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def add(body = nil, api_key: nil, **fields)
|
|
23
|
+
request(ApiPaths::SUPPRESSIONS, method: :post, body: payload(body, fields), repeatable: true, api_key:)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def remove(id, api_key: nil)
|
|
27
|
+
request(fill(ApiPaths::SUPPRESSION, id:), method: :delete, api_key:)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OpenEmail
|
|
4
|
+
module Resources
|
|
5
|
+
class TempMail < Resource
|
|
6
|
+
def list_domains(inbox_token: nil)
|
|
7
|
+
envelope = request(ApiPaths::TEMP_MAIL_DOMAINS, anonymous: true)
|
|
8
|
+
Pagination.items_of(envelope.is_a?(Hash) ? envelope : {})
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def create(body = nil, inbox_token: nil, **fields)
|
|
12
|
+
request(ApiPaths::TEMP_MAIL_INBOXES, method: :post, body: payload(body, fields), anonymous: true)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def get(inbox_id, inbox_token: nil)
|
|
16
|
+
request(fill(ApiPaths::TEMP_MAIL_INBOX, id: inbox_id), inbox_token:)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def extend(inbox_id, *modules, inbox_token: nil)
|
|
20
|
+
return super(inbox_id, *modules) if inbox_id.is_a?(Module)
|
|
21
|
+
|
|
22
|
+
request(fill(ApiPaths::TEMP_MAIL_INBOX_EXTEND, id: inbox_id), method: :post, inbox_token:)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def delete(inbox_id, inbox_token: nil)
|
|
26
|
+
request(fill(ApiPaths::TEMP_MAIL_INBOX, id: inbox_id), method: :delete, inbox_token:)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def list_messages(inbox_id, limit: nil, cursor: nil, inbox_token: nil)
|
|
30
|
+
envelope = request(fill(ApiPaths::TEMP_MAIL_MESSAGES, id: inbox_id), query: query_params(limit:, cursor:),
|
|
31
|
+
inbox_token:)
|
|
32
|
+
envelope = {} unless envelope.is_a?(Hash)
|
|
33
|
+
next_cursor = Pagination.cursor_of(envelope[:nextCursor])
|
|
34
|
+
|
|
35
|
+
TempMessagesPage.new(
|
|
36
|
+
items: Pagination.items_of(envelope),
|
|
37
|
+
has_more: Pagination.more?(envelope, next_cursor),
|
|
38
|
+
next_cursor:,
|
|
39
|
+
expires_at: envelope[:expiresAt]
|
|
40
|
+
)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def list_all_messages(inbox_id, limit: nil, cursor: nil, inbox_token: nil)
|
|
44
|
+
iterate_messages(inbox_id, limit:, cursor:, inbox_token:).to_a
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def iterate_messages(inbox_id, limit: nil, cursor: nil, inbox_token: nil, &)
|
|
48
|
+
pages = Pagination.walk(cursor) { |current| list_messages(inbox_id, limit:, cursor: current, inbox_token:) }
|
|
49
|
+
each_or_enumerator(pages, &)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def get_message(inbox_id, message_id, inbox_token: nil)
|
|
53
|
+
request(fill(ApiPaths::TEMP_MAIL_MESSAGE, id: inbox_id, messageId: message_id), inbox_token:)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def delete_message(inbox_id, message_id, inbox_token: nil)
|
|
57
|
+
request(fill(ApiPaths::TEMP_MAIL_MESSAGE, id: inbox_id, messageId: message_id), method: :delete, inbox_token:)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def list_attachments(inbox_id, message_id, inbox_token: nil)
|
|
61
|
+
envelope = request(fill(ApiPaths::TEMP_MAIL_MESSAGE_ATTACHMENTS, id: inbox_id, messageId: message_id),
|
|
62
|
+
inbox_token:)
|
|
63
|
+
Pagination.items_of(envelope.is_a?(Hash) ? envelope : {})
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OpenEmail
|
|
4
|
+
module Resources
|
|
5
|
+
class Templates < Resource
|
|
6
|
+
def list(status: nil, search: nil, sort: nil, limit: nil, cursor: nil, api_key: nil)
|
|
7
|
+
fetch_page(ApiPaths::TEMPLATES, query_params(status:, search:, sort:), limit:, cursor:, api_key:)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def list_all(status: nil, search: nil, sort: nil, limit: nil, cursor: nil, api_key: nil)
|
|
11
|
+
collect_all(ApiPaths::TEMPLATES, query_params(status:, search:, sort:), limit:, cursor:, api_key:)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def iterate(status: nil, search: nil, sort: nil, limit: nil, cursor: nil, api_key: nil, &)
|
|
15
|
+
iterate_pages(ApiPaths::TEMPLATES, query_params(status:, search:, sort:), limit:, cursor:, api_key:, &)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def list_starters(api_key: nil)
|
|
19
|
+
fetch_list(ApiPaths::TEMPLATE_STARTERS, api_key:)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def list_fonts(api_key: nil)
|
|
23
|
+
fetch_list(ApiPaths::TEMPLATE_FONTS, api_key:)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def get_starter(slug, api_key: nil)
|
|
27
|
+
request(fill(ApiPaths::TEMPLATE_STARTER, slug:), api_key:)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def render(body = nil, api_key: nil, **fields)
|
|
31
|
+
request(ApiPaths::TEMPLATE_RENDER, method: :post, body: payload(body, fields), repeatable: true, api_key:)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def get(id_or_slug, api_key: nil)
|
|
35
|
+
request(fill(ApiPaths::TEMPLATE, id: id_or_slug), api_key:)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def create(body = nil, api_key: nil, **fields)
|
|
39
|
+
request(ApiPaths::TEMPLATES, method: :post, body: payload(body, fields), api_key:)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def update(id_or_slug, patch = nil, api_key: nil, **fields)
|
|
43
|
+
request(fill(ApiPaths::TEMPLATE, id: id_or_slug), method: :patch, body: payload(patch, fields), api_key:)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def delete(id_or_slug, api_key: nil)
|
|
47
|
+
request(fill(ApiPaths::TEMPLATE, id: id_or_slug), method: :delete, api_key:)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def duplicate(id_or_slug, body = nil, api_key: nil, **fields)
|
|
51
|
+
request(fill(ApiPaths::TEMPLATE_DUPLICATE, id: id_or_slug), method: :post, body: payload(body, fields),
|
|
52
|
+
api_key:)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def replace_content(id_or_slug, body = nil, api_key: nil, **fields)
|
|
56
|
+
request(fill(ApiPaths::TEMPLATE_CONTENT, id: id_or_slug), method: :post, body: payload(body, fields), api_key:)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def list_versions(id_or_slug, limit: nil, cursor: nil, api_key: nil)
|
|
60
|
+
fetch_page(fill(ApiPaths::TEMPLATE_VERSIONS, id: id_or_slug), limit:, cursor:, api_key:)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def list_all_versions(id_or_slug, limit: nil, cursor: nil, api_key: nil)
|
|
64
|
+
collect_all(fill(ApiPaths::TEMPLATE_VERSIONS, id: id_or_slug), limit:, cursor:, api_key:)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def iterate_versions(id_or_slug, limit: nil, cursor: nil, api_key: nil, &)
|
|
68
|
+
iterate_pages(fill(ApiPaths::TEMPLATE_VERSIONS, id: id_or_slug), limit:, cursor:, api_key:, &)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def get_version(id_or_slug, version, api_key: nil)
|
|
72
|
+
request(fill(ApiPaths::TEMPLATE_VERSION, id: id_or_slug, version:), api_key:)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def delete_version(id_or_slug, version, api_key: nil)
|
|
76
|
+
request(fill(ApiPaths::TEMPLATE_VERSION, id: id_or_slug, version:), method: :delete, api_key:)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def restore_version(id_or_slug, version, body = nil, api_key: nil, **fields)
|
|
80
|
+
request(fill(ApiPaths::TEMPLATE_VERSION_RESTORE, id: id_or_slug, version:), method: :post,
|
|
81
|
+
body: payload(body, fields), api_key:)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def publish(id_or_slug, api_key: nil)
|
|
85
|
+
request(fill(ApiPaths::TEMPLATE_VERSIONS, id: id_or_slug), method: :post, repeatable: true, api_key:)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def preview(id_or_slug, body = nil, api_key: nil, **fields)
|
|
89
|
+
request(fill(ApiPaths::TEMPLATE_PREVIEW, id: id_or_slug), method: :post, body: payload(body, fields),
|
|
90
|
+
repeatable: true, api_key:)
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def get_analytics(id_or_slug, days: nil, minutes: nil, grain: nil, offset_minutes: nil, api_key: nil)
|
|
94
|
+
request(fill(ApiPaths::TEMPLATE_ANALYTICS, id: id_or_slug), query: window_query(days, minutes, grain,
|
|
95
|
+
offset_minutes), api_key:)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def list_sends(id_or_slug, page: nil, page_size: nil, search: nil, source: nil, version: nil, opened: nil,
|
|
99
|
+
clicked: nil, tracked: nil, days: nil, minutes: nil, grain: nil, offset_minutes: nil, api_key: nil)
|
|
100
|
+
query = window_query(days, minutes, grain, offset_minutes).merge(query_params(page:, page_size:, search:,
|
|
101
|
+
source:, version:, opened: flag(opened), clicked: flag(clicked), tracked: flag(tracked)))
|
|
102
|
+
envelope = request(fill(ApiPaths::TEMPLATE_SENDS, id: id_or_slug), query:, api_key:)
|
|
103
|
+
envelope = {} unless envelope.is_a?(Hash)
|
|
104
|
+
|
|
105
|
+
TemplateSends.new(
|
|
106
|
+
items: Pagination.items_of(envelope),
|
|
107
|
+
total: envelope[:total] || 0,
|
|
108
|
+
page: envelope[:page] || 1,
|
|
109
|
+
page_size: envelope[:pageSize] || 0
|
|
110
|
+
)
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def send(id_or_slug, body = nil, idempotency_key: nil, api_key: nil, **fields)
|
|
114
|
+
request(fill(ApiPaths::TEMPLATE_SEND, id: id_or_slug), method: :post, body: Wire.recipients(payload(body, fields)),
|
|
115
|
+
idempotent: true, idempotency_key:, repeatable: true, api_key:)
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def list_images(limit: nil, cursor: nil, api_key: nil)
|
|
119
|
+
fetch_page(ApiPaths::TEMPLATE_IMAGES, limit:, cursor:, api_key:)
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
def list_all_images(limit: nil, cursor: nil, api_key: nil)
|
|
123
|
+
collect_all(ApiPaths::TEMPLATE_IMAGES, limit:, cursor:, api_key:)
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
def iterate_images(limit: nil, cursor: nil, api_key: nil, &)
|
|
127
|
+
iterate_pages(ApiPaths::TEMPLATE_IMAGES, limit:, cursor:, api_key:, &)
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
def upload_image(data, content_type: nil, api_key: nil)
|
|
131
|
+
request(ApiPaths::TEMPLATE_IMAGES, method: :post, raw: data, content_type: raw_content_type(data, content_type),
|
|
132
|
+
api_key:)
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
def design(body = nil, api_key: nil, **fields)
|
|
136
|
+
request(ApiPaths::TEMPLATES_DESIGN, method: :post, body: payload(body, fields), api_key:)
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
def redesign(id_or_slug, body = nil, api_key: nil, **fields)
|
|
140
|
+
request(fill(ApiPaths::TEMPLATE_REDESIGN, id: id_or_slug), method: :post, body: payload(body, fields),
|
|
141
|
+
api_key:)
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
private
|
|
145
|
+
|
|
146
|
+
def window_query(days, minutes, grain, offset_minutes)
|
|
147
|
+
query_params(days:, minutes:, grain:, offset_minutes:)
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
end
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OpenEmail
|
|
4
|
+
module Resources
|
|
5
|
+
class Threads < Resource
|
|
6
|
+
def list(folder: nil, query: nil, label_ids: nil, sort: nil, date_from: nil, date_to: nil, from_contacts: nil,
|
|
7
|
+
limit: nil, cursor: nil, api_key: nil)
|
|
8
|
+
fetch_page(ApiPaths::THREADS, list_query(folder, query, label_ids, sort, date_from, date_to, from_contacts),
|
|
9
|
+
style: PAGE_TOKEN, limit:, cursor:, api_key:)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def list_all(folder: nil, query: nil, label_ids: nil, sort: nil, date_from: nil, date_to: nil,
|
|
13
|
+
from_contacts: nil, limit: nil, cursor: nil, api_key: nil)
|
|
14
|
+
collect_all(ApiPaths::THREADS, list_query(folder, query, label_ids, sort, date_from, date_to, from_contacts),
|
|
15
|
+
style: PAGE_TOKEN, limit:, cursor:, api_key:)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def iterate(folder: nil, query: nil, label_ids: nil, sort: nil, date_from: nil, date_to: nil, from_contacts: nil,
|
|
19
|
+
limit: nil, cursor: nil, api_key: nil, &)
|
|
20
|
+
iterate_pages(ApiPaths::THREADS, list_query(folder, query, label_ids, sort, date_from, date_to, from_contacts),
|
|
21
|
+
style: PAGE_TOKEN, limit:, cursor:, api_key:, &)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def get(id, api_key: nil)
|
|
25
|
+
request(fill(ApiPaths::THREAD, id:), api_key:)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def update(id, patch = nil, api_key: nil, **fields)
|
|
29
|
+
request(fill(ApiPaths::THREAD, id:), method: :patch, body: payload(patch, fields), repeatable: true, api_key:)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def trash(id, api_key: nil)
|
|
33
|
+
request(fill(ApiPaths::THREAD_TRASH, id:), method: :post, repeatable: true, api_key:)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def snooze(id, wake_at, api_key: nil)
|
|
37
|
+
request(fill(ApiPaths::THREAD_SNOOZE, id:), method: :post, body: {"wakeAt" => instant(wake_at)},
|
|
38
|
+
repeatable: true, api_key:)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def unsnooze(id, api_key: nil)
|
|
42
|
+
request(fill(ApiPaths::THREAD_UNSNOOZE, id:), method: :post, repeatable: true, api_key:)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def list_attachments(id, message_id, api_key: nil)
|
|
46
|
+
fetch_list(fill(ApiPaths::THREAD_MESSAGE_ATTACHMENTS, id:, messageId: message_id), api_key:)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def get_event(id, api_key: nil)
|
|
50
|
+
request(fill(ApiPaths::THREAD_EVENT, id:), api_key:)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def list_notes(id, api_key: nil)
|
|
54
|
+
fetch_list(fill(ApiPaths::THREAD_NOTES, id:), api_key:)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def create_note(id, body = nil, api_key: nil, **fields)
|
|
58
|
+
request(fill(ApiPaths::THREAD_NOTES, id:), method: :post, body: payload(body, fields), api_key:)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def update_note(id, note_id, patch = nil, api_key: nil, **fields)
|
|
62
|
+
request(fill(ApiPaths::THREAD_NOTE, id:, noteId: note_id), method: :patch, body: payload(patch, fields),
|
|
63
|
+
repeatable: true, api_key:)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def delete_note(id, note_id, api_key: nil)
|
|
67
|
+
request(fill(ApiPaths::THREAD_NOTE, id:, noteId: note_id), method: :delete, api_key:)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def reorder_notes(id, ids, api_key: nil)
|
|
71
|
+
envelope = request(fill(ApiPaths::THREAD_NOTES_REORDER, id:), method: :post, body: {"ids" => ids},
|
|
72
|
+
repeatable: true, api_key:)
|
|
73
|
+
Pagination.items_of(envelope.is_a?(Hash) ? envelope : {})
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def counts(address: nil, api_key: nil)
|
|
77
|
+
request(ApiPaths::THREADS_COUNTS, query: query_params(address:), api_key:)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def summary(id, api_key: nil)
|
|
81
|
+
request(fill(ApiPaths::THREAD_SUMMARY, id:), api_key:)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def restore(id, api_key: nil)
|
|
85
|
+
request(fill(ApiPaths::THREAD_RESTORE, id:), method: :post, repeatable: true, api_key:)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def delete(id, api_key: nil)
|
|
89
|
+
request(fill(ApiPaths::THREAD, id:), method: :delete, api_key:)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def unsubscribe(id, api_key: nil)
|
|
93
|
+
request(fill(ApiPaths::THREAD_UNSUBSCRIBE, id:), method: :post, api_key:)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
private
|
|
97
|
+
|
|
98
|
+
def list_query(folder, query, label_ids, sort, date_from, date_to, from_contacts)
|
|
99
|
+
query_params(folder:, query:, label_ids: joined(label_ids), sort:, date_from: instant(date_from),
|
|
100
|
+
date_to: instant(date_to), from_contacts: flag(from_contacts))
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OpenEmail
|
|
4
|
+
module Resources
|
|
5
|
+
class Tools < Resource
|
|
6
|
+
def check_dmarc(domain, api_key: nil)
|
|
7
|
+
request(ApiPaths::TOOLS_DMARC, query: query_params(domain:), api_key:)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def check_bimi(domain, api_key: nil)
|
|
11
|
+
request(ApiPaths::TOOLS_BIMI, query: query_params(domain:), api_key:)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def check_deliverability(domain, api_key: nil)
|
|
15
|
+
request(ApiPaths::TOOLS_DELIVERABILITY, query: query_params(domain:), api_key:)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OpenEmail
|
|
4
|
+
module Resources
|
|
5
|
+
class Tracking < Resource
|
|
6
|
+
def list(opened: nil, clicked: nil, days: nil, minutes: nil, grain: nil, limit: nil, cursor: nil, api_key: nil)
|
|
7
|
+
fetch_page(ApiPaths::TRACKING, list_query(opened, clicked, days, minutes, grain), limit:, cursor:, api_key:)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def list_all(opened: nil, clicked: nil, days: nil, minutes: nil, grain: nil, limit: nil, cursor: nil,
|
|
11
|
+
api_key: nil)
|
|
12
|
+
collect_all(ApiPaths::TRACKING, list_query(opened, clicked, days, minutes, grain), limit:, cursor:, api_key:)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def iterate(opened: nil, clicked: nil, days: nil, minutes: nil, grain: nil, limit: nil, cursor: nil,
|
|
16
|
+
api_key: nil, &)
|
|
17
|
+
iterate_pages(ApiPaths::TRACKING, list_query(opened, clicked, days, minutes, grain), limit:, cursor:, api_key:, &)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def get_stats(days: nil, minutes: nil, grain: nil, offset_minutes: nil, api_key: nil)
|
|
21
|
+
request(ApiPaths::TRACKING_STATS, query: query_params(days:, minutes:, grain:, offset_minutes:), api_key:)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def get(id, api_key: nil)
|
|
25
|
+
request(fill(ApiPaths::TRACKED, id:), api_key:)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def list_opens(id, include_machine: nil, limit: nil, cursor: nil, api_key: nil)
|
|
29
|
+
fetch_page(fill(ApiPaths::TRACKED_OPENS, id:), hit_query(include_machine), limit:, cursor:, api_key:)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def list_all_opens(id, include_machine: nil, limit: nil, cursor: nil, api_key: nil)
|
|
33
|
+
collect_all(fill(ApiPaths::TRACKED_OPENS, id:), hit_query(include_machine), limit:, cursor:, api_key:)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def iterate_opens(id, include_machine: nil, limit: nil, cursor: nil, api_key: nil, &)
|
|
37
|
+
iterate_pages(fill(ApiPaths::TRACKED_OPENS, id:), hit_query(include_machine), limit:, cursor:, api_key:, &)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def list_clicks(id, include_machine: nil, limit: nil, cursor: nil, api_key: nil)
|
|
41
|
+
fetch_page(fill(ApiPaths::TRACKED_CLICKS, id:), hit_query(include_machine), limit:, cursor:, api_key:)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def list_all_clicks(id, include_machine: nil, limit: nil, cursor: nil, api_key: nil)
|
|
45
|
+
collect_all(fill(ApiPaths::TRACKED_CLICKS, id:), hit_query(include_machine), limit:, cursor:, api_key:)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def iterate_clicks(id, include_machine: nil, limit: nil, cursor: nil, api_key: nil, &)
|
|
49
|
+
iterate_pages(fill(ApiPaths::TRACKED_CLICKS, id:), hit_query(include_machine), limit:, cursor:, api_key:, &)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
private
|
|
53
|
+
|
|
54
|
+
def list_query(opened, clicked, days, minutes, grain)
|
|
55
|
+
query_params(opened: flag(opened), clicked: flag(clicked), days:, minutes:, grain:)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def hit_query(include_machine)
|
|
59
|
+
query_params(include_machine: flag(include_machine))
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|