cdnconnect-api 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -3
- data/lib/cdnconnect_api.rb +20 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e14424ffa772eae0884c92cbe5ca7f372c708dff
|
4
|
+
data.tar.gz: 8acc7e7039ecd25f8962738a20c63f5e0d94c5b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc1434d7a16cda0a7e02bfdce07a0a5664d38a358afb0867b78d41f64b7b0ce7026d9eb8eb1eb403fae6ca64ddf5e89d5f022524160fa2038e84937a89dce4cb
|
7
|
+
data.tar.gz: fe16c5b082c3dcdf28b00292b685a9d2b53e47101380f3290e6385422624660f106c1fab53b07cbf9fc73a4c8121ee19cefe347e6d1fcee816ff6a67b8dabd8a
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# CDN Connect API Ruby Client, v0.2.
|
1
|
+
# CDN Connect API Ruby Client, v0.2.2
|
2
2
|
|
3
3
|
CDN Connect makes it easier to manage production assets for teams of developers and designers, all while serving files from a fast content delivery network. Features include image optimization, resizing, cropping, filters, changing output formats, convert to WebP image format, etc. The CDN Connect API Ruby Client makes it easier to upload files and interact with the API with only a few lines of code.
|
4
4
|
|
@@ -44,7 +44,8 @@ Below are the possible parameters for the `upload` method. You must set `destina
|
|
44
44
|
- `valid_extensions` : An array of valid extensions which should be uploaded. This is only applied when the `source_folder_path` options is used. If nothing is provided, which is the default, all files within the folder are uploaded. The extensions should be in all lower case, and they should not contain a period or asterisks. Example `valid_extensions => ['js', 'css', 'jpg', jpeg', 'png', 'gif', 'webp']`
|
45
45
|
- `recursive_local_folders` : A true or false value indicating if this call should recursively upload all of the local folder's sub-folders, and their sub-folders, etc. This option is only used when the `source_folder_path` option is used.
|
46
46
|
- `async` : A true or false value indicating if the processing of the data should be asynchronous or not. The default value is false meaning that the processing of the data will be synchronous. An async response will be faster because the resposne doesn't wait on the system to complete processing the data. However, because an async response does not wait for the data to complete processing then the response will not contain any information about the data which was just uploaded. Use async only if you do not need to know the details of the upload.
|
47
|
-
- `webhook_url` : A URL which the system should `POST` the response to. This works for both synchronous and asynchronous calls. The data sent to the `webhook_url` will be the same as the data that is
|
47
|
+
- `webhook_url` : A URL which the system should `POST` the response to. This works for both synchronous and asynchronous calls. The data sent to the `webhook_url` will be the same as the data that is responded in a synchronous response, and is sent within the `data` parameter. The format sent can be in either `json` or `xml` by using the `webhook_format` parameter. By default there is no webhook URL.
|
48
|
+
- `webhook_format` : When a `webhook_url` is provided, you can have the data formatted as either `json` or `xml`. The defautl format is `json`.
|
48
49
|
|
49
50
|
### Upload One File: `source_file_path`
|
50
51
|
|
@@ -83,11 +84,16 @@ Both files and folders are considered "objects", and object data contains inform
|
|
83
84
|
response = api_client.get_object(:path => '/images/spacewalk.jpg')
|
84
85
|
|
85
86
|
|
86
|
-
#### Get Folder Information
|
87
|
+
#### Get Folder's Basic Information
|
87
88
|
|
88
89
|
response = api_client.get_object(:path => '/images')
|
89
90
|
|
90
91
|
|
92
|
+
#### Get Folder's Sub-Files and Sub-Folders
|
93
|
+
|
94
|
+
response = api_client.get_object(:path => '/images', :files => true, :folders => true)
|
95
|
+
|
96
|
+
|
91
97
|
## Rename File or Folder
|
92
98
|
|
93
99
|
Renames a file or folder, which are both also known as an object.
|
data/lib/cdnconnect_api.rb
CHANGED
@@ -150,7 +150,13 @@ module CDNConnect
|
|
150
150
|
# - <code>:webhook_url</code> -
|
151
151
|
# A URL which the system should `POST` the response to. This works for both synchronous
|
152
152
|
# and asynchronous calls. The data sent to the `webhook_url` will be the same as the
|
153
|
-
# data that is
|
153
|
+
# data that is responded in a synchronous response, and is sent within the `data`
|
154
|
+
# parameter. The format sent can be in either `json` or `xml` by using the
|
155
|
+
# `webhook_format` parameter. By default there is no webhook URL.
|
156
|
+
# - <code>:webhook_format</code> -
|
157
|
+
# When a `webhook_url` is provided, you can have the data formatted as either `json`
|
158
|
+
# or `xml`. The defautl format is `json`.
|
159
|
+
#
|
154
160
|
# @return [APIResponse] A response object with helper methods to read the response.
|
155
161
|
def upload(options={})
|
156
162
|
# Make sure we've got good source data before starting the upload
|
@@ -196,7 +202,9 @@ module CDNConnect
|
|
196
202
|
post_data = build_post_data(destination_path,
|
197
203
|
max_files_per_request = 25,
|
198
204
|
max_request_size = 25165824,
|
199
|
-
async = options.fetch(:async, false)
|
205
|
+
async = options.fetch(:async, false),
|
206
|
+
webhook_url = options[:webhook_url],
|
207
|
+
webhook_format = options[:webhook_format])
|
200
208
|
|
201
209
|
# Build the request to send to the API
|
202
210
|
# Uses the Faraday: https://github.com/lostisland/faraday
|
@@ -247,7 +255,7 @@ module CDNConnect
|
|
247
255
|
##
|
248
256
|
# Build the POST data that gets sent in the request
|
249
257
|
# @!visibility private
|
250
|
-
def build_post_data(destination_path, max_files_per_request = 25, max_request_size = 25165824, async = false)
|
258
|
+
def build_post_data(destination_path, max_files_per_request = 25, max_request_size = 25165824, async = false, webhook_url = nil, webhook_format = nil)
|
251
259
|
# @active_uploads will hold all of the upload keys
|
252
260
|
# which are actively being uploaded.
|
253
261
|
@active_uploads = []
|
@@ -261,6 +269,15 @@ module CDNConnect
|
|
261
269
|
# Processing of the data can be async. However, an async response will
|
262
270
|
# not contain any information about the data uploaded.
|
263
271
|
post_data[:async] = async
|
272
|
+
|
273
|
+
# send with the post data the webhook_url if there is one
|
274
|
+
if webhook_url != nil
|
275
|
+
post_data[:webhook_url] = webhook_url
|
276
|
+
# send in the webhook_format, but defaults to json if nothing sent
|
277
|
+
if webhook_format != nil
|
278
|
+
post_data[:webhook_format] = webhook_format
|
279
|
+
end
|
280
|
+
end
|
264
281
|
|
265
282
|
# Mime type doesn't matter because it gets figured out on the server-side
|
266
283
|
# using the file extension. So be sure file extensions are valid!
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cdnconnect-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Bradley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|