openemail 0.0.1 → 0.0.3

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.
@@ -40,7 +40,72 @@ module OpenEmail
40
40
  end
41
41
 
42
42
  def respond_to_event(id, body = nil, api_key: nil, **fields)
43
- request(fill(ApiPaths::CALENDAR_EVENT_RESPOND, id:), method: :post, body: payload(body, fields), api_key:)
43
+ request(fill(ApiPaths::CALENDAR_EVENT_RESPOND, id:), method: :post, body: answer_wire(payload(body, fields)), api_key:)
44
+ end
45
+
46
+ def decline_proposal(id, body = nil, api_key: nil, **fields)
47
+ request(fill(ApiPaths::CALENDAR_EVENT_DECLINE_PROPOSAL, id:), method: :post, body: payload(body, fields), api_key:)
48
+ end
49
+
50
+ def list_feeds(api_key: nil)
51
+ fetch_list(ApiPaths::CALENDAR_FEEDS, api_key:)
52
+ end
53
+
54
+ def create_feed(body = nil, api_key: nil, **fields)
55
+ request(ApiPaths::CALENDAR_FEEDS, method: :post, body: payload(body, fields), api_key:)
56
+ end
57
+
58
+ def reset_feed(id, api_key: nil)
59
+ request(fill(ApiPaths::CALENDAR_FEED_RESET, id:), method: :post, api_key:)
60
+ end
61
+
62
+ def delete_feed(id, api_key: nil)
63
+ request(fill(ApiPaths::CALENDAR_FEED, id:), method: :delete, api_key:)
64
+ end
65
+
66
+ def list_subscriptions(api_key: nil)
67
+ fetch_list(ApiPaths::CALENDAR_SUBSCRIPTIONS, api_key:)
68
+ end
69
+
70
+ def create_subscription(body = nil, api_key: nil, **fields)
71
+ request(ApiPaths::CALENDAR_SUBSCRIPTIONS, method: :post, body: payload(body, fields), api_key:)
72
+ end
73
+
74
+ def update_subscription(id, patch = nil, api_key: nil, **fields)
75
+ request(fill(ApiPaths::CALENDAR_SUBSCRIPTION, id:), method: :patch, body: payload(patch, fields), api_key:)
76
+ end
77
+
78
+ def refresh_subscription(id, api_key: nil)
79
+ request(fill(ApiPaths::CALENDAR_SUBSCRIPTION_REFRESH, id:), method: :post, api_key:)
80
+ end
81
+
82
+ def delete_subscription(id, api_key: nil)
83
+ request(fill(ApiPaths::CALENDAR_SUBSCRIPTION, id:), method: :delete, api_key:)
84
+ end
85
+
86
+ def import_ics(data, filename: nil, api_key: nil)
87
+ request(ApiPaths::CALENDAR_IMPORTS, method: :post, query: query_params(filename: optional_upload_name(data, filename)),
88
+ raw: data, content_type: Protocol::CONTENT_TYPES[:CALENDAR], api_key:)
89
+ end
90
+
91
+ def list_imports(limit: nil, cursor: nil, api_key: nil)
92
+ fetch_page(ApiPaths::CALENDAR_IMPORTS, limit:, cursor:, api_key:)
93
+ end
94
+
95
+ def list_all_imports(limit: nil, cursor: nil, api_key: nil)
96
+ collect_all(ApiPaths::CALENDAR_IMPORTS, limit:, cursor:, api_key:)
97
+ end
98
+
99
+ def iterate_imports(limit: nil, cursor: nil, api_key: nil, &)
100
+ iterate_pages(ApiPaths::CALENDAR_IMPORTS, limit:, cursor:, api_key:, &)
101
+ end
102
+
103
+ def get_import(id, api_key: nil)
104
+ request(fill(ApiPaths::CALENDAR_IMPORT, id:), api_key:)
105
+ end
106
+
107
+ def undo_import(id, api_key: nil)
108
+ request(fill(ApiPaths::CALENDAR_IMPORT_UNDO, id:), method: :post, api_key:)
44
109
  end
45
110
 
46
111
  private
