pp_login 0.0.2 → 0.0.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1787eddf02af2b4df67d24692c349c0137d8a824
4
- data.tar.gz: 75afb51ce7384b1e7916d872ab2a71a07025ccd9
3
+ metadata.gz: 400e72f1eb22bdc43381e5fdc80f7303c9aba24c
4
+ data.tar.gz: e182b04da2d4ee96539a6924cf09e640d6612a6d
5
5
  SHA512:
6
- metadata.gz: 5ea96eaec20f6f338658bf192b2c2ef78a70cdb22e24be102e9f8a1424b583fc1d5a809e2fd4f45c3f9d9c4f8a950e4e61a3b32f5bc461c640899fee11489487
7
- data.tar.gz: 0290c09456d39452be602c5338a7734a557027325dfb990ad130cc7187617d761d3c23c6712bf00ce9f01a683e6e1bf57ef15441f75af3de4907bf53cf13260c
6
+ metadata.gz: c2900e950bade950ea119724d515d9b20c1df3384824a844471b70c9dad43d57dd80127c22e491cc47e297bd5de17e6465340dc59787ab2fdff244d427229849
7
+ data.tar.gz: 4877f97241b7b3eb295f5fc69023c1179547234b0939eaad654a8c658adc013ef2cd19830dd49a222b5d75a8d4f4f95333a1cc86d63760be9b5039560c744c58
@@ -1,4 +1,7 @@
1
1
  module PpLogin
2
2
  class ApplicationController < ActionController::Base
3
+
4
+ include PpLogin::Helpers
5
+
3
6
  end
4
7
  end
@@ -1,23 +1,23 @@
1
1
  module PpLogin
2
- class PpAccount < ApplicationController
2
+ class PpAccountController < ApplicationController
3
3
 
4
4
  def get_token
5
- token = Engine.get_access_token(token_params[:code])
5
+ token = get_access_token(token_params[:code])
6
6
  save_info(token)
7
7
  end
8
8
 
9
9
  def refresh_token
10
- token = Engine.refresh_token(token_params[:refresh_token])
10
+ token = refresh_token(token_params[:refresh_token])
11
11
  save_info(token)
12
12
  end
13
13
 
14
14
  def user_info
15
- user_info = Engine.get_user_info(token_params[:access_token])
15
+ user_info = get_user_info(token_params[:access_token])
16
16
  save_info(user_info)
17
17
  end
18
18
 
19
19
  def logout
20
- token = Engine.refresh_token(token_params[:refresh_token])
20
+ token = refresh_token(token_params[:refresh_token])
21
21
  redirect_to token.logout_url
22
22
  end
23
23
 
@@ -26,18 +26,6 @@ module PpLogin
26
26
  { token_type: params[:token_type] ,expires_in: params[:expires_in] ,refresh_token: params[:refresh_token] ,access_token: params[:access_token], code: params[:code] }
27
27
  end
28
28
 
29
- def for_action
30
- @to_return ||= begin
31
- case(action_name)
32
- when 'get_token', 'refresh_token'
33
- return {store: PpLogin.token_store, type: :token}
34
- when 'user_info'
35
- return {store: PpLogin.user_store, type: :user}
36
- end
37
- end
38
-
39
- end
40
-
41
29
  def save_info(info)
42
30
  case(for_action[:store])
43
31
  when :param
@@ -55,4 +43,4 @@ module PpLogin
55
43
 
56
44
  end
57
45
  end
58
- end
46
+ end
@@ -17,5 +17,9 @@ module PpLogin
17
17
  PpLogin.loginURL = Tokeninfo.authorize_url( scope: scope)
18
18
  end
19
19
  end
20
+
21
+ def temp(value)
22
+ return (value + 59)
23
+ end
20
24
  end
21
25
  end
@@ -1,19 +1,15 @@
1
1
  module PpLogin
2
2
 
3
- class Engine < ::Rails::Engine
4
-
5
- def self.get_access_token(code)
6
- return Tokeninfo.create(code)
7
- end
8
-
9
- def self.refresh_token(refresh_token)
10
- return Tokeninfo.refresh(refresh_token)
11
- end
3
+ def self.get_access_token(code)
4
+ return Engine.instance_exec(code){|c| return self::Tokeninfo.create(c) }
5
+ end
12
6
 
13
- def self.get_user_info(access_token)
14
- return Userinfo.get(access_token)
15
- end
7
+ def self.refresh_token(refresh_token)
8
+ return Engine.instance_exec(refresh_token){|rt| self::Tokeninfo.refresh(rt) }
9
+ end
16
10
 
11
+ def self.get_user_info(access_token)
12
+ return Engine.instance_exec(get_access_token){|at| self::Userinfo.get(at) }
17
13
  end
18
14
 
19
- end
15
+ end
@@ -1,32 +1,54 @@
1
1
  module PpLogin
2
2
  module Helpers
3
3
  def self.included(base)
4
- base.send :helper_method, :user_info, :token
4
+ base.send :helper_method, :user_info, :token, :paypal_login
5
5
  end
6
- def user_info
7
- case(PpLogin.user_store)
8
- when :param
9
- JSON.parse(params[:user])
10
- when :session
11
- JSON.parse(session[:user])
12
- when :cookie
13
- JSON.parse(cookies[:user])
14
- when :db
15
- p 'This Method of saving is not yet implimented'
6
+
7
+ def for_action manual
8
+ @to_return ||= begin
9
+ case(manual || action_name)
10
+ when 'get_token', 'refresh_token'
11
+ return {store: PpLogin.token_store, type: :token}
12
+ when 'user_info'
13
+ return {store: PpLogin.user_store, type: :user}
14
+ end
16
15
  end
17
16
  end
18
17
 
18
+ def user_info
19
+ get_info('get_token')
20
+ end
21
+
22
+
23
+
19
24
  def token
20
- case(PpLogin.token_store)
21
- when :param
22
- JSON.parse(params[:token])
23
- when :session
24
- JSON.parse(session[:token])
25
- when :cookie
26
- JSON.parse(cookies[:token])
27
- when :db
28
- p 'This Method of saving is not yet implimented'
29
- end
25
+ get_info('get_token')
30
26
  end
27
+
28
+ def paypal_login type, prop={}
29
+ self.instance_exec(type,prop) do |type,prop|
30
+ case(type)
31
+ when :link
32
+ link_to prop[:text]||'Login With PayPal',PpLogin.loginURL, prop
33
+ when :button
34
+ button_to prop[:text]||'Login With PayPal',PpLogin.loginURL, prop
35
+ end
36
+ end
37
+ end
38
+
39
+ private
40
+
41
+ def get_info(kind)
42
+ case(for_action(kind)[:store])
43
+ when :param
44
+ JSON.parse(params[for_action[:type]])
45
+ when :session
46
+ JSON.parse(session[for_action[:type]])
47
+ when :cookie
48
+ JSON.parse(cookies[for_action[:type]])
49
+ when :db
50
+ p 'This Method of saving is not yet implimented'
51
+ end
52
+ end
31
53
  end
32
- end
54
+ end
@@ -1,5 +1,5 @@
1
1
  module PpLogin
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  Desc ="This gem will Add an engine to handle loging in with paypal,
4
4
  getting user info and logging out again.
5
5
  "
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pp_login
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thermatix