cdnconnect-api 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +19 -17
- data/lib/cdnconnect_api.rb +106 -20
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6d3d3255939e60f875633fb33fc3d0a5f2a52e2
|
4
|
+
data.tar.gz: 58ec54989764b9eb02b4d59802caddbda326dffb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42d5a6ea40556f3dced79a275fb61be47b83446e3588ea83a54a8b2de7da9f94d87fcf8d49219fd778c419750005b8af5e931f5920b0f3c5989063772fbb064a
|
7
|
+
data.tar.gz: 8369b89dc1e239689322b7df3d22ba0c5c65b97efa8701e4d1767520505d375e390b4f9ff0ae5fd161f002e5f9a149d16b822f1b8828772a6fb35cec6a1d6c64
|
data/README.md
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
# CDN Connect API Ruby Client, v0.0.
|
2
|
-
|
3
|
-
## Description
|
1
|
+
# CDN Connect API Ruby Client, v0.0.2
|
4
2
|
|
5
3
|
The CDN Connect API Ruby Client makes it easier to upload files and interact with
|
6
4
|
our API. Most interactions with CDN Connect APIs require users to authorize applications via OAuth 2.0. This library simplifies the communication with CDN Connect even further allowing you
|
@@ -10,9 +8,11 @@ to easily upload files and get information with only a few lines of code.
|
|
10
8
|
|
11
9
|
$ sudo gem install cdnconnect-api
|
12
10
|
|
11
|
+
[RubyGems.org: cdnconnect-api](https://rubygems.org/gems/cdnconnect-api)
|
12
|
+
|
13
13
|
## API Key
|
14
14
|
|
15
|
-
An API Key
|
15
|
+
An API Key can be created for a specific app within your CDN Connect's account. Sign into your account and go to the "API Key" tab for the app you want to interact with. Next click "Add API Key" and use this value when creating a new API client within the code. The API Key can be revoked
|
16
16
|
by you at any time and numerous keys can be created.
|
17
17
|
|
18
18
|
## Example Usage
|
@@ -47,25 +47,27 @@ An object can be either a file or a folder. Pass the `get` method the `url` you
|
|
47
47
|
|
48
48
|
All responses will be structured the same with both a `results` and `msgs` object at the root level, such as:
|
49
49
|
|
50
|
-
|
50
|
+
{
|
51
51
|
"results":
|
52
52
|
{
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
53
|
+
"data":
|
54
|
+
{
|
55
|
+
"id": "bU1SS1JyvF9I",
|
56
|
+
"status": 1,
|
57
|
+
"name": "images",
|
58
|
+
"created": "2013-03-12T17:02Z",
|
59
|
+
"parent_id": "iF637hnbwI4G",
|
60
|
+
"folder": true,
|
61
|
+
"files": [],
|
62
|
+
"folders": []
|
63
63
|
}
|
64
64
|
},
|
65
65
|
"msgs":[]
|
66
|
-
|
66
|
+
}
|
67
|
+
|
68
|
+
The `results` object contains the guts of the information your looking for, and the `msgs` object contains an array of messages which can represent errors, warnings and information. The `results` object can be null, or it can contain many objects within it. Each response can have different data within `results` object and `msgs` object. In the case above, the `results` object contains the key `data`, and within the `data` object it contains summary information of the images folder.
|
69
|
+
|
67
70
|
|
68
|
-
The `results` object contains the guts of the information your looking for, and the `msgs` object contains an array of messages which can represent errors, warnings and information. The `results` object can be null, or it can contain many objects within it. Each response can have different data within `results` object and `msgs` object. In the case above, the `results` object contains the key `data`, and within the `data` object it contains summary information of the images folder.
|
69
71
|
|
70
72
|
## Support
|
71
73
|
|
data/lib/cdnconnect_api.rb
CHANGED
@@ -23,7 +23,7 @@ module CDNConnect
|
|
23
23
|
class APIClient
|
24
24
|
|
25
25
|
@@application_name = 'cdnconnect-api-ruby'
|
26
|
-
@@application_version = '0.0
|
26
|
+
@@application_version = '0.1.0'
|
27
27
|
@@api_host = 'https://api.cdnconnect.com'
|
28
28
|
@@user_agent = @@application_name + ' v' + @@application_version
|
29
29
|
|
@@ -42,11 +42,13 @@ module CDNConnect
|
|
42
42
|
# include application/json, application/xml. JSON is the default.
|
43
43
|
# - <code>:client_id</code> -
|
44
44
|
# A unique identifier issued to the client to identify itself to CDN Connect's
|
45
|
-
# authorization server. This is issued by CDN Connect to
|
45
|
+
# authorization server. This is issued by CDN Connect to external clients.
|
46
|
+
# This is only needed if an API Key isn't already known.
|
46
47
|
# - <code>:client_secret</code> -
|
47
|
-
# A
|
48
|
+
# A secret issued by the CDN Connect's authorization server,
|
48
49
|
# which is used to authenticate the client. Do not confuse this is an access_token
|
49
|
-
# or an api_key.
|
50
|
+
# or an api_key. This is only required if an API Key
|
51
|
+
# isn't already known. A client secret should not be shared.
|
50
52
|
# - <code>:scope</code> -
|
51
53
|
# The scope of the access request, expressed either as an Array
|
52
54
|
# or as a space-delimited String.
|
@@ -88,23 +90,53 @@ module CDNConnect
|
|
88
90
|
|
89
91
|
|
90
92
|
##
|
91
|
-
#
|
92
|
-
#
|
93
|
-
# app_id and obj_id.
|
93
|
+
# Executes a GET request to an API URL and returns a response object.
|
94
|
+
# GET requests are used when reading data.
|
94
95
|
#
|
95
|
-
# @param [
|
96
|
-
#
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
#
|
106
|
-
|
107
|
-
|
96
|
+
# @param url [String] The API URL to send a GET request to.
|
97
|
+
# @return [APIResponse] A response object with helper methods to read the response.
|
98
|
+
def get(url)
|
99
|
+
options[:path] = url
|
100
|
+
options[:method] = 'GET'
|
101
|
+
return self.fetch(options)
|
102
|
+
end
|
103
|
+
|
104
|
+
|
105
|
+
##
|
106
|
+
# Executes a POST request to an API URL and returns a response object.
|
107
|
+
# POST requests are used when creating data.
|
108
|
+
#
|
109
|
+
# @param url [String] The API URL to send a POST request to.
|
110
|
+
# @return [APIResponse] A response object with helper methods to read the response.
|
111
|
+
def post(url)
|
112
|
+
options[:path] = url
|
113
|
+
options[:method] = 'POST'
|
114
|
+
return self.fetch(options)
|
115
|
+
end
|
116
|
+
|
117
|
+
|
118
|
+
##
|
119
|
+
# Executes a PUT request to an API URL and returns a response object.
|
120
|
+
# PUT requests are used when updating data.
|
121
|
+
#
|
122
|
+
# @param url [String] The API URL to send a GET request to.
|
123
|
+
# @return [APIResponse] A response object with helper methods to read the response.
|
124
|
+
def post(url)
|
125
|
+
options[:path] = url
|
126
|
+
options[:method] = 'POST'
|
127
|
+
return self.fetch(options)
|
128
|
+
end
|
129
|
+
|
130
|
+
|
131
|
+
##
|
132
|
+
# Executes a DELETE request to an API URL and returns a response object.
|
133
|
+
# DELETE requests are used when (you guessed it) deleting data.
|
134
|
+
#
|
135
|
+
# @param url [String] The API URL to send a DELETE request to.
|
136
|
+
# @return [APIResponse] A response object with helper methods to read the response.
|
137
|
+
def delete(url)
|
138
|
+
options[:path] = url
|
139
|
+
options[:method] = 'DELETE'
|
108
140
|
return self.fetch(options)
|
109
141
|
end
|
110
142
|
|
@@ -127,6 +159,7 @@ module CDNConnect
|
|
127
159
|
# are not provided then you must use the url option.
|
128
160
|
# - <code>:source_file_local_path</code> -
|
129
161
|
# A string of a source file's local paths to upload.
|
162
|
+
# @return [APIResponse] A response object with helper methods to read the response.
|
130
163
|
def upload(options={})
|
131
164
|
# Make sure we've got good data before starting the upload
|
132
165
|
prepare_upload(options)
|
@@ -278,6 +311,11 @@ module CDNConnect
|
|
278
311
|
# path common needed by a few methods.
|
279
312
|
# @!visibility private
|
280
313
|
def generate_obj_path(options={})
|
314
|
+
path = options[:path]
|
315
|
+
if path != nil
|
316
|
+
return path
|
317
|
+
end
|
318
|
+
|
281
319
|
app_id = options[:app_id]
|
282
320
|
obj_id = options[:obj_id]
|
283
321
|
uri = options[:uri] || options[:url]
|
@@ -350,36 +388,84 @@ module CDNConnect
|
|
350
388
|
end
|
351
389
|
|
352
390
|
end
|
391
|
+
# - <code>:code</code> -
|
392
|
+
# The authorization code received from the authorization server.
|
393
|
+
# - <code>:redirect_uri</code> -
|
394
|
+
# The redirection URI used in the initial request.
|
395
|
+
# - <code>:access_token</code> -
|
396
|
+
# The current access token for this client, also known as the API Key.
|
353
397
|
|
354
398
|
|
399
|
+
##
|
400
|
+
# A unique identifier issued to the client to identify itself to CDN Connect's
|
401
|
+
# authorization server. This is issued by CDN Connect to external clients.
|
402
|
+
# This is only needed if an API Key isn't already known.
|
403
|
+
#
|
404
|
+
# @return [String]
|
355
405
|
def client_id
|
356
406
|
@client_id
|
357
407
|
end
|
358
408
|
|
409
|
+
|
410
|
+
##
|
411
|
+
# A secret issued by the CDN Connect's authorization server,
|
412
|
+
# which is used to authenticate the client. Do not confuse this is an access_token
|
413
|
+
# or an api_key. This is only required if an API Key
|
414
|
+
# isn't already known. A client secret should not be shared.
|
415
|
+
#
|
416
|
+
# @return [String]
|
359
417
|
def client_secret
|
360
418
|
@client_secret
|
361
419
|
end
|
362
420
|
|
421
|
+
|
422
|
+
##
|
423
|
+
# The scope of the access request, expressed either as an Array
|
424
|
+
# or as a space-delimited String. This is only required if an API Key
|
425
|
+
# isn't already known.
|
426
|
+
#
|
427
|
+
# @return [String]
|
363
428
|
def scope
|
364
429
|
@scope
|
365
430
|
end
|
366
431
|
|
432
|
+
|
433
|
+
##
|
434
|
+
# An unguessable random string designed to allow the client to maintain state
|
435
|
+
# to protect against cross-site request forgery attacks.
|
436
|
+
# This is only required if an API Key isn't already known.
|
437
|
+
#
|
438
|
+
# @return [String]
|
367
439
|
def state
|
368
440
|
@state
|
369
441
|
end
|
370
442
|
|
443
|
+
|
444
|
+
# @return [String]
|
371
445
|
def code
|
372
446
|
@code
|
373
447
|
end
|
374
448
|
|
449
|
+
|
450
|
+
# @return [String]
|
375
451
|
def redirect_uri
|
376
452
|
@redirect_uri
|
377
453
|
end
|
378
454
|
|
455
|
+
|
456
|
+
# @return [String]
|
379
457
|
def access_token
|
380
458
|
@access_token
|
381
459
|
end
|
382
460
|
|
461
|
+
|
462
|
+
# @return [String]
|
463
|
+
def api_key
|
464
|
+
@access_token
|
465
|
+
end
|
466
|
+
|
467
|
+
|
468
|
+
# @return [String]
|
383
469
|
def response_format
|
384
470
|
@response_format
|
385
471
|
end
|
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.0
|
4
|
+
version: 0.1.0
|
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-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -38,7 +38,11 @@ dependencies:
|
|
38
38
|
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 0.4.5
|
41
|
-
description: CDN Connect API Ruby Client
|
41
|
+
description: The CDN Connect API Ruby Client makes it easier to upload files and interact
|
42
|
+
with our API. Most interactions with CDN Connect APIs require users to authorize
|
43
|
+
applications via OAuth 2.0. This library simplifies the communication with CDN Connect
|
44
|
+
even further allowing you to easily upload files and get information with only a
|
45
|
+
few lines of code.
|
42
46
|
email: developer@cdnconnect.com
|
43
47
|
executables: []
|
44
48
|
extensions: []
|