nohead 0.9.0 → 0.10.0
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 +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +21 -1
- data/lib/nohead/client.rb +31 -12
- data/lib/nohead/operations.rb +11 -0
- data/lib/nohead/resources/drafts.rb +20 -17
- data/lib/nohead/resources/records.rb +38 -28
- data/lib/nohead/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 614f02b14cf5307614caf01ae06d458d770bff423c34d567d0fe8f7924467298
|
|
4
|
+
data.tar.gz: 052d1089ecc31f984b4d1e143638b4b26b8d393c1a8eac9764a5e6df8a76d364
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 432a87faa068fb1719a38ba559520de892c0cf48abc0783b1ba1c0114d6fbe252b5cffd72c0d89d40de323c563e7c528334796ff7da0695ff2b48b2636fa46da
|
|
7
|
+
data.tar.gz: 1383b012a30ec74972234dcda1c61f62f75e948929c9f8c6d14e52fcd7245595521c2e00426b0e0030a4b3887dc77231c2808ec5ef0390aa8818b8f655216c2e
|
data/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,15 @@ Changes to the `nohead` gem that you can notice. Versions follow
|
|
|
5
5
|
releases; a change that could break your code is a major one. Each release's
|
|
6
6
|
section is its GitHub release's notes.
|
|
7
7
|
|
|
8
|
+
## 0.10.0
|
|
9
|
+
|
|
10
|
+
- Rich text fields read as HTML or Markdown with `rich_text:` (`"document"`,
|
|
11
|
+
the default, `"html"` or `"markdown"`), on `Nohead::Client.new` and
|
|
12
|
+
`with_options` for every call, or on a call: the methods that return
|
|
13
|
+
records or drafts take it, and a call's value wins over the client's. The
|
|
14
|
+
field's value is then a string, in records embedded with `expand:` too.
|
|
15
|
+
Writing Markdown already worked: `data` is sent as it is.
|
|
16
|
+
|
|
8
17
|
## 0.9.0
|
|
9
18
|
|
|
10
19
|
- **Breaking:** the client no longer reads `NOHEAD_API_URL`: a stray value
|
data/README.md
CHANGED
|
@@ -20,6 +20,7 @@ end
|
|
|
20
20
|
- [Configuration](#configuration)
|
|
21
21
|
- [Records](#records)
|
|
22
22
|
- [Drafts](#drafts)
|
|
23
|
+
- [Rich text](#rich-text)
|
|
23
24
|
- [Pagination](#pagination)
|
|
24
25
|
- [Errors](#errors)
|
|
25
26
|
- [Retries and idempotency](#retries-and-idempotency)
|
|
@@ -63,10 +64,11 @@ nohead = Nohead::Client.new(
|
|
|
63
64
|
| `headers:` | `{}` | Added to every request. |
|
|
64
65
|
| `warnings:` | `true` | Warns about deprecated operations and plan usage, once each. |
|
|
65
66
|
| `on_retry:` | | Called before each retry's wait. See [retries](#retries-and-idempotency). |
|
|
67
|
+
| `rich_text:` | `"document"` | How rich text fields read: see [rich text](#rich-text). |
|
|
66
68
|
|
|
67
69
|
An empty string is the same as leaving an option out (`api_key: ""` reads `NOHEAD_API_KEY`, `base_url: ""` uses `https://api.nohead.io`). The base URL comes only from `base_url:`, never from the environment. A `base_url:` that isn't `http` or `https` raises `Nohead::Error`.
|
|
68
70
|
|
|
69
|
-
`with_options` gives a copy of the client with other settings (`timeout:`, `max_retries:`, `headers:`, added to the client's, and `
|
|
71
|
+
`with_options` gives a copy of the client with other settings (`timeout:`, `max_retries:`, `headers:`, added to the client's, `on_retry:` and `rich_text:`), sharing its project lookup:
|
|
70
72
|
|
|
71
73
|
```ruby
|
|
72
74
|
nohead.with_options(timeout: 5, max_retries: 0).records.get(id)
|
|
@@ -113,6 +115,24 @@ nohead.drafts.merge(draft.id) # or drafts.schedule(draft.id, merge_at: ...)
|
|
|
113
115
|
- `records.drafts(id)` lists a record's draft, and `drafts.list(collection)` a collection's.
|
|
114
116
|
- `drafts.discard` deletes one for good.
|
|
115
117
|
|
|
118
|
+
## Rich text
|
|
119
|
+
|
|
120
|
+
A rich text field is written as Markdown or as a document (ProseMirror JSON), and reads as a document unless you ask for HTML or Markdown with `rich_text:`, for the whole client or for one call:
|
|
121
|
+
|
|
122
|
+
```ruby
|
|
123
|
+
nohead.records.create("posts", data: { body: "## Hello\n\nWritten in **Markdown**." })
|
|
124
|
+
|
|
125
|
+
nohead = Nohead::Client.new(rich_text: "html")
|
|
126
|
+
nohead.records.get(id).data["body"] # an HTML string
|
|
127
|
+
nohead.records.get(id, rich_text: "markdown").data["body"] # a Markdown string
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
- With `"html"` or `"markdown"`, the field's value is a string instead of the document, in records embedded with `expand:` too. `"document"` is the default.
|
|
131
|
+
- The methods that return records or drafts take `rich_text:`; a call's value wins over the client's, and other methods never send it.
|
|
132
|
+
- HTML has every text and attribute escaped, ready to put in a page. Images come with their URLs, so they need no `expand:`.
|
|
133
|
+
- Record history (`records.revisions.list` and `get`) and webhook events keep documents.
|
|
134
|
+
- A string you write is read as Markdown, so write back Markdown or the document, never the HTML: with `rich_text: "html"` on the client, writes answer with HTML too.
|
|
135
|
+
|
|
116
136
|
## Pagination
|
|
117
137
|
|
|
118
138
|
List methods return the first page, a `Nohead::Page`. It's Enumerable: `each`, `map`, `first` and so on walk every item across pages, fetching the next page only when needed.
|
data/lib/nohead/client.rb
CHANGED
|
@@ -61,10 +61,13 @@ module Nohead
|
|
|
61
61
|
# warnings:: Warn about deprecated operations and plan usage (once each).
|
|
62
62
|
# on_retry:: Called with a RetryEvent before each retry's wait, for
|
|
63
63
|
# example to log it.
|
|
64
|
+
# rich_text:: How rich text fields read in the records and drafts
|
|
65
|
+
# returned: "document" (the API's default), "html" or
|
|
66
|
+
# "markdown". A method's own `rich_text:` wins.
|
|
64
67
|
#
|
|
65
68
|
# An empty string is the same as leaving an option out.
|
|
66
69
|
def initialize(api_key: nil, base_url: nil, project_id: nil, max_retries: 2, timeout: 60,
|
|
67
|
-
headers: {}, warnings: true, on_retry: nil, transport: Transport.new)
|
|
70
|
+
headers: {}, warnings: true, on_retry: nil, rich_text: nil, transport: Transport.new)
|
|
68
71
|
@api_key = present(api_key) || present(ENV.fetch("NOHEAD_API_KEY", nil)) or
|
|
69
72
|
raise Error, "Missing API key: pass api_key or set NOHEAD_API_KEY"
|
|
70
73
|
@base_url = checked_base_url(present(base_url) || DEFAULT_BASE_URL)
|
|
@@ -74,6 +77,7 @@ module Nohead
|
|
|
74
77
|
@headers = merge_headers({}, headers.to_h)
|
|
75
78
|
@warnings = warnings
|
|
76
79
|
@on_retry = on_retry
|
|
80
|
+
@rich_text = present(rich_text)
|
|
77
81
|
@transport = transport
|
|
78
82
|
build_resources
|
|
79
83
|
end
|
|
@@ -81,8 +85,11 @@ module Nohead
|
|
|
81
85
|
# A copy of the client with other settings, which shares its transport
|
|
82
86
|
# and project lookup: `nohead.with_options(timeout: 5).records.get(id)`.
|
|
83
87
|
# `headers:` are added to the client's.
|
|
84
|
-
def with_options(timeout: @timeout, max_retries: @max_retries, headers: {}, on_retry: @on_retry
|
|
85
|
-
|
|
88
|
+
def with_options(timeout: @timeout, max_retries: @max_retries, headers: {}, on_retry: @on_retry,
|
|
89
|
+
rich_text: @rich_text)
|
|
90
|
+
dup.tap do |copy|
|
|
91
|
+
copy.configure(timeout, max_retries, merge_headers(@headers, headers.to_h), on_retry, present(rich_text))
|
|
92
|
+
end
|
|
86
93
|
end
|
|
87
94
|
|
|
88
95
|
# Full-text search across the key's project (or some of its collections),
|
|
@@ -90,10 +97,11 @@ module Nohead
|
|
|
90
97
|
# `published_at` ({ published_at: { exists: true } } for published
|
|
91
98
|
# records), as records.list does. `collections` wins over a `collection`
|
|
92
99
|
# filter.
|
|
93
|
-
def search(query, collections: nil, filter: nil, limit: nil, cursor: nil)
|
|
100
|
+
def search(query, collections: nil, filter: nil, limit: nil, cursor: nil, rich_text: nil)
|
|
94
101
|
filter = filter.to_h.transform_keys(&:to_sym)
|
|
95
102
|
filter = filter.merge(collection: { in: collections }) unless collections.nil?
|
|
96
|
-
paginate("projects_search", query: { q: query, filter: filter, limit: limit, cursor: cursor }
|
|
103
|
+
paginate("projects_search", query: { q: query, filter: filter, limit: limit, cursor: cursor },
|
|
104
|
+
rich_text: rich_text)
|
|
97
105
|
end
|
|
98
106
|
|
|
99
107
|
# The API key's project, from GET /v1/me the first time. Threads that
|
|
@@ -110,17 +118,18 @@ module Nohead
|
|
|
110
118
|
# result. The resources call this; it is public for operations the SDK
|
|
111
119
|
# does not wrap yet.
|
|
112
120
|
def request(operation, path: {}, query: {}, body: nil, idempotency_key: nil,
|
|
113
|
-
change_note: nil, if_match: nil)
|
|
121
|
+
change_note: nil, if_match: nil, rich_text: nil)
|
|
114
122
|
NoheadObject.wrap(exchange(operation, path: path, query: query, body: body, idempotency_key: idempotency_key,
|
|
115
|
-
change_note: change_note, if_match: if_match).first)
|
|
123
|
+
change_note: change_note, if_match: if_match, rich_text: rich_text).first)
|
|
116
124
|
end
|
|
117
125
|
|
|
118
126
|
# A list operation as a Page that fetches the following pages as needed.
|
|
119
|
-
def paginate(operation, path: {}, query: {})
|
|
127
|
+
def paginate(operation, path: {}, query: {}, rich_text: nil)
|
|
120
128
|
params = query.dup
|
|
121
129
|
cursor = params.delete(:cursor)
|
|
122
130
|
fetch = lambda do |next_cursor|
|
|
123
|
-
list, status = exchange(operation, path: path, query: params.merge(cursor: next_cursor)
|
|
131
|
+
list, status = exchange(operation, path: path, query: params.merge(cursor: next_cursor),
|
|
132
|
+
rich_text: rich_text)
|
|
124
133
|
unless list.is_a?(Hash) && list["data"].is_a?(Array) && list["meta"].is_a?(Hash)
|
|
125
134
|
raise Error, "The API's response could not be read (HTTP #{status})"
|
|
126
135
|
end
|
|
@@ -158,11 +167,12 @@ module Nohead
|
|
|
158
167
|
protected
|
|
159
168
|
|
|
160
169
|
# with_options' settings, on its copy.
|
|
161
|
-
def configure(timeout, max_retries, headers, on_retry)
|
|
170
|
+
def configure(timeout, max_retries, headers, on_retry, rich_text)
|
|
162
171
|
@timeout = timeout
|
|
163
172
|
@max_retries = max_retries
|
|
164
173
|
@headers = headers
|
|
165
174
|
@on_retry = on_retry
|
|
175
|
+
@rich_text = rich_text
|
|
166
176
|
end
|
|
167
177
|
|
|
168
178
|
private
|
|
@@ -189,9 +199,9 @@ module Nohead
|
|
|
189
199
|
|
|
190
200
|
# The parsed body of a 2xx response, and its status.
|
|
191
201
|
def exchange(operation, path: {}, query: {}, body: nil, idempotency_key: nil,
|
|
192
|
-
change_note: nil, if_match: nil)
|
|
202
|
+
change_note: nil, if_match: nil, rich_text: nil)
|
|
193
203
|
method, template = OPERATIONS.fetch(operation)
|
|
194
|
-
url = build_url(template, path) + query_string(query)
|
|
204
|
+
url = build_url(template, path) + query_string(query.merge(rich_text_query(operation, rich_text)))
|
|
195
205
|
headers = request_headers(method, body, idempotency_key, change_note, if_match)
|
|
196
206
|
payload = body.nil? ? nil : JSON.generate(json_ready(body))
|
|
197
207
|
attempt = 0
|
|
@@ -238,6 +248,15 @@ module Nohead
|
|
|
238
248
|
@base_url + path
|
|
239
249
|
end
|
|
240
250
|
|
|
251
|
+
# The request's `rich_text`, else the client's, for an operation that
|
|
252
|
+
# takes it. Others never send the client's.
|
|
253
|
+
def rich_text_query(operation, rich_text)
|
|
254
|
+
return { rich_text: present(rich_text) || @rich_text } if RICH_TEXT_OPERATIONS.include?(operation)
|
|
255
|
+
raise ArgumentError, "#{operation} does not take rich_text" if present(rich_text)
|
|
256
|
+
|
|
257
|
+
{}
|
|
258
|
+
end
|
|
259
|
+
|
|
241
260
|
# Query parameters as the API reads them: hashes become key[sub]=...
|
|
242
261
|
# (filter[price][lt]=50), arrays are comma-separated (expand=author,tags)
|
|
243
262
|
# with \, for a comma inside a value and \\ for a backslash, times are
|
data/lib/nohead/operations.rb
CHANGED
|
@@ -97,4 +97,15 @@ module Nohead
|
|
|
97
97
|
|
|
98
98
|
# The objects whose `data` is a record's field values.
|
|
99
99
|
RECORD_DATA_OBJECTS = %w[draft record record_revision revert_preview].to_set.freeze
|
|
100
|
+
|
|
101
|
+
# The operations that take `rich_text`: how rich text fields read in the
|
|
102
|
+
# records and drafts they return.
|
|
103
|
+
RICH_TEXT_OPERATIONS = %w[
|
|
104
|
+
collections_search drafts_create drafts_discard drafts_get
|
|
105
|
+
drafts_list drafts_merge drafts_schedule drafts_unschedule
|
|
106
|
+
drafts_update projects_search record_drafts_list record_revisions_revert
|
|
107
|
+
records_bulk records_create records_delete records_get
|
|
108
|
+
records_list records_publish records_restore records_unpublish
|
|
109
|
+
records_update
|
|
110
|
+
].to_set.freeze
|
|
100
111
|
end
|
|
@@ -5,57 +5,60 @@ module Nohead
|
|
|
5
5
|
# Drafts: changes to a record's content that wait until they are merged
|
|
6
6
|
# into it, now or at a set time, while the record keeps its current
|
|
7
7
|
# content. A record has at most one. `draft` is a draft ID ("drf_..."),
|
|
8
|
-
# `record` a record ID and `collection` a collection ID or slug.
|
|
8
|
+
# `record` a record ID and `collection` a collection ID or slug. Every
|
|
9
|
+
# method takes `rich_text:`, as records' do.
|
|
9
10
|
class Drafts < Resource
|
|
10
11
|
# Starts the record's draft: `data` over the record's values, or with
|
|
11
12
|
# `from_revision`, over an earlier revision's. A second draft raises
|
|
12
13
|
# ConflictError (detail code `draft_exists`, with its `draft_id`).
|
|
13
|
-
def create(record, data: {}, from_revision: nil, idempotency_key: nil)
|
|
14
|
+
def create(record, data: {}, from_revision: nil, idempotency_key: nil, rich_text: nil)
|
|
14
15
|
@client.request("drafts_create", path: { record_id: record },
|
|
15
16
|
body: { data: data, from_revision: from_revision }.compact,
|
|
16
|
-
idempotency_key: idempotency_key)
|
|
17
|
+
idempotency_key: idempotency_key, rich_text: rich_text)
|
|
17
18
|
end
|
|
18
19
|
|
|
19
20
|
# A collection's drafts, most recently changed first. One record's
|
|
20
21
|
# draft is `records.drafts(record)`.
|
|
21
|
-
def list(collection, sort: nil, limit: nil, cursor: nil)
|
|
22
|
+
def list(collection, sort: nil, limit: nil, cursor: nil, rich_text: nil)
|
|
22
23
|
@client.paginate("drafts_list", path: { collection_id: collection },
|
|
23
|
-
query: { sort: sort, limit: limit, cursor: cursor })
|
|
24
|
+
query: { sort: sort, limit: limit, cursor: cursor }, rich_text: rich_text)
|
|
24
25
|
end
|
|
25
26
|
|
|
26
27
|
# With `data` as the record reads after the merge, for previews.
|
|
27
|
-
def get(draft, expand: nil)
|
|
28
|
-
@client.request("drafts_get", path: { draft_id: draft }, query: { expand: expand })
|
|
28
|
+
def get(draft, expand: nil, rich_text: nil)
|
|
29
|
+
@client.request("drafts_get", path: { draft_id: draft }, query: { expand: expand }, rich_text: rich_text)
|
|
29
30
|
end
|
|
30
31
|
|
|
31
32
|
# Sets the given fields (nil clears one), as a record update does.
|
|
32
|
-
def update(draft, data:, if_match: nil, idempotency_key: nil)
|
|
33
|
+
def update(draft, data:, if_match: nil, idempotency_key: nil, rich_text: nil)
|
|
33
34
|
@client.request("drafts_update", path: { draft_id: draft }, body: { data: data },
|
|
34
|
-
if_match: if_match, idempotency_key: idempotency_key)
|
|
35
|
+
if_match: if_match, idempotency_key: idempotency_key, rich_text: rich_text)
|
|
35
36
|
end
|
|
36
37
|
|
|
37
38
|
# Deletes the draft for good; returns it as it was.
|
|
38
|
-
def discard(draft, if_match: nil, idempotency_key: nil)
|
|
39
|
+
def discard(draft, if_match: nil, idempotency_key: nil, rich_text: nil)
|
|
39
40
|
@client.request("drafts_discard", path: { draft_id: draft }, if_match: if_match,
|
|
40
|
-
idempotency_key: idempotency_key)
|
|
41
|
+
idempotency_key: idempotency_key, rich_text: rich_text)
|
|
41
42
|
end
|
|
42
43
|
|
|
43
44
|
# Applies the draft to its record now, as one `merge` revision, and
|
|
44
45
|
# returns the record. Content only: the record stays live or not.
|
|
45
|
-
def merge(draft, if_match: nil, idempotency_key: nil, change_note: nil)
|
|
46
|
+
def merge(draft, if_match: nil, idempotency_key: nil, change_note: nil, rich_text: nil)
|
|
46
47
|
@client.request("drafts_merge", path: { draft_id: draft }, if_match: if_match,
|
|
47
|
-
idempotency_key: idempotency_key, change_note: change_note
|
|
48
|
+
idempotency_key: idempotency_key, change_note: change_note,
|
|
49
|
+
rich_text: rich_text)
|
|
48
50
|
end
|
|
49
51
|
|
|
50
52
|
# Merges the draft at `merge_at` (a Time or ISO 8601 string in the
|
|
51
53
|
# future); returns the draft.
|
|
52
|
-
def schedule(draft, merge_at:, idempotency_key: nil)
|
|
54
|
+
def schedule(draft, merge_at:, idempotency_key: nil, rich_text: nil)
|
|
53
55
|
@client.request("drafts_schedule", path: { draft_id: draft }, body: { merge_at: merge_at },
|
|
54
|
-
idempotency_key: idempotency_key)
|
|
56
|
+
idempotency_key: idempotency_key, rich_text: rich_text)
|
|
55
57
|
end
|
|
56
58
|
|
|
57
|
-
def unschedule(draft, idempotency_key: nil)
|
|
58
|
-
@client.request("drafts_unschedule", path: { draft_id: draft }, idempotency_key: idempotency_key
|
|
59
|
+
def unschedule(draft, idempotency_key: nil, rich_text: nil)
|
|
60
|
+
@client.request("drafts_unschedule", path: { draft_id: draft }, idempotency_key: idempotency_key,
|
|
61
|
+
rich_text: rich_text)
|
|
59
62
|
end
|
|
60
63
|
end
|
|
61
64
|
end
|
|
@@ -4,8 +4,8 @@ module Nohead
|
|
|
4
4
|
module Resources
|
|
5
5
|
# The base of the resources: each holds the client it sends requests with.
|
|
6
6
|
class Resource
|
|
7
|
-
# Request options
|
|
8
|
-
OPTIONS = %i[change_note if_match].freeze
|
|
7
|
+
# Request options, not body fields.
|
|
8
|
+
OPTIONS = %i[change_note if_match rich_text].freeze
|
|
9
9
|
|
|
10
10
|
def initialize(client)
|
|
11
11
|
@client = client
|
|
@@ -17,8 +17,8 @@ module Nohead
|
|
|
17
17
|
|
|
18
18
|
# The keyword arguments a method sends as the body. SDK options would
|
|
19
19
|
# land there when the method doesn't take them (its operation doesn't
|
|
20
|
-
# declare the header), so they raise ArgumentError as
|
|
21
|
-
# unknown keywords.
|
|
20
|
+
# declare the header or query parameter), so they raise ArgumentError as
|
|
21
|
+
# Ruby does for unknown keywords.
|
|
22
22
|
def body_of(params)
|
|
23
23
|
option = OPTIONS.find { |name| params.key?(name) }
|
|
24
24
|
raise ArgumentError, "unknown keyword: :#{option}" if option
|
|
@@ -48,56 +48,62 @@ module Nohead
|
|
|
48
48
|
# A collection's records, newest first by default. `filter` holds
|
|
49
49
|
# filters ({ published_at: { exists: true } } for published records),
|
|
50
50
|
# `expand` relation or asset fields to embed under `expanded` (at most 5).
|
|
51
|
-
|
|
51
|
+
# Methods that return records or drafts take `rich_text:` ("document",
|
|
52
|
+
# "html" or "markdown"): how their rich text fields read.
|
|
53
|
+
def list(collection, filter: nil, sort: nil, expand: nil, limit: nil, cursor: nil, rich_text: nil)
|
|
52
54
|
@client.paginate("records_list", path: { collection_id: collection }, query: {
|
|
53
55
|
filter: filter, sort: sort, expand: expand, limit: limit, cursor: cursor
|
|
54
|
-
})
|
|
56
|
+
}, rich_text: rich_text)
|
|
55
57
|
end
|
|
56
58
|
|
|
57
59
|
# A deleted record too, with `deleted_at` and `purge_after`.
|
|
58
|
-
def get(record, expand: nil)
|
|
59
|
-
@client.request("records_get", path: { record_id: record }, query: { expand: expand })
|
|
60
|
+
def get(record, expand: nil, rich_text: nil)
|
|
61
|
+
@client.request("records_get", path: { record_id: record }, query: { expand: expand }, rich_text: rich_text)
|
|
60
62
|
end
|
|
61
63
|
|
|
62
64
|
# Creates an unpublished record: create("posts", data: { title: "Hello" }).
|
|
63
65
|
# With upsert_on:, the key of a unique field, it updates the record holding
|
|
64
66
|
# that value instead, if one exists, so a sync can run again without
|
|
65
67
|
# duplicates; if_match: then applies to that update.
|
|
66
|
-
def create(collection, if_match: nil, idempotency_key: nil, change_note: nil, **params)
|
|
68
|
+
def create(collection, if_match: nil, idempotency_key: nil, change_note: nil, rich_text: nil, **params)
|
|
67
69
|
@client.request("records_create", path: { collection_id: collection }, body: body_of(params),
|
|
68
70
|
if_match: if_match, idempotency_key: idempotency_key,
|
|
69
|
-
change_note: change_note)
|
|
71
|
+
change_note: change_note, rich_text: rich_text)
|
|
70
72
|
end
|
|
71
73
|
|
|
72
74
|
# Sets the given fields (nil clears one); others keep their values.
|
|
73
|
-
def update(record, if_match: nil, idempotency_key: nil, change_note: nil, **params)
|
|
75
|
+
def update(record, if_match: nil, idempotency_key: nil, change_note: nil, rich_text: nil, **params)
|
|
74
76
|
@client.request("records_update", path: { record_id: record }, body: body_of(params),
|
|
75
77
|
if_match: if_match, idempotency_key: idempotency_key,
|
|
76
|
-
change_note: change_note)
|
|
78
|
+
change_note: change_note, rich_text: rich_text)
|
|
77
79
|
end
|
|
78
80
|
|
|
79
81
|
# Soft-deletes the record: restore brings it back until its `purge_after`.
|
|
80
82
|
# Deleting a deleted record changes nothing.
|
|
81
|
-
def delete(record, if_match: nil, idempotency_key: nil, change_note: nil)
|
|
83
|
+
def delete(record, if_match: nil, idempotency_key: nil, change_note: nil, rich_text: nil)
|
|
82
84
|
@client.request("records_delete", path: { record_id: record }, if_match: if_match,
|
|
83
|
-
idempotency_key: idempotency_key, change_note: change_note
|
|
85
|
+
idempotency_key: idempotency_key, change_note: change_note,
|
|
86
|
+
rich_text: rich_text)
|
|
84
87
|
end
|
|
85
88
|
|
|
86
|
-
def restore(record, if_match: nil, idempotency_key: nil, change_note: nil)
|
|
89
|
+
def restore(record, if_match: nil, idempotency_key: nil, change_note: nil, rich_text: nil)
|
|
87
90
|
@client.request("records_restore", path: { record_id: record }, if_match: if_match,
|
|
88
|
-
idempotency_key: idempotency_key, change_note: change_note
|
|
91
|
+
idempotency_key: idempotency_key, change_note: change_note,
|
|
92
|
+
rich_text: rich_text)
|
|
89
93
|
end
|
|
90
94
|
|
|
91
95
|
# A live record with a pending draft raises ConflictError (detail code
|
|
92
96
|
# `draft_pending`): publishing never merges a draft (drafts.merge does).
|
|
93
|
-
def publish(record, if_match: nil, idempotency_key: nil, change_note: nil)
|
|
97
|
+
def publish(record, if_match: nil, idempotency_key: nil, change_note: nil, rich_text: nil)
|
|
94
98
|
@client.request("records_publish", path: { record_id: record }, if_match: if_match,
|
|
95
|
-
idempotency_key: idempotency_key, change_note: change_note
|
|
99
|
+
idempotency_key: idempotency_key, change_note: change_note,
|
|
100
|
+
rich_text: rich_text)
|
|
96
101
|
end
|
|
97
102
|
|
|
98
|
-
def unpublish(record, if_match: nil, idempotency_key: nil, change_note: nil)
|
|
103
|
+
def unpublish(record, if_match: nil, idempotency_key: nil, change_note: nil, rich_text: nil)
|
|
99
104
|
@client.request("records_unpublish", path: { record_id: record }, if_match: if_match,
|
|
100
|
-
idempotency_key: idempotency_key, change_note: change_note
|
|
105
|
+
idempotency_key: idempotency_key, change_note: change_note,
|
|
106
|
+
rich_text: rich_text)
|
|
101
107
|
end
|
|
102
108
|
|
|
103
109
|
# What is live: since when, by whom, and the revision. Raises
|
|
@@ -130,8 +136,9 @@ module Nohead
|
|
|
130
136
|
end
|
|
131
137
|
|
|
132
138
|
# The record's drafts: at most one for now.
|
|
133
|
-
def drafts(record, limit: nil, cursor: nil)
|
|
134
|
-
@client.paginate("record_drafts_list", path: { record_id: record }, query: { limit: limit, cursor: cursor }
|
|
139
|
+
def drafts(record, limit: nil, cursor: nil, rich_text: nil)
|
|
140
|
+
@client.paginate("record_drafts_list", path: { record_id: record }, query: { limit: limit, cursor: cursor },
|
|
141
|
+
rich_text: rich_text)
|
|
135
142
|
end
|
|
136
143
|
|
|
137
144
|
# A collection's pending scheduled changes, soonest first: publishes,
|
|
@@ -149,9 +156,10 @@ module Nohead
|
|
|
149
156
|
|
|
150
157
|
# Publishes, unpublishes, deletes, restores or updates up to 100 records.
|
|
151
158
|
# Each record succeeds or fails on its own; see `results`.
|
|
152
|
-
def bulk(collection, idempotency_key: nil, change_note: nil, **params)
|
|
159
|
+
def bulk(collection, idempotency_key: nil, change_note: nil, rich_text: nil, **params)
|
|
153
160
|
@client.request("records_bulk", path: { collection_id: collection }, body: body_of(params),
|
|
154
|
-
idempotency_key: idempotency_key, change_note: change_note
|
|
161
|
+
idempotency_key: idempotency_key, change_note: change_note,
|
|
162
|
+
rich_text: rich_text)
|
|
155
163
|
end
|
|
156
164
|
|
|
157
165
|
# The changes between two revisions: diff(record, from: 1, to: 2).
|
|
@@ -161,11 +169,11 @@ module Nohead
|
|
|
161
169
|
|
|
162
170
|
# Full-text search in one collection, matching its searchable fields, most
|
|
163
171
|
# relevant first, through the first 1,000 hits.
|
|
164
|
-
def search(collection, query, filter: nil, sort: nil, expand: nil, limit: nil, cursor: nil)
|
|
172
|
+
def search(collection, query, filter: nil, sort: nil, expand: nil, limit: nil, cursor: nil, rich_text: nil)
|
|
165
173
|
@client.paginate("collections_search", path: { collection_id: collection }, query: {
|
|
166
174
|
q: query, filter: filter, sort: sort, expand: expand, limit: limit,
|
|
167
175
|
cursor: cursor
|
|
168
|
-
})
|
|
176
|
+
}, rich_text: rich_text)
|
|
169
177
|
end
|
|
170
178
|
end
|
|
171
179
|
|
|
@@ -184,10 +192,12 @@ module Nohead
|
|
|
184
192
|
|
|
185
193
|
# Restores the record's data as of `revision`, as a new revision. With
|
|
186
194
|
# dry_run: true, previews it.
|
|
187
|
-
def revert(record, revision, dry_run: false, if_match: nil, idempotency_key: nil, change_note: nil
|
|
195
|
+
def revert(record, revision, dry_run: false, if_match: nil, idempotency_key: nil, change_note: nil,
|
|
196
|
+
rich_text: nil)
|
|
188
197
|
@client.request("record_revisions_revert", path: { record_id: record, revision: revision },
|
|
189
198
|
query: { dry_run: dry_run || nil }, if_match: if_match,
|
|
190
|
-
idempotency_key: idempotency_key, change_note: change_note
|
|
199
|
+
idempotency_key: idempotency_key, change_note: change_note,
|
|
200
|
+
rich_text: rich_text)
|
|
191
201
|
end
|
|
192
202
|
end
|
|
193
203
|
|
data/lib/nohead/version.rb
CHANGED