unipass_api 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -8,18 +8,22 @@ This is wrapper for Unipass REST API. In order to use it, you will need to get u
8
8
 
9
9
  Add to your `Gemfile` following line:
10
10
 
11
- gem 'unipass_api'
11
+ ``` ruby
12
+ gem 'unipass_api'
13
+ ```
12
14
 
13
15
  Create `config/initializers/unipass_api.rb` with configuration options:
14
16
 
15
- UnipassApi.configure do |config|
16
- config.client_id = 'some_client_id'
17
- config.client_secret = 'some_client_secret'
18
- config.site = 'some_site'
19
- config.api_site = 'some_api_site'
20
- config.authorize_url = 'some_authorize_url'
21
- config.token_url = 'some_token_url'
22
- end
17
+ ``` ruby
18
+ UnipassApi.configure do |config|
19
+ config.client_id = 'some_client_id'
20
+ config.client_secret = 'some_client_secret'
21
+ config.site = 'some_site'
22
+ config.api_site = 'some_api_site'
23
+ config.authorize_url = 'some_authorize_url'
24
+ config.token_url = 'some_token_url'
25
+ end
26
+ ```
23
27
 
24
28
  And you are ready to go.
25
29
 
@@ -27,41 +31,48 @@ And you are ready to go.
27
31
 
28
32
  Assuming you are using omniauth, and you are succesfull logged in into unipass, you can create client in your application controller:
29
33
 
30
- def unipass_api(force_refresh_token = false)
31
- @unipass_api ||= UnipassApi::Client.new(
32
- :access_token => session[:access_token],
33
- :expires_at => session[:access_token_expires_at],
34
- :refresh_token => session[:refresh_token]
35
- )
36
- if @unipass_api.expired? || force_refresh_token
37
- @unipass_api.refresh!
38
- session[:access_token] = @unipass_api.access_token
39
- session[:access_token_expires_at] = @unipass_api.expires_at
40
- session[:refresh_token] = @unipass_api.refresh_token
41
- end
42
- @unipass_api
43
- end
34
+ ``` ruby
35
+ def unipass_api(force_refresh_token = false)
36
+ @unipass_api ||= UnipassApi::Client.new(
37
+ :access_token => session[:access_token],
38
+ :expires_at => session[:access_token_expires_at],
39
+ :refresh_token => session[:refresh_token]
40
+ )
41
+ if @unipass_api.expired? || force_refresh_token
42
+ @unipass_api.refresh!
43
+ session[:access_token] = @unipass_api.access_token
44
+ session[:access_token_expires_at] = @unipass_api.expires_at
45
+ session[:refresh_token] = @unipass_api.refresh_token
46
+ end
47
+ @unipass_api
48
+ end
49
+ ```
44
50
 
45
51
  And then you can just use it as follows:
46
52
 
47
- unipass_api.post('groups', :params => {:name => 'group_name'})
53
+ ``` ruby
54
+ unipass_api.post('groups', :params => {:name => 'group_name'})
55
+ ```
48
56
 
49
57
  ## Adding property ##
50
58
 
51
- @property = begin
52
- unipass_api.post("me/properties/weight", :params => {:value => '57 kg'})
53
- rescue UnipassApi::ResourceInvalid => error
54
- @errors = error.response.parsed
55
- render :show and return
56
- end
59
+ ``` ruby
60
+ @property = begin
61
+ unipass_api.post("me/properties/weight", :params => {:value => '57 kg'})
62
+ rescue UnipassApi::ResourceInvalid => error
63
+ @errors = error.response.parsed
64
+ render :show and return
65
+ end
66
+ ```
57
67
 
58
68
  ## Showing property ##
59
69
 
60
- @property = begin
61
- unipass_api.get("me/properties/#{key}")
62
- rescue UnipassApi::ResourceNotFound
63
- nil
64
- end
65
-
70
+ ``` ruby
71
+ @property = begin
72
+ unipass_api.get("me/properties/#{key}")
73
+ rescue UnipassApi::ResourceNotFound
74
+ nil
75
+ end
76
+ ```
66
77
 
67
78
 
@@ -1,3 +1,3 @@
1
1
  module UnipassApi
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/unipass_api.gemspec CHANGED
@@ -14,7 +14,6 @@ Gem::Specification.new do |gem|
14
14
  gem.require_paths = ['lib']
