nineflats-api 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -36,6 +36,10 @@ module Nineflats
36
36
  request_token.get_access_token(:oauth_verifier => verifier)
37
37
  end
38
38
 
39
+ def authorized?
40
+ !access_token.nil?
41
+ end
42
+
39
43
  private
40
44
 
41
45
  def initialize(api_key, api_secret, options={})
@@ -0,0 +1,3 @@
1
+ module Nineflats
2
+ class NotAuthenticatedException < StandardError; end
3
+ end
@@ -17,13 +17,11 @@ module Nineflats
17
17
  end # user
18
18
 
19
19
  def bookings(user_id)
20
+ raise Nineflats::NotAuthenticatedException.new("User is not authenticated yet!") unless Client.client.authorized?
21
+
20
22
  params = {:client_id => consumer.key}
21
- if client.access_token
22
- response = client.access_token.request(:get, "/api/v1/users/#{user_id}/bookings?#{Nineflats::QueryStringNormalizer.normalize(params)}")
23
- JSON.parse(response.body)
24
- else
25
- raise "So what?"
26
- end
23
+ response = client.access_token.request(:get, "/api/v1/users/#{user_id}/bookings?#{Nineflats::QueryStringNormalizer.normalize(params)}")
24
+ JSON.parse(response.body)
27
25
  end # bookings
28
26
 
29
27
  end
@@ -1,5 +1,5 @@
1
1
  module Nineflats
2
2
  module Api
3
- VERSION = "0.0.6"
3
+ VERSION = "0.0.7"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nineflats-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,12 +10,12 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2011-11-02 00:00:00.000000000 +01:00
13
+ date: 2011-11-03 00:00:00.000000000 +01:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: oauth
18
- requirement: &2152423640 !ruby/object:Gem::Requirement
18
+ requirement: &2152501520 !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
21
  - - ! '>='
@@ -23,10 +23,10 @@ dependencies:
23
23
  version: '0'
24
24
  type: :runtime
25
25
  prerelease: false
26
- version_requirements: *2152423640
26
+ version_requirements: *2152501520
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
- requirement: &2152422700 !ruby/object:Gem::Requirement
29
+ requirement: &2152500600 !ruby/object:Gem::Requirement
30
30
  none: false
31
31
  requirements:
32
32
  - - ~>
@@ -34,10 +34,10 @@ dependencies:
34
34
  version: 0.9.0
35
35
  type: :development
36
36
  prerelease: false
37
- version_requirements: *2152422700
37
+ version_requirements: *2152500600
38
38
  - !ruby/object:Gem::Dependency
39
39
  name: rspec
40
- requirement: &2152421900 !ruby/object:Gem::Requirement
40
+ requirement: &2152499760 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
43
  - - ! '>='
@@ -45,10 +45,10 @@ dependencies:
45
45
  version: '0'
46
46
  type: :development
47
47
  prerelease: false
48
- version_requirements: *2152421900
48
+ version_requirements: *2152499760
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: fakeweb
51
- requirement: &2152403820 !ruby/object:Gem::Requirement
51
+ requirement: &2152499060 !ruby/object:Gem::Requirement
52
52
  none: false
53
53
  requirements:
54
54
  - - ! '>='
@@ -56,7 +56,7 @@ dependencies:
56
56
  version: '0'
57
57
  type: :development
58
58
  prerelease: false
59
- version_requirements: *2152403820
59
+ version_requirements: *2152499060
60
60
  description: Let's you use the 9flats API'
61
61
  email:
62
62
  - lena@zeromail.org
@@ -73,6 +73,7 @@ files:
73
73
  - lib/nineflats-api/base.rb
74
74
  - lib/nineflats-api/calendar.rb
75
75
  - lib/nineflats-api/client.rb
76
+ - lib/nineflats-api/errors.rb
76
77
  - lib/nineflats-api/helpers.rb
77
78
  - lib/nineflats-api/paginated_array.rb
78
79
  - lib/nineflats-api/photo.rb
@@ -117,7 +118,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
117
118
  version: '0'
118
119
  segments:
119
120
  - 0
120
- hash: -279830250257948186
121
+ hash: 4559477721164976265
121
122
  required_rubygems_version: !ruby/object:Gem::Requirement
122
123
  none: false
123
124
  requirements:
@@ -126,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
127
  version: '0'
127
128
  segments:
128
129
  - 0
129
- hash: -279830250257948186
130
+ hash: 4559477721164976265
130
131
  requirements: []
131
132
  rubyforge_project:
132
133
  rubygems_version: 1.6.2