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,112 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Nextmail
|
|
4
|
+
module Resources
|
|
5
|
+
class Forms < Resource
|
|
6
|
+
def list(limit: nil, cursor: nil, api_key: nil)
|
|
7
|
+
fetch_page(ApiPaths::FORMS, limit:, cursor:, api_key:)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def list_all(limit: nil, cursor: nil, api_key: nil)
|
|
11
|
+
collect_all(ApiPaths::FORMS, limit:, cursor:, api_key:)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def iterate(limit: nil, cursor: nil, api_key: nil, &)
|
|
15
|
+
iterate_pages(ApiPaths::FORMS, limit:, cursor:, api_key:, &)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def create(body = nil, api_key: nil, **fields)
|
|
19
|
+
request(ApiPaths::FORMS, method: :post, body: payload(body, fields), api_key:)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def design(body = nil, api_key: nil, **fields)
|
|
23
|
+
request(ApiPaths::FORMS_DESIGN, method: :post, body: payload(body, fields), api_key:)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def redesign(id, body = nil, api_key: nil, **fields)
|
|
27
|
+
request(fill(ApiPaths::FORM_REDESIGN, id:), method: :post, body: payload(body, fields), api_key:)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def list_starters(api_key: nil)
|
|
31
|
+
fetch_list(ApiPaths::FORM_STARTERS, api_key:)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def get_starter(slug, api_key: nil)
|
|
35
|
+
request(fill(ApiPaths::FORM_STARTER, slug:), api_key:)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def get(id, api_key: nil)
|
|
39
|
+
request(fill(ApiPaths::FORM, id:), api_key:)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def update(id, patch = nil, api_key: nil, **fields)
|
|
43
|
+
request(fill(ApiPaths::FORM, id:), method: :patch, body: payload(patch, fields), repeatable: true, api_key:)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def delete(id, api_key: nil)
|
|
47
|
+
request(fill(ApiPaths::FORM, id:), method: :delete, api_key:)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def publish(id, api_key: nil)
|
|
51
|
+
request(fill(ApiPaths::FORM_PUBLISH, id:), method: :post, repeatable: true, api_key:)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def pause(id, api_key: nil)
|
|
55
|
+
request(fill(ApiPaths::FORM_PAUSE, id:), method: :post, repeatable: true, api_key:)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def resume(id, api_key: nil)
|
|
59
|
+
request(fill(ApiPaths::FORM_RESUME, id:), method: :post, repeatable: true, api_key:)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def duplicate(id, api_key: nil)
|
|
63
|
+
request(fill(ApiPaths::FORM_DUPLICATE, id:), method: :post, api_key:)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def analytics(id, days: nil, minutes: nil, since: nil, until: nil, grain: nil, offset_minutes: nil, api_key: nil)
|
|
67
|
+
query = query_params(days:, minutes:, grain:, offset_minutes:)
|
|
68
|
+
.merge(log_window_query(since, binding.local_variable_get(:until)))
|
|
69
|
+
request(fill(ApiPaths::FORM_ANALYTICS, id:), query:, api_key:)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def list_submissions(id, q: nil, status: nil, limit: nil, cursor: nil, api_key: nil)
|
|
73
|
+
fetch_page(fill(ApiPaths::FORM_SUBMISSIONS, id:), query_params(q:, status:), limit:, cursor:, api_key:)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def list_all_submissions(id, q: nil, status: nil, limit: nil, cursor: nil, api_key: nil)
|
|
77
|
+
collect_all(fill(ApiPaths::FORM_SUBMISSIONS, id:), query_params(q:, status:), limit:, cursor:, api_key:)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def iterate_submissions(id, q: nil, status: nil, limit: nil, cursor: nil, api_key: nil, &)
|
|
81
|
+
iterate_pages(fill(ApiPaths::FORM_SUBMISSIONS, id:), query_params(q:, status:), limit:, cursor:, api_key:, &)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def get_submission(id, submission_id, api_key: nil)
|
|
85
|
+
request(fill(ApiPaths::FORM_SUBMISSION, id:, submissionId: submission_id), api_key:)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def delete_submission(id, submission_id, api_key: nil)
|
|
89
|
+
request(fill(ApiPaths::FORM_SUBMISSION, id:, submissionId: submission_id), method: :delete, api_key:)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def delete_submissions(id, submission_ids, api_key: nil)
|
|
93
|
+
request(fill(ApiPaths::FORM_SUBMISSIONS_BATCH_REMOVE, id:), method: :post, body: {"ids" => submission_ids},
|
|
94
|
+
api_key:)
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def approve_submission(id, submission_id, api_key: nil)
|
|
98
|
+
request(fill(ApiPaths::FORM_SUBMISSION_APPROVE, id:, submissionId: submission_id), method: :post,
|
|
99
|
+
repeatable: true, api_key:)
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def resend_confirmation(id, submission_id, api_key: nil)
|
|
103
|
+
request(fill(ApiPaths::FORM_SUBMISSION_RESEND, id:, submissionId: submission_id), method: :post, api_key:)
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def subscribe(form_id, values = nil, api_key: nil, **fields)
|
|
107
|
+
request(fill(ApiPaths::SUBSCRIBE_FORM, formId: form_id), method: :post, body: payload(values, fields),
|
|
108
|
+
anonymous: true, api_key:)
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
end
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Nextmail
|
|
4
|
+
module Resources
|
|
5
|
+
class Imports < Resource
|
|
6
|
+
def list(address_id: nil, source: nil, status: nil, search: nil, limit: nil, cursor: nil, api_key: nil)
|
|
7
|
+
fetch_page(ApiPaths::IMPORTS, list_query(address_id, source, status, search), limit:, cursor:, api_key:)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def list_all(address_id: nil, source: nil, status: nil, search: nil, limit: nil, cursor: nil, api_key: nil)
|
|
11
|
+
collect_all(ApiPaths::IMPORTS, list_query(address_id, source, status, search), limit:, cursor:, api_key:)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def iterate(address_id: nil, source: nil, status: nil, search: nil, limit: nil, cursor: nil, api_key: nil, &)
|
|
15
|
+
iterate_pages(ApiPaths::IMPORTS, list_query(address_id, source, status, search), limit:, cursor:, api_key:, &)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def get(id, api_key: nil)
|
|
19
|
+
request(fill(ApiPaths::IMPORT, id:), api_key:)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def create(body = nil, api_key: nil, **fields)
|
|
23
|
+
request(ApiPaths::IMPORTS, method: :post, body: payload(body, fields), api_key:)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def upload_state(id, api_key: nil)
|
|
27
|
+
request(fill(ApiPaths::IMPORT_UPLOAD, id:), api_key:)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def upload_chunk(id, file, chunk, data, api_key: nil)
|
|
31
|
+
request(fill(ApiPaths::IMPORT_FILE_CHUNK, id:, file:, chunk:), method: :put, raw: data, repeatable: true,
|
|
32
|
+
api_key:)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def start(id, api_key: nil)
|
|
36
|
+
request(fill(ApiPaths::IMPORT_START, id:), method: :post, repeatable: true, api_key:)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def cancel(id, api_key: nil)
|
|
40
|
+
request(fill(ApiPaths::IMPORT_CANCEL, id:), method: :post, api_key:)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def list_failures(id, after: nil, limit: nil, api_key: nil)
|
|
44
|
+
request(fill(ApiPaths::IMPORT_FAILURES, id:), query: {"after" => after, "limit" => limit}, api_key:)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def delete_upload(id, api_key: nil)
|
|
48
|
+
request(fill(ApiPaths::IMPORT_UPLOAD, id:), method: :delete, api_key:)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def discover_mailbox(email, api_key: nil)
|
|
52
|
+
request(ApiPaths::IMPORT_MAILBOX_SETTINGS, query: query_params(email:), api_key:)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def check_mailbox(body = nil, api_key: nil, **fields)
|
|
56
|
+
request(ApiPaths::IMPORT_MAILBOX_CHECK, method: :post, body: payload(body, fields), api_key:)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def connect_mailbox(body = nil, api_key: nil, **fields)
|
|
60
|
+
request(ApiPaths::IMPORT_MAILBOX, method: :post, body: payload(body, fields), api_key:)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def resume(id, body = nil, api_key: nil, **fields)
|
|
64
|
+
request(fill(ApiPaths::IMPORT_RESUME, id:), method: :post, body: payload(body, fields), api_key:)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def import_files(input = nil, api_key: nil, **fields, &on_progress)
|
|
68
|
+
spec = payload(input, fields)
|
|
69
|
+
files = Array(spec["files"]).map { |file| file.to_h.transform_keys(&:to_s) }
|
|
70
|
+
created = create(import_body(spec, files), api_key:)
|
|
71
|
+
return created if files.empty?
|
|
72
|
+
|
|
73
|
+
upload_files(created, files, on_progress || spec["onProgress"], api_key)
|
|
74
|
+
start(created[:id], api_key:)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
private
|
|
78
|
+
|
|
79
|
+
def list_query(address_id, source, status, search)
|
|
80
|
+
{"addressId" => address_id}.merge(query_params(source:, status:, search:))
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def import_body(spec, files)
|
|
84
|
+
sizes = files.map { |file| {"name" => file["name"], "bytes" => RawBody.size(file["data"])} }
|
|
85
|
+
spec.slice("addressId", "options").merge("files" => sizes)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def upload_files(created, files, progress, api_key)
|
|
89
|
+
uploaded = 0
|
|
90
|
+
|
|
91
|
+
files.each_with_index do |file, index|
|
|
92
|
+
size = RawBody.size(file["data"])
|
|
93
|
+
chunks = created.dig(:files, index, :chunks) || 1
|
|
94
|
+
|
|
95
|
+
chunks.times do |chunk|
|
|
96
|
+
offset = chunk * created[:chunkBytes]
|
|
97
|
+
length = [size, offset + created[:chunkBytes]].min - offset
|
|
98
|
+
upload_chunk(created[:id], index, chunk, RawBody.slice(file["data"], offset, length), api_key:)
|
|
99
|
+
uploaded += length
|
|
100
|
+
progress&.call(uploaded, created[:totalBytes])
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
end
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Nextmail
|
|
4
|
+
module Resources
|
|
5
|
+
class Keys < Resource
|
|
6
|
+
def list(q: nil, limit: nil, cursor: nil, api_key: nil)
|
|
7
|
+
fetch_page(ApiPaths::KEYS, query_params(q:), limit:, cursor:, api_key:)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def list_all(q: nil, limit: nil, cursor: nil, api_key: nil)
|
|
11
|
+
collect_all(ApiPaths::KEYS, query_params(q:), limit:, cursor:, api_key:)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def iterate(q: nil, limit: nil, cursor: nil, api_key: nil, &)
|
|
15
|
+
iterate_pages(ApiPaths::KEYS, query_params(q:), limit:, cursor:, api_key:, &)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def get(id, api_key: nil)
|
|
19
|
+
request(fill(ApiPaths::KEY, id:), api_key:)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def create(body = nil, api_key: nil, **fields)
|
|
23
|
+
request(ApiPaths::KEYS, 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::KEY, id:), method: :patch, body: payload(patch, fields), repeatable: true, api_key:)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def delete(id, api_key: nil)
|
|
31
|
+
request(fill(ApiPaths::KEY, id:), method: :delete, api_key:)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def rotate(id, api_key: nil)
|
|
35
|
+
request(fill(ApiPaths::KEY_ROTATE, id:), method: :post, api_key:)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def revoke(id, body = nil, api_key: nil, **fields)
|
|
39
|
+
request(fill(ApiPaths::KEY_REVOKE, id:), method: :post, body: payload(body, fields), repeatable: true,
|
|
40
|
+
api_key:)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def list_requests(id, failed_only: nil, statuses: nil, path: nil, since: nil, until: nil, limit: nil,
|
|
44
|
+
cursor: nil, api_key: nil)
|
|
45
|
+
query = log_request_query(since, binding.local_variable_get(:until), failed_only, statuses, path)
|
|
46
|
+
fetch_page(fill(ApiPaths::KEY_REQUESTS, id:), query, limit:, cursor:, api_key:)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def list_all_requests(id, failed_only: nil, statuses: nil, path: nil, since: nil, until: nil, limit: nil,
|
|
50
|
+
cursor: nil, api_key: nil)
|
|
51
|
+
query = log_request_query(since, binding.local_variable_get(:until), failed_only, statuses, path)
|
|
52
|
+
collect_all(fill(ApiPaths::KEY_REQUESTS, id:), query, limit:, cursor:, api_key:)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def iterate_requests(id, failed_only: nil, statuses: nil, path: nil, since: nil, until: nil, limit: nil,
|
|
56
|
+
cursor: nil, api_key: nil, &)
|
|
57
|
+
query = log_request_query(since, binding.local_variable_get(:until), failed_only, statuses, path)
|
|
58
|
+
iterate_pages(fill(ApiPaths::KEY_REQUESTS, id:), query, limit:, cursor:, api_key:, &)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def list_activity(id, since: nil, until: nil, limit: nil, cursor: nil, api_key: nil)
|
|
62
|
+
query = log_window_query(since, binding.local_variable_get(:until))
|
|
63
|
+
fetch_page(fill(ApiPaths::KEY_ACTIVITY, id:), query, limit:, cursor:, api_key:)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def list_all_activity(id, since: nil, until: nil, limit: nil, cursor: nil, api_key: nil)
|
|
67
|
+
query = log_window_query(since, binding.local_variable_get(:until))
|
|
68
|
+
collect_all(fill(ApiPaths::KEY_ACTIVITY, id:), query, limit:, cursor:, api_key:)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def iterate_activity(id, since: nil, until: nil, limit: nil, cursor: nil, api_key: nil, &)
|
|
72
|
+
query = log_window_query(since, binding.local_variable_get(:until))
|
|
73
|
+
iterate_pages(fill(ApiPaths::KEY_ACTIVITY, id:), query, limit:, cursor:, api_key:, &)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def list_workspace_requests(key_ids: nil, failed_only: nil, statuses: nil, path: nil, since: nil, until: nil,
|
|
77
|
+
limit: nil, cursor: nil, api_key: nil)
|
|
78
|
+
query = workspace_request_query(since, binding.local_variable_get(:until), failed_only, statuses, path, key_ids)
|
|
79
|
+
fetch_page(ApiPaths::KEYS_REQUESTS, query, limit:, cursor:, api_key:)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def list_all_workspace_requests(key_ids: nil, failed_only: nil, statuses: nil, path: nil, since: nil, until: nil,
|
|
83
|
+
limit: nil, cursor: nil, api_key: nil)
|
|
84
|
+
query = workspace_request_query(since, binding.local_variable_get(:until), failed_only, statuses, path, key_ids)
|
|
85
|
+
collect_all(ApiPaths::KEYS_REQUESTS, query, limit:, cursor:, api_key:)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def iterate_workspace_requests(key_ids: nil, failed_only: nil, statuses: nil, path: nil, since: nil, until: nil,
|
|
89
|
+
limit: nil, cursor: nil, api_key: nil, &)
|
|
90
|
+
query = workspace_request_query(since, binding.local_variable_get(:until), failed_only, statuses, path, key_ids)
|
|
91
|
+
iterate_pages(ApiPaths::KEYS_REQUESTS, query, limit:, cursor:, api_key:, &)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def list_workspace_activity(key_ids: nil, since: nil, until: nil, limit: nil, cursor: nil, api_key: nil)
|
|
95
|
+
query = workspace_activity_query(since, binding.local_variable_get(:until), key_ids)
|
|
96
|
+
fetch_page(ApiPaths::KEYS_ACTIVITY, query, limit:, cursor:, api_key:)
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def list_all_workspace_activity(key_ids: nil, since: nil, until: nil, limit: nil, cursor: nil, api_key: nil)
|
|
100
|
+
query = workspace_activity_query(since, binding.local_variable_get(:until), key_ids)
|
|
101
|
+
collect_all(ApiPaths::KEYS_ACTIVITY, query, limit:, cursor:, api_key:)
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def iterate_workspace_activity(key_ids: nil, since: nil, until: nil, limit: nil, cursor: nil, api_key: nil, &)
|
|
105
|
+
query = workspace_activity_query(since, binding.local_variable_get(:until), key_ids)
|
|
106
|
+
iterate_pages(ApiPaths::KEYS_ACTIVITY, query, limit:, cursor:, api_key:, &)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def stats(key_ids: nil, since: nil, until: nil, grain: nil, offset_minutes: nil, api_key: nil)
|
|
110
|
+
query = log_window_query(since, binding.local_variable_get(:until))
|
|
111
|
+
.merge(query_params(key_ids: joined(key_ids), grain:, offset_minutes:))
|
|
112
|
+
request(ApiPaths::KEYS_STATS, query:, api_key:)
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
private
|
|
116
|
+
|
|
117
|
+
def workspace_request_query(since, until_value, failed_only, statuses, path, key_ids)
|
|
118
|
+
log_request_query(since, until_value, failed_only, statuses, path).merge(query_params(key_ids: joined(key_ids)))
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def workspace_activity_query(since, until_value, key_ids)
|
|
122
|
+
log_window_query(since, until_value).merge(query_params(key_ids: joined(key_ids)))
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
end
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Nextmail
|
|
4
|
+
module Resources
|
|
5
|
+
class Knowledge < Resource
|
|
6
|
+
def list(scope: nil, level: nil, kind: nil, status: nil, pinned: nil, q: nil, limit: nil, cursor: nil,
|
|
7
|
+
api_key: nil)
|
|
8
|
+
fetch_page(ApiPaths::KNOWLEDGE, list_query(scope, level, kind, status, pinned, q), limit:, cursor:, api_key:)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def list_all(scope: nil, level: nil, kind: nil, status: nil, pinned: nil, q: nil, limit: nil, cursor: nil,
|
|
12
|
+
api_key: nil)
|
|
13
|
+
collect_all(ApiPaths::KNOWLEDGE, list_query(scope, level, kind, status, pinned, q), limit:, cursor:, api_key:)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def iterate(scope: nil, level: nil, kind: nil, status: nil, pinned: nil, q: nil, limit: nil, cursor: nil,
|
|
17
|
+
api_key: nil, &)
|
|
18
|
+
iterate_pages(ApiPaths::KNOWLEDGE, list_query(scope, level, kind, status, pinned, q), limit:, cursor:,
|
|
19
|
+
api_key:, &)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def levels(api_key: nil)
|
|
23
|
+
fetch_list(ApiPaths::KNOWLEDGE_LEVELS, api_key:)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def usage(api_key: nil)
|
|
27
|
+
request(ApiPaths::KNOWLEDGE_USAGE, api_key:)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def search(body = nil, api_key: nil, **fields)
|
|
31
|
+
request(ApiPaths::KNOWLEDGE_SEARCH, method: :post, body: payload(body, fields), repeatable: true, api_key:)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def create_note(body = nil, api_key: nil, **fields)
|
|
35
|
+
request(ApiPaths::KNOWLEDGE_NOTES, method: :post, body: payload(body, fields), api_key:)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def add_link(body = nil, api_key: nil, **fields)
|
|
39
|
+
request(ApiPaths::KNOWLEDGE_LINKS, method: :post, body: payload(body, fields), api_key:)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def upload_file(data, filename: nil, content_type: nil, scope: nil, title: nil, timeout: nil, api_key: nil)
|
|
43
|
+
query = query_params(filename: upload_name(data, filename), scope:, title:)
|
|
44
|
+
request(ApiPaths::KNOWLEDGE_FILES, method: :post, query:, raw: data,
|
|
45
|
+
content_type: raw_content_type(data, content_type), timeout: upload_timeout(timeout), api_key:)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def get(id, api_key: nil)
|
|
49
|
+
request(fill(ApiPaths::KNOWLEDGE_ITEM, id:), api_key:)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def update(id, patch = nil, api_key: nil, **fields)
|
|
53
|
+
request(fill(ApiPaths::KNOWLEDGE_ITEM, id:), method: :patch, body: payload(patch, fields), repeatable: true,
|
|
54
|
+
api_key:)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def delete(id, api_key: nil)
|
|
58
|
+
request(fill(ApiPaths::KNOWLEDGE_ITEM, id:), method: :delete, api_key:)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def refresh(id, api_key: nil)
|
|
62
|
+
request(fill(ApiPaths::KNOWLEDGE_ITEM_REFRESH, id:), method: :post, repeatable: true, api_key:)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def stats(days: nil, api_key: nil)
|
|
66
|
+
request(ApiPaths::KNOWLEDGE_STATS, query: query_params(days:), api_key:)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def list_suggestions(kind: nil, status: nil, limit: nil, cursor: nil, api_key: nil)
|
|
70
|
+
fetch_page(ApiPaths::KNOWLEDGE_SUGGESTIONS, suggestion_query(kind, status), limit:, cursor:, api_key:)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def list_all_suggestions(kind: nil, status: nil, limit: nil, cursor: nil, api_key: nil)
|
|
74
|
+
collect_all(ApiPaths::KNOWLEDGE_SUGGESTIONS, suggestion_query(kind, status), limit:, cursor:, api_key:)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def iterate_suggestions(kind: nil, status: nil, limit: nil, cursor: nil, api_key: nil, &)
|
|
78
|
+
iterate_pages(ApiPaths::KNOWLEDGE_SUGGESTIONS, suggestion_query(kind, status), limit:, cursor:, api_key:, &)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def accept_suggestion(id, body = nil, api_key: nil, **fields)
|
|
82
|
+
request(fill(ApiPaths::KNOWLEDGE_SUGGESTION_ACCEPT, id:), method: :post, body: payload(body, fields), api_key:)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def dismiss_suggestion(id, api_key: nil)
|
|
86
|
+
request(fill(ApiPaths::KNOWLEDGE_SUGGESTION_DISMISS, id:), method: :post, api_key:)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def list_flags(item_id: nil, limit: nil, api_key: nil)
|
|
90
|
+
fetch_list(ApiPaths::KNOWLEDGE_FLAGS, query_params(item_id:, limit:), api_key:)
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def dismiss_flag(id, api_key: nil)
|
|
94
|
+
request(fill(ApiPaths::KNOWLEDGE_FLAG_DISMISS, id:), method: :post, repeatable: true, api_key:)
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def list_connectors(api_key: nil)
|
|
98
|
+
fetch_list(ApiPaths::KNOWLEDGE_CONNECTORS, api_key:)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def add_connector(body = nil, api_key: nil, **fields)
|
|
102
|
+
request(ApiPaths::KNOWLEDGE_CONNECTORS, method: :post, body: payload(body, fields), api_key:)
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def get_connector(id, api_key: nil)
|
|
106
|
+
request(fill(ApiPaths::KNOWLEDGE_CONNECTOR, id:), api_key:)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def update_connector(id, patch = nil, api_key: nil, **fields)
|
|
110
|
+
request(fill(ApiPaths::KNOWLEDGE_CONNECTOR, id:), method: :patch, body: payload(patch, fields), repeatable: true,
|
|
111
|
+
api_key:)
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
def delete_connector(id, api_key: nil)
|
|
115
|
+
request(fill(ApiPaths::KNOWLEDGE_CONNECTOR, id:), method: :delete, api_key:)
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def sync_connector(id, api_key: nil)
|
|
119
|
+
request(fill(ApiPaths::KNOWLEDGE_CONNECTOR_SYNC, id:), method: :post, repeatable: true, api_key:)
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
def draft_from_thread(body = nil, api_key: nil, **fields)
|
|
123
|
+
request(ApiPaths::KNOWLEDGE_DRAFTS, method: :post, body: payload(body, fields), api_key:)
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
private
|
|
127
|
+
|
|
128
|
+
def list_query(scope, level, kind, status, pinned, q)
|
|
129
|
+
query_params(scope:, level:, kind:, status:, pinned: flag(pinned), q:)
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
def suggestion_query(kind, status)
|
|
133
|
+
query_params(kind:, status:)
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Nextmail
|
|
4
|
+
module Resources
|
|
5
|
+
class Labels < Resource
|
|
6
|
+
def list(limit: nil, cursor: nil, api_key: nil)
|
|
7
|
+
fetch_page(ApiPaths::LABELS, limit:, cursor:, api_key:)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def list_all(limit: nil, cursor: nil, api_key: nil)
|
|
11
|
+
collect_all(ApiPaths::LABELS, limit:, cursor:, api_key:)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def iterate(limit: nil, cursor: nil, api_key: nil, &)
|
|
15
|
+
iterate_pages(ApiPaths::LABELS, limit:, cursor:, api_key:, &)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def list_colors(api_key: nil)
|
|
19
|
+
fetch_list(ApiPaths::LABEL_COLORS, api_key:)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def get(id, api_key: nil)
|
|
23
|
+
request(fill(ApiPaths::LABEL, id:), api_key:)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def create(body = nil, api_key: nil, **fields)
|
|
27
|
+
request(ApiPaths::LABELS, method: :post, body: payload(body, fields), api_key:)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def update(id, patch = nil, api_key: nil, **fields)
|
|
31
|
+
request(fill(ApiPaths::LABEL, id:), method: :patch, body: payload(patch, fields), repeatable: true, api_key:)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def test(id, body = nil, api_key: nil, **fields)
|
|
35
|
+
request(fill(ApiPaths::LABEL_TEST, id:), method: :post, body: payload(body, fields), api_key:)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def delete(id, api_key: nil)
|
|
39
|
+
request(fill(ApiPaths::LABEL, id:), method: :delete, api_key:)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Nextmail
|
|
4
|
+
module Resources
|
|
5
|
+
class Me < Resource
|
|
6
|
+
def get(api_key: nil)
|
|
7
|
+
request(ApiPaths::KEY_SELF, api_key:)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def ping(api_key: nil)
|
|
11
|
+
request(ApiPaths::PING, api_key:)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def rotate(api_key: nil)
|
|
15
|
+
request(ApiPaths::KEY_SELF_ROTATE, method: :post, api_key:)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def list_requests(failed_only: nil, statuses: nil, path: nil, since: nil, until: nil, limit: nil, cursor: nil,
|
|
19
|
+
api_key: nil)
|
|
20
|
+
query = log_request_query(since, binding.local_variable_get(:until), failed_only, statuses, path)
|
|
21
|
+
fetch_page(ApiPaths::KEY_SELF_REQUESTS, query, limit:, cursor:, api_key:)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def list_all_requests(failed_only: nil, statuses: nil, path: nil, since: nil, until: nil, limit: nil, cursor: nil,
|
|
25
|
+
api_key: nil)
|
|
26
|
+
query = log_request_query(since, binding.local_variable_get(:until), failed_only, statuses, path)
|
|
27
|
+
collect_all(ApiPaths::KEY_SELF_REQUESTS, query, limit:, cursor:, api_key:)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def iterate_requests(failed_only: nil, statuses: nil, path: nil, since: nil, until: nil, limit: nil, cursor: nil,
|
|
31
|
+
api_key: nil, &)
|
|
32
|
+
query = log_request_query(since, binding.local_variable_get(:until), failed_only, statuses, path)
|
|
33
|
+
iterate_pages(ApiPaths::KEY_SELF_REQUESTS, query, limit:, cursor:, api_key:, &)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def list_activity(since: nil, until: nil, limit: nil, cursor: nil, api_key: nil)
|
|
37
|
+
query = log_window_query(since, binding.local_variable_get(:until))
|
|
38
|
+
fetch_page(ApiPaths::KEY_SELF_ACTIVITY, query, limit:, cursor:, api_key:)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def list_all_activity(since: nil, until: nil, limit: nil, cursor: nil, api_key: nil)
|
|
42
|
+
query = log_window_query(since, binding.local_variable_get(:until))
|
|
43
|
+
collect_all(ApiPaths::KEY_SELF_ACTIVITY, query, limit:, cursor:, api_key:)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def iterate_activity(since: nil, until: nil, limit: nil, cursor: nil, api_key: nil, &)
|
|
47
|
+
query = log_window_query(since, binding.local_variable_get(:until))
|
|
48
|
+
iterate_pages(ApiPaths::KEY_SELF_ACTIVITY, query, limit:, cursor:, api_key:, &)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def stats(since: nil, until: nil, grain: nil, offset_minutes: nil, api_key: nil)
|
|
52
|
+
query = log_window_query(since, binding.local_variable_get(:until)).merge(query_params(grain:, offset_minutes:))
|
|
53
|
+
request(ApiPaths::KEY_SELF_STATS, query:, api_key:)
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|