15
15
  gem.version = UnipassApi::VERSION
16
16
 
17
- gem.add_dependency 'omniauth', '~> 0.3.2'
18
17
  gem.add_dependency 'oauth2'
19
18
  gem.add_dependency 'rake'
20
19
  end
metadata CHANGED
@@ -1,78 +1,47 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: unipass_api
3
- version: !ruby/object:Gem::Version
4
- hash: 29
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 1
10
- version: 0.0.1
11
6
  platform: ruby
12
- authors:
13
- - "Aleksadner D\xC4\x85browski"
7
+ authors:
8
+ - Aleksadner Dąbrowski
14
9
  - Karol Sarnacki
15
10
  autorequire:
16
11
  bindir: bin
17
12
  cert_chain: []
18
-
19
- date: 2011-11-07 00:00:00 Z
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
22
- type: :runtime
23
- requirement: &id001 !ruby/object:Gem::Requirement
13
+ date: 2012-02-23 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: oauth2
17
+ requirement: &70184899560120 !ruby/object:Gem::Requirement
24
18
  none: false
25
- requirements:
26
- - - ~>
27
- - !ruby/object:Gem::Version
28
- hash: 23
29
- segments:
30
- - 0
31
- - 3
32
- - 2
33
- version: 0.3.2
34
- prerelease: false
35
- name: omniauth
36
- version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
38
23
  type: :runtime
39
- requirement: &id002 !ruby/object:Gem::Requirement
40
- none: false
41
- requirements:
42
- - - ">="
43
- - !ruby/object:Gem::Version
44
- hash: 3
45
- segments:
46
- - 0
47
- version: "0"
48
24
  prerelease: false
49
- name: oauth2
50
- version_requirements: *id002
51
- - !ruby/object:Gem::Dependency
52
- type: :runtime
53
- requirement: &id003 !ruby/object:Gem::Requirement
25
+ version_requirements: *70184899560120
26
+ - !ruby/object:Gem::Dependency
27
+ name: rake
28
+ requirement: &70184899559240 !ruby/object:Gem::Requirement
54
29
  none: false
55
- requirements:
56
- - - ">="
57
- - !ruby/object:Gem::Version
58
- hash: 3
59
- segments:
60
- - 0
61
- version: "0"
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
62
35
  prerelease: false
63
- name: rake
64
- version_requirements: *id003
36
+ version_requirements: *70184899559240
65
37
  description: Unipass client API
66
- email:
38
+ email:
67
39
  - aleksander.dabrowski@connectmedica.com
68
40
  - karol.sarnacki@connectmedica.pl
69
41
  executables: []
70
-
71
42
  extensions: []
72
-
73
43
  extra_rdoc_files: []
74
-
75
- files:
44
+ files:
76
45
  - .gitignore
77
46
  - Gemfile
78
47
  - README.md
@@ -88,36 +57,34 @@ files:
88
57
  - unipass_api.gemspec
89
58
  homepage: https://github.com/tjeden/unipass-api
90
59
  licenses: []
91
-
92
60
  post_install_message:
93
61
  rdoc_options: []
94
-
95
- require_paths:
62
+ require_paths:
96
63
  - lib
97
- required_ruby_version: !ruby/object:Gem::Requirement
64
+ required_ruby_version: !ruby/object:Gem::Requirement
98
65
  none: false
99
- requirements:
100
- - - ">="
101
- - !ruby/object:Gem::Version
102
- hash: 3
103
- segments:
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ segments:
104
71
  - 0
105
- version: "0"
106
- required_rubygems_version: !ruby/object:Gem::Requirement
72
+ hash: 3109678707931568601
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
107
74
  none: false
108
- requirements:
109
- - - ">="
110
- - !ruby/object:Gem::Version
111
- hash: 3
112
- segments:
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ segments:
113
80
  - 0
114
- version: "0"
81
+ hash: 3109678707931568601
115
82
  requirements: []
116
-
117
83
  rubyforge_project:
118
- rubygems_version: 1.8.10
84
+ rubygems_version: 1.8.11
119
85
  signing_key:
120
86
  specification_version: 3
121
87
  summary: In order to use unipass API you can use it.
122
- test_files: []
123
-
88
+ test_files:
89
+ - test/client_test.rb
90
+ - test/test_helper.rb