bannerbear 0.1.2 → 0.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4b43c04b16e54a26e481bc12d7eb6f5588db0224238945443bf6438bcb626328
4
- data.tar.gz: 905e9f0804d0630e3dd48ad0636a2e7c7df0c67f50cfa1130a672ba0f33d237c
3
+ metadata.gz: f2da12377f479bda2685084b6de8bbaedd54b043f565e2b8d646ff9d36c1ec93
4
+ data.tar.gz: 477db9f95c4df6f068667816546d813e4021288301103a207c61e6227aa199d6
5
5
  SHA512:
6
- metadata.gz: 06c3244bd4254f8252d76d3bd0c4cb64227e3be258db9edb8234867f64448ed1c8c888884bcad29cc8b485ab838abf43b90e5911713fdf5dbb59ca3b61c3170c
7
- data.tar.gz: 0a20d795212da248f077ed9908e4ac7a0e219b8feac7eadcbc853e74224985535d2b145645d4c4cf49dc9482d75186a7ce284851ad4e06660913f1648246b165
6
+ metadata.gz: 619e0c3e44fd9be99a86d0874418d6f4d6db14bf94c6200f3decb78a83f0fd7cb8e02ced1f86bd3d562a53d617e7e98f99165ce4372d5a49bafdaf4f55b411d8
7
+ data.tar.gz: 64d0ed8cec035ce84a9976915515ab63106e0e9ed8e890b37887b57e41cc68401877e877a228e0cae7e6c594da4319cd5fc72a44c0390046cbab37a162ddd8e3
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bannerbear (0.1.1)
4
+ bannerbear (0.1.2)
5
5
  httparty
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -20,7 +20,21 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
- ### Create the Client
23
+ ### Table of Contents
24
+
25
+ - [Authentication](#authentication)
26
+ - [Account Info](#account-info)
27
+ - [Images](#images)
28
+ - [Videos](#videos)
29
+ - [Collections](#collections)
30
+ - [Animated Gifs](#animated-gifs)
31
+ - [Movies](#movies)
32
+ - [Screenshots](#screenshots)
33
+ - [Templates](#templates)
34
+ - [Template Sets](#template-sets)
35
+ - [Video Templates](#video-templates)
36
+
37
+ ### Authentication
24
38
 
25
39
  Get the API key for your project in Bannerbear and create a client.
26
40
 
@@ -34,7 +48,7 @@ Alternatively you can place your API key in an ENV variable named `BANNERBEAR_AP
34
48
  bb = Bannerbear::Client.new
35
49
  ```
36
50
 
37
- ### Get Account Info
51
+ ### Account Info
38
52
 
39
53
  Return info about the Account / Project associated with this API key.
40
54
 
@@ -42,7 +56,9 @@ Return info about the Account / Project associated with this API key.
42
56
  bb.account
43
57
  ```
44
58
 
45
- ### Create an Image
59
+ ### Images
60
+
61
+ #### Create an Image
46
62
 
47
63
  To create an image you reference a template uid and a list of modifications. The default is async generation meaning the API will respond with a `pending` status and you can use `get_image` to retrieve the final image.
48
64
 
@@ -79,21 +95,22 @@ bb.create_image("template uid",
79
95
  )
80
96
  ```
81
97
 
82
- #### Options
98
+ ##### Options
83
99
 
84
100
  - `modifications`: an array of [modifications](https://developers.bannerbear.com/#post-v2-images) you would like to make (`array`)
85
101
  - `webhook_url`: a webhook url to post the final image object to (`string`)
86
102
  - `transparent`: render image with a transparent background (`boolean`)
103
+ - `synchronous`: generate the image synchronously (`boolean`)
87
104
  - `render_pdf`: render a PDF in addition to an image (`boolean`)
88
105
  - `metadata`: include any metadata to reference at a later point (`string`)
89
106
 
90
- ### Get an Image
107
+ #### Get an Image
91
108
 
92
109
  ```ruby
93
110
  bb.get_image("image uid")
94
111
  ```
95
112
 
96
- ### List all Images
113
+ #### List all Images
97
114
 
98
115
  ```ruby
99
116
  bb.list_images
@@ -103,12 +120,14 @@ bb.list_images
103
120
  bb.list_images(:page => 10)
104
121
  ```
105
122
 
106
- #### Options
123
+ ##### Options
107
124
 
108
125
  - `page`: pagination (`integer`)
109
126
  - `limit`: return n images per page (`integer`)
110
127
 
111
- ### Create a Video
128
+ ### Videos
129
+
130
+ #### Create a Video
112
131
 
113
132
  To create a video you reference a *video template uid*, an input media and a list of modifications. Videos are created async - use `get_video` to retrieve the final video.
114
133
 
@@ -124,7 +143,7 @@ bb.create_video("video template uid",
124
143
  )
125
144
  ```
126
145
 
127
- #### Options
146
+ ##### Options
128
147
 
129
148
  - `input_media_url`: a url to a publicly available video file you want to import (`string`)
130
149
  - `modifications`: an array of modifications you would like to make to the video overlay (`array`)
@@ -139,37 +158,177 @@ If your video is using the "Multi Overlay" build pack then you can pass in a set
139
158
  - `frames`: an array of sets of `modifications` (`array`)
140
159
  - `frame_durations`: specify the duration of each frame (`array`)
141
160
 
142
- ### Get a Video
161
+ #### Get a Video
143
162
 
144
163
  ```ruby
145
164
  bb.get_video("video uid")
146
165
  ```
147
166
 
148
- ### List all Videos
167
+ #### Update a Video
168
+
169
+ Updating a video is only relevant under specific conditions. Video Templates using the build pack `transcribe` and set to manual approval (via the dashboard) will result in videos that enter a `pending_approval` status. At this point, the video is waiting for approval before final rendering. The purpose of this is to check the transcript is correct, make any changes, and approve the video for rendering.
170
+
171
+ ```ruby
172
+ bb.update_video("video uid",
173
+ :approved => true,
174
+ :transcription => [
175
+ "This is a new transcription",
176
+ "It must contain the same number of lines",
177
+ "As the previous transcription"
178
+ ]
179
+ )
180
+ ```
181
+
182
+ ##### Options
183
+
184
+ - `approved`: approve the video for rendering (`boolean`)
185
+ - `transcription`: an array of strings to represent the new transcription (will overwrite the existing one) (`array`)
186
+
187
+ #### List all Videos
149
188
 
150
189
  ```ruby
151
190
  bb.list_videos
152
191
  ```
153
192
 
154
- #### Options
193
+ ##### Options
155
194
 
156
195
  - `page`: pagination (`integer`)
157
196
 
158
- ### Templates, Template Sets and Video Templates
197
+ ### Collections
159
198
 
160
- Various operations exist for handling templates.
199
+ Create multiple images in one API request.
200
+
201
+ ```ruby
202
+ bb.get_collection("collection uid")
203
+ bb.list_collections(:page => 3)
204
+ bb.create_collection("template set uid",
205
+ :synchronous => true,
206
+ :modifications => [
207
+ {
208
+ :name => "headline",
209
+ :text => "Hello World!"
210
+ }
211
+ ]
212
+ )
213
+ ```
214
+
215
+ ##### Options for `create_collection`
216
+
217
+ - `modifications`: an array of [modifications](https://developers.bannerbear.com/#post-v2-images) you would like to make (`array`)
218
+ - `webhook_url`: a webhook url to post the final collection object to (`string`)
219
+ - `transparent`: render image with a transparent background (`boolean`)
220
+ - `synchronous`: generate the images synchronously (`boolean`)
221
+ - `metadata`: include any metadata to reference at a later point (`string`)
222
+
223
+ ### Animated Gifs
224
+
225
+ Create a slideshow style gif
226
+
227
+ ```ruby
228
+ bb.get_animated_gif("gif uid")
229
+ bb.list_animated_gifs(:page => 3)
230
+ bb.create_animated_gif("template uid",
231
+ :frames => [
232
+ [ #frame 1 starts here
233
+ {
234
+ :name => "layer1",
235
+ :text => "This is my text"
236
+ },
237
+ {
238
+ :name => "photo",
239
+ :image_url => "https://www.pathtomyphoto.com/1.jpg"
240
+ }
241
+ ],
242
+ [ #frame 2 starts here
243
+ {
244
+ :name => "layer1",
245
+ :text => "This is my follow up text"
246
+ },
247
+ {
248
+ :name => "photo",
249
+ :image_url => "https://www.pathtomyphoto.com/2.jpg"
250
+ }
251
+ ]
252
+ ]
253
+ )
254
+ ```
255
+
256
+ ##### Options for `create_animated_gif`
257
+
258
+ - `frames`: an array of arrays of [modifications](https://developers.bannerbear.com/#post-v2-images) you would like to make (`array`)
259
+ - `frame_durations`: an array of times (in seconds) to show each frame (`array`)
260
+ - `input_media_url`: optionally import an external video file to use as part of the gif
261
+ - `fps`: frames per second e.g. 1 (`integer`)
262
+ - `loop`: whether to loop or not (`boolean`)
263
+ - `webhook_url`: a webhook url to post the final gif object to (`string`)
264
+ - `metadata`: include any metadata to reference at a later point (`string`)
265
+
266
+ ### Movies
267
+
268
+ Assemble video clips or still images into a single movie with transitions.
269
+
270
+ ```ruby
271
+ bb.get_movie("movie uid")
272
+ bb.list_movies(:page => 3)
273
+ bb.create_movie(:width => 800, :height => 800, :transition => "pixelize", :inputs => [
274
+ {
275
+ :asset_url => "https://images.unsplash.com/photo-1635910160061-4b688344bd20?w=500&q=60"
276
+ },
277
+ {
278
+ :asset_url => "https://i.imgur.com/fH7a5dO.png"
279
+ }
280
+ ])
281
+ ```
282
+
283
+ ##### Options for `create_movie`
284
+
285
+ - `width`: the movie width in pixels (`integer`)
286
+ - `height`: the movie height in pixels (`integer`)
287
+ - `transition`: the transition style: fade, pixelize, slidedown, slideright, slideup, slideleft (`string`)
288
+ - `inputs`: a list of [inputs](https://developers.bannerbear.com/#post-v2-movies) (`array`)
289
+ - `webhook_url`: a webhook url to post the final movie object to (`string`)
290
+ - `metadata`: include any metadata to reference at a later point (`string`)
291
+
292
+
293
+ ### Screenshots
294
+
295
+ Take screenshots of websites.
296
+
297
+ ```ruby
298
+ bb.get_screenshot("screenshot uid")
299
+ bb.list_screenshots(:page => 3)
300
+ bb.create_screenshot("https://www.bannerbear.com/",
301
+ :synchronous => true,
302
+ :width => 1000
303
+ )
304
+ ```
305
+
306
+ ##### Options for `create_screenshot`
307
+
308
+ - `width`: the desired screenshot width in pixels (`integer`)
309
+ - `height`: the desired screenshot height in pixels (`integer`)
310
+ - `synchronous`: generate the screenshot synchronously (`boolean`)
311
+ - `mobile`: use a mobile user agent
312
+ - `webhook_url`: a webhook url to post the final screenshot object to (`string`)
313
+
314
+ ### Templates
161
315
 
162
316
  ```ruby
163
- # Templates
164
317
  bb.get_template("template uid")
165
318
  bb.update_template("template uid", :name => "New Template Name", :tags => ["portrait", "instagram"])
166
319
  bb.list_templates(:page => 2, :tag => "portrait")
320
+ ```
167
321
 
168
- # Template Sets
322
+ ### Template Sets
323
+
324
+ ```ruby
169
325
  bb.get_template_set("template set uid")
170
326
  bb.list_template_sets(:page => 2)
327
+ ```
328
+
329
+ ### Video Templates
171
330
 
172
- # Video Templates
331
+ ```ruby
173
332
  bb.get_video_template("video template uid")
174
333
  bb.list_video_templates(:page => 2)
175
334
  ```
@@ -141,7 +141,14 @@ module Bannerbear
141
141
  get_response "/video_templates?#{URI.encode_www_form(params.slice(:page))}"
142
142
  end
143
143
 
144
+ # Signed URLS
144
145
 
146
+ def generate_signed_url(base_id, params = {})
147
+ base = "https://ondemand.bannerbear.com/signedurl/#{base_id}/image.jpg"
148
+ query = "?modifications=" + Base64.urlsafe_encode64(params[:modifications].to_json, :padding => false)
149
+ signature = OpenSSL::HMAC.hexdigest("SHA256", @api_key, base + query)
150
+ return base + query + "&s=" + signature
151
+ end
145
152
 
146
153
 
147
154
  private
@@ -1,3 +1,3 @@
1
1
  module Bannerbear
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
data/lib/bannerbear.rb CHANGED
@@ -1,4 +1,6 @@
1
1
  require "httparty"
2
+ require "openssl"
3
+ require "base64"
2
4
  require "bannerbear/version"
3
5
  require "bannerbear/client"
4
6
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bannerbear
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Yongfook
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-12-01 00:00:00.000000000 Z
11
+ date: 2021-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty