itrigga-admin_api_client 0.2.0 → 0.2.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.
data/README.rdoc CHANGED
@@ -22,12 +22,14 @@ And returns:
22
22
  "aggregated" => 1,
23
23
  "editorial" => 22
24
24
  },
25
- "status_code" => 200,
26
25
  "max_scheduled_job_id" => 1252
27
26
  }
28
27
 
29
- Each call will return results as a Mash.
30
-
28
+ Each call will return results as a Mash with 2 keys:
29
+ {
30
+ :status_code - the HTTP status code (200 for a success)
31
+ :data - whatever the api call returned (in the example above this would be a hash)
32
+ }
31
33
  Each call will return a :status_code (normally 200 for when it went ok, else an error code eg 500)
32
34
 
33
35
  If an error occurs a Mash will be returned like:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{itrigga-admin_api_client}
8
- s.version = "0.2.0"
8
+ s.version = "0.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Anson Kelly"]
12
- s.date = %q{2011-10-17}
12
+ s.date = %q{2011-10-18}
13
13
  s.description = %q{Wraps API calls to iTrigga applications}
14
14
  s.email = %q{support@itrigga.com}
15
15
  s.extra_rdoc_files = [
@@ -2,14 +2,12 @@
2
2
  this_dir = File.dirname(__FILE__)
3
3
  $: << this_dir unless $:.include?(this_dir)
4
4
 
5
- #require 'faster_csv'
6
5
  require 'yaml'
7
6
  require 'hashie'
8
7
  require 'core_ext'
9
8
  require 'trigga/param_fu'
10
9
  require 'net_helper'
11
10
 
12
- #require 'trigga/param_fu'
13
11
  Dir[File.join(File.dirname(File.expand_path(__FILE__)),"admin_api_client","proxies","*.rb")].each {|f| require f }
14
12
  Dir[File.join(File.dirname(File.expand_path(__FILE__)),"admin_api_client","*.rb")].each {|f| require f }
15
13
 
@@ -17,17 +17,13 @@ module Itrigga
17
17
  Itrigga.add_log_line("[API Client] - #{url}")
18
18
 
19
19
  response = JSON.parse(Itrigga::NetHelper.do_get(url))
20
- ::Hashie::Mash.new(response.kind_of?(Array) ? default_response : response.merge(default_response) )
20
+ ::Hashie::Mash.new(:status_code => 200, :data => response )
21
21
 
22
22
  rescue Exception => e
23
23
  Itrigga.add_log_line "[API Client Error] - #{e.message}\n#{e.backtrace.join('\n')}" if RAILS_ENV == "development"
24
24
  ::Hashie::Mash.new(:error => e.message, :status_code => status_code_from_error(e.message))
25
25
  end
26
- end
27
-
28
- def self.default_response
29
- {:status_code => 200}
30
- end
26
+ end
31
27
 
32
28
  def self.make_endpoint_absolute(endpoint)
33
29
  endpoint.to_s.match(/^\/{1}.*/) ? endpoint : "/#{endpoint}"
@@ -55,7 +55,7 @@ describe Itrigga::AdminApiClient do
55
55
  end
56
56
 
57
57
  it "should return a mash with the status code" do
58
- Itrigga::AdminApiClient.make_call("test","stats",@opts).should == Hashie::Mash.new(:response => "text", :status_code => 200)
58
+ Itrigga::AdminApiClient.make_call("test","stats",@opts).should == Hashie::Mash.new(:data => { :response => "text" }, :status_code => 200)
59
59
  end
60
60
 
61
61
  describe "when an error occurs" do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: itrigga-admin_api_client
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 0
10
- version: 0.2.0
9
+ - 1
10
+ version: 0.2.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Anson Kelly
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-10-17 00:00:00 +01:00
18
+ date: 2011-10-18 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency