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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 003b2a6ea479c7d10c830a1e8990ebbcb2d3cf2d
4
- data.tar.gz: a152d8dc8d7bc6c393c968b409ba4cf3eacc9e7f
3
+ metadata.gz: 5b1927a121609f5f80071326dae5a35749b7ca64
4
+ data.tar.gz: 5d5ad9dd4d8769ea5678f26ecf00c8d3886c0b3c
5
5
  SHA512:
6
- metadata.gz: b9b447175cbae4a5b6111b08e95c62566f1438810819720b11ed2bfd387e89cbd77ea9aef0f2f800a8d94b5602b3791ef039f6e23425aa3b1de29cf7c2e147fa
7
- data.tar.gz: b0952dbce2737aa3214b5f96361903ca53c4a52c6bece83f80d4178dadd27a695a90acd12a90fd5189e055e6bd7ae759c3cf99b982b4573ea931267e1a7a1e28
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.0
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
 
@@ -25,7 +25,7 @@ module CDNConnect
25
25
  class APIClient
26
26
 
27
27
  @@application_name = 'cdnconnect-api-ruby'
28
- @@application_version = '0.2.0'
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
- get(api_path)
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, body)
633
- fetch(:api_path => api_path, :method => 'POST', :body => body)
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 POST request to.
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, body)
644
- fetch(:api_path => api_path, :method => 'PUT', :body => body)
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 + '/' + @@api_version + '/' + @app_host + options[:api_path]
670
- options[:url] = options[:uri]
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
@@ -258,6 +258,10 @@ module CDNConnect
258
258
  status == 503
259
259
  end
260
260
 
261
+ def to_s # called with print / puts
262
+ "Status: #{status}\nBody: #{body}"
263
+ end
264
+
261
265
  end
262
266
 
263
267
  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.2.0
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-18 00:00:00.000000000 Z
11
+ date: 2013-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday