nimbu-api 0.0.1 → 0.0.2
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/lib/nimbu-api/client.rb
CHANGED
@@ -0,0 +1,26 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Nimbu
|
4
|
+
module Endpoints
|
5
|
+
class Login < Endpoint
|
6
|
+
|
7
|
+
def initialize(options={}, &block)
|
8
|
+
super
|
9
|
+
|
10
|
+
require_authentication
|
11
|
+
|
12
|
+
# fetch api token
|
13
|
+
@response = post_request("/auth/login")
|
14
|
+
end
|
15
|
+
|
16
|
+
def response
|
17
|
+
@response
|
18
|
+
end
|
19
|
+
|
20
|
+
def require_authentication
|
21
|
+
raise ArgumentError, 'A username and password is required in order to login' unless authenticated?
|
22
|
+
end
|
23
|
+
|
24
|
+
end # Authorizations
|
25
|
+
end # Endpoints
|
26
|
+
end # Nimbu
|
@@ -18,7 +18,7 @@ module Nimbu
|
|
18
18
|
require_authentication
|
19
19
|
arguments(args, :required => [:site_id])
|
20
20
|
|
21
|
-
get_request("/
|
21
|
+
get_request("/sites/#{site_id}", arguments.params)
|
22
22
|
end
|
23
23
|
alias :find :get
|
24
24
|
|
@@ -26,7 +26,7 @@ module Nimbu
|
|
26
26
|
private
|
27
27
|
|
28
28
|
def require_authentication
|
29
|
-
raise ArgumentError, 'You need to be
|
29
|
+
raise ArgumentError, 'You need to be authenticated to access the sites' unless authenticated?
|
30
30
|
end
|
31
31
|
|
32
32
|
end # Authorizations
|
@@ -7,11 +7,11 @@ module Nimbu
|
|
7
7
|
class Response::RaiseError < Faraday::Response::Middleware
|
8
8
|
|
9
9
|
def on_complete(env)
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
status_code = env[:status].to_i
|
11
|
+
service_error = Nimbu::Error::ServiceError
|
12
|
+
error_class = service_error.errors[status_code]
|
13
|
+
error_class = service_error if !error_class and (400...600).include? status_code
|
14
|
+
raise error_class.new(env) if error_class
|
15
15
|
end
|
16
16
|
|
17
17
|
end # Response::RaiseError
|
data/lib/nimbu-api/version.rb
CHANGED
data/lib/nimbu-api.rb
CHANGED
@@ -15,6 +15,7 @@ require 'nimbu-api/endpoint'
|
|
15
15
|
require 'nimbu-api/client'
|
16
16
|
|
17
17
|
require 'nimbu-api/endpoints/authorizations'
|
18
|
+
require 'nimbu-api/endpoints/login'
|
18
19
|
require 'nimbu-api/endpoints/sites'
|
19
20
|
require 'nimbu-api/endpoints/channels'
|
20
21
|
require 'nimbu-api/endpoints/channels/entries'
|
metadata
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
name: nimbu-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Peter Dedene
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
12
|
+
date: 2013-03-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -210,6 +210,7 @@ files:
|
|
210
210
|
- lib/nimbu-api/endpoints/authorizations.rb
|
211
211
|
- lib/nimbu-api/endpoints/channels.rb
|
212
212
|
- lib/nimbu-api/endpoints/channels/entries.rb
|
213
|
+
- lib/nimbu-api/endpoints/login.rb
|
213
214
|
- lib/nimbu-api/endpoints/sites.rb
|
214
215
|
- lib/nimbu-api/endpoints/videos.rb
|
215
216
|
- lib/nimbu-api/errors.rb
|
@@ -274,7 +275,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
274
275
|
- !ruby/object:Gem::Version
|
275
276
|
segments:
|
276
277
|
- 0
|
277
|
-
hash:
|
278
|
+
hash: 3347433547534944339
|
278
279
|
version: '0'
|
279
280
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
280
281
|
none: false
|
@@ -283,7 +284,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
283
284
|
- !ruby/object:Gem::Version
|
284
285
|
segments:
|
285
286
|
- 0
|
286
|
-
hash:
|
287
|
+
hash: 3347433547534944339
|
287
288
|
version: '0'
|
288
289
|
requirements: []
|
289
290
|
rubyforge_project:
|