cdnconnect-api 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/cdnconnect_api.rb +38 -11
- data/lib/cdnconnect_api/response.rb +4 -0
- 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: 5b1927a121609f5f80071326dae5a35749b7ca64
|
4
|
+
data.tar.gz: 5d5ad9dd4d8769ea5678f26ecf00c8d3886c0b3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e660745ae9fa2805368ab3120022e464de1f901ec1266604d76ff82a332c2d4ab37e6a93dd4a04ca50bb61e0e675fd298cefa6f4fec5c3675338fae686761087
|
7
|
+
data.tar.gz: 543c7d4a4aed195bf8322913602c4410ce1968e733edd74fe9aec71337345ec4d33f215630cc435e93ace66d428c7eb02848f9ebdf9d3cef82c0d1a87ffde22c
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# CDN Connect API Ruby Client, v0.2.
|
1
|
+
# CDN Connect API Ruby Client, v0.2.1
|
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
|
|
data/lib/cdnconnect_api.rb
CHANGED
@@ -25,7 +25,7 @@ module CDNConnect
|
|
25
25
|
class APIClient
|
26
26
|
|
27
27
|
@@application_name = 'cdnconnect-api-ruby'
|
28
|
-
@@application_version = '0.2.
|
28
|
+
@@application_version = '0.2.1'
|
29
29
|
@@user_agent = @@application_name + ' v' + @@application_version
|
30
30
|
@@api_host = 'https://api.cdnconnect.com'
|
31
31
|
@@api_version = 'v1'
|
@@ -565,10 +565,23 @@ module CDNConnect
|
|
565
565
|
# @param [Hash] options
|
566
566
|
# - <code>:path</code> -
|
567
567
|
# The path to the CDN Connect object to get. (required)
|
568
|
+
# - <code>:files</code> -
|
569
|
+
# True or false value indicating if a folder's response should contain
|
570
|
+
# its sub-files or not. Default is false.
|
571
|
+
# - <code>:folders</code> -
|
572
|
+
# True or false value indicating if a folder's response should contain
|
573
|
+
# its sub-folders or not. Default is false.
|
568
574
|
# @return [APIResponse] A response object with helper methods to read the response.
|
569
575
|
def get_object(options={})
|
570
576
|
api_path = options[:path] + '.json'
|
571
|
-
|
577
|
+
data = {}
|
578
|
+
if options[:files] == true
|
579
|
+
data[:files] = true
|
580
|
+
end
|
581
|
+
if options[:folders] == true
|
582
|
+
data[:folders] = true
|
583
|
+
end
|
584
|
+
get(api_path, data)
|
572
585
|
end
|
573
586
|
|
574
587
|
|
@@ -617,9 +630,10 @@ module CDNConnect
|
|
617
630
|
# GET requests are used when reading data.
|
618
631
|
#
|
619
632
|
# @param api_path [String] The API path to send the GET request to.
|
633
|
+
# @param data [Hash] Data which will be placed in the GET request's querystring. (Optional)
|
620
634
|
# @return [APIResponse] A response object with helper methods to read the response.
|
621
|
-
def get(api_path)
|
622
|
-
fetch(:api_path => api_path, :method => 'GET')
|
635
|
+
def get(api_path, data={})
|
636
|
+
fetch(:api_path => api_path, :method => 'GET', :data => data)
|
623
637
|
end
|
624
638
|
|
625
639
|
|
@@ -628,9 +642,10 @@ module CDNConnect
|
|
628
642
|
# POST requests are used when creating data.
|
629
643
|
#
|
630
644
|
# @param api_path [String] The API path to send the POST request to.
|
645
|
+
# @param data [Hash] Data which will be sent in the POST request.
|
631
646
|
# @return [APIResponse] A response object with helper methods to read the response.
|
632
|
-
def post(api_path,
|
633
|
-
fetch(:api_path => api_path, :method => 'POST', :
|
647
|
+
def post(api_path, data)
|
648
|
+
fetch(:api_path => api_path, :method => 'POST', :data => data)
|
634
649
|
end
|
635
650
|
|
636
651
|
|
@@ -638,10 +653,11 @@ module CDNConnect
|
|
638
653
|
# Executes a PUT request to an API URL and returns a response object.
|
639
654
|
# PUT requests are used when updating data.
|
640
655
|
#
|
641
|
-
# @param api_path [String] The API path to send the
|
656
|
+
# @param api_path [String] The API path to send the PUT request to.
|
657
|
+
# @param data [Hash] Data which will be sent in the PUT request.
|
642
658
|
# @return [APIResponse] A response object with helper methods to read the response.
|
643
|
-
def put(api_path,
|
644
|
-
fetch(:api_path => api_path, :method => 'PUT', :
|
659
|
+
def put(api_path, data)
|
660
|
+
fetch(:api_path => api_path, :method => 'PUT', :data => data)
|
645
661
|
end
|
646
662
|
|
647
663
|
|
@@ -666,9 +682,19 @@ module CDNConnect
|
|
666
682
|
end
|
667
683
|
|
668
684
|
options[:headers] = { 'User-Agent' => @@user_agent }
|
669
|
-
options[:uri] = @@api_host
|
670
|
-
|
685
|
+
options[:uri] = "#{@@api_host}/#{@@api_version}/#{@app_host}#{options[:api_path]}"
|
686
|
+
|
671
687
|
options[:method] = options[:method] || 'GET'
|
688
|
+
|
689
|
+
if options[:method] == 'GET' and options[:data] != nil and options[:data].length > 0
|
690
|
+
require "addressable/uri"
|
691
|
+
uri = Addressable::URI.new
|
692
|
+
uri.query_values = options[:data]
|
693
|
+
options[:uri] = "#{options[:uri]}?#{uri.query}"
|
694
|
+
options[:data] = nil
|
695
|
+
end
|
696
|
+
|
697
|
+
options[:url] = options[:uri]
|
672
698
|
|
673
699
|
options
|
674
700
|
end
|
@@ -687,6 +713,7 @@ module CDNConnect
|
|
687
713
|
|
688
714
|
begin
|
689
715
|
# Send the request and get the response
|
716
|
+
options[:body] = options[:data]
|
690
717
|
http_response = @client.fetch_protected_resource(options)
|
691
718
|
|
692
719
|
# Return the API response
|
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.1
|
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-06-
|
11
|
+
date: 2013-06-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|