ibm_tools-people 1.0.4 → 1.1.1

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
  SHA256:
3
- metadata.gz: b028aef66c16115dd938f4845197bfa185a04d9fe7d436385027958fe837c11b
4
- data.tar.gz: 30fb23190bd601f7bf7dc43c72b3cedb8c204e6b0c7b05fb266d2d71dd6342dc
3
+ metadata.gz: 51f4d6a531af302ea58c562547649c271bb6c7d516aae5499850c75cd10d9dc0
4
+ data.tar.gz: 923ef485df6bfa6edfa82fdc385f3d8213a26e80a2739b17073c42f3bde0c318
5
5
  SHA512:
6
- metadata.gz: 23fb1a3369fbe2c0624c430739a05355506e9e1f947dbae8050e63c4fec09777df09dadc97df0371b65a4248e9d71fafa28b19cde545691125692f72c8e4b8ea
7
- data.tar.gz: 19cf5ae6bd5f1e00cc2a0f82c653e05489a0be9df5a08eea84ac3dfe955ce33cea9a7730dbb2138ae7f65d551f48217cffc90b9c6cf497b1379a03be56aab6db
6
+ metadata.gz: 4a2493f5506e630bc8f187640ecab57f892fce875d4c4230c0445530d03f7a7e8f9b04ecdb0e53c7931387b0ee7415fce40774c04aaff96d350e535ce537b773
7
+ data.tar.gz: 4386b1dac3ecd4e44681ba76a4ec30f863a25f6038586a56298733eea3ab345ba6cff48cc7849b58895f604176aa6cb83ab365561df5e9dd428baf349ceead06
data/README.md CHANGED
@@ -1,9 +1,17 @@
1
1
  # IMPORTANT
