omniauth-parallelmarkets 0.1.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 730b44e26921f1aad13a281a367d4dd2cbe9570d23753446d6ecf6fa4edb7748
4
- data.tar.gz: a4e0bb4f3a5c8b5989542200bfb897e3a6c74cca66a56d709203454498504859
3
+ metadata.gz: a09a136f927f294185559a7dfab444e5fb74998f1de4eeccea20380a4f16de31
4
+ data.tar.gz: d9dba23f966d094ca5ea5998e9750d4aefba87b8a34069b5372f9ac524aa270c
5
5
  SHA512:
6
- metadata.gz: 5ce112a2d2b3608ece94ab87c7b687ceeb793aae2e7c96df4d540b2a11c3ce7a35ed13e66e893d5a10407ee53be468bf39b1792243a4666d97e796b0deac099c
7
- data.tar.gz: e74674e76bf1de82a28ecd846d89b06145fa8b50f53eb6accdd20733c4a6866fb56611ab12a785ce0b11c4f134ac799e5f4bb462bb40b79c7ff8355ff64da174
6
+ metadata.gz: c874ad3849bf22c15ffd1a8388ccbcf0120ad36e24222e7250c4434432ceda003df5628a4f4be2a7be6caac8a6b9dd453aba361909f183f6fb6f95f506b2c5fe
7
+ data.tar.gz: df94ef490b155c9e7cf1117c3fb925d606e1e6a1faef01a390de63bd9f28d0d9c169069959e106f867268d4851eb481ce5aeaaf730cf71b349c67139abc57f09
data/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  This gem contains the [Parallel Markets](https://parallelmarkets.com) strategy for OmniAuth.
7
7
 
8
- ParallelMarkets uses the OAuth2 flow, you can read about at [docs.parallelmarkets.com/api](https://docs.parallelmarkets.com/api/).
8
+ ParallelMarkets uses the OAuth2 flow, you can read about at [developer.parallelmarkets.com/api](https://developer.parallelmarkets.com).
9
9
 
10
10
  ## Installation
11
11
 
@@ -28,6 +28,7 @@ Or install it yourself as:
28
28
  You'll need to register your application with [Parallel Markets Support](mailto:help@parallelmarkets.com) and get `client_id` & `client_secret`.
29
29
 
30
30
  Here's an example for adding the middleware to a Rails app in config/initializers/omniauth.rb:
31
+
31
32
  ```ruby
32
33
  Rails.application.config.middleware.use OmniAuth::Builder do
33
34
  provider :parallelmarkets, ENV["CLIENT_ID"], ENV["CLIENT_SECRET"]
@@ -40,7 +41,7 @@ See the documentation for [OmniAuth](https://github.com/omniauth/omniauth) for m
40
41
  ```ruby
41
42
  {
42
43
  "provider"=>"parallelmarkets",
43
- "uid"=>"123456",
44
+ "uid"=>"VXNlcjox",
44
45
  "info"=> {
45
46
  "name"=>"Snake Plissken",
46
47
  "email"=>"snake@example.com",
@@ -54,6 +55,8 @@ See the documentation for [OmniAuth](https://github.com/omniauth/omniauth) for m
54
55
  "expires"=>true
55
56
  },
56
57
  "extra"=> {
58
+ "type"=>"individual",
59
+ "user_id"=>"VXNlcjox",
57
60
  "accreditations"=>[
58
61
  {
59
62
  "id"=>321,
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OmniAuth
4
4
  module ParallelMarkets
5
- VERSION = '0.1.0'
5
+ VERSION = '0.4.0'
6
6
  end
7
7
  end
@@ -9,37 +9,68 @@ module OmniAuth
9
9
  site: 'https://api.parallelmarkets.com',
10
10
  authorize_url: '/v1/oauth/authorize',
11
11
  token_url: '/v1/oauth/token'
12
+ option :authorize_options, %i[scope force_accreditation_check]
12
13
 
13
- uid { raw_info['uid'] }
14
+ uid { raw_info['id'] }
14
15
 
15
16
  info do
16
17
  {
17
- name: raw_info['name'] || "#{raw_info['first_name']} #{raw_info['last_name']}",
18
- first_name: raw_info['first_name'],
19
- last_name: raw_info['last_name'],
20
- email: raw_info['email']
18
+ name: profile['name'] || "#{profile['first_name']} #{profile['last_name']}",
19
+ first_name: profile['first_name'],
20
+ last_name: profile['last_name'],
21
+ email: profile['email']
21
22
  }
22
23
  end
23
24
 
24
25
  extra do
25
26
  {
26
- accreditations: raw_info['accreditations'],
27
+ accreditations: accreditations,
28
+ indicated_unaccredited: indicated_unaccredited,
29
+ business_type: profile['business_type'],
30
+ primary_contact: profile['primary_contact'].nil? ? nil : {
31
+ name: "#{profile['primary_contact']['first_name']} #{profile['primary_contact']['last_name']}",
32
+ first_name: profile['primary_contact']['first_name'],
33
+ last_name: profile['primary_contact']['last_name'],
34
+ email: profile['primary_contact']['email']
35
+ },
27
36
  type: raw_info['type'],
37
+ user_id: raw_info['user_id'],
28
38
  raw_info: raw_info
29
39
  }
30
40
  end
31
41
 
32
42
  def authorize_params
33
43
  super.tap do |params|
34
- %w[scope client_options].each do |v|
35
- params[v.to_sym] = request.params[v] if request.params[v]
44
+ options[:authorize_options].each do |k|
45
+ params[k] = request.params[k.to_s] if request.params[k.to_s]
36
46
  end
37
47
  end
38
48
  end
39
49
 
50
+ # this is dumb, but https://github.com/omniauth/omniauth-oauth2/issues/93 is still open
51
+ def callback_url
52
+ options[:redirect_uri] || (full_host + script_name + callback_path)
53
+ end
54
+
40
55
  def raw_info
41
56
  @raw_info ||= access_token.get('/v1/me').parsed
42
57
  end
58
+
59
+ def profile
60
+ @profile ||= raw_info.fetch('profile', {})
61
+ end
62
+
63
+ def raw_accreditations
64
+ @raw_accreditations ||= access_token.get('/v1/accreditations').parsed
65
+ end
66
+
67
+ def indicated_unaccredited
68
+ raw_accreditations['indicated_unaccredited']
69
+ end
70
+
71
+ def accreditations
72
+ raw_accreditations['accreditations']
73
+ end
43
74
  end
44
75
  end
45
76
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-parallelmarkets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Muller
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-15 00:00:00.000000000 Z
11
+ date: 2020-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: omniauth-oauth2
@@ -89,7 +89,7 @@ homepage: https://github.com/parallel-markets/omniauth-parallelmarkets
89
89
  licenses:
90
90
  - MIT
91
91
  metadata: {}
92
- post_install_message:
92
+ post_install_message:
93
93
  rdoc_options: []
94
94
  require_paths:
95
95
  - lib
@@ -104,8 +104,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
104
  - !ruby/object:Gem::Version
105
105
  version: '0'
106
106
  requirements: []
107
- rubygems_version: 3.0.3
108
- signing_key:
107
+ rubygems_version: 3.0.8
108
+ signing_key:
109
109
  specification_version: 4
110
110
  summary: Parallel Markets OAuth strategy for OmniAuth
111
111
  test_files: []