dato-rails 0.7.4 → 0.7.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cd0388aa8f2f5230feb9b58e501d0d2b32d9a276eccf4029864061ea4fb42745
4
- data.tar.gz: c084383123cfa44fe5834c8eb61e247d8b5482f4ce983bd9f712044e36fe1f5e
3
+ metadata.gz: 7d61ca3870d999b82aed6ff238182a3a6fd4b294f87c608b1b9c4ee9425d97ad
4
+ data.tar.gz: 3032c72e0226946239830f8c5aaeb1a5f0640328aa349a269c1f156d9b40f6b8
5
5
  SHA512:
6
- metadata.gz: 6cde762f15270f855bc106c523e6d428fca9763005b380177852fa990627ccd35445ba6abe8913d76f9899f6c7a30a132a829ef6ac00be2bda9d672faff99299
7
- data.tar.gz: e54d6ac310cc81b0c62f65470e4a2c9ab0333e7ff71e9ca652a83f0ee1e3b9699c4889140cf3a6f8aaae421a3785433deb4eed48b01878ff9cfc5973afb7bbbd
6
+ metadata.gz: 7733a018553585d7f51a8d85920932dabe04944581772d84c6e9bea5d9c8ec6107e0269c6b0832da4028533128d95c0fa91e409b17a4a1d4acf429ae9c5e1591
7
+ data.tar.gz: c705f72bf8f0ed731ff656459b0ef0e5adc4c0a351a79b250f4db55eb0835f6e17df8adb5e9e9a01f6420704c78c92972f894fc06935169795462b142b3a2a70
data/README.md CHANGED
@@ -173,6 +173,9 @@ Dato::Client.new.items.destroy(item_id: '123')
173
173
  Dato Rails also supports file uploads.
174
174
  These can be created either from a local file or from a url.
175
175
  Basically all file types are supported, as long as they are valid in the CMS.
176
+ Be aware that dato jobs are not synchronous, so you may need to
177
+ implement some kind of polling to check if the upload is finished.
178
+ The create method returns a job id, which can be used to retrieve the upload result.
176
179
 
177
180
  > In addition to the binary file, also attributes and metadata can be uploaded.
178
181
  Both metadata and attributes are optional.
@@ -203,9 +206,17 @@ attributes = { author: 'Dato Rails', default_field_metadata: meta }
203
206
  ```ruby
204
207
  Dato::Client.new.uploads.create_from_url('https://picsum.photos/seed/picsum/200/300', filename: 'test.png')
205
208
  Dato::Client.new.uploads.create_from_file(file.path, filename: 'test.png')
206
-
207
209
  ```
208
210
 
211
+
212
+ ### Getting the upload id
213
+ As the file upload is asynchronous, you may need to implement some kind of polling to check if the upload is finished.
214
+ With the retrieve_job_result method you can retrieve the upload id from the job result.
215
+ ```ruby
216
+ job_id = client.uploads.create_from_file(file.path) # get back a job id
217
+ response = client.uploads.retrieve_job_result(job_id).parse # check the status
218
+ upload_id = response.dig('data', 'attributes', 'payload', 'data', 'id') # if nil, it's not done yet
219
+ ```
209
220
  ## Configuration
210
221
 
211
222
  The following options are available:
@@ -279,7 +290,8 @@ You can now clone the dato-rails project
279
290
 
280
291
 
281
292
  You then need to set a `DATO_API_TOKEN=abcd123x` in the `.env` file on the root of your project
282
- to consume data from your project.
293
+ to consume data from your project. For testing purposes, set `TEST_MODEL_TYPE_ID=1234` in the `.env` file
294
+ with the id of the author model type in your project.
283
295
 
284
296
  Then, run `bundle exec rspec` to run the tests.
285
297
 
data/lib/dato/uploads.rb CHANGED
@@ -30,10 +30,7 @@ module Dato
30
30
 
31
31
  upload_file_to_bucket(url: upload_url, path: path_to_file)
32
32
 
33
- job_id = upload_file_to_dato(upload_id:, attributes:)
34
- upload_id = retrieve_job_result(job_id).parse["data"]["attributes"]["payload"]["data"]["id"]
35
-
36
- {upload_id:}
33
+ upload_file_to_dato(upload_id:, attributes:)
37
34
  end
38
35
 
39
36
  def retrieve_job_result(job_id)
data/lib/dato/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Dato
2
- VERSION = "0.7.4"
2
+ VERSION = "0.7.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dato-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.4
4
+ version: 0.7.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alessandro Rodi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-16 00:00:00.000000000 Z
11
+ date: 2023-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec-rails