barkibu-kb 0.25.0 â 0.27.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -1
- data/Gemfile.lock +3 -3
- data/README.md +11 -0
- data/lib/barkibu-kb.rb +4 -0
- data/lib/kb/client.rb +3 -1
- 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/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be4768b7d24f774209a31733ac0e00209831fca472439774979b825a7cd10de3
|
4
|
+
data.tar.gz: be8447d966156578a51670ca233894505a1c416be5e5a18d831910e565d10367
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f16f6ffef3e44bc152ded87d4d5a091029b46823369a6c71adbbf2bc5919fe4c001415061fe43758a2a679d23375b3936dcecf80479f8425ec23cbabe6cd4686
|
7
|
+
data.tar.gz: 53e00f26cd104a280881721cd53cc628beb668859c631cad50bd47462b3f17d49ced01e923392bbddb3e933c16e07d138f908c41a7d39d06755942546edb922a
|
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.27.0]
|
12
|
+
- Add configuration option for request timeout
|
13
|
+
|
14
|
+
# [0.26.0]
|
15
|
+
- Add `#iban` and `#update_iban` to `PetParent`
|
16
|
+
- Add /iban endpoints in fake API
|
10
17
|
|
11
18
|
# [0.25.0]
|
12
19
|
- Add support for Ruby 3.2
|
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.27.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.27.0)
|
14
|
+
barkibu-kb (= 0.27.0)
|
15
15
|
countries
|
16
16
|
sinatra
|
17
17
|
webmock
|
data/README.md
CHANGED
@@ -42,6 +42,12 @@ KB.config.cache.expires_in = 1.second # 0 by default
|
|
42
42
|
KB.config.log_level = :debugger # :info by default
|
43
43
|
```
|
44
44
|
|
45
|
+
#### Request timeout configuration
|
46
|
+
```ruby
|
47
|
+
# config/initializers/kb_ruby.rb
|
48
|
+
KB.config.request.timeout = 10 # 5 by default
|
49
|
+
```
|
50
|
+
|
45
51
|
### Exposed Entities
|
46
52
|
|
47
53
|
#### Pet Parent đ§đŸ
|
@@ -74,6 +80,11 @@ KB.config.log_level = :debugger # :info by default
|
|
74
80
|
- returns all the KB::Referral associated with this pet parent
|
75
81
|
- `referrers`
|
76
82
|
- returns all the KB::Referral associated with any of the pet parent's pets
|
83
|
+
- `iban`
|
84
|
+
- returns the IBAN of the pet parent
|
85
|
+
- `update_iban`
|
86
|
+
- arg: `iban` string
|
87
|
+
- updates the IBAN of the pet parent and reloads the entity
|
77
88
|
|
78
89
|
#### Assessment đ
|
79
90
|
|
data/lib/barkibu-kb.rb
CHANGED
data/lib/kb/client.rb
CHANGED
@@ -74,7 +74,9 @@ module KB
|
|
74
74
|
end
|
75
75
|
|
76
76
|
def connection
|
77
|
-
@connection ||= Faraday.new(url: base_url,
|
77
|
+
@connection ||= Faraday.new(url: base_url,
|
78
|
+
headers: headers,
|
79
|
+
request: { timeout: KB.config.request.timeout }) do |conn|
|
78
80
|
conn.response :json
|
79
81
|
conn.response :raise_error
|
80
82
|
if KB.config.log_level == :debugger
|
@@ -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)
|
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.27.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-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-configurable
|