@@ -54,6 +119,12 @@ module OpenEmail
54
119
  wire["end"] = instant(wire["end"]) if wire.key?("end")
55
120
  wire
56
121
  end
122
+
123
+ def answer_wire(wire)
124
+ wire["proposedStart"] = instant(wire["proposedStart"]) if wire.key?("proposedStart")
125
+ wire["proposedEnd"] = instant(wire["proposedEnd"]) if wire.key?("proposedEnd")
126
+ wire
127
+ end
57
128
  end
58
129
  end
59
130
  end
@@ -96,16 +96,86 @@ module OpenEmail
96
96
  iterate_pages(fill(ApiPaths::CONTACT_THREADS, email:), query_params(q:, sort:), limit:, cursor:, api_key:, &)
97
97
  end
98
98
 
99
+ def list_events(email, name: nil, limit: nil, cursor: nil, api_key: nil)
100
+ fetch_page(fill(ApiPaths::CONTACT_EVENTS, email:), query_params(name:), limit:, cursor:, api_key:)
101
+ end
102
+
103
+ def list_all_events(email, name: nil, limit: nil, cursor: nil, api_key: nil)
104
+ collect_all(fill(ApiPaths::CONTACT_EVENTS, email:), query_params(name:), limit:, cursor:, api_key:)
105
+ end
106
+
107
+ def iterate_events(email, name: nil, limit: nil, cursor: nil, api_key: nil, &)
108
+ iterate_pages(fill(ApiPaths::CONTACT_EVENTS, email:), query_params(name:), limit:, cursor:, api_key:, &)
109
+ end
110
+
99
111
  def activity(email, minutes: nil, grain: nil, offset_minutes: nil, api_key: nil)
100
112
  request(fill(ApiPaths::CONTACT_ACTIVITY, email:), query: query_params(minutes:, grain:, offset_minutes:),
101
113
  api_key:)
102
114
  end
103
115
 
116
+ def list_cards(email: nil, without_email: nil, limit: nil, cursor: nil, api_key: nil)
117
+ fetch_page(ApiPaths::CONTACT_CARDS, card_query(email, without_email), limit:, cursor:, api_key:)
118
+ end
119
+
120
+ def list_all_cards(email: nil, without_email: nil, limit: nil, cursor: nil, api_key: nil)
121
+ collect_all(ApiPaths::CONTACT_CARDS, card_query(email, without_email), limit:, cursor:, api_key:)
122
+ end
123
+
124
+ def iterate_cards(email: nil, without_email: nil, limit: nil, cursor: nil, api_key: nil, &)
125
+ iterate_pages(ApiPaths::CONTACT_CARDS, card_query(email, without_email), limit:, cursor:, api_key:, &)
126
+ end
127
+
128
+ def get_card(id, api_key: nil)
129
+ request(fill(ApiPaths::CONTACT_CARD, id:), api_key:)
130
+ end
131
+
132
+ def create_card(body = nil, api_key: nil, **fields)
133
+ request(ApiPaths::CONTACT_CARDS, method: :post, body: payload(body, fields), api_key:)
134
+ end
135
+
136
+ def update_card(id, patch = nil, api_key: nil, **fields)
137
+ request(fill(ApiPaths::CONTACT_CARD, id:), method: :patch, body: payload(patch, fields), repeatable: true,
138
+ api_key:)
139
+ end
140
+
141
+ def delete_card(id, api_key: nil)
142
+ request(fill(ApiPaths::CONTACT_CARD, id:), method: :delete, api_key:)
143
+ end
144
+
145
+ def import_vcf(data, filename: nil, api_key: nil)
146
+ request(ApiPaths::CONTACT_IMPORTS, method: :post, query: query_params(filename: optional_upload_name(data, filename)),
147
+ raw: data, content_type: Protocol::CONTENT_TYPES[:VCARD], api_key:)
148
+ end
149
+
150
+ def list_imports(limit: nil, cursor: nil, api_key: nil)
151
+ fetch_page(ApiPaths::CONTACT_IMPORTS, limit:, cursor:, api_key:)
152
+ end
153
+
154
+ def list_all_imports(limit: nil, cursor: nil, api_key: nil)
155
+ collect_all(ApiPaths::CONTACT_IMPORTS, limit:, cursor:, api_key:)
156
+ end
157
+
158
+ def iterate_imports(limit: nil, cursor: nil, api_key: nil, &)
159
+ iterate_pages(ApiPaths::CONTACT_IMPORTS, limit:, cursor:, api_key:, &)
160
+ end
161
+
162
+ def get_import(id, api_key: nil)
163
+ request(fill(ApiPaths::CONTACT_IMPORT, id:), api_key:)
164
+ end
165
+
166
+ def undo_import(id, api_key: nil)
167
+ request(fill(ApiPaths::CONTACT_IMPORT_UNDO, id:), method: :post, api_key:)
168
+ end
169
+
104
170
  private
