nextmail 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/nextmail/api_paths.rb +447 -0
- data/lib/nextmail/client.rb +81 -0
- data/lib/nextmail/constants.rb +1621 -0
- data/lib/nextmail/credentials.rb +53 -0
- data/lib/nextmail/decode.rb +34 -0
- data/lib/nextmail/defaults.rb +114 -0
- data/lib/nextmail/endpoint.rb +144 -0
- data/lib/nextmail/errors.rb +121 -0
- data/lib/nextmail/http.rb +172 -0
- data/lib/nextmail/image_crop.rb +38 -0
- data/lib/nextmail/languages.rb +42 -0
- data/lib/nextmail/pagination.rb +63 -0
- data/lib/nextmail/protocol.rb +221 -0
- data/lib/nextmail/raw_body.rb +83 -0
- data/lib/nextmail/request_path.rb +50 -0
- data/lib/nextmail/resource.rb +109 -0
- data/lib/nextmail/resources/account.rb +155 -0
- data/lib/nextmail/resources/addresses.rb +38 -0
- data/lib/nextmail/resources/analytics.rb +19 -0
- data/lib/nextmail/resources/app_host.rb +23 -0
- data/lib/nextmail/resources/audiences.rb +95 -0
- data/lib/nextmail/resources/automations.rb +125 -0
- data/lib/nextmail/resources/billing.rb +76 -0
- data/lib/nextmail/resources/bookings.rb +100 -0
- data/lib/nextmail/resources/branding.rb +24 -0
- data/lib/nextmail/resources/broadcasts.rb +102 -0
- data/lib/nextmail/resources/calendar.rb +153 -0
- data/lib/nextmail/resources/chats.rb +62 -0
- data/lib/nextmail/resources/connected_mailboxes.rb +35 -0
- data/lib/nextmail/resources/connectors.rb +75 -0
- data/lib/nextmail/resources/contacts.rb +197 -0
- data/lib/nextmail/resources/dns_connections.rb +23 -0
- data/lib/nextmail/resources/domains.rb +264 -0
- data/lib/nextmail/resources/drafts.rb +36 -0
- data/lib/nextmail/resources/emails.rb +120 -0
- data/lib/nextmail/resources/encryption.rb +19 -0
- data/lib/nextmail/resources/events.rb +22 -0
- data/lib/nextmail/resources/exports.rb +27 -0
- data/lib/nextmail/resources/files.rb +82 -0
- data/lib/nextmail/resources/follow_ups.rb +21 -0
- data/lib/nextmail/resources/forms.rb +112 -0
- data/lib/nextmail/resources/imports.rb +106 -0
- data/lib/nextmail/resources/keys.rb +126 -0
- data/lib/nextmail/resources/knowledge.rb +137 -0
- data/lib/nextmail/resources/labels.rb +43 -0
- data/lib/nextmail/resources/languages.rb +11 -0
- data/lib/nextmail/resources/me.rb +57 -0
- data/lib/nextmail/resources/members.rb +100 -0
- data/lib/nextmail/resources/out_of_office.rb +28 -0
- data/lib/nextmail/resources/provider_imports.rb +48 -0
- data/lib/nextmail/resources/roles.rb +39 -0
- data/lib/nextmail/resources/rules.rb +73 -0
- data/lib/nextmail/resources/security.rb +39 -0
- data/lib/nextmail/resources/segments.rb +31 -0
- data/lib/nextmail/resources/senders.rb +19 -0
- data/lib/nextmail/resources/sending.rb +23 -0
- data/lib/nextmail/resources/settings.rb +16 -0
- data/lib/nextmail/resources/signatures.rb +41 -0
- data/lib/nextmail/resources/subscriptions.rb +55 -0
- data/lib/nextmail/resources/support.rb +11 -0
- data/lib/nextmail/resources/suppressions.rb +43 -0
- data/lib/nextmail/resources/tasks.rb +95 -0
- data/lib/nextmail/resources/temp_mail.rb +67 -0
- data/lib/nextmail/resources/templates.rb +153 -0
- data/lib/nextmail/resources/threads.rb +218 -0
- data/lib/nextmail/resources/tools.rb +35 -0
- data/lib/nextmail/resources/tracking.rb +72 -0
- data/lib/nextmail/resources/webhooks.rb +170 -0
- data/lib/nextmail/resources/workspaces.rb +40 -0
- data/lib/nextmail/results.rb +33 -0
- data/lib/nextmail/transport.rb +272 -0
- data/lib/nextmail/update_notice.rb +69 -0
- data/lib/nextmail/version.rb +5 -0
- data/lib/nextmail/webhook.rb +82 -0
- data/lib/nextmail/wire.rb +102 -0
- data/lib/nextmail.rb +126 -0
- metadata +122 -0
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Nextmail
|
|
4
|
+
module Resources
|
|
5
|
+
class Account < Resource
|
|
6
|
+
def set_name(name, api_key: nil)
|
|
7
|
+
request(ApiPaths::ACCOUNT, method: :patch, body: {"name" => name}, repeatable: true, api_key:)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def get_notifications(api_key: nil)
|
|
11
|
+
request(ApiPaths::ACCOUNT_NOTIFICATIONS, api_key:)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def set_email_notification(category, body = nil, api_key: nil, **fields)
|
|
15
|
+
request(fill(ApiPaths::ACCOUNT_NOTIFICATION_EMAIL, category:), method: :put,
|
|
16
|
+
body: payload(body, fields).slice("enabled"), repeatable: true, api_key:)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def set_push_muted(workspace_id, body = nil, api_key: nil, **fields)
|
|
20
|
+
request(fill(ApiPaths::ACCOUNT_NOTIFICATION_PUSH, workspaceId: workspace_id), method: :put,
|
|
21
|
+
body: payload(body, fields).slice("muted"), repeatable: true, api_key:)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def list_push_devices(api_key: nil)
|
|
25
|
+
fetch_list(ApiPaths::ACCOUNT_PUSH_DEVICES, api_key:)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def remove_push_device(device_id, api_key: nil)
|
|
29
|
+
request(fill(ApiPaths::ACCOUNT_PUSH_DEVICE, deviceId: device_id), method: :delete, api_key:)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def send_test_push(body = nil, api_key: nil, **fields)
|
|
33
|
+
request(ApiPaths::ACCOUNT_PUSH_DEVICES_TEST, method: :post, body: payload(body, fields), api_key:)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def set_photo(data, content_type: nil, crop: nil, api_key: nil)
|
|
37
|
+
request(ApiPaths::ACCOUNT_PHOTO, method: :put, query: crop_query(crop), raw: data,
|
|
38
|
+
content_type: raw_content_type(data, content_type), repeatable: true, timeout: upload_timeout, api_key:)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def remove_photo(api_key: nil)
|
|
42
|
+
request(ApiPaths::ACCOUNT_PHOTO, method: :delete, repeatable: true, api_key:)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def get_username(api_key: nil)
|
|
46
|
+
request(ApiPaths::ACCOUNT_USERNAME, api_key:)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def check_username(username, api_key: nil)
|
|
50
|
+
request(ApiPaths::ACCOUNT_USERNAME_AVAILABILITY, query: query_params(username:), api_key:)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def set_username(username, api_key: nil)
|
|
54
|
+
request(ApiPaths::ACCOUNT_USERNAME, method: :put, body: {"username" => username}, api_key:)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def list_connected_apps(api_key: nil)
|
|
58
|
+
fetch_list(ApiPaths::ACCOUNT_CONNECTED_APPS, api_key:)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def list_connected_app_requests(client_id, failed_only: nil, statuses: nil, since: nil, until: nil, limit: nil,
|
|
62
|
+
cursor: nil, api_key: nil)
|
|
63
|
+
query = log_request_query(since, binding.local_variable_get(:until), failed_only, statuses, nil)
|
|
64
|
+
fetch_page(fill(ApiPaths::ACCOUNT_CONNECTED_APP_REQUESTS, clientId: client_id), query, limit:, cursor:, api_key:)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def list_all_connected_app_requests(client_id, failed_only: nil, statuses: nil, since: nil, until: nil,
|
|
68
|
+
limit: nil, cursor: nil, api_key: nil)
|
|
69
|
+
query = log_request_query(since, binding.local_variable_get(:until), failed_only, statuses, nil)
|
|
70
|
+
collect_all(fill(ApiPaths::ACCOUNT_CONNECTED_APP_REQUESTS, clientId: client_id), query, limit:, cursor:,
|
|
71
|
+
api_key:)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def iterate_connected_app_requests(client_id, failed_only: nil, statuses: nil, since: nil, until: nil,
|
|
75
|
+
limit: nil, cursor: nil, api_key: nil, &)
|
|
76
|
+
query = log_request_query(since, binding.local_variable_get(:until), failed_only, statuses, nil)
|
|
77
|
+
iterate_pages(fill(ApiPaths::ACCOUNT_CONNECTED_APP_REQUESTS, clientId: client_id), query, limit:, cursor:,
|
|
78
|
+
api_key:, &)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def revoke_connected_app(client_id, api_key: nil)
|
|
82
|
+
request(fill(ApiPaths::ACCOUNT_CONNECTED_APP, clientId: client_id), method: :delete, api_key:)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def end_connected_app_elevation(client_id, api_key: nil)
|
|
86
|
+
request(fill(ApiPaths::ACCOUNT_CONNECTED_APP_ELEVATION, clientId: client_id), method: :delete, repeatable: true,
|
|
87
|
+
api_key:)
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def list_sessions(api_key: nil)
|
|
91
|
+
fetch_list(ApiPaths::ACCOUNT_SESSIONS, api_key:)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def revoke_session(session_id, api_key: nil)
|
|
95
|
+
request(fill(ApiPaths::ACCOUNT_SESSION, sessionId: session_id), method: :delete, api_key:)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def revoke_sessions(connected_apps: nil, api_key: nil)
|
|
99
|
+
request(ApiPaths::ACCOUNT_SESSIONS, method: :delete, query: query_params(connected_apps: flag(connected_apps)),
|
|
100
|
+
api_key:)
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def list_security_events(limit: nil, cursor: nil, api_key: nil)
|
|
104
|
+
fetch_page(ApiPaths::ACCOUNT_SECURITY_EVENTS, limit:, cursor:, api_key:)
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def list_all_security_events(limit: nil, cursor: nil, api_key: nil)
|
|
108
|
+
collect_all(ApiPaths::ACCOUNT_SECURITY_EVENTS, limit:, cursor:, api_key:)
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def iterate_security_events(limit: nil, cursor: nil, api_key: nil, &)
|
|
112
|
+
iterate_pages(ApiPaths::ACCOUNT_SECURITY_EVENTS, limit:, cursor:, api_key:, &)
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def list_passkeys(api_key: nil)
|
|
116
|
+
fetch_list(ApiPaths::ACCOUNT_PASSKEYS, api_key:)
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def rename_passkey(passkey_id, name, api_key: nil)
|
|
120
|
+
request(fill(ApiPaths::ACCOUNT_PASSKEY, passkeyId: passkey_id), method: :patch, body: {"name" => name},
|
|
121
|
+
repeatable: true, api_key:)
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def remove_passkey(passkey_id, api_key: nil)
|
|
125
|
+
request(fill(ApiPaths::ACCOUNT_PASSKEY, passkeyId: passkey_id), method: :delete, api_key:)
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def list_invitations(api_key: nil)
|
|
129
|
+
fetch_list(ApiPaths::ACCOUNT_INVITATIONS, api_key:)
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
def accept_invitation(invitation_id, activate: nil, api_key: nil)
|
|
133
|
+
request(fill(ApiPaths::ACCOUNT_INVITATION_ACCEPT, invitationId: invitation_id), method: :post,
|
|
134
|
+
body: activate.nil? ? {} : {"activate" => activate}, repeatable: true, api_key:)
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
def decline_invitation(invitation_id, api_key: nil)
|
|
138
|
+
request(fill(ApiPaths::ACCOUNT_INVITATION_DECLINE, invitationId: invitation_id), method: :post,
|
|
139
|
+
repeatable: true, api_key:)
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
def list_ownership_offers(api_key: nil)
|
|
143
|
+
fetch_list(ApiPaths::ACCOUNT_OWNERSHIP_OFFERS, api_key:)
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
def accept_ownership_offer(workspace_id, api_key: nil)
|
|
147
|
+
request(fill(ApiPaths::ACCOUNT_OWNERSHIP_OFFER_ACCEPT, workspaceId: workspace_id), method: :post, api_key:)
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
def decline_ownership_offer(workspace_id, api_key: nil)
|
|
151
|
+
request(fill(ApiPaths::ACCOUNT_OWNERSHIP_OFFER_DECLINE, workspaceId: workspace_id), method: :post, api_key:)
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Nextmail
|
|
4
|
+
module Resources
|
|
5
|
+
class Addresses < Resource
|
|
6
|
+
def list(limit: nil, cursor: nil, api_key: nil)
|
|
7
|
+
envelope = request(ApiPaths::ADDRESSES, query: Pagination.page_query(nil, CURSOR, limit, cursor), api_key:)
|
|
8
|
+
envelope = {} unless envelope.is_a?(Hash)
|
|
9
|
+
next_cursor = Pagination.cursor_of(envelope[:nextCursor])
|
|
10
|
+
|
|
11
|
+
AddressBookPage.new(
|
|
12
|
+
unrestricted: envelope[:unrestricted],
|
|
13
|
+
addresses: Pagination.items_of(envelope),
|
|
14
|
+
domains: envelope[:domains].is_a?(Array) ? envelope[:domains] : [],
|
|
15
|
+
has_more: Pagination.more?(envelope, next_cursor),
|
|
16
|
+
next_cursor:
|
|
17
|
+
)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def list_all(limit: nil, cursor: nil, api_key: nil)
|
|
21
|
+
current = list(limit:, cursor:, api_key:)
|
|
22
|
+
addresses = current.addresses.dup
|
|
23
|
+
|
|
24
|
+
while current.has_more && current.next_cursor && current.next_cursor != cursor
|
|
25
|
+
cursor = current.next_cursor
|
|
26
|
+
current = list(limit:, cursor:, api_key:)
|
|
27
|
+
addresses.concat(current.addresses)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
AddressBook.new(unrestricted: current.unrestricted, addresses:, domains: current.domains)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def iterate(limit: nil, cursor: nil, api_key: nil, &)
|
|
34
|
+
iterate_pages(ApiPaths::ADDRESSES, limit:, cursor:, api_key:, &)
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Nextmail
|
|
4
|
+
module Resources
|
|
5
|
+
class Analytics < Resource
|
|
6
|
+
def mailbox(from: nil, to: nil, offset_minutes: nil, grain: nil, address: nil, api_key: nil)
|
|
7
|
+
query = query_params(from: instant(from), to: instant(to), offset_minutes:, grain:, address:)
|
|
8
|
+
request(ApiPaths::ANALYTICS_MAILBOX, query:, api_key:)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def sending(days: nil, minutes: nil, offset_minutes: nil, grain: nil, address: nil, since: nil, until: nil,
|
|
12
|
+
recipient: nil, tag: nil, api_key: nil)
|
|
13
|
+
query = query_params(days:, minutes:, offset_minutes:, grain:, address:, since: instant(since),
|
|
14
|
+
until: instant(binding.local_variable_get(:until)), recipient:, tag:)
|
|
15
|
+
request(ApiPaths::ANALYTICS_SENDING, query:, api_key:)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Nextmail
|
|
4
|
+
module Resources
|
|
5
|
+
class AppHost < Resource
|
|
6
|
+
def get(api_key: nil)
|
|
7
|
+
request(ApiPaths::APP_HOST, api_key:)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def set(body = nil, api_key: nil, **fields)
|
|
11
|
+
request(ApiPaths::APP_HOST, method: :put, body: payload(body, fields), repeatable: true, api_key:)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def verify(api_key: nil)
|
|
15
|
+
request(ApiPaths::APP_HOST_VERIFY, method: :post, repeatable: true, api_key:)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def delete(api_key: nil)
|
|
19
|
+
request(ApiPaths::APP_HOST, method: :delete, repeatable: true, api_key:)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Nextmail
|
|
4
|
+
module Resources
|
|
5
|
+
class Audiences < Resource
|
|
6
|
+
def list(limit: nil, cursor: nil, api_key: nil)
|
|
7
|
+
fetch_page(ApiPaths::AUDIENCES, limit:, cursor:, api_key:)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def list_all(limit: nil, cursor: nil, api_key: nil)
|
|
11
|
+
collect_all(ApiPaths::AUDIENCES, limit:, cursor:, api_key:)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def iterate(limit: nil, cursor: nil, api_key: nil, &)
|
|
15
|
+
iterate_pages(ApiPaths::AUDIENCES, limit:, cursor:, api_key:, &)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def growth(audience_ids: nil, days: nil, minutes: nil, since: nil, until: nil, grain: nil, offset_minutes: nil,
|
|
19
|
+
api_key: nil)
|
|
20
|
+
query = query_params(audience_ids: joined(audience_ids), days:, minutes:, grain:, offset_minutes:)
|
|
21
|
+
.merge(log_window_query(since, binding.local_variable_get(:until)))
|
|
22
|
+
request(ApiPaths::AUDIENCES_GROWTH, query:, api_key:)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def get(id, api_key: nil)
|
|
26
|
+
request(fill(ApiPaths::AUDIENCE, id:), api_key:)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def create(body = nil, api_key: nil, **fields)
|
|
30
|
+
request(ApiPaths::AUDIENCES, method: :post, body: payload(body, fields), api_key:)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def update(id, patch = nil, api_key: nil, **fields)
|
|
34
|
+
request(fill(ApiPaths::AUDIENCE, id:), method: :patch, body: payload(patch, fields), repeatable: true, api_key:)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def delete(id, api_key: nil)
|
|
38
|
+
request(fill(ApiPaths::AUDIENCE, id:), method: :delete, api_key:)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def empty(id, api_key: nil)
|
|
42
|
+
request(fill(ApiPaths::AUDIENCE_EMPTY, id:), method: :post, api_key:)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def list_contacts(id, q: nil, source: nil, sort: nil, statuses: nil, inactive_days: nil, limit: nil, cursor: nil,
|
|
46
|
+
api_key: nil)
|
|
47
|
+
fetch_page(fill(ApiPaths::AUDIENCE_CONTACTS, id:), member_query(q, source, sort, statuses, inactive_days),
|
|
48
|
+
limit:, cursor:, api_key:)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def list_all_contacts(id, q: nil, source: nil, sort: nil, statuses: nil, inactive_days: nil, limit: nil,
|
|
52
|
+
cursor: nil, api_key: nil)
|
|
53
|
+
collect_all(fill(ApiPaths::AUDIENCE_CONTACTS, id:), member_query(q, source, sort, statuses, inactive_days),
|
|
54
|
+
limit:, cursor:, api_key:)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def iterate_contacts(id, q: nil, source: nil, sort: nil, statuses: nil, inactive_days: nil, limit: nil,
|
|
58
|
+
cursor: nil, api_key: nil, &)
|
|
59
|
+
iterate_pages(fill(ApiPaths::AUDIENCE_CONTACTS, id:), member_query(q, source, sort, statuses, inactive_days),
|
|
60
|
+
limit:, cursor:, api_key:, &)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def add_contact(id, body = nil, api_key: nil, **fields)
|
|
64
|
+
request(fill(ApiPaths::AUDIENCE_CONTACTS, id:), method: :post, body: payload(body, fields), repeatable: true,
|
|
65
|
+
api_key:)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def remove_contact(id, email, api_key: nil)
|
|
69
|
+
request(fill(ApiPaths::AUDIENCE_CONTACT, id:, email:), method: :delete, api_key:)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def add_contacts(id, body = nil, api_key: nil, **fields)
|
|
73
|
+
request(fill(ApiPaths::AUDIENCE_CONTACTS_BATCH, id:), method: :post, body: payload(body, fields),
|
|
74
|
+
repeatable: true, api_key:)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def remove_contacts(id, body = nil, api_key: nil, **fields)
|
|
78
|
+
request(fill(ApiPaths::AUDIENCE_CONTACTS_BATCH_REMOVE, id:), method: :post, body: payload(body, fields),
|
|
79
|
+
repeatable: true, api_key:)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def import_contacts(id, body = nil, api_key: nil, **fields)
|
|
83
|
+
request(fill(ApiPaths::AUDIENCE_IMPORT, id:), method: :post, body: payload(body, fields), repeatable: true,
|
|
84
|
+
api_key:)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
private
|
|
88
|
+
|
|
89
|
+
def member_query(q, source, sort, statuses, inactive_days)
|
|
90
|
+
status = (statuses.nil? || statuses.empty?) ? nil : joined(statuses)
|
|
91
|
+
query_params(q:, source:, sort:, status:, inactive_days:)
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Nextmail
|
|
4
|
+
module Resources
|
|
5
|
+
class Automations < Resource
|
|
6
|
+
def list(status: nil, limit: nil, cursor: nil, api_key: nil)
|
|
7
|
+
fetch_page(ApiPaths::AUTOMATIONS, query_params(status:), limit:, cursor:, api_key:)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def list_all(status: nil, limit: nil, cursor: nil, api_key: nil)
|
|
11
|
+
collect_all(ApiPaths::AUTOMATIONS, query_params(status:), limit:, cursor:, api_key:)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def iterate(status: nil, limit: nil, cursor: nil, api_key: nil, &)
|
|
15
|
+
iterate_pages(ApiPaths::AUTOMATIONS, query_params(status:), limit:, cursor:, api_key:, &)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def create(body = nil, api_key: nil, **fields)
|
|
19
|
+
request(ApiPaths::AUTOMATIONS, method: :post, body: payload(body, fields), api_key:)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def list_starters(api_key: nil)
|
|
23
|
+
fetch_list(ApiPaths::AUTOMATION_STARTERS, api_key:)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def get(id, api_key: nil)
|
|
27
|
+
request(fill(ApiPaths::AUTOMATION, id:), api_key:)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def update(id, patch = nil, api_key: nil, **fields)
|
|
31
|
+
request(fill(ApiPaths::AUTOMATION, id:), method: :patch, body: payload(patch, fields), repeatable: true,
|
|
32
|
+
api_key:)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def delete(id, api_key: nil)
|
|
36
|
+
request(fill(ApiPaths::AUTOMATION, id:), method: :delete, api_key:)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def publish(id, api_key: nil)
|
|
40
|
+
request(fill(ApiPaths::AUTOMATION_PUBLISH, id:), method: :post, repeatable: true, api_key:)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def pause(id, api_key: nil)
|
|
44
|
+
request(fill(ApiPaths::AUTOMATION_PAUSE, id:), method: :post, repeatable: true, api_key:)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def resume(id, api_key: nil)
|
|
48
|
+
request(fill(ApiPaths::AUTOMATION_RESUME, id:), method: :post, repeatable: true, api_key:)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def archive(id, api_key: nil)
|
|
52
|
+
request(fill(ApiPaths::AUTOMATION_ARCHIVE, id:), method: :post, repeatable: true, api_key:)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def duplicate(id, api_key: nil)
|
|
56
|
+
request(fill(ApiPaths::AUTOMATION_DUPLICATE, id:), method: :post, api_key:)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def send_test(id, body = nil, api_key: nil, **fields)
|
|
60
|
+
request(fill(ApiPaths::AUTOMATION_TEST, id:), method: :post, body: payload(body, fields), api_key:)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def list_versions(id, api_key: nil)
|
|
64
|
+
fetch_list(fill(ApiPaths::AUTOMATION_VERSIONS, id:), api_key:)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def restore_version(id, version, api_key: nil)
|
|
68
|
+
request(fill(ApiPaths::AUTOMATION_VERSION_RESTORE, id:, version:), method: :post, repeatable: true, api_key:)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def stats(id, since: nil, until: nil, api_key: nil)
|
|
72
|
+
query = log_window_query(since, binding.local_variable_get(:until))
|
|
73
|
+
request(fill(ApiPaths::AUTOMATION_STATS, id:), query:, api_key:)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def analytics(automation_ids: nil, since: nil, until: nil, api_key: nil)
|
|
77
|
+
query = query_params(automation_ids: joined(automation_ids))
|
|
78
|
+
.merge(log_window_query(since, binding.local_variable_get(:until)))
|
|
79
|
+
request(ApiPaths::AUTOMATIONS_ANALYTICS, query:, api_key:)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def list_runs(id, event: nil, step_key: nil, outcome: nil, limit: nil, cursor: nil, api_key: nil)
|
|
83
|
+
fetch_page(fill(ApiPaths::AUTOMATION_RUNS, id:), query_params(event:, step_key:, outcome:), limit:, cursor:,
|
|
84
|
+
api_key:)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def list_all_runs(id, event: nil, step_key: nil, outcome: nil, limit: nil, cursor: nil, api_key: nil)
|
|
88
|
+
collect_all(fill(ApiPaths::AUTOMATION_RUNS, id:), query_params(event:, step_key:, outcome:), limit:, cursor:,
|
|
89
|
+
api_key:)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def iterate_runs(id, event: nil, step_key: nil, outcome: nil, limit: nil, cursor: nil, api_key: nil, &)
|
|
93
|
+
iterate_pages(fill(ApiPaths::AUTOMATION_RUNS, id:), query_params(event:, step_key:, outcome:), limit:,
|
|
94
|
+
cursor:, api_key:, &)
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def list_enrollments(id, status: nil, step_key: nil, q: nil, limit: nil, cursor: nil, api_key: nil)
|
|
98
|
+
fetch_page(fill(ApiPaths::AUTOMATION_ENROLLMENTS, id:), query_params(status:, step_key:, q:), limit:, cursor:,
|
|
99
|
+
api_key:)
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def list_all_enrollments(id, status: nil, step_key: nil, q: nil, limit: nil, cursor: nil, api_key: nil)
|
|
103
|
+
collect_all(fill(ApiPaths::AUTOMATION_ENROLLMENTS, id:), query_params(status:, step_key:, q:), limit:, cursor:,
|
|
104
|
+
api_key:)
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def iterate_enrollments(id, status: nil, step_key: nil, q: nil, limit: nil, cursor: nil, api_key: nil, &)
|
|
108
|
+
iterate_pages(fill(ApiPaths::AUTOMATION_ENROLLMENTS, id:), query_params(status:, step_key:, q:), limit:,
|
|
109
|
+
cursor:, api_key:, &)
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
def get_enrollment(id, enrollment_id, api_key: nil)
|
|
113
|
+
request(fill(ApiPaths::AUTOMATION_ENROLLMENT, id:, enrollmentId: enrollment_id), api_key:)
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def enroll(id, body = nil, api_key: nil, **fields)
|
|
117
|
+
request(fill(ApiPaths::AUTOMATION_ENROLLMENTS, id:), method: :post, body: payload(body, fields), api_key:)
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def exit_enrollment(id, enrollment_id, api_key: nil)
|
|
121
|
+
request(fill(ApiPaths::AUTOMATION_ENROLLMENT_EXIT, id:, enrollmentId: enrollment_id), method: :post, api_key:)
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
end
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Nextmail
|
|
4
|
+
module Resources
|
|
5
|
+
class Billing < Resource
|
|
6
|
+
def get(api_key: nil)
|
|
7
|
+
request(ApiPaths::BILLING, api_key:)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def list_plans(api_key: nil)
|
|
11
|
+
request(ApiPaths::BILLING_PLANS, api_key:)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def get_usage(days: nil, api_key: nil)
|
|
15
|
+
request(ApiPaths::BILLING_USAGE, query: query_params(days:), api_key:)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def list_alerts(api_key: nil)
|
|
19
|
+
request(ApiPaths::BILLING_ALERTS, api_key:)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def list_countries(api_key: nil)
|
|
23
|
+
request(ApiPaths::BILLING_COUNTRIES, api_key:)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def get_pay_as_you_go(api_key: nil)
|
|
27
|
+
request(ApiPaths::BILLING_PAY_AS_YOU_GO, api_key:)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def set_pay_as_you_go(body = nil, api_key: nil, **fields)
|
|
31
|
+
request(ApiPaths::BILLING_PAY_AS_YOU_GO, method: :patch, body: payload(body, fields), api_key:)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def set_pay_as_you_go_limit(body = nil, api_key: nil, **fields)
|
|
35
|
+
request(ApiPaths::BILLING_PAY_AS_YOU_GO_LIMIT, method: :put, body: payload(body, fields), api_key:)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def confirm_pay_as_you_go(api_key: nil)
|
|
39
|
+
request(ApiPaths::BILLING_PAY_AS_YOU_GO_CONFIRM, method: :post, api_key:)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def start_checkout(body = nil, api_key: nil, **fields)
|
|
43
|
+
request(ApiPaths::BILLING_CHECKOUT, method: :post, body: payload(body, fields), api_key:)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def list_add_ons(api_key: nil)
|
|
47
|
+
request(ApiPaths::BILLING_ADD_ONS, api_key:)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def start_add_on_checkout(body = nil, api_key: nil, **fields)
|
|
51
|
+
request(ApiPaths::BILLING_ADD_ON_CHECKOUT, method: :post, body: payload(body, fields), api_key:)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def cancel_add_on(add_on, api_key: nil)
|
|
55
|
+
request(fill(ApiPaths::BILLING_ADD_ON, addOn: add_on), method: :delete, api_key:)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def open_portal(body = nil, api_key: nil, **fields)
|
|
59
|
+
request(ApiPaths::BILLING_PORTAL, method: :post, body: payload(body, fields), api_key:)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def list_invoices(page: nil, limit: nil, sort: nil, search: nil, api_key: nil)
|
|
63
|
+
request(ApiPaths::BILLING_INVOICES, query: query_params(page:, limit:, sort:, search:), api_key:)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def get_invoice(order_id, api_key: nil)
|
|
67
|
+
request(fill(ApiPaths::BILLING_INVOICE, orderId: order_id), api_key:)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def save_invoice_details(order_id, body = nil, api_key: nil, **fields)
|
|
71
|
+
request(fill(ApiPaths::BILLING_INVOICE_DETAILS, orderId: order_id), method: :put, body: payload(body, fields),
|
|
72
|
+
api_key:)
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Nextmail
|
|
4
|
+
module Resources
|
|
5
|
+
class Bookings < Resource
|
|
6
|
+
def list_pages(q: nil, status: nil, since: nil, until: nil, sort: nil, api_key: nil)
|
|
7
|
+
until_value = binding.local_variable_get(:until)
|
|
8
|
+
query = query_params(q:, status:, since: instant(since), until: instant(until_value), sort:)
|
|
9
|
+
fetch_list(ApiPaths::BOOKING_PAGES, query, api_key:)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def get_page(id, api_key: nil)
|
|
13
|
+
request(fill(ApiPaths::BOOKING_PAGE, id:), api_key:)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def create_page(body = nil, api_key: nil, **fields)
|
|
17
|
+
request(ApiPaths::BOOKING_PAGES, method: :post, body: payload(body, fields), api_key:)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def update_page(id, patch = nil, api_key: nil, **fields)
|
|
21
|
+
request(fill(ApiPaths::BOOKING_PAGE, id:), method: :patch, body: payload(patch, fields), repeatable: true, api_key:)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def upload_background(id, data, content_type: nil, crop: nil, api_key: nil)
|
|
25
|
+
request(fill(ApiPaths::BOOKING_PAGE_BACKGROUND, id:), method: :put, query: crop_query(crop), raw: data,
|
|
26
|
+
content_type: raw_content_type(data, content_type), repeatable: true, timeout: upload_timeout, api_key:)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def remove_background(id, api_key: nil)
|
|
30
|
+
request(fill(ApiPaths::BOOKING_PAGE_BACKGROUND, id:), method: :delete, repeatable: true, api_key:)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def delete_page(id, api_key: nil)
|
|
34
|
+
request(fill(ApiPaths::BOOKING_PAGE, id:), method: :delete, api_key:)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def list_times(id, from: nil, to: nil, duration_minutes: nil, booking_id: nil, api_key: nil)
|
|
38
|
+
query = query_params(from: instant(from), to: instant(to), duration_minutes:, booking_id:)
|
|
39
|
+
request(fill(ApiPaths::BOOKING_PAGE_TIMES, id:), query:, api_key:)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def list(view: nil, page_id: nil, page_ids: nil, q: nil, from: nil, to: nil, limit: nil, cursor: nil, api_key: nil)
|
|
43
|
+
fetch_page(ApiPaths::BOOKINGS, list_query(view, page_id, page_ids, q, from, to), limit:, cursor:, api_key:)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def list_all(view: nil, page_id: nil, page_ids: nil, q: nil, from: nil, to: nil, limit: nil, cursor: nil,
|
|
47
|
+
api_key: nil)
|
|
48
|
+
collect_all(ApiPaths::BOOKINGS, list_query(view, page_id, page_ids, q, from, to), limit:, cursor:, api_key:)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def iterate(view: nil, page_id: nil, page_ids: nil, q: nil, from: nil, to: nil, limit: nil, cursor: nil,
|
|
52
|
+
api_key: nil, &)
|
|
53
|
+
iterate_pages(ApiPaths::BOOKINGS, list_query(view, page_id, page_ids, q, from, to), limit:, cursor:, api_key:, &)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def get(id, api_key: nil)
|
|
57
|
+
request(fill(ApiPaths::BOOKING, id:), api_key:)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def approve(id, api_key: nil)
|
|
61
|
+
request(fill(ApiPaths::BOOKING_APPROVE, id:), method: :post, api_key:)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def decline(id, body = nil, api_key: nil, **fields)
|
|
65
|
+
request(fill(ApiPaths::BOOKING_DECLINE, id:), method: :post, body: payload(body, fields), api_key:)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def cancel(id, body = nil, api_key: nil, **fields)
|
|
69
|
+
request(fill(ApiPaths::BOOKING_CANCEL, id:), method: :post, body: payload(body, fields), api_key:)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def reschedule(id, body = nil, api_key: nil, **fields)
|
|
73
|
+
request(fill(ApiPaths::BOOKING_RESCHEDULE, id:), method: :post, body: reschedule_wire(payload(body, fields)),
|
|
74
|
+
api_key:)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def resend_email(id, api_key: nil)
|
|
78
|
+
request(fill(ApiPaths::BOOKING_RESEND, id:), method: :post, api_key:)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def analytics(page_ids: nil, days: nil, minutes: nil, since: nil, until: nil, grain: nil, offset_minutes: nil,
|
|
82
|
+
api_key: nil)
|
|
83
|
+
query = query_params(page_ids: joined(page_ids), days:, minutes:, grain:, offset_minutes:)
|
|
84
|
+
.merge(log_window_query(since, binding.local_variable_get(:until)))
|
|
85
|
+
request(ApiPaths::BOOKINGS_ANALYTICS, query:, api_key:)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
private
|
|
89
|
+
|
|
90
|
+
def list_query(view, page_id, page_ids, q, from, to)
|
|
91
|
+
query_params(view:, page_id:, page_ids: joined(page_ids), q:, from: instant(from), to: instant(to))
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def reschedule_wire(wire)
|
|
95
|
+
wire["start"] = instant(wire["start"]) if wire.key?("start")
|
|
96
|
+
wire
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Nextmail
|
|
4
|
+
module Resources
|
|
5
|
+
class Branding < Resource
|
|
6
|
+
def get(api_key: nil)
|
|
7
|
+
request(ApiPaths::BRANDING, api_key:)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def update(body = nil, api_key: nil, **fields)
|
|
11
|
+
request(ApiPaths::BRANDING, method: :patch, body: payload(body, fields), repeatable: true, api_key:)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def upload_image(variant, data, content_type: nil, crop: nil, api_key: nil)
|
|
15
|
+
request(fill(ApiPaths::BRANDING_IMAGE, variant:), method: :put, query: crop_query(crop), raw: data,
|
|
16
|
+
content_type: raw_content_type(data, content_type), repeatable: true, timeout: upload_timeout, api_key:)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def remove_image(variant, api_key: nil)
|
|
20
|
+
request(fill(ApiPaths::BRANDING_IMAGE, variant:), method: :delete, repeatable: true, api_key:)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|