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,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OpenEmail
|
|
4
|
+
module Resources
|
|
5
|
+
class Exports < Resource
|
|
6
|
+
def preview(api_key: nil)
|
|
7
|
+
request(ApiPaths::MAILBOX_EXPORTS_PREVIEW, api_key:)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def list(limit: nil, offset: nil, api_key: nil)
|
|
11
|
+
request(ApiPaths::MAILBOX_EXPORTS, query: query_params(limit:, offset:), api_key:)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def get(id, api_key: nil)
|
|
15
|
+
request(fill(ApiPaths::MAILBOX_EXPORT, id:), api_key:)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def start(api_key: nil)
|
|
19
|
+
request(ApiPaths::MAILBOX_EXPORTS, method: :post, api_key:)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def download(id, api_key: nil)
|
|
23
|
+
request(fill(ApiPaths::MAILBOX_EXPORT_CONTENT, id:), binary: true, api_key:)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OpenEmail
|
|
4
|
+
module Resources
|
|
5
|
+
class Files < Resource
|
|
6
|
+
def list(q: nil, kind: nil, direction: nil, address: nil, since: nil, until: nil, sort: nil, limit: nil,
|
|
7
|
+
cursor: nil, api_key: nil)
|
|
8
|
+
query = list_query(q, kind, direction, address, since, binding.local_variable_get(:until), sort)
|
|
9
|
+
fetch_page(ApiPaths::FILES, query, limit:, cursor:, api_key:)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def list_all(q: nil, kind: nil, direction: nil, address: nil, since: nil, until: nil, sort: nil, limit: nil,
|
|
13
|
+
cursor: nil, api_key: nil)
|
|
14
|
+
query = list_query(q, kind, direction, address, since, binding.local_variable_get(:until), sort)
|
|
15
|
+
collect_all(ApiPaths::FILES, query, limit:, cursor:, api_key:)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def iterate(q: nil, kind: nil, direction: nil, address: nil, since: nil, until: nil, sort: nil, limit: nil,
|
|
19
|
+
cursor: nil, api_key: nil, &)
|
|
20
|
+
query = list_query(q, kind, direction, address, since, binding.local_variable_get(:until), sort)
|
|
21
|
+
iterate_pages(ApiPaths::FILES, query, limit:, cursor:, api_key:, &)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def get(id, api_key: nil)
|
|
25
|
+
request(fill(ApiPaths::FILE, id:), api_key:)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def stats(api_key: nil)
|
|
29
|
+
request(ApiPaths::FILES_STATS, api_key:)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def download(id, api_key: nil)
|
|
33
|
+
request(fill(ApiPaths::FILE_CONTENT, id:), binary: true, api_key:)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def list_links(id, limit: nil, cursor: nil, api_key: nil)
|
|
37
|
+
fetch_page(fill(ApiPaths::FILE_LINKS, id:), limit:, cursor:, api_key:)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def list_all_links(id, limit: nil, cursor: nil, api_key: nil)
|
|
41
|
+
collect_all(fill(ApiPaths::FILE_LINKS, id:), limit:, cursor:, api_key:)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def iterate_links(id, limit: nil, cursor: nil, api_key: nil, &)
|
|
45
|
+
iterate_pages(fill(ApiPaths::FILE_LINKS, id:), limit:, cursor:, api_key:, &)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def create_link(id, domain: nil, api_key: nil)
|
|
49
|
+
body = (domain.nil? || domain == "") ? {} : {"domain" => domain}
|
|
50
|
+
request(fill(ApiPaths::FILE_LINKS, id:), method: :post, body:, api_key:)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def revoke_link(id, link_id, api_key: nil)
|
|
54
|
+
request(fill(ApiPaths::FILE_LINK, id:, linkId: link_id), method: :delete, repeatable: true, api_key:)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def revoke_all_links(id, api_key: nil)
|
|
58
|
+
request(fill(ApiPaths::FILE_LINKS, id:), method: :delete, repeatable: true, api_key:)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def upload(data, filename: nil, content_type: nil, timeout: nil, api_key: nil)
|
|
62
|
+
request(ApiPaths::FILES, method: :post, query: query_params(filename: upload_name(data, filename)), raw: data,
|
|
63
|
+
content_type: raw_content_type(data, content_type), timeout: upload_timeout(timeout), api_key:)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def delete(id, api_key: nil)
|
|
67
|
+
request(fill(ApiPaths::FILE, id:), method: :delete, api_key:)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def delete_many(ids, api_key: nil)
|
|
71
|
+
request(ApiPaths::FILES_BATCH_DELETE, method: :post, body: {"ids" => ids}, api_key:)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
private
|
|
75
|
+
|
|
76
|
+
def list_query(q, kind, direction, address, since, until_value, sort)
|
|
77
|
+
query_params(q:, kind:, direction:, address:, since: instant(since), until: instant(until_value), sort:)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def upload_name(data, filename)
|
|
81
|
+
name = (filename.nil? ? RawBody.file_name(data) : filename).to_s.strip
|
|
82
|
+
raise ArgumentError, Defaults::MESSAGES[:FILENAME_REQUIRED] if name.empty?
|
|
83
|
+
|
|
84
|
+
name
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def upload_timeout(timeout)
|
|
88
|
+
return timeout unless timeout.nil?
|
|
89
|
+
|
|
90
|
+
base = @transport.timeout
|
|
91
|
+
base.to_f.positive? ? [base, Defaults::UPLOAD_TIMEOUT].max : base
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OpenEmail
|
|
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, grain: nil, offset_minutes: nil, api_key: nil)
|
|
67
|
+
request(fill(ApiPaths::FORM_ANALYTICS, id:), query: query_params(days:, minutes:, grain:, offset_minutes:),
|
|
68
|
+
api_key:)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def list_submissions(id, q: nil, status: nil, limit: nil, cursor: nil, api_key: nil)
|
|
72
|
+
fetch_page(fill(ApiPaths::FORM_SUBMISSIONS, id:), query_params(q:, status:), limit:, cursor:, api_key:)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def list_all_submissions(id, q: nil, status: nil, limit: nil, cursor: nil, api_key: nil)
|
|
76
|
+
collect_all(fill(ApiPaths::FORM_SUBMISSIONS, id:), query_params(q:, status:), limit:, cursor:, api_key:)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def iterate_submissions(id, q: nil, status: nil, limit: nil, cursor: nil, api_key: nil, &)
|
|
80
|
+
iterate_pages(fill(ApiPaths::FORM_SUBMISSIONS, id:), query_params(q:, status:), limit:, cursor:, api_key:, &)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def get_submission(id, submission_id, api_key: nil)
|
|
84
|
+
request(fill(ApiPaths::FORM_SUBMISSION, id:, submissionId: submission_id), api_key:)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def delete_submission(id, submission_id, api_key: nil)
|
|
88
|
+
request(fill(ApiPaths::FORM_SUBMISSION, id:, submissionId: submission_id), method: :delete, api_key:)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def delete_submissions(id, submission_ids, api_key: nil)
|
|
92
|
+
request(fill(ApiPaths::FORM_SUBMISSIONS_BATCH_REMOVE, id:), method: :post, body: {"ids" => submission_ids},
|
|
93
|
+
api_key:)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def approve_submission(id, submission_id, api_key: nil)
|
|
97
|
+
request(fill(ApiPaths::FORM_SUBMISSION_APPROVE, id:, submissionId: submission_id), method: :post,
|
|
98
|
+
repeatable: true, api_key:)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def resend_confirmation(id, submission_id, api_key: nil)
|
|
102
|
+
request(fill(ApiPaths::FORM_SUBMISSION_RESEND, id:, submissionId: submission_id), method: :post, api_key:)
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def subscribe(form_id, values = nil, api_key: nil, **fields)
|
|
106
|
+
request(fill(ApiPaths::SUBSCRIBE_FORM, formId: form_id), method: :post, body: payload(values, fields),
|
|
107
|
+
anonymous: true, api_key:)
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OpenEmail
|
|
4
|
+
module Resources
|
|
5
|
+
class Imports < Resource
|
|
6
|
+
def list(address_id: nil, limit: nil, cursor: nil, api_key: nil)
|
|
7
|
+
fetch_page(ApiPaths::IMPORTS, {"addressId" => address_id}, limit:, cursor:, api_key:)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def list_all(address_id: nil, limit: nil, cursor: nil, api_key: nil)
|
|
11
|
+
collect_all(ApiPaths::IMPORTS, {"addressId" => address_id}, limit:, cursor:, api_key:)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def iterate(address_id: nil, limit: nil, cursor: nil, api_key: nil, &)
|
|
15
|
+
iterate_pages(ApiPaths::IMPORTS, {"addressId" => address_id}, 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 import_files(input = nil, api_key: nil, **fields, &on_progress)
|
|
52
|
+
spec = payload(input, fields)
|
|
53
|
+
files = Array(spec["files"]).map { |file| file.to_h.transform_keys(&:to_s) }
|
|
54
|
+
created = create(import_body(spec, files), api_key:)
|
|
55
|
+
return created if files.empty?
|
|
56
|
+
|
|
57
|
+
upload_files(created, files, on_progress || spec["onProgress"], api_key)
|
|
58
|
+
start(created[:id], api_key:)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
private
|
|
62
|
+
|
|
63
|
+
def import_body(spec, files)
|
|
64
|
+
sizes = files.map { |file| {"name" => file["name"], "bytes" => RawBody.size(file["data"])} }
|
|
65
|
+
spec.slice("addressId", "options").merge("files" => sizes)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def upload_files(created, files, progress, api_key)
|
|
69
|
+
uploaded = 0
|
|
70
|
+
|
|
71
|
+
files.each_with_index do |file, index|
|
|
72
|
+
size = RawBody.size(file["data"])
|
|
73
|
+
chunks = created.dig(:files, index, :chunks) || 1
|
|
74
|
+
|
|
75
|
+
chunks.times do |chunk|
|
|
76
|
+
offset = chunk * created[:chunkBytes]
|
|
77
|
+
length = [size, offset + created[:chunkBytes]].min - offset
|
|
78
|
+
upload_chunk(created[:id], index, chunk, RawBody.slice(file["data"], offset, length), api_key:)
|
|
79
|
+
uploaded += length
|
|
80
|
+
progress&.call(uploaded, created[:totalBytes])
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OpenEmail
|
|
4
|
+
module Resources
|
|
5
|
+
class Keys < Resource
|
|
6
|
+
def list(limit: nil, cursor: nil, api_key: nil)
|
|
7
|
+
fetch_page(ApiPaths::KEYS, limit:, cursor:, api_key:)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def list_all(limit: nil, cursor: nil, api_key: nil)
|
|
11
|
+
collect_all(ApiPaths::KEYS, limit:, cursor:, api_key:)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def iterate(limit: nil, cursor: nil, api_key: nil, &)
|
|
15
|
+
iterate_pages(ApiPaths::KEYS, 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, since: nil, until: nil, limit: nil, cursor: nil, api_key: nil)
|
|
44
|
+
query = request_query(since, binding.local_variable_get(:until), failed_only)
|
|
45
|
+
fetch_page(fill(ApiPaths::KEY_REQUESTS, id:), query, limit:, cursor:, api_key:)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def list_all_requests(id, failed_only: nil, since: nil, until: nil, limit: nil, cursor: nil, api_key: nil)
|
|
49
|
+
query = request_query(since, binding.local_variable_get(:until), failed_only)
|
|
50
|
+
collect_all(fill(ApiPaths::KEY_REQUESTS, id:), query, limit:, cursor:, api_key:)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def iterate_requests(id, failed_only: nil, since: nil, until: nil, limit: nil, cursor: nil, api_key: nil, &)
|
|
54
|
+
query = request_query(since, binding.local_variable_get(:until), failed_only)
|
|
55
|
+
iterate_pages(fill(ApiPaths::KEY_REQUESTS, id:), query, limit:, cursor:, api_key:, &)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def list_activity(id, since: nil, until: nil, limit: nil, cursor: nil, api_key: nil)
|
|
59
|
+
query = window_query(since, binding.local_variable_get(:until))
|
|
60
|
+
fetch_page(fill(ApiPaths::KEY_ACTIVITY, id:), query, limit:, cursor:, api_key:)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def list_all_activity(id, since: nil, until: nil, limit: nil, cursor: nil, api_key: nil)
|
|
64
|
+
query = window_query(since, binding.local_variable_get(:until))
|
|
65
|
+
collect_all(fill(ApiPaths::KEY_ACTIVITY, id:), query, limit:, cursor:, api_key:)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def iterate_activity(id, since: nil, until: nil, limit: nil, cursor: nil, api_key: nil, &)
|
|
69
|
+
query = window_query(since, binding.local_variable_get(:until))
|
|
70
|
+
iterate_pages(fill(ApiPaths::KEY_ACTIVITY, id:), query, limit:, cursor:, api_key:, &)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def list_workspace_requests(key_ids: nil, failed_only: nil, since: nil, until: nil, limit: nil, cursor: nil,
|
|
74
|
+
api_key: nil)
|
|
75
|
+
query = workspace_request_query(since, binding.local_variable_get(:until), failed_only, key_ids)
|
|
76
|
+
fetch_page(ApiPaths::KEYS_REQUESTS, query, limit:, cursor:, api_key:)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def list_all_workspace_requests(key_ids: nil, failed_only: nil, since: nil, until: nil, limit: nil, cursor: nil,
|
|
80
|
+
api_key: nil)
|
|
81
|
+
query = workspace_request_query(since, binding.local_variable_get(:until), failed_only, key_ids)
|
|
82
|
+
collect_all(ApiPaths::KEYS_REQUESTS, query, limit:, cursor:, api_key:)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def iterate_workspace_requests(key_ids: nil, failed_only: nil, since: nil, until: nil, limit: nil, cursor: nil,
|
|
86
|
+
api_key: nil, &)
|
|
87
|
+
query = workspace_request_query(since, binding.local_variable_get(:until), failed_only, key_ids)
|
|
88
|
+
iterate_pages(ApiPaths::KEYS_REQUESTS, query, limit:, cursor:, api_key:, &)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def list_workspace_activity(key_ids: nil, since: nil, until: nil, limit: nil, cursor: nil, api_key: nil)
|
|
92
|
+
query = window_query(since, binding.local_variable_get(:until)).merge(query_params(key_ids: joined(key_ids)))
|
|
93
|
+
fetch_page(ApiPaths::KEYS_ACTIVITY, query, limit:, cursor:, api_key:)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def list_all_workspace_activity(key_ids: nil, since: nil, until: nil, limit: nil, cursor: nil, api_key: nil)
|
|
97
|
+
query = window_query(since, binding.local_variable_get(:until)).merge(query_params(key_ids: joined(key_ids)))
|
|
98
|
+
collect_all(ApiPaths::KEYS_ACTIVITY, query, limit:, cursor:, api_key:)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def iterate_workspace_activity(key_ids: nil, since: nil, until: nil, limit: nil, cursor: nil, api_key: nil, &)
|
|
102
|
+
query = window_query(since, binding.local_variable_get(:until)).merge(query_params(key_ids: joined(key_ids)))
|
|
103
|
+
iterate_pages(ApiPaths::KEYS_ACTIVITY, query, limit:, cursor:, api_key:, &)
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def stats(key_ids: nil, since: nil, until: nil, grain: nil, offset_minutes: nil, api_key: nil)
|
|
107
|
+
query = window_query(since, binding.local_variable_get(:until))
|
|
108
|
+
.merge(query_params(key_ids: joined(key_ids), grain:, offset_minutes:))
|
|
109
|
+
request(ApiPaths::KEYS_STATS, query:, api_key:)
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
private
|
|
113
|
+
|
|
114
|
+
def window_query(since, until_value)
|
|
115
|
+
query_params(since: instant(since), until: instant(until_value))
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def request_query(since, until_value, failed_only)
|
|
119
|
+
window_query(since, until_value).merge(query_params(failed_only: flag(failed_only)))
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
def workspace_request_query(since, until_value, failed_only, key_ids)
|
|
123
|
+
request_query(since, until_value, failed_only).merge(query_params(key_ids: joined(key_ids)))
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OpenEmail
|
|
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 delete(id, api_key: nil)
|
|
35
|
+
request(fill(ApiPaths::LABEL, id:), method: :delete, api_key:)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OpenEmail
|
|
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
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OpenEmail
|
|
4
|
+
module Resources
|
|
5
|
+
class Members < Resource
|
|
6
|
+
def list(limit: nil, cursor: nil, api_key: nil)
|
|
7
|
+
fetch_page(ApiPaths::MEMBERS, limit:, cursor:, api_key:)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def list_all(limit: nil, cursor: nil, api_key: nil)
|
|
11
|
+
collect_all(ApiPaths::MEMBERS, limit:, cursor:, api_key:)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def iterate(limit: nil, cursor: nil, api_key: nil, &)
|
|
15
|
+
iterate_pages(ApiPaths::MEMBERS, limit:, cursor:, api_key:, &)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def get(user_id, api_key: nil)
|
|
19
|
+
request(fill(ApiPaths::MEMBER, userId: user_id), api_key:)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def add(body = nil, api_key: nil, **fields)
|
|
23
|
+
request(ApiPaths::MEMBERS, method: :post, body: payload(body, fields), api_key:)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def update(user_id, patch = nil, api_key: nil, **fields)
|
|
27
|
+
request(fill(ApiPaths::MEMBER, userId: user_id), method: :patch, body: payload(patch, fields),
|
|
28
|
+
repeatable: true, api_key:)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def remove(user_id, api_key: nil)
|
|
32
|
+
request(fill(ApiPaths::MEMBER, userId: user_id), method: :delete, api_key:)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def grant_address(user_id, body = nil, api_key: nil, **fields)
|
|
36
|
+
request(fill(ApiPaths::MEMBER_ADDRESSES, userId: user_id), method: :post, body: payload(body, fields),
|
|
37
|
+
repeatable: true, api_key:)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def revoke_address(user_id, address_id, api_key: nil)
|
|
41
|
+
request(fill(ApiPaths::MEMBER_ADDRESS, userId: user_id, addressId: address_id), method: :delete, api_key:)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def grant_domain(user_id, body = nil, api_key: nil, **fields)
|
|
45
|
+
request(fill(ApiPaths::MEMBER_DOMAINS, userId: user_id), method: :post, body: payload(body, fields),
|
|
46
|
+
repeatable: true, api_key:)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def revoke_domain(user_id, domain_id, api_key: nil)
|
|
50
|
+
request(fill(ApiPaths::MEMBER_DOMAIN, userId: user_id, domainId: domain_id), method: :delete, api_key:)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def list_invitations(limit: nil, cursor: nil, api_key: nil)
|
|
54
|
+
fetch_page(ApiPaths::MEMBER_INVITATIONS, limit:, cursor:, api_key:)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def list_all_invitations(limit: nil, cursor: nil, api_key: nil)
|
|
58
|
+
collect_all(ApiPaths::MEMBER_INVITATIONS, limit:, cursor:, api_key:)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def iterate_invitations(limit: nil, cursor: nil, api_key: nil, &)
|
|
62
|
+
iterate_pages(ApiPaths::MEMBER_INVITATIONS, limit:, cursor:, api_key:, &)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def revoke_invitation(invitation_id, api_key: nil)
|
|
66
|
+
request(fill(ApiPaths::MEMBER_INVITATION, invitationId: invitation_id), method: :delete, api_key:)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def resend_invitation(invitation_id, api_key: nil)
|
|
70
|
+
request(fill(ApiPaths::MEMBER_INVITATION_RESEND, invitationId: invitation_id), method: :post, api_key:)
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OpenEmail
|
|
4
|
+
module Resources
|
|
5
|
+
class ProviderImports < Resource
|
|
6
|
+
NOT_GIVEN = Object.new.freeze
|
|
7
|
+
private_constant :NOT_GIVEN
|
|
8
|
+
|
|
9
|
+
def inspect(provider_key = NOT_GIVEN, api_key: nil)
|
|
10
|
+
return super() if provider_key.equal?(NOT_GIVEN)
|
|
11
|
+
|
|
12
|
+
request(ApiPaths::PROVIDER_IMPORTS_INSPECT, method: :post, body: {"apiKey" => provider_key}, api_key:)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def create(body = nil, api_key: nil, **fields)
|
|
16
|
+
request(ApiPaths::PROVIDER_IMPORTS, method: :post, body: payload(body, fields), api_key:)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def list(limit: nil, cursor: nil, api_key: nil)
|
|
20
|
+
fetch_page(ApiPaths::PROVIDER_IMPORTS, limit:, cursor:, api_key:)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def list_all(limit: nil, cursor: nil, api_key: nil)
|
|
24
|
+
collect_all(ApiPaths::PROVIDER_IMPORTS, limit:, cursor:, api_key:)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def iterate(limit: nil, cursor: nil, api_key: nil, &)
|
|
28
|
+
iterate_pages(ApiPaths::PROVIDER_IMPORTS, limit:, cursor:, api_key:, &)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def get(id, api_key: nil)
|
|
32
|
+
request(fill(ApiPaths::PROVIDER_IMPORT, id:), api_key:)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def cancel(id, api_key: nil)
|
|
36
|
+
request(fill(ApiPaths::PROVIDER_IMPORT_CANCEL, id:), method: :post, api_key:)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module OpenEmail
|
|
4
|
+
module Resources
|
|
5
|
+
class Roles < Resource
|
|
6
|
+
def list(limit: nil, cursor: nil, api_key: nil)
|
|
7
|
+
fetch_page(ApiPaths::ROLES, limit:, cursor:, api_key:)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def list_all(limit: nil, cursor: nil, api_key: nil)
|
|
11
|
+
collect_all(ApiPaths::ROLES, limit:, cursor:, api_key:)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def iterate(limit: nil, cursor: nil, api_key: nil, &)
|
|
15
|
+
iterate_pages(ApiPaths::ROLES, limit:, cursor:, api_key:, &)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def get(id, api_key: nil)
|
|
19
|
+
request(fill(ApiPaths::ROLE, id:), api_key:)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def create(body = nil, api_key: nil, **fields)
|
|
23
|
+
request(ApiPaths::ROLES, 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::ROLE, id:), method: :patch, body: payload(patch, fields), repeatable: true, api_key:)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def delete(id, reassign_to: nil, api_key: nil)
|
|
31
|
+
request(fill(ApiPaths::ROLE, id:), method: :delete, query: query_params(reassign_to:), api_key:)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def list_permissions(api_key: nil)
|
|
35
|
+
fetch_list(ApiPaths::ROLE_PERMISSIONS, api_key:)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|