barkibu-kb 0.24.1 → 0.26.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/.ruby-version +1 -2
- data/CHANGELOG.md +8 -1
- data/Gemfile.lock +17 -15
- data/README.md +7 -2
- data/barkibu-kb-fake.gemspec +1 -1
- data/barkibu-kb.gemspec +1 -1
- data/docker-compose.yaml +2 -2
- data/lib/kb/fake/bounded_context/pet_family/pet_parents.rb +28 -0
- data/lib/kb/models/assessment.rb +4 -6
- data/lib/kb/models/base_model.rb +17 -11
- data/lib/kb/models/breed.rb +1 -3
- data/lib/kb/models/concerns/findable.rb +6 -0
- data/lib/kb/models/hubspot_relationship.rb +2 -7
- data/lib/kb/models/pet.rb +3 -11
- data/lib/kb/models/pet_contract.rb +3 -11
- data/lib/kb/models/pet_parent.rb +18 -14
- data/lib/kb/models/plan.rb +2 -7
- data/lib/kb/models/product.rb +2 -7
- data/lib/kb/models/referral.rb +2 -7
- data/lib/kb/validators/uniqueness_validator.rb +2 -2
- data/lib/kb/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 764bc253dcc5b70bd9e72c7daf6f740813b82e4ab1c479e189c179ca247cb860
|
4
|
+
data.tar.gz: addb4558e1b7e624f1c82c79818b26978814e4df605eeef54fa81f486b69df11
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db382311f048cfedc62265241b487c05c40a977b0e906248426383d471db931f5b5fd169b6d69b51dcbef219d8d429e652d971a013ce1e101d22021161abf531
|
7
|
+
data.tar.gz: 5d0e713464fc4eee1f8c1a6c4ca537caee773085a2a1f3178eba80f65abf16dafab7df10185483bfeab538656a207ec9bd8c4b7720336ccc80e1119e0c194ae4
|
data/.rubocop.yml
CHANGED
data/.ruby-version
CHANGED
@@ -1,2 +1 @@
|
|
1
|
-
ruby-2.
|
2
|
-
|
1
|
+
ruby-3.2.3
|
data/CHANGELOG.md
CHANGED
@@ -6,7 +6,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
7
|
|
8
8
|
## [unreleased]
|
9
|
-
- See diff: https://github.com/barkibu/kb-ruby/compare/v0.
|
9
|
+
- See diff: https://github.com/barkibu/kb-ruby/compare/v0.26...HEAD
|
10
|
+
|
11
|
+
# [0.26.0]
|
12
|
+
- Add `#iban` and `#update_iban` to `PetParent`
|
13
|
+
- Add /iban endpoints in fake API
|
14
|
+
|
15
|
+
# [0.25.0]
|
16
|
+
- Add support for Ruby 3.2
|
10
17
|
|
11
18
|
# [0.24.1]
|
12
19
|
- Add support for `.referrers` method on `PetParent` in fake model
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
barkibu-kb (0.
|
4
|
+
barkibu-kb (0.26.0)
|
5
5
|
activemodel (>= 4.0.2)
|
6
6
|
activerecord
|
7
7
|
activesupport (>= 3.0.0)
|
@@ -10,8 +10,8 @@ PATH
|
|
10
10
|
faraday-http
|
11
11
|
faraday_middleware
|
12
12
|
i18n
|
13
|
-
barkibu-kb-fake (0.
|
14
|
-
barkibu-kb (= 0.
|
13
|
+
barkibu-kb-fake (0.26.0)
|
14
|
+
barkibu-kb (= 0.26.0)
|
15
15
|
countries
|
16
16
|
sinatra
|
17
17
|
webmock
|
@@ -98,17 +98,19 @@ GEM
|
|
98
98
|
multipart-post (2.3.0)
|
99
99
|
mustermann (3.0.0)
|
100
100
|
ruby2_keywords (~> 0.0.1)
|
101
|
-
parallel (1.
|
102
|
-
parser (3.0.
|
101
|
+
parallel (1.24.0)
|
102
|
+
parser (3.3.0.5)
|
103
103
|
ast (~> 2.4.1)
|
104
|
+
racc
|
104
105
|
public_suffix (4.0.7)
|
106
|
+
racc (1.7.3)
|
105
107
|
rack (2.2.6.3)
|
106
108
|
rack-protection (3.0.5)
|
107
109
|
rack
|
108
|
-
rainbow (3.
|
110
|
+
rainbow (3.1.1)
|
109
111
|
rake (13.0.6)
|
110
|
-
regexp_parser (2.
|
111
|
-
rexml (3.2.
|
112
|
+
regexp_parser (2.9.0)
|
113
|
+
rexml (3.2.6)
|
112
114
|
rspec (3.10.0)
|
113
115
|
rspec-core (~> 3.10.0)
|
114
116
|
rspec-expectations (~> 3.10.0)
|
@@ -122,20 +124,20 @@ GEM
|
|
122
124
|
diff-lcs (>= 1.2.0, < 2.0)
|
123
125
|
rspec-support (~> 3.10.0)
|
124
126
|
rspec-support (3.10.2)
|
125
|
-
rubocop (1.
|
127
|
+
rubocop (1.26.0)
|
126
128
|
parallel (~> 1.10)
|
127
|
-
parser (>= 3.
|
129
|
+
parser (>= 3.1.0.0)
|
128
130
|
rainbow (>= 2.2.2, < 4.0)
|
129
131
|
regexp_parser (>= 1.8, < 3.0)
|
130
132
|
rexml
|
131
|
-
rubocop-ast (>= 1.
|
133
|
+
rubocop-ast (>= 1.16.0, < 2.0)
|
132
134
|
ruby-progressbar (~> 1.7)
|
133
135
|
unicode-display_width (>= 1.4.0, < 3.0)
|
134
|
-
rubocop-ast (1.
|
135
|
-
parser (>= 3.0.
|
136
|
+
rubocop-ast (1.31.1)
|
137
|
+
parser (>= 3.3.0.4)
|
136
138
|
rubocop-rspec (2.5.0)
|
137
139
|
rubocop (~> 1.19)
|
138
|
-
ruby-progressbar (1.
|
140
|
+
ruby-progressbar (1.13.0)
|
139
141
|
ruby2_keywords (0.0.5)
|
140
142
|
simplecov (0.21.2)
|
141
143
|
docile (~> 1.1)
|
@@ -155,7 +157,7 @@ GEM
|
|
155
157
|
unf (0.1.4)
|
156
158
|
unf_ext
|
157
159
|
unf_ext (0.0.8.2)
|
158
|
-
unicode-display_width (2.
|
160
|
+
unicode-display_width (2.5.0)
|
159
161
|
webmock (3.14.0)
|
160
162
|
addressable (>= 2.8.0)
|
161
163
|
crack (>= 0.3.2)
|
data/README.md
CHANGED
@@ -73,7 +73,12 @@ KB.config.log_level = :debugger # :info by default
|
|
73
73
|
- `referrals`
|
74
74
|
- returns all the KB::Referral associated with this pet parent
|
75
75
|
- `referrers`
|
76
|
-
- returns all the KB::Referral associated with any of the pet parent's pets
|
76
|
+
- returns all the KB::Referral associated with any of the pet parent's pets
|
77
|
+
- `iban`
|
78
|
+
- returns the IBAN of the pet parent
|
79
|
+
- `update_iban`
|
80
|
+
- arg: `iban` string
|
81
|
+
- updates the IBAN of the pet parent and reloads the entity
|
77
82
|
|
78
83
|
#### Assessment 📄
|
79
84
|
|
@@ -245,7 +250,7 @@ You should be able to use the API seemlessly and the calls to the API will be in
|
|
245
250
|
## Development & Testing
|
246
251
|
|
247
252
|
```bash
|
248
|
-
docker run
|
253
|
+
docker compose run --rm kb bash
|
249
254
|
> bundle install
|
250
255
|
> rspec
|
251
256
|
```
|
data/barkibu-kb-fake.gemspec
CHANGED
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.bindir = 'exe'
|
33
33
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
34
34
|
spec.require_paths = ['lib']
|
35
|
-
spec.required_ruby_version = '>= 2.6'
|
35
|
+
spec.required_ruby_version = '>= 2.6', '< 3.3'
|
36
36
|
|
37
37
|
spec.add_runtime_dependency 'barkibu-kb', KB::VERSION
|
38
38
|
spec.add_runtime_dependency 'countries'
|
data/barkibu-kb.gemspec
CHANGED
@@ -34,7 +34,7 @@ Gem::Specification.new do |spec|
|
|
34
34
|
spec.bindir = 'exe'
|
35
35
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
36
36
|
spec.require_paths = ['lib']
|
37
|
-
spec.required_ruby_version = '>= 2.6'
|
37
|
+
spec.required_ruby_version = '>= 2.6', '< 3.3'
|
38
38
|
|
39
39
|
spec.add_dependency 'dry-configurable', '~> 0.9'
|
40
40
|
spec.add_development_dependency 'bundler'
|
data/docker-compose.yaml
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
version: "3.0"
|
2
2
|
services:
|
3
3
|
kb:
|
4
|
-
image: ruby:2.
|
4
|
+
image: ruby:3.2.3
|
5
5
|
working_dir: /app
|
6
6
|
volumes:
|
7
7
|
- .:/app
|
8
8
|
- bundle:/usr/local/bundle
|
9
|
-
environment:
|
9
|
+
environment:
|
10
10
|
- KB_API_URL_TEMPLATE=$KB_API_URL_TEMPLATE
|
11
11
|
- KB_PARTNER_KEY=$KB_PARTNER_KEY
|
12
12
|
- KB_API_KEY=$KB_API_KEY
|
@@ -15,6 +15,15 @@ module BoundedContext
|
|
15
15
|
KB::PetParent::FIELDS.map { |k| k.to_s.camelize(:lower) }
|
16
16
|
end
|
17
17
|
|
18
|
+
def on_petparents_show(_version)
|
19
|
+
pet_parent = pet_parent_by_key(params).dup
|
20
|
+
return json_response 404, {} if pet_parent.nil?
|
21
|
+
|
22
|
+
pet_parent['iban_last4'] = pet_parent.delete('iban')&.chars&.last(4)&.join
|
23
|
+
|
24
|
+
json_response 200, pet_parent
|
25
|
+
end
|
26
|
+
|
18
27
|
get '/v1/petparents/:key/pets' do
|
19
28
|
json_response 200, pets_by_pet_parent_key(params['key'])
|
20
29
|
end
|
@@ -70,6 +79,25 @@ module BoundedContext
|
|
70
79
|
json_response 200, resource
|
71
80
|
end
|
72
81
|
|
82
|
+
get '/v1/petparents/:key/iban' do
|
83
|
+
pet_parent = pet_parent_by_key(params)
|
84
|
+
return json_response 404, {} if pet_parent.blank?
|
85
|
+
|
86
|
+
json_response 200, { iban: pet_parent['iban'] }
|
87
|
+
end
|
88
|
+
|
89
|
+
put '/v1/petparents/:key/iban' do
|
90
|
+
pet_parent = pet_parent_by_key(params)
|
91
|
+
return json_response 404, {} if pet_parent.blank?
|
92
|
+
|
93
|
+
body = JSON.parse(request.body.read)
|
94
|
+
|
95
|
+
updated_pet_parent = pet_parent.merge body.slice('iban')
|
96
|
+
update_resource_state(:petparents, updated_pet_parent)
|
97
|
+
|
98
|
+
json_response 200, { iban: updated_pet_parent['iban'] }
|
99
|
+
end
|
100
|
+
|
73
101
|
private
|
74
102
|
|
75
103
|
def pet_parent_by_key(params)
|
data/lib/kb/models/assessment.rb
CHANGED
@@ -30,6 +30,9 @@ module KB
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
+
STRING_FIELDS = %i[key pet_key urgency].freeze
|
34
|
+
FIELDS = [*STRING_FIELDS, :date, :should_stop, :finished, :conditions, :symptoms, :next_question].freeze
|
35
|
+
|
33
36
|
# Legacy Field Name From Anamnesis
|
34
37
|
alias_attribute :consultation_id, :key
|
35
38
|
alias_attribute :should_stop, :finished
|
@@ -42,12 +45,7 @@ module KB
|
|
42
45
|
attribute :date, :datetime
|
43
46
|
attribute :finished, :boolean, default: false
|
44
47
|
|
45
|
-
|
46
|
-
attribute :key, :string
|
47
|
-
attribute :pet_key, :string
|
48
|
-
|
49
|
-
STRING_FIELDS = %i[key pet_key urgency].freeze
|
50
|
-
FIELDS = [*STRING_FIELDS, :date, :should_stop, :finished, :conditions, :symptoms, :next_question].freeze
|
48
|
+
define_attributes STRING_FIELDS, :string
|
51
49
|
|
52
50
|
def urgent
|
53
51
|
return false if urgency == 'low'
|
data/lib/kb/models/base_model.rb
CHANGED
@@ -13,6 +13,23 @@ module KB
|
|
13
13
|
|
14
14
|
class << self
|
15
15
|
delegate :clear_cache_for, to: :kb_client
|
16
|
+
|
17
|
+
def define_attribute_methods(*fields)
|
18
|
+
super
|
19
|
+
fields.each do |field|
|
20
|
+
define_method :"#{field}=" do |value|
|
21
|
+
super(value).tap do
|
22
|
+
public_send "#{field}_will_change!" if public_send("#{field}_changed?")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def define_attributes(attributes, cast_type = nil)
|
29
|
+
attributes.each do |attribute|
|
30
|
+
attribute attribute, cast_type&.to_sym
|
31
|
+
end
|
32
|
+
end
|
16
33
|
end
|
17
34
|
|
18
35
|
def initialize(attributes = {})
|
@@ -39,16 +56,5 @@ module KB
|
|
39
56
|
other.key == key)
|
40
57
|
end
|
41
58
|
alias eql? ==
|
42
|
-
|
43
|
-
def self.define_attribute_methods(*fields)
|
44
|
-
super
|
45
|
-
fields.each do |field|
|
46
|
-
define_method :"#{field}=" do |value|
|
47
|
-
super(value).tap do
|
48
|
-
public_send "#{field}_will_change!" if public_send("#{field}_changed?")
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
59
|
end
|
54
60
|
end
|
data/lib/kb/models/breed.rb
CHANGED
@@ -16,13 +16,8 @@ module KB
|
|
16
16
|
|
17
17
|
define_attribute_methods(*FIELDS)
|
18
18
|
|
19
|
-
STRING_FIELDS
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
DATE_FIELDS.each do |field|
|
24
|
-
attribute field, :date
|
25
|
-
end
|
19
|
+
define_attributes STRING_FIELDS, :string
|
20
|
+
define_attributes DATE_FIELDS, :date
|
26
21
|
|
27
22
|
def self.find(model, model_key)
|
28
23
|
response = kb_client.request("#{model}/#{model_key}/relationship")
|
data/lib/kb/models/pet.rb
CHANGED
@@ -21,17 +21,9 @@ module KB
|
|
21
21
|
|
22
22
|
define_attribute_methods(*FIELDS)
|
23
23
|
|
24
|
-
STRING_FIELDS
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
BOOLEAN_FIELDS.each do |field|
|
29
|
-
attribute field, :boolean
|
30
|
-
end
|
31
|
-
|
32
|
-
DATE_FIELDS.each do |field|
|
33
|
-
attribute field, :date
|
34
|
-
end
|
24
|
+
define_attributes STRING_FIELDS, :string
|
25
|
+
define_attributes DATE_FIELDS, :date
|
26
|
+
define_attributes BOOLEAN_FIELDS, :boolean
|
35
27
|
|
36
28
|
def save!
|
37
29
|
return unless changed?
|
@@ -31,17 +31,9 @@ module KB
|
|
31
31
|
|
32
32
|
define_attribute_methods(*FIELDS)
|
33
33
|
|
34
|
-
STRING_FIELDS
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
DATE_FIELDS.each do |field|
|
39
|
-
attribute field, :date
|
40
|
-
end
|
41
|
-
|
42
|
-
INTEGER_FIELDS.each do |field|
|
43
|
-
attribute field, :integer
|
44
|
-
end
|
34
|
+
define_attributes STRING_FIELDS, :string
|
35
|
+
define_attributes DATE_FIELDS, :date
|
36
|
+
define_attributes INTEGER_FIELDS, :integer
|
45
37
|
|
46
38
|
def save!
|
47
39
|
return unless changed?
|
data/lib/kb/models/pet_parent.rb
CHANGED
@@ -41,8 +41,8 @@ module KB
|
|
41
41
|
|
42
42
|
private_class_method :attributes_from_response
|
43
43
|
|
44
|
-
STRING_FIELDS = %i[key partner_name first_name last_name prefix_phone_number
|
45
|
-
|
44
|
+
STRING_FIELDS = %i[key partner_name first_name last_name prefix_phone_number phone_number email country address
|
45
|
+
zip_code nif affiliate_code city iban_last4].freeze
|
46
46
|
DATE_FIELDS = %i[birth_date deleted_at].freeze
|
47
47
|
BOOLEAN_FIELDS = %i[phone_number_verified email_verified].freeze
|
48
48
|
FIELDS = [*STRING_FIELDS, *DATE_FIELDS, *BOOLEAN_FIELDS].freeze
|
@@ -52,18 +52,9 @@ module KB
|
|
52
52
|
alias phone_number_prefix prefix_phone_number
|
53
53
|
alias phone_number_prefix= prefix_phone_number=
|
54
54
|
|
55
|
-
STRING_FIELDS
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
DATE_FIELDS.each do |field|
|
60
|
-
attribute field, :date
|
61
|
-
end
|
62
|
-
|
63
|
-
BOOLEAN_FIELDS.each do |field|
|
64
|
-
attribute field, :boolean
|
65
|
-
end
|
66
|
-
|
55
|
+
define_attributes STRING_FIELDS, :string
|
56
|
+
define_attributes DATE_FIELDS, :date
|
57
|
+
define_attributes BOOLEAN_FIELDS, :boolean
|
67
58
|
attribute :first_name, :string, default: ''
|
68
59
|
|
69
60
|
def save!
|
@@ -119,5 +110,18 @@ module KB
|
|
119
110
|
Referral.from_api(referral)
|
120
111
|
end
|
121
112
|
end
|
113
|
+
|
114
|
+
def iban
|
115
|
+
@iban ||= self.class.kb_client.request("#{key}/iban")['iban']
|
116
|
+
rescue Faraday::Error => e
|
117
|
+
raise KB::Error.from_faraday(e)
|
118
|
+
end
|
119
|
+
|
120
|
+
def update_iban(iban)
|
121
|
+
self.class.kb_client.request("#{key}/iban", filters: { iban: iban }, method: :put)
|
122
|
+
reload
|
123
|
+
rescue Faraday::Error => e
|
124
|
+
raise KB::Error.from_faraday(e)
|
125
|
+
end
|
122
126
|
end
|
123
127
|
end
|
data/lib/kb/models/plan.rb
CHANGED
@@ -19,13 +19,8 @@ module KB
|
|
19
19
|
attribute :plan_life_in_months, :integer
|
20
20
|
attribute :buyable, :boolean
|
21
21
|
|
22
|
-
STRING_FIELDS
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
|
-
HASH_FIELDS.each do |field|
|
27
|
-
attribute field
|
28
|
-
end
|
22
|
+
define_attributes STRING_FIELDS, :string
|
23
|
+
define_attributes HASH_FIELDS
|
29
24
|
|
30
25
|
def save!
|
31
26
|
return unless changed?
|
data/lib/kb/models/product.rb
CHANGED
@@ -23,12 +23,7 @@ module KB
|
|
23
23
|
|
24
24
|
attribute :purchasable, :boolean
|
25
25
|
|
26
|
-
STRING_FIELDS
|
27
|
-
|
28
|
-
end
|
29
|
-
|
30
|
-
STRING_ARRAY_FIELDS.each do |field|
|
31
|
-
attribute field, :array_of_strings
|
32
|
-
end
|
26
|
+
define_attributes STRING_FIELDS, :string
|
27
|
+
define_attributes STRING_ARRAY_FIELDS, :array_of_strings
|
33
28
|
end
|
34
29
|
end
|
data/lib/kb/models/referral.rb
CHANGED
@@ -16,13 +16,8 @@ module KB
|
|
16
16
|
|
17
17
|
define_attribute_methods(*FIELDS)
|
18
18
|
|
19
|
-
STRING_FIELDS
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
DATE_FIELDS.each do |field|
|
24
|
-
attribute field, :date
|
25
|
-
end
|
19
|
+
define_attributes STRING_FIELDS, :string
|
20
|
+
define_attributes DATE_FIELDS, :date
|
26
21
|
|
27
22
|
def self.create(pet_parent_key, attributes)
|
28
23
|
response = kb_client.request("#{pet_parent_key}/referrals", filters: attributes, method: :post)
|
@@ -18,9 +18,9 @@ module KB
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def scope_filters(record, _attribute, _value)
|
21
|
-
Array.wrap(options[:scope]).
|
21
|
+
Array.wrap(options[:scope]).to_h do |scope_attribute|
|
22
22
|
[scope_attribute, record.send(scope_attribute)]
|
23
|
-
end
|
23
|
+
end
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
data/lib/kb/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: barkibu-kb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.26.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Léo Figea
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-configurable
|
@@ -332,6 +332,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
332
332
|
- - ">="
|
333
333
|
- !ruby/object:Gem::Version
|
334
334
|
version: '2.6'
|
335
|
+
- - "<"
|
336
|
+
- !ruby/object:Gem::Version
|
337
|
+
version: '3.3'
|
335
338
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
336
339
|
requirements:
|
337
340
|
- - ">="
|