yoti 1.6.3 → 1.6.4

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: 296612e32508787e11d3c6f9404434b9d9575284008ae7d60df4a20f83526f6f
4
- data.tar.gz: 4e0e6a0c0ea6a297399df4a9937ae3e6cd82da95f67d5a70b8cc7db0665e5c50
3
+ metadata.gz: d1d2cbb57b376a252d798c35820fcee63a46eb99809422441e592ed25bc0f9da
4
+ data.tar.gz: 1e31e86853d8e419cad2bec50a260d9e26a9c8043299ff6dc10620635c9169c9
5
5
  SHA512:
6
- metadata.gz: fc8a50eab70a1b29ba480e7df303144d56b4edb46b48124292dbfb98de9167659eee80b2d38e0c633c709151953252cb888dad5f2114c721eed8871915b3f0b2
7
- data.tar.gz: 2c8dcc5342813067af5fb6980ef0acb8c5c8f2981c23fbf4311261a46034f852ba35b1c028a6cfed33c5fda52d0b193cb857e145cbafa4b342e0377e0ff2effb
6
+ metadata.gz: 88a932e08b8b73b81ef7153935e984df1d0816c9cfdf0fe912342a57ca8b12a91892aec6b226520cd48f94b660264dca2cadd593ef85008dc2564c97c811a409
7
+ data.tar.gz: 1b0bdb68176391c56302aff5bda6040aece1d891d6b4491ea605af30029c079de046ea6e03df81c49c99100a1500a0730adfbc6e705c69f18c2a6c96172f0c09
@@ -16,35 +16,6 @@ bundle exec guard
16
16
 
17
17
  Although this gem supports Ruby 2.0.0, in order to use the latest development dependencies you have to use at least Ruby 2.2.2.
18
18
 
19
- If you wish to compile `.proto` definitions to Ruby, you will need to install [Google's Protocol Buffers](http://code.google.com/p/protobuf).
20
-
21
- ### OSX
22
-
23
- ```shell
24
- brew install protobuf
25
- ```
26
-
27
- ### Ubuntu
28
-
29
- ```shell
30
- sudo apt-get install -y protobuf
31
- ```
32
-
33
- This gem relies heavily on the [Ruby Protobuf][] gem. For more information on how Google Protobuf works, please see the [Wiki pages][].
34
-
35
- Compiling the common and attribute `.proto` definitions can be done with the following commands:
36
-
37
- ```shell
38
- cd lib/yoti/protobuf/v1
39
- protoc -I definitions/attribute-public-api/attrpubapi_v1 --ruby_out ./attribute_public_api definitions/attribute-public-api/attrpubapi_v1/*.proto
40
- protoc -I definitions/common-public-api/compubapi_v1/ --ruby_out ./common_public_api definitions/common-public-api/compubapi_v1/*.proto
41
- ```
42
-
43
- These commands will overwrite the current protobuf Ruby modules, which have been modified. If the protobuf files have to be updated, a good idea would be to change them manually, or generate the files in a new location, and compare the content.
44
-
45
- [Ruby Protobuf]: https://github.com/ruby-protobuf/protobuf/
46
- [Wiki Pages]: https://github.com/ruby-protobuf/protobuf/wiki
47
-
48
19
  ## Requirements
49
20
 
50
21
  ### Code coverage
data/Rakefile CHANGED
@@ -6,8 +6,13 @@ require 'yaml'
6
6
  # Tests #
7
7
  ################################
8
8
 
9
- RSpec::Core::RakeTask.new
10
- task test: :spec
9
+ RSpec::Core::RakeTask.new(:spec) do |t|
10
+ t.pattern = ['spec/yoti']
11
+ end
12
+
13
+ RSpec::Core::RakeTask.new(:test_generators) do |t|
14
+ t.pattern = ['spec/generators']
15
+ end
11
16
 
12
17
  ################################
13
18
  # Coveralls #
@@ -46,4 +51,4 @@ end
46
51
  # Defaults #
47
52
  ################################
48
53
 
49
- task default: %i[spec rubocop]
54
+ task default: %i[spec test_generators rubocop]
@@ -1,14 +1,23 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'time'
4
+
3
5
  module Yoti
4
6
  module DynamicSharingService
5
7
  class ThirdPartyAttributeDefinition
8
+ #
9
+ # @param [String] name
10
+ #
6
11
  def initialize(name)
7
12
  @name = name
8
13
  end
9
14
 
15
+ def as_json(*_args)
16
+ { name: @name }
17
+ end
18
+
10
19
  def to_json(*_args)
11
- { name: @name }.to_json
20
+ as_json.to_json
12
21
  end
13
22
  end
14
23
 
@@ -18,11 +27,21 @@ module Yoti
18
27
  @definitions = []
19
28
  end
20
29
 
30
+ #
31
+ # @param [DateTime,Time] expiry_date
32
+ #
33
+ # @return [self]
34
+ #
21
35
  def with_expiry_date(expiry_date)
22
36
  @expiry_date = expiry_date
23
37
  self
24
38
  end
25
39
 
40
+ #
41
+ # @param [String] *names
42
+ #
43
+ # @return [self]
44
+ #
26
45
  def with_definitions(*names)
27
46
  @definitions += names.map do |name|
28
47
  ThirdPartyAttributeDefinition.new(name)
@@ -30,39 +49,71 @@ module Yoti
30
49
  self
31
50
  end
32
51
 
52
+ #
53
+ # @return [ThirdPartyAttributeExtension]
54
+ #
33
55
  def build
34
- extension = ThirdPartyAttributeExtension.new
35
- extension.instance_variable_get(:@content)[:expiry_date] = @expiry_date
36
- extension.instance_variable_get(:@content)[:definitions] = @definitions
37
- extension
56
+ content = ThirdPartyAttributeExtensionContent.new(@expiry_date, @definitions)
57
+ ThirdPartyAttributeExtension.new(content)
38
58
  end
39
59
  end
40
60
 
41
61
  class ThirdPartyAttributeExtension
42
62
  EXTENSION_TYPE = 'THIRD_PARTY_ATTRIBUTE'
43
63
 
64
+ # @return [ThirdPartyAttributeExtensionContent]
44
65
  attr_reader :content
66
+
67
+ # @return [String]
45
68
  attr_reader :type
46
69
 
47
- def initialize
48
- @content = {}
70
+ #
71
+ # @param [ThirdPartyAttributeExtensionContent] content
72
+ #
73
+ def initialize(content = nil)
74
+ @content = content
49
75
  @type = EXTENSION_TYPE
50
76
  end
51
77
 
52
78
  def as_json(*_args)
53
- {
54
- type: @type,
55
- content: @content
56
- }
79
+ json = {}
80
+ json[:type] = @type
81
+ json[:content] = @content.as_json unless @content.nil?
82
+ json
57
83
  end
58
84
 
59
85
  def to_json(*_args)
60
86
  as_json.to_json
61
87
  end
62
88
 
89
+ #
90
+ # @return [ThirdPartyAttributeExtensionBuilder]
91
+ #
63
92
  def self.builder
64
93
  ThirdPartyAttributeExtensionBuilder.new
65
94
  end
66
95
  end
96
+
97
+ class ThirdPartyAttributeExtensionContent
98
+ #
99
+ # @param [DateTime,Time] expiry_date
100
+ # @param [Array<ThirdPartyAttributeDefinition>] definitions
101
+ #
102
+ def initialize(expiry_date, definitions)
103
+ @expiry_date = expiry_date
104
+ @definitions = definitions
105
+ end
106
+
107
+ def as_json(*_args)
108
+ json = {}
109
+ json[:expiry_date] = @expiry_date.to_time.utc.strftime('%FT%T.%3NZ') unless @expiry_date.nil?
110
+ json[:definitions] = @definitions.map(&:as_json)
111
+ json
112
+ end
113
+
114
+ def to_json(*_args)
115
+ as_json.to_json
116
+ end
117
+ end
67
118
  end
68
119
  end
@@ -105,19 +105,19 @@ module Yoti
105
105
  end
106
106
 
107
107
  def with_family_name(options = {})
108
- with_wanted_attribute_by_name Attribute::FAMILY_NAME, options
108
+ with_wanted_attribute_by_name Attribute::FAMILY_NAME, **options
109
109
  end
110
110
 
111
111
  def with_given_names(options = {})
112
- with_wanted_attribute_by_name Attribute::GIVEN_NAMES, options
112
+ with_wanted_attribute_by_name Attribute::GIVEN_NAMES, **options
113
113
  end
114
114
 
115
115
  def with_full_name(options = {})
116
- with_wanted_attribute_by_name Attribute::FULL_NAME, options
116
+ with_wanted_attribute_by_name Attribute::FULL_NAME, **options
117
117
  end
118
118
 
119
119
  def with_date_of_birth(options = {})
120
- with_wanted_attribute_by_name Attribute::DATE_OF_BIRTH, options
120
+ with_wanted_attribute_by_name Attribute::DATE_OF_BIRTH, **options
121
121
  end
122
122
 
123
123
  #
@@ -138,42 +138,42 @@ module Yoti
138
138
  # @param [Integer] derivation
139
139
  #
140
140
  def with_age_over(age, options = {})
141
- with_age_derived_attribute(Attribute::AGE_OVER + age.to_s, options)
141
+ with_age_derived_attribute(Attribute::AGE_OVER + age.to_s, **options)
142
142
  end
143
143
 
144
144
  #
145
145
  # @param [Integer] derivation
146
146
  #
147
147
  def with_age_under(age, options = {})
148
- with_age_derived_attribute(Attribute::AGE_UNDER + age.to_s, options)
148
+ with_age_derived_attribute(Attribute::AGE_UNDER + age.to_s, **options)
149
149
  end
150
150
 
151
151
  def with_gender(options = {})
152
- with_wanted_attribute_by_name Attribute::GENDER, options
152
+ with_wanted_attribute_by_name Attribute::GENDER, **options
153
153
  end
154
154
 
155
155
  def with_postal_address(options = {})
156
- with_wanted_attribute_by_name(Attribute::POSTAL_ADDRESS, options)
156
+ with_wanted_attribute_by_name(Attribute::POSTAL_ADDRESS, **options)
157
157
  end
158
158
 
159
159
  def with_structured_postal_address(options = {})
160
- with_wanted_attribute_by_name(Attribute::STRUCTURED_POSTAL_ADDRESS, options)
160
+ with_wanted_attribute_by_name(Attribute::STRUCTURED_POSTAL_ADDRESS, **options)
161
161
  end
162
162
 
163
163
  def with_nationality(options = {})
164
- with_wanted_attribute_by_name(Attribute::NATIONALITY, options)
164
+ with_wanted_attribute_by_name(Attribute::NATIONALITY, **options)
165
165
  end
166
166
 
167
167
  def with_phone_number(options = {})
168
- with_wanted_attribute_by_name(Attribute::PHONE_NUMBER, options)
168
+ with_wanted_attribute_by_name(Attribute::PHONE_NUMBER, **options)
169
169
  end
170
170
 
171
171
  def with_selfie(options = {})
172
- with_wanted_attribute_by_name(Attribute::SELFIE, options)
172
+ with_wanted_attribute_by_name(Attribute::SELFIE, **options)
173
173
  end
174
174
 
175
175
  def with_email(options = {})
176
- with_wanted_attribute_by_name(Attribute::EMAIL_ADDRESS, options)
176
+ with_wanted_attribute_by_name(Attribute::EMAIL_ADDRESS, **options)
177
177
  end
178
178
 
179
179
  def with_document_details
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'securerandom'
4
+
3
5
  module Yoti
4
6
  module DynamicSharingService
5
7
  class Share
@@ -1,3 +1,5 @@
1
+ require 'securerandom'
2
+
1
3
  module Yoti
2
4
  # Manage the API's HTTPS requests
3
5
  class Request
@@ -94,7 +94,7 @@ module Yoti
94
94
  proto_multi_value = Yoti::Protobuf::Attrpubapi::MultiValue.decode(value)
95
95
  items = []
96
96
  proto_multi_value.values.each do |item|
97
- items.append value_based_on_content_type(item.data, item.content_type)
97
+ items << value_based_on_content_type(item.data, item.content_type)
98
98
  end
99
99
  MultiValue.new(items)
100
100
  end
@@ -1,4 +1,4 @@
1
1
  module Yoti
2
2
  # @return [String] the gem's current version
3
- VERSION = '1.6.3'.freeze
3
+ VERSION = '1.6.4'.freeze
4
4
  end
@@ -23,9 +23,7 @@ Gem::Specification.new do |spec|
23
23
 
24
24
  spec.required_ruby_version = '>= 2.4'
25
25
 
26
- spec.add_dependency 'activesupport', '~> 5.0' # Pin activesupport library to 5.x for Ruby 2.4 support
27
- spec.add_dependency 'google-protobuf', '~> 3.7', '>= 3.7.0'
28
- spec.add_dependency 'protobuf', '~> 3.6'
26
+ spec.add_dependency 'google-protobuf', '~> 3.7'
29
27
 
30
28
  spec.add_development_dependency 'bundler', '~> 2.0'
31
29
  spec.add_development_dependency 'coveralls', '~> 0.8'
metadata CHANGED
@@ -1,36 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yoti
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.3
4
+ version: 1.6.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian Zaremba
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-06 00:00:00.000000000 Z
11
+ date: 2020-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: activesupport
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '5.0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '5.0'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: google-protobuf
29
15
  requirement: !ruby/object:Gem::Requirement
30
16
  requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: 3.7.0
34
17
  - - "~>"
35
18
  - !ruby/object:Gem::Version
36
19
  version: '3.7'
@@ -38,26 +21,9 @@ dependencies:
38
21
  prerelease: false
39
22
  version_requirements: !ruby/object:Gem::Requirement
40
23
  requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- version: 3.7.0
44
24
  - - "~>"
45
25
  - !ruby/object:Gem::Version
46
26
  version: '3.7'
47
- - !ruby/object:Gem::Dependency
48
- name: protobuf
49
- requirement: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - "~>"
52
- - !ruby/object:Gem::Version
53
- version: '3.6'
54
- type: :runtime
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - "~>"
59
- - !ruby/object:Gem::Version
60
- version: '3.6'
61
27
  - !ruby/object:Gem::Dependency
62
28
  name: bundler
63
29
  requirement: !ruby/object:Gem::Requirement