itrigga-admin_api_client 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -19,11 +19,4 @@ group :development do
19
19
  gem "fastercsv"
20
20
  gem "hpricot"
21
21
  gem "json_pure"
22
- end
23
-
24
- group :test do
25
- gem "rspec", "1.3.0"
26
- gem "rspec-rails", "1.3.2"
27
- gem "bundler", "~> 1.0.0"
28
- gem "rcov", ">= 0"
29
22
  end
data/Rakefile CHANGED
@@ -15,7 +15,7 @@ require 'jeweler'
15
15
  Jeweler::Tasks.new do |gem|
16
16
  # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
17
  gem.name = "itrigga-admin_api_client"
18
- gem.homepage = "http://rubygems.org/itrigga-admin_api_client"
18
+ gem.homepage = "http://rubygems.org/gems/itrigga-admin_api_client"
19
19
  gem.license = "MIT"
20
20
  gem.summary = %Q{Wraps API calls to iTrigga applications}
21
21
  gem.description = %Q{Wraps API calls to iTrigga applications}
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -0,0 +1,103 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{itrigga-admin_api_client}
8
+ s.version = "0.1.2"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Anson Kelly"]
12
+ s.date = %q{2011-10-11}
13
+ s.description = %q{Wraps API calls to iTrigga applications}
14
+ s.email = %q{support@itrigga.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".rspec",
22
+ "Gemfile",
23
+ "Gemfile.lock",
24
+ "LICENSE.txt",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "configuration.yml",
29
+ "itrigga-admin_api_client.gemspec",
30
+ "lib/trigga/admin_api_client.rb",
31
+ "lib/trigga/admin_api_client/admin_api_client.rb",
32
+ "lib/trigga/admin_api_client/proxies/admin.rb",
33
+ "lib/trigga/admin_api_client/proxies/api.rb",
34
+ "lib/trigga/admin_api_client/proxies/search_tracker.rb",
35
+ "spec/admin_api_client_spec.rb",
36
+ "spec/proxies/admin_spec.rb",
37
+ "spec/proxies/api_spec.rb",
38
+ "spec/proxies/search_tracker_spec.rb",
39
+ "spec/spec.opts",
40
+ "spec/spec_helper.rb"
41
+ ]
42
+ s.homepage = %q{http://rubygems.org/gems/itrigga-admin_api_client}
43
+ s.licenses = ["MIT"]
44
+ s.require_paths = ["lib"]
45
+ s.rubygems_version = %q{1.3.7}
46
+ s.summary = %q{Wraps API calls to iTrigga applications}
47
+
48
+ if s.respond_to? :specification_version then
49
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
50
+ s.specification_version = 3
51
+
52
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
53
+ s.add_runtime_dependency(%q<itrigga-core_ext>, [">= 0"])
54
+ s.add_runtime_dependency(%q<itrigga-param_fu>, [">= 0"])
55
+ s.add_runtime_dependency(%q<itrigga-net_helper>, [">= 0"])
56
+ s.add_runtime_dependency(%q<hashie>, [">= 0"])
57
+ s.add_development_dependency(%q<rspec>, ["= 1.3.0"])
58
+ s.add_development_dependency(%q<rspec-rails>, ["= 1.3.2"])
59
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
60
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
61
+ s.add_development_dependency(%q<rcov>, [">= 0"])
62
+ s.add_development_dependency(%q<fastercsv>, [">= 0"])
63
+ s.add_development_dependency(%q<hpricot>, [">= 0"])
64
+ s.add_development_dependency(%q<json_pure>, [">= 0"])
65
+ s.add_runtime_dependency(%q<itrigga-core_ext>, [">= 0"])
66
+ s.add_runtime_dependency(%q<itrigga-param_fu>, [">= 0"])
67
+ s.add_runtime_dependency(%q<itrigga-net_helper>, [">= 0"])
68
+ else
69
+ s.add_dependency(%q<itrigga-core_ext>, [">= 0"])
70
+ s.add_dependency(%q<itrigga-param_fu>, [">= 0"])
71
+ s.add_dependency(%q<itrigga-net_helper>, [">= 0"])
72
+ s.add_dependency(%q<hashie>, [">= 0"])
73
+ s.add_dependency(%q<rspec>, ["= 1.3.0"])
74
+ s.add_dependency(%q<rspec-rails>, ["= 1.3.2"])
75
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
76
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
77
+ s.add_dependency(%q<rcov>, [">= 0"])
78
+ s.add_dependency(%q<fastercsv>, [">= 0"])
79
+ s.add_dependency(%q<hpricot>, [">= 0"])
80
+ s.add_dependency(%q<json_pure>, [">= 0"])
81
+ s.add_dependency(%q<itrigga-core_ext>, [">= 0"])
82
+ s.add_dependency(%q<itrigga-param_fu>, [">= 0"])
83
+ s.add_dependency(%q<itrigga-net_helper>, [">= 0"])
84
+ end
85
+ else
86
+ s.add_dependency(%q<itrigga-core_ext>, [">= 0"])
87
+ s.add_dependency(%q<itrigga-param_fu>, [">= 0"])
88
+ s.add_dependency(%q<itrigga-net_helper>, [">= 0"])
89
+ s.add_dependency(%q<hashie>, [">= 0"])
90
+ s.add_dependency(%q<rspec>, ["= 1.3.0"])
91
+ s.add_dependency(%q<rspec-rails>, ["= 1.3.2"])
92
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
93
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
94
+ s.add_dependency(%q<rcov>, [">= 0"])
95
+ s.add_dependency(%q<fastercsv>, [">= 0"])
96
+ s.add_dependency(%q<hpricot>, [">= 0"])
97
+ s.add_dependency(%q<json_pure>, [">= 0"])
98
+ s.add_dependency(%q<itrigga-core_ext>, [">= 0"])
99
+ s.add_dependency(%q<itrigga-param_fu>, [">= 0"])
100
+ s.add_dependency(%q<itrigga-net_helper>, [">= 0"])
101
+ end
102
+ end
103
+
@@ -16,15 +16,19 @@ module Trigga
16
16
  url = build_url(host,endpoint,opts)
17
17
  Trigga.add_log_line("[API Client] - #{url}")
18
18
 
19
- response = Itrigga::NetHelper.do_get(url)
20
- ::Hashie::Mash.new(JSON.parse(response).merge(:status_code => 200))
19
+ response = JSON.parse(Itrigga::NetHelper.do_get(url))
20
+ ::Hashie::Mash.new(response.kind_of?(Array) ? default_response : response.merge(default_response) )
21
21
 
22
22
  rescue Exception => e
23
- Trigga.add_log_line "[API Client Error] - #{e.message}\n#{e.backtrace.join('\n')}"
23
+ Trigga.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
26
  end
27
27
 
28
+ def self.default_response
29
+ {:status_code => 200}
30
+ end
31
+
28
32
  def self.make_endpoint_absolute(endpoint)
29
33
  endpoint.to_s.match(/^\/{1}.*/) ? endpoint : "/#{endpoint}"
30
34
  end
@@ -5,13 +5,21 @@ module Trigga
5
5
 
6
6
  def self.included(base)
7
7
  base.send("extend",self)
8
- base.send(:include, Trigga::ParamFu)
9
8
  end
10
9
 
11
- def get_stats( opts )
10
+ def get_stats( opts = {})
12
11
  Trigga::AdminApiClient.make_call "admin", "stats", opts
13
12
  end
14
13
 
14
+ def get_clients(opts = {})
15
+ Trigga::AdminApiClient.make_call "admin", "clients", opts
16
+ end
17
+
18
+ def get_client(opts = {})
19
+ require_param(opts, :client_id)
20
+ Trigga::AdminApiClient.make_call "admin", "clients/#{opts[:client_id]}", opts
21
+ end
22
+
15
23
  end
16
24
  end
17
25
  end
@@ -5,7 +5,6 @@ module Trigga
5
5
 
6
6
  def self.included(base)
7
7
  base.send("extend",self)
8
- base.send(:include, Trigga::ParamFu)
9
8
  end
10
9
 
11
10
  private
@@ -5,7 +5,6 @@ module Trigga
5
5
 
6
6
  def self.included(base)
7
7
  base.send("extend",self)
8
- base.send(:include, Trigga::ParamFu)
9
8
  end
10
9
 
11
10
  end
@@ -22,6 +22,7 @@ describe Trigga::AdminApiClient do
22
22
  describe "make_call" do
23
23
  before do
24
24
  TRIGGA_ADMIN_API_CLIENT_CONFIG = {"test" => Hashie::Mash.new(:base_url => "base_url")}
25
+
25
26
  Trigga::AdminApiClient.stub!(:require_param).and_return(true)
26
27
  Trigga::AdminApiClient.stub!(:build_url).and_return("a url")
27
28
  Itrigga::NetHelper.stub!(:do_get).and_return({:response => "text"}.to_json)
@@ -1,10 +1,18 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__),'..', 'spec_helper'))
2
2
 