105
171
 
106
172
  def people_query(q, email, sort, blocked)
107
173
  query_params(q:, email:, sort:, blocked: flag(blocked))
108
174
  end
175
+
176
+ def card_query(email, without_email)
177
+ query_params(email:, without_email: flag(without_email))
178
+ end
109
179
  end
110
180
  end
111
181
  end
@@ -137,6 +137,39 @@ module OpenEmail
137
137
  request(fill(ApiPaths::DOMAIN_ADDRESS_LOGIN, id:, addressId: address_id), method: :delete, api_key:)
138
138
  end
139
139
 
140
+ def get_mail_app_settings(id, address_id, api_key: nil)
141
+ request(fill(ApiPaths::DOMAIN_ADDRESS_MAIL_APPS, id:, addressId: address_id), api_key:)
142
+ end
143
+
144
+ def update_mail_app_settings(id, address_id, patch = nil, api_key: nil, **fields)
145
+ request(fill(ApiPaths::DOMAIN_ADDRESS_MAIL_APPS, id:, addressId: address_id), method: :patch,
146
+ body: payload(patch, fields), repeatable: true, api_key:)
147
+ end
148
+
149
+ def list_app_passwords(id, address_id, api_key: nil)
150
+ request(fill(ApiPaths::DOMAIN_ADDRESS_APP_PASSWORDS, id:, addressId: address_id), api_key:)
151
+ end
152
+
153
+ def create_app_password(id, address_id, body = nil, api_key: nil, **fields)
154
+ request(fill(ApiPaths::DOMAIN_ADDRESS_APP_PASSWORDS, id:, addressId: address_id), method: :post,
155
+ body: payload(body, fields), api_key:)
156
+ end
157
+
158
+ def update_app_password(id, address_id, password_id, patch = nil, api_key: nil, **fields)
159
+ request(fill(ApiPaths::DOMAIN_ADDRESS_APP_PASSWORD, id:, addressId: address_id, passwordId: password_id),
160
+ method: :patch, body: payload(patch, fields), repeatable: true, api_key:)
161
+ end
162
+
163
+ def delete_app_password(id, address_id, password_id, api_key: nil)
164
+ request(fill(ApiPaths::DOMAIN_ADDRESS_APP_PASSWORD, id:, addressId: address_id, passwordId: password_id),
165
+ method: :delete, api_key:)
166
+ end
167
+
168
+ def send_mail_app_setup(id, address_id, body = nil, api_key: nil, **fields)
169
+ request(fill(ApiPaths::DOMAIN_ADDRESS_MAIL_APP_SETUP, id:, addressId: address_id), method: :post,
170
+ body: payload(body, fields), api_key:)
171
+ end
172
+
140
173
  def get_dns(id, refresh: nil, api_key: nil)
141
174
  request(fill(ApiPaths::DOMAIN_DNS, id:), query: query_params(refresh:), api_key:)
142
175
  end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OpenEmail
4
+ module Resources
5
+ class Events < Resource
6
+ def send(body = nil, idempotency_key: nil, api_key: nil, **fields)
7
+ request(ApiPaths::EVENTS, method: :post, body: payload(body, fields), idempotent: true, idempotency_key:,
8
+ repeatable: true, api_key:)
9
+ end
10
+
11
+ def send_batch(events, idempotency_key: nil, api_key: nil)
12
+ wire = events.map { |event| payload(event, {}) }
13
+ request(ApiPaths::EVENTS_BATCH, method: :post, body: {"events" => wire}, idempotent: true, idempotency_key:,
14
+ repeatable: true, api_key:)
15
+ end
16
+
17
+ def list_names(api_key: nil)
18
+ fetch_list(ApiPaths::EVENT_NAMES, api_key:)
19
+ end
20
+ end
21
+ end
22
+ end
@@ -76,20 +76,6 @@ module OpenEmail
76
76
  def list_query(q, kind, direction, address, since, until_value, sort)
77
77
  query_params(q:, kind:, direction:, address:, since: instant(since), until: instant(until_value), sort:)
78
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
79
  end
94
80
  end
95
81
  end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OpenEmail
4
+ module Resources
5
+ class FollowUps < Resource
6
+ def list(status: nil, thread_id: nil, limit: nil, api_key: nil)
7
+ fetch_list(ApiPaths::FOLLOW_UPS, query_params(status:, thread_id:, limit:), api_key:)
8
+ end
9
+
10
+ def set(body = nil, api_key: nil, **fields)
11
+ wire = payload(body, fields).slice("threadId", "remindAt")
12
+ wire["remindAt"] = instant(wire["remindAt"]) if wire.key?("remindAt")
13
+ request(ApiPaths::FOLLOW_UPS, method: :post, body: wire, repeatable: true, api_key:)
14
+ end
15
+
16
+ def cancel(id, api_key: nil)
17
+ request(fill(ApiPaths::FOLLOW_UP, id:), method: :delete, repeatable: true, api_key:)
18
+ end
19
+ end
20
+ end
21
+ end
@@ -48,6 +48,22 @@ module OpenEmail
48
48
  request(fill(ApiPaths::IMPORT_UPLOAD, id:), method: :delete, api_key:)
49
49
  end
50
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
+
51
67
  def import_files(input = nil, api_key: nil, **fields, &on_progress)
52
68
  spec = payload(input, fields)
53
69
  files = Array(spec["files"]).map { |file| file.to_h.transform_keys(&:to_s) }
@@ -40,87 +40,86 @@ module OpenEmail
40
40
  api_key:)
41
41
  end
42
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)
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)
45
46
  fetch_page(fill(ApiPaths::KEY_REQUESTS, id:), query, limit:, cursor:, api_key:)
46
47
  end
47
48
 
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)
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)
50
52
  collect_all(fill(ApiPaths::KEY_REQUESTS, id:), query, limit:, cursor:, api_key:)
51
53
  end
52
54
 
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
+ 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)
55
58
  iterate_pages(fill(ApiPaths::KEY_REQUESTS, id:), query, limit:, cursor:, api_key:, &)
56
59
  end
57
60
 
58
61
  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))
62
+ query = log_window_query(since, binding.local_variable_get(:until))
60
63
  fetch_page(fill(ApiPaths::KEY_ACTIVITY, id:), query, limit:, cursor:, api_key:)
61
64
  end
62
65
 
63
66
  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))
67
+ query = log_window_query(since, binding.local_variable_get(:until))
65
68
  collect_all(fill(ApiPaths::KEY_ACTIVITY, id:), query, limit:, cursor:, api_key:)
66
69
  end
67
70
 
68
71
  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))
72
+ query = log_window_query(since, binding.local_variable_get(:until))
70
73
  iterate_pages(fill(ApiPaths::KEY_ACTIVITY, id:), query, limit:, cursor:, api_key:, &)
71
74
  end
72
75
 
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
+ 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)
76
79
  fetch_page(ApiPaths::KEYS_REQUESTS, query, limit:, cursor:, api_key:)
77
80
  end
78
81
 
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
+ 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)
82
85
  collect_all(ApiPaths::KEYS_REQUESTS, query, limit:, cursor:, api_key:)
83
86
  end
84
87
 
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
+ 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)
88
91
  iterate_pages(ApiPaths::KEYS_REQUESTS, query, limit:, cursor:, api_key:, &)
89
92
  end
90
93
 
91
94
  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)))
95
+ query = workspace_activity_query(since, binding.local_variable_get(:until), key_ids)
93
96
  fetch_page(ApiPaths::KEYS_ACTIVITY, query, limit:, cursor:, api_key:)
94
97
  end
95
98
 
96
99
  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)))
100
+ query = workspace_activity_query(since, binding.local_variable_get(:until), key_ids)
98
101
  collect_all(ApiPaths::KEYS_ACTIVITY, query, limit:, cursor:, api_key:)
99
102
  end
100
103
 
101
104
  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)))
105
+ query = workspace_activity_query(since, binding.local_variable_get(:until), key_ids)
103
106
  iterate_pages(ApiPaths::KEYS_ACTIVITY, query, limit:, cursor:, api_key:, &)
104
107
  end
105
108
 
106
109
  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))
110
+ query = log_window_query(since, binding.local_variable_get(:until))
108
111
  .merge(query_params(key_ids: joined(key_ids), grain:, offset_minutes:))
109
112
  request(ApiPaths::KEYS_STATS, query:, api_key:)
110
113
  end
111
114
 
112
115
  private
113
116
 
114
- def window_query(since, until_value)
115
- query_params(since: instant(since), until: instant(until_value))
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)))
116
119
  end
117
120
 
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)))
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)))
124
123
  end
125
124
  end
126
125
  end
@@ -0,0 +1,137 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OpenEmail
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
@@ -31,6 +31,10 @@ module OpenEmail
31
31
  request(fill(ApiPaths::LABEL, id:), method: :patch, body: payload(patch, fields), repeatable: true, api_key:)
32
32
  end
33
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
+
34
38
  def delete(id, api_key: nil)
35
39
  request(fill(ApiPaths::LABEL, id:), method: :delete, api_key:)
36
40
  end
@@ -14,6 +14,44 @@ module OpenEmail
14
14
  def rotate(api_key: nil)
15
15
  request(ApiPaths::KEY_SELF_ROTATE, method: :post, api_key:)
16
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
17
55
  end
18
56
  end
19
57
  end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OpenEmail
4
+ module Resources
5
+ class OutOfOffice < Resource
6
+ def list(address: nil, api_key: nil)
7
+ fetch_list(ApiPaths::OUT_OF_OFFICE, query_params(address:), api_key:)
8
+ end
9
+
10
+ def set(address, body = nil, api_key: nil, **fields)
11
+ request(ApiPaths::OUT_OF_OFFICE, method: :put, query: query_params(address:),
12
+ body: reply_wire(payload(body, fields)), repeatable: true, api_key:)
13
+ end
14
+
15
+ def clear(address, api_key: nil)
16
+ request(ApiPaths::OUT_OF_OFFICE, method: :delete, query: query_params(address:), repeatable: true, api_key:)
17
+ end
18
+
19
+ private
20
+
21
+ def reply_wire(wire)
22
+ wire["startsAt"] = instant(wire["startsAt"]) if wire.key?("startsAt")
23
+ wire["endsAt"] = instant(wire["endsAt"]) if wire.key?("endsAt")
24
+ wire
25
+ end
26
+ end
27
+ end
28
+ end
@@ -6,10 +6,12 @@ module OpenEmail
6
6
  NOT_GIVEN = Object.new.freeze
7
7
  private_constant :NOT_GIVEN
8
8
 
9
- def inspect(provider_key = NOT_GIVEN, api_key: nil)
9
+ def inspect(provider_key = NOT_GIVEN, provider: nil, api_key: nil)
10
10
  return super() if provider_key.equal?(NOT_GIVEN)
11
11
 
12
- request(ApiPaths::PROVIDER_IMPORTS_INSPECT, method: :post, body: {"apiKey" => provider_key}, api_key:)
12
+ body = {"apiKey" => provider_key}
13
+ body["provider"] = provider unless provider.nil?
14
+ request(ApiPaths::PROVIDER_IMPORTS_INSPECT, method: :post, body:, api_key:)
13
15
  end
14
16
 
15
17
  def create(body = nil, api_key: nil, **fields)