2
+
3
+ ## Comunicate 1
4
+
5
+ Due to the new mandatory change regarding the new Tokenization of the API we launch the version 1.1, now aside from the default parameters, we will have to request your token via boarding process and then use it with the API, details regarding the api usage, were updated, but if you want to know more about the tokenization, check the [FAQ](https://w3.ibm.com/w3publisher/w3/people/unified-profile-apis/api-key-faq).
6
+
7
+ ## Comunicate 2
8
+
2
9
  Due to the `case-2022-05-05-1450` opened by the __CSIRT team__ we had to migrate from the Public Github to the Github Enterprise, this change forced us to change the name of the gem.
3
10
 
4
11
  Since the ruby does require the name of the gem to be used as the name of the class. Check below what changed:
5
12
 
6
- ## Action 1 - Gemfile
13
+ ### Action 1 - Gemfile
14
+
7
15
  Change the name of the gem to the new one in your Gemfile file and hit `bundle install` on your terminal.
8
16
  ```ruby
9
17
  # From
@@ -13,7 +21,8 @@ gem 'rails_ibm-uprofile', '~> 0.3.2', require: 'rails_ibm/uprofile'
13
21
  gem 'ibm_tools-people', '~> 1.0.0', require: 'ibm_tools/people'
14
22
  ```
15
23
 
16
- ## Action 2 - Usage
24
+ ### Action 2 - Usage
25
+
17
26
  Change everywhere you have within your application from the old class name to the new one.
18
27
  ```ruby
19
28
  # From
@@ -27,6 +36,8 @@ From now on it should be transparent and require no other action.
27
36
  _________
28
37
  <br><br>
29
38
 
39
+
40
+
30
41
  # IBM Tools
31
42
 
32
43
  Welcome to your Rais IBM Tools module! This gem intend to provide you some fetures used on IBM Web applications __*__.
@@ -102,6 +113,9 @@ Since there are different kind of ways to search the user and to ensure readabil
102
113
  | email | String | `IbmTools::People.info(email: 'johndoe@ibm.com')`
103
114
  | emails | Array | `IbmTools::People.info(emails: ['johndoe@ibm.com', 'janedoe@ibm.com'])`
104
115
  | query | String | `IbmTools::People.info(query: 'John Doe')`
116
+ | token | String | `token: nbvcsw23456yhbvfrt6789olkmnhyu8i9olkmnhgtrdf`*
117
+
118
+ > Token can be used as a argument of the module, but it will also look for the environment variable `IBM_PEOPLE_API_KEY`
105
119
 
106
120
  #### Options (`optional`)
107
121
 
@@ -201,6 +215,9 @@ Since there are different kind of ways to search the user and to ensure readabil
201
215
  | --- | --- | ---
202
216
  | uid | String | `IbmTools::People.info(uid: '000000000')`
203
217
  | email | String | `IbmTools::People.info(email: 'johndoe@ibm.com')`
218
+ | token | String | `token: nbvcsw23456yhbvfrt6789olkmnhyu8i9olkmnhgtrdf`*
219
+
220
+ > Token can be used as a argument of the module, but it will also look for the environment variable `IBM_PEOPLE_API_KEY`
204
221
 
205
222
  #### Schemas
206
223
 
@@ -226,6 +243,10 @@ Since there are different kind of ways to search the user and to ensure readabil
226
243
  | --- | --- | ---
227
244
  | uid | String | `IbmTools::People.info(uid: '000000000')`
228
245
  | email | String | `IbmTools::People.info(email: 'johndoe@ibm.com')`
246
+ | token | String | `token: nbvcsw23456yhbvfrt6789olkmnhyu8i9olkmnhgtrdf`*
247
+
248
+ > Token can be used as a argument of the module, but it will also look for the environment variable `IBM_PEOPLE_API_KEY`
249
+
229
250
 
230
251
  #### Schemas
231
252
 
@@ -251,6 +272,9 @@ Since there are different kind of ways to search the user and to ensure readabil
251
272
  | --- | --- | ---
252
273
  | uid | String | `IbmTools::People.info(uid: '000000000')`
253
274
  | email | String | `IbmTools::People.info(email: 'johndoe@ibm.com')`
275
+ | token | String | `token: nbvcsw23456yhbvfrt6789olkmnhyu8i9olkmnhgtrdf`*
276
+
277
+ > Token can be used as a argument of the module, but it will also look for the environment variable `IBM_PEOPLE_API_KEY`
254
278
 
255
279
  #### Schemas
256
280
 
@@ -36,4 +36,7 @@ Gem::Specification.new do |spec|
36
36
 
37
37
  # For more information and examples about making a new gem, checkout our
38
38
  # guide at: https://bundler.io/guides/creating_gem.html
39
+
40
+ # For troubleshooting:
41
+ # rm -rf gem_name-version.gem && gem build gem_name.gemspec && gem install ./gem_name-version.gem
39
42
  end
@@ -15,6 +15,7 @@ module IbmTools
15
15
  raise SyntaxError.new description: "Invalid Argument. #{DOC_LINK}" if invalid_options
16
16
  raise SyntaxError.new description: "More than one required Argument. #{DOC_LINK}" if multiple
17
17
  raise SyntaxError.new description: "Missing required Argument. #{DOC_LINK}" if missing
18
+ raise SyntaxError.new description: "Missing TOKEN argument. #{DOC_LINK}" if missing_token
18
19
  raise TypeError.new description: "Invalid Argument type. #{DOC_LINK}" if invalid_type || unmatch_type
19
20
 
20
21
  true
@@ -30,6 +31,11 @@ module IbmTools
30
31
  value == nil
31
32
  end
32
33
 
34
+ def missing_token
35
+ return false if @options.keys.include?(:query)
36
+ @options[:token] == nil
37
+ end
38
+
33
39
  def multiple
34
40
  allowed = %i[uid uids email emails query]
35
41
  @options.keys.select { |k| allowed.include?(k) }.size > 1
@@ -6,8 +6,9 @@ module IbmTools
6
6
  module People
7
7
  module Profile
8
8
  class Fetch
9
- def initialize(uri:)
9
+ def initialize(uri:, token:)
10
10
  @uri = uri
11
+ @token = token
11
12
  end
12
13
 
13
14
  def execute(query:)
@@ -44,6 +45,7 @@ module IbmTools
44
45
 
45
46
  def headers
46
47
  {
48
+ 'X-UP-API-KEY': @token,
47
49
  'Content-Type': 'application/json',
48
50
  accept: 'application/json'
49
51
  }
@@ -10,10 +10,10 @@ module IbmTools
10
10
  class Search < Mapper
11
11
  class IbmTools::People::Profile::SearchError < StandardError; end
12
12
 
13
- def initialize(query)
13
+ def initialize(query, token = nil)
14
14
  @query = [query].flatten
15
15
 
16
- fetch = IbmTools::People::Profile::Fetch.new(uri: IbmTools::People::BLUEPAGES_V3_URI)
16
+ fetch = IbmTools::People::Profile::Fetch.new(uri: IbmTools::People::BLUEPAGES_V3_URI, token: token)
17
17
  @response = fetch.execute(query: @query)
18
18
  end
19
19
 
@@ -5,7 +5,8 @@ module IbmTools
5
5
  module People
6
6
  module Profile
7
7
  class Skills < Search
8
- def initialize(query)
8
+ def initialize(query, token = nil)
9
+ @token = token
9
10
  @response = HTTParty.get(uri(query: query), header: headers)
10
11
  end
11
12
 
@@ -21,6 +22,7 @@ module IbmTools
21
22
 
22
23
  def headers
23
24
  {
25
+ 'X-UP-API-KEY': @token,
24
26
  'Content-Type': 'application/json',
25
27
  accept: 'application/json'
26
28
  }
@@ -5,7 +5,8 @@ module IbmTools
5
5
  module People
6
6
  module Profile
7
7
  class Teams < Search
8
- def initialize(query)
8
+ def initialize(query, token = nil)
9
+ @token = token
9
10
  @response = HTTParty.get(uri(query: query), header: headers)
10
11
  end
11
12
 
@@ -21,6 +22,7 @@ module IbmTools
21
22
 
22
23
  def headers
23
24
  {
25
+ 'X-UP-API-KEY': @token,
24
26
  'Content-Type': 'application/json',
25
27
  accept: 'application/json'
26
28
  }
@@ -6,8 +6,9 @@ module IbmTools
6
6
  module People
7
7
  module Profile
8
8
  class Typeahead < Search
9
- def initialize(query, serial: '000000', limit: 10, start: 0)
9
+ def initialize(query, token = nil, serial: '000000', limit: 10, start: 0)
10
10
  uri = "#{IbmTools::People::BLUEPAGES_V1_URI}?userId=#{serial}&rows=#{limit}&start=#{start}&query=#{query}&searchConfig=typeahead_search"
11
+ @token = token
11
12
  @response = HTTParty.get(uri, header: headers, format: :plain)
12
13
  end
13
14
 
@@ -19,6 +20,7 @@ module IbmTools
19
20
 
20
21
  def headers
21
22
  {
23
+ 'X-UP-API-KEY': @token,
22
24
  'Content-Type': 'application/json',
23
25
  accept: 'application/json'
24
26
  }
@@ -2,7 +2,7 @@
2
2
 
3
3
  module IbmTools
4
4
  module People
5
- VERSION = "1.0.4"
5
+ VERSION = "1.1.1"
6
6
  BLUEPAGES_V3_URI = "https://w3-unifiedprofile-api.dal1a.cirrus.ibm.com/v3/profiles"
7
7
  BLUEPAGES_V1_URI = "https://w3-unifiedprofile-search.dal1a.cirrus.ibm.com/search"
8
8
  EMAIL_REGEX = %r{\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z}i
@@ -15,30 +15,31 @@ module IbmTools
15
15
  DOC_LINK = "Please refer to 'https://github.com/niightly/rails_ibm-uprofile/blob/master/README.md#usage' for more details.'".freeze
16
16
 
17
17
  def self.info(options = {})
18
+ options[:token] = options[:token] || ENV['IBM_PEOPLE_API_KEY']
18
19
  args = verify(options)
19
20
 
20
21
  if options.include?(:emails) || options.include?(:email)
21
- IbmTools::People::Profile::Email.new([options[:emails] || options[:email]].flatten).results(**args.filter(%i[parsed remap]))
22
+ IbmTools::People::Profile::Email.new([options[:emails] || options[:email]].flatten, options[:token]).results(**args.filter(%i[parsed remap]))
22
23
  elsif options.include?(:uids) || options.include?(:uid)
23
- IbmTools::People::Profile::Uid.new([options[:uids] || options[:uid]].flatten).results(**args.filter(%i[parsed remap]))
24
+ IbmTools::People::Profile::Uid.new([options[:uids] || options[:uid]].flatten, options[:token]).results(**args.filter(%i[parsed remap]))
24
25
  elsif options.include?(:query)
25
- IbmTools::People::Profile::Typeahead.new(options[:query], **default_params(options)).results(**args.filter(%i[parsed remap detailed array]))
26
+ IbmTools::People::Profile::Typeahead.new(options[:query], options[:token], **default_params(options)).results(**args.filter(%i[parsed remap detailed array]))
26
27
  end
27
28
  end
28
29
 
29
30
  def self.skills(options = {})
30
31
  args = verify(options, single: true)
31
- IbmTools::People::Profile::Skills.new(options[:uid] || options[:email]).results
32
+ IbmTools::People::Profile::Skills.new(options[:uid] || options[:email], options[:token]).results
32
33
  end
33
34
 
34
35
  def self.teams(options = {})
35
36
  args = verify(options, single: true)
36
- IbmTools::People::Profile::Teams.new(options[:uid] || options[:email]).results
37
+ IbmTools::People::Profile::Teams.new(options[:uid] || options[:email], options[:token]).results
37
38
  end
38
39
 
39
40
  def self.all(options = {})
40
41
  args = verify(options, single: true)
41
- IbmTools::People::Profile::All.new(options[:uid] || options[:email]).results
42
+ IbmTools::People::Profile::All.new(options[:uid] || options[:email], options[:token]).results
42
43
  end
43
44
 
44
45
  private
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ibm_tools-people
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thiago Silva
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-02-16 00:00:00.000000000 Z
11
+ date: 2024-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -95,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  requirements: []
98
- rubygems_version: 3.1.6
98
+ rubygems_version: 3.4.15
99
99
  signing_key:
100
100
  specification_version: 4
101
101
  summary: IBM Module - Profile