3
3
  class AdminApiClientProxyTest
4
+ include Trigga::ParamFu
4
5
  include Trigga::AdminApiClient::Proxies::Admin
5
6
  end
6
7
 
7
8
  describe Trigga::AdminApiClient::Proxies::Admin do
9
+ before do
10
+ AdminApiClientProxyTest.stub!(:require_one_of).and_return(true)
11
+ AdminApiClientProxyTest.stub!(:require_param).and_return(true)
12
+ Trigga::AdminApiClient.stub!(:make_call).and_return(true)
13
+ @opts = {:abc => 123, :api_key => "blah"}
14
+ end
15
+
8
16
  describe "get_stats" do
9
17
  before do
10
18
  @opts = {:abc => 123}
@@ -15,4 +23,30 @@ describe Trigga::AdminApiClient::Proxies::Admin do
15
23
  AdminApiClientProxyTest.new.get_stats @opts
16
24
  end
17
25
  end
26
+
27
+
28
+ describe "get_clients" do
29
+ it "should call make_call" do
30
+ Trigga::AdminApiClient.should_receive(:make_call).with("admin","clients",@opts)
31
+ AdminApiClientProxyTest.new.get_clients @opts
32
+ end
33
+ end
34
+
35
+
36
+ describe "get_client" do
37
+ before do
38
+ @opts = {:client_id => 42}
39
+ end
40
+
41
+ it "should require client_id" do
42
+ AdminApiClientProxyTest.should_receive(:require_param).with(@opts, :client_id)
43
+ AdminApiClientProxyTest.new.get_client @opts
44
+ end
45
+
46
+ it "should call make_call" do
47
+ Trigga::AdminApiClient.should_receive(:make_call).with("admin","clients/42",@opts)
48
+ AdminApiClientProxyTest.new.get_client @opts
49
+ end
50
+ end
51
+
18
52
  end
@@ -1,6 +1,7 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__),'..', 'spec_helper'))
2
2
 
3
3
  class ApiApiClientProxyTest
4
+ include Trigga::ParamFu
4
5
  include Trigga::AdminApiClient::Proxies::Api
5
6
  end
6
7
 
@@ -0,0 +1,9 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__),'..', 'spec_helper'))
2
+
3
+ class SearchTrackerApiClientProxyTest
4
+ include Trigga::ParamFu
5
+ include Trigga::AdminApiClient::Proxies::SearchTracker
6
+ end
7
+
8
+ describe Trigga::AdminApiClient::Proxies::SearchTracker do
9
+ end
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: 25
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.1
9
+ - 2
10
+ version: 0.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Anson Kelly
@@ -255,6 +255,7 @@ files:
255
255
  - Rakefile
256
256
  - VERSION
257
257
  - configuration.yml
258
+ - itrigga-admin_api_client.gemspec
258
259
  - lib/trigga/admin_api_client.rb
259
260
  - lib/trigga/admin_api_client/admin_api_client.rb
260
261
  - lib/trigga/admin_api_client/proxies/admin.rb
@@ -263,10 +264,11 @@ files:
263
264
  - spec/admin_api_client_spec.rb
264
265
  - spec/proxies/admin_spec.rb
265
266
  - spec/proxies/api_spec.rb
267
+ - spec/proxies/search_tracker_spec.rb
266
268
  - spec/spec.opts
267
269
  - spec/spec_helper.rb
268
270
  has_rdoc: true
269
- homepage: http://rubygems.org/itrigga-admin_api_client
271
+ homepage: http://rubygems.org/gems/itrigga-admin_api_client
270
272
  licenses:
271
273
  - MIT
272
274
  post_install_message: