bannerbear 0.1.0 → 0.1.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 +4 -4
- data/Gemfile.lock +2 -2
- data/README.md +153 -10
- data/bannerbear.gemspec +1 -1
- data/lib/bannerbear/client.rb +64 -1
- data/lib/bannerbear/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e7af6c8f418095cdd98b0aca144cab75fa95911d926bef172d6c3850274e3c2
|
4
|
+
data.tar.gz: f9931adef63f70a4c14b9ccee4c04b72be00c55c6c3b9ff16fbf64e764af31bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6bfc15b798a35ec932f76770f94ebb6c4bf74f3a52fd3de526301e9da9ace91476949f5f54b9b9fed1cade8d887c0cffc24c48180b6f10e62df3634ae114732d
|
7
|
+
data.tar.gz: 358759f57e2873ae5f8e4c2c5a63a14a9d19144bd2234fc58219018f5882673ae3e73096c8913c3c4a74d92b1687b2f17fb45cee43e318678bb2a9a77137e5e7
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# Bannerbear
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
Ruby wrapper for the [Bannerbear API](https://developers.bannerbear.com) - an image and video generation service.
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
@@ -22,18 +20,163 @@ Or install it yourself as:
|
|
22
20
|
|
23
21
|
## Usage
|
24
22
|
|
25
|
-
|
23
|
+
### Create the Client
|
26
24
|
|
27
|
-
|
25
|
+
Get the API key for your project in Bannerbear and create a client.
|
28
26
|
|
29
|
-
|
27
|
+
```ruby
|
28
|
+
bb = Bannerbear::Client.new("your API key")
|
29
|
+
```
|
30
30
|
|
31
|
-
|
31
|
+
Alternatively you can place your API key in an ENV variable named `BANNERBEAR_API_KEY` and create the client:
|
32
32
|
|
33
|
-
|
33
|
+
```ruby
|
34
|
+
bb = Bannerbear::Client.new
|
35
|
+
```
|
36
|
+
|
37
|
+
### Get Account Info
|
38
|
+
|
39
|
+
Return info about the Account / Project associated with this API key.
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
bb.account
|
43
|
+
```
|
44
|
+
|
45
|
+
### Create an Image
|
46
|
+
|
47
|
+
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
|
+
|
49
|
+
```ruby
|
50
|
+
bb.create_image("template uid",
|
51
|
+
:modifications => [
|
52
|
+
{
|
53
|
+
:name => "headline",
|
54
|
+
:text => "Hello World!"
|
55
|
+
},
|
56
|
+
{
|
57
|
+
:name => "photo",
|
58
|
+
:image_url => "https://images.unsplash.com/photo-1555400038-63f5ba517a47?w=1000&q=80"
|
59
|
+
}
|
60
|
+
]
|
61
|
+
)
|
62
|
+
```
|
63
|
+
|
64
|
+
You can also create images synchronously - this will take longer to respond but the image will be delivered in the response:
|
65
|
+
|
66
|
+
```ruby
|
67
|
+
bb.create_image("template uid",
|
68
|
+
:synchronous => true,
|
69
|
+
:modifications => [
|
70
|
+
{
|
71
|
+
:name => "headline",
|
72
|
+
:text => "Hello World!"
|
73
|
+
},
|
74
|
+
{
|
75
|
+
:name => "photo",
|
76
|
+
:image_url => "https://images.unsplash.com/photo-1555400038-63f5ba517a47?w=1000&q=80"
|
77
|
+
}
|
78
|
+
]
|
79
|
+
)
|
80
|
+
```
|
81
|
+
|
82
|
+
#### Options
|
83
|
+
|
84
|
+
- `modifications`: an array of [modifications](https://developers.bannerbear.com/#post-v2-images) you would like to make (`array`)
|
85
|
+
- `webhook_url`: a webhook url to post the final image object to (`string`)
|
86
|
+
- `transparent`: render image with a transparent background (`boolean`)
|
87
|
+
- `render_pdf`: render a PDF in addition to an image (`boolean`)
|
88
|
+
- `metadata`: include any metadata to reference at a later point (`string`)
|
89
|
+
|
90
|
+
### Get an Image
|
91
|
+
|
92
|
+
```ruby
|
93
|
+
bb.get_image("image uid")
|
94
|
+
```
|
95
|
+
|
96
|
+
### List all Images
|
97
|
+
|
98
|
+
```ruby
|
99
|
+
bb.list_images
|
100
|
+
```
|
34
101
|
|
35
|
-
|
102
|
+
```ruby
|
103
|
+
bb.list_images(:page => 10)
|
104
|
+
```
|
105
|
+
|
106
|
+
#### Options
|
107
|
+
|
108
|
+
- `page`: pagination (`integer`)
|
109
|
+
- `limit`: return n images per page (`integer`)
|
110
|
+
|
111
|
+
### Create a Video
|
112
|
+
|
113
|
+
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
|
+
|
115
|
+
```ruby
|
116
|
+
bb.create_video("video template uid",
|
117
|
+
:input_media_url => "https://www.yourserver.com/videos/awesome_video.mp4",
|
118
|
+
:modifications => [
|
119
|
+
{
|
120
|
+
:name => "headline",
|
121
|
+
:text => "Hello World!"
|
122
|
+
}
|
123
|
+
]
|
124
|
+
)
|
125
|
+
```
|
126
|
+
|
127
|
+
#### Options
|
128
|
+
|
129
|
+
- `input_media_url`: a url to a publicly available video file you want to import (`string`)
|
130
|
+
- `modifications`: an array of modifications you would like to make to the video overlay (`array`)
|
131
|
+
- `webhook_url`: a webhook url to post the final video object to (`string`)
|
132
|
+
- `blur`: blur the imported video from 1-10 (`integer`)
|
133
|
+
- `trim_to_length_in_seconds`: trim the video to a specific length (`integer`)
|
134
|
+
- `create_gif_preview`: create a short preview gif (`boolean`)
|
135
|
+
- `metadata`: include any metadata to reference at a later point (`string`)
|
136
|
+
|
137
|
+
If your video is using the "Multi Overlay" build pack then you can pass in a set of frames to render via:
|
138
|
+
|
139
|
+
- `frames`: an array of sets of `modifications` (`array`)
|
140
|
+
- `frame_durations`: specify the duration of each frame (`array`)
|
141
|
+
|
142
|
+
### Get a Video
|
143
|
+
|
144
|
+
```ruby
|
145
|
+
bb.get_video("video uid")
|
146
|
+
```
|
147
|
+
|
148
|
+
### List all Videos
|
149
|
+
|
150
|
+
```ruby
|
151
|
+
bb.list_videos
|
152
|
+
```
|
153
|
+
|
154
|
+
#### Options
|
155
|
+
|
156
|
+
- `page`: pagination (`integer`)
|
157
|
+
|
158
|
+
### Templates, Template Sets and Video Templates
|
159
|
+
|
160
|
+
Various operations exist for handling templates.
|
161
|
+
|
162
|
+
```ruby
|
163
|
+
# Templates
|
164
|
+
bb.get_template("template uid")
|
165
|
+
bb.update_template("template uid", :name => "New Template Name", :tags => ["portrait", "instagram"])
|
166
|
+
bb.list_templates(:page => 2, :tag => "portrait")
|
167
|
+
|
168
|
+
# Template Sets
|
169
|
+
bb.get_template_set("template set uid")
|
170
|
+
bb.list_template_sets(:page => 2)
|
171
|
+
|
172
|
+
# Video Templates
|
173
|
+
bb.get_video_template("video template uid")
|
174
|
+
bb.list_video_templates(:page => 2)
|
175
|
+
```
|
176
|
+
|
177
|
+
## Contributing
|
36
178
|
|
179
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/yongfook/bannerbear-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/yongfook/bannerbear-ruby/blob/master/CODE_OF_CONDUCT.md).
|
37
180
|
|
38
181
|
## License
|
39
182
|
|
@@ -41,4 +184,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
41
184
|
|
42
185
|
## Code of Conduct
|
43
186
|
|
44
|
-
Everyone interacting in the Bannerbear project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/
|
187
|
+
Everyone interacting in the Bannerbear project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/yongfook/bannerbear-ruby/blob/master/CODE_OF_CONDUCT.md).
|
data/bannerbear.gemspec
CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |spec|
|
|
7
7
|
spec.email = ["yongfook@gmail.com"]
|
8
8
|
|
9
9
|
spec.summary = "Ruby wrapper for the Bannerbear API"
|
10
|
-
spec.homepage = "https://
|
10
|
+
spec.homepage = "https://github.com/yongfook/bannerbear-ruby"
|
11
11
|
spec.license = "MIT"
|
12
12
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
|
13
13
|
|
data/lib/bannerbear/client.rb
CHANGED
@@ -10,6 +10,14 @@ module Bannerbear
|
|
10
10
|
get_response "/account"
|
11
11
|
end
|
12
12
|
|
13
|
+
def fonts
|
14
|
+
get_response "/fonts"
|
15
|
+
end
|
16
|
+
|
17
|
+
def effects
|
18
|
+
get_response "/effects"
|
19
|
+
end
|
20
|
+
|
13
21
|
# Images
|
14
22
|
|
15
23
|
def get_image(uid)
|
@@ -35,13 +43,68 @@ module Bannerbear
|
|
35
43
|
end
|
36
44
|
|
37
45
|
def create_video(uid, payload = {})
|
38
|
-
post_response "/videos", payload.slice(:input_media_url, :modifications, :blur, :trim_to_length_in_seconds, :webhook_url, :
|
46
|
+
post_response "/videos", payload.slice(:input_media_url, :modifications, :blur, :trim_to_length_in_seconds, :webhook_url, :metadata, :frames, :frame_durations, :create_gif_preview).merge({:video_template => uid})
|
39
47
|
end
|
40
48
|
|
41
49
|
def update_video(uid, payload = {})
|
42
50
|
patch_response "/videos", payload.slice(:transcription, :approved).merge({:uid => uid})
|
43
51
|
end
|
44
52
|
|
53
|
+
# Collections
|
54
|
+
|
55
|
+
def get_collection(uid)
|
56
|
+
get_response "/collections/#{uid}"
|
57
|
+
end
|
58
|
+
|
59
|
+
def list_collections(params = {})
|
60
|
+
get_response "/collections?#{URI.encode_www_form(params.slice(:page))}"
|
61
|
+
end
|
62
|
+
|
63
|
+
def create_collection(uid, payload = {})
|
64
|
+
post_response "/collections", payload.slice(:modifications, :webhook_url, :transparent, :metadata).merge({:template_set => uid}), payload[:synchronous]
|
65
|
+
end
|
66
|
+
|
67
|
+
# Screenshots
|
68
|
+
|
69
|
+
def get_screenshot(uid)
|
70
|
+
get_response "/screenshots/#{uid}"
|
71
|
+
end
|
72
|
+
|
73
|
+
def list_screenshots(params = {})
|
74
|
+
get_response "/screenshots?#{URI.encode_www_form(params.slice(:page))}"
|
75
|
+
end
|
76
|
+
|
77
|
+
def create_screenshot(url, payload = {})
|
78
|
+
post_response "/screenshots", payload.slice(:width, :height, :mobile, :webhook_url).merge({:url => url}), payload[:synchronous]
|
79
|
+
end
|
80
|
+
|
81
|
+
# Animated Gifs
|
82
|
+
|
83
|
+
def get_animated_gif(uid)
|
84
|
+
get_response "/animated_gifs/#{uid}"
|
85
|
+
end
|
86
|
+
|
87
|
+
def list_animated_gifs(params = {})
|
88
|
+
get_response "/animated_gifs?#{URI.encode_www_form(params.slice(:page))}"
|
89
|
+
end
|
90
|
+
|
91
|
+
def create_animated_gif(uid, payload = {})
|
92
|
+
post_response "/animated_gifs", payload.slice(:frames, :input_media_url, :webhook_url, :metadata, :loop, :frame_durations, :fps).merge({:template => uid})
|
93
|
+
end
|
94
|
+
|
95
|
+
# Movies
|
96
|
+
|
97
|
+
def get_movie(uid)
|
98
|
+
get_response "/movies/#{uid}"
|
99
|
+
end
|
100
|
+
|
101
|
+
def list_movies(params = {})
|
102
|
+
get_response "/movies?#{URI.encode_www_form(params.slice(:page))}"
|
103
|
+
end
|
104
|
+
|
105
|
+
def create_movie(payload = {})
|
106
|
+
post_response "/movies", payload.slice(:width, :height, :inputs, :transition, :soundtrack_url, :webhook_url, :metadata)
|
107
|
+
end
|
45
108
|
|
46
109
|
|
47
110
|
# Templates
|
data/lib/bannerbear/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bannerbear
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Yongfook
|
@@ -44,11 +44,11 @@ files:
|
|
44
44
|
- lib/bannerbear.rb
|
45
45
|
- lib/bannerbear/client.rb
|
46
46
|
- lib/bannerbear/version.rb
|
47
|
-
homepage: https://
|
47
|
+
homepage: https://github.com/yongfook/bannerbear-ruby
|
48
48
|
licenses:
|
49
49
|
- MIT
|
50
50
|
metadata:
|
51
|
-
homepage_uri: https://
|
51
|
+
homepage_uri: https://github.com/yongfook/bannerbear-ruby
|
52
52
|
post_install_message:
|
53
53
|
rdoc_options: []
|
54
54
|
require_paths:
|