barkibu-kb-fake 0.16.2 → 0.17.0
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 +4 -4
- data/lib/kb/fake/api.rb +6 -3
- data/lib/kb/fake/bounded_context/pet_family/pet_parents.rb +16 -0
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b71663986ee94f064a87196bc52f73cf066cdbc5a3e5a25fcba2a2d5d5ccd01
|
4
|
+
data.tar.gz: c34050ddb3bd1d8826e27de971b62c95028349f2feea6822f40aa5ff226e023c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98b9fc46c426869b6bd82cc2eb2110f1d358a8f87671ee54d64f4d331b7b81256a9e2027617ac31e3861535e209b3d525de7e83a8aea349441299c9f675a7121
|
7
|
+
data.tar.gz: c5dd96aef9d6716b45aa3f715f94f4bf55b3b4c662e1ea04de2c97f087e78c6121f035f0f8dd11caf36f8e8a55728f624f42818cf54b6613fd2f088e5f39508d
|
data/lib/kb/fake/api.rb
CHANGED
@@ -8,11 +8,12 @@ require 'kb/fake/bounded_context/pet_family/hubspot_relationship'
|
|
8
8
|
module KB
|
9
9
|
module Fake
|
10
10
|
class ApiState
|
11
|
-
attr_accessor :petparents, :pets, :consultations, :petcontracts, :plans, :breeds, :products,
|
11
|
+
attr_accessor :petparents, :pets, :consultations, :petcontracts, :plans, :breeds, :products,
|
12
|
+
:hubspot_relationship, :referrals
|
12
13
|
|
13
14
|
# rubocop:disable Metrics/ParameterLists
|
14
15
|
def initialize(petparents: [], pets: [], consultations: [], petcontracts: [], plans: [], breeds: [],
|
15
|
-
products: [], hubspot_relationship: [])
|
16
|
+
products: [], hubspot_relationship: [], referrals: [])
|
16
17
|
@petparents = petparents
|
17
18
|
@pets = pets
|
18
19
|
@consultations = consultations
|
@@ -21,6 +22,7 @@ module KB
|
|
21
22
|
@breeds = breeds
|
22
23
|
@products = products
|
23
24
|
@hubspot_relationship = hubspot_relationship
|
25
|
+
@referrals = referrals
|
24
26
|
end
|
25
27
|
# rubocop:enable Metrics/ParameterLists
|
26
28
|
|
@@ -33,7 +35,8 @@ module KB
|
|
33
35
|
plans: @plans.clone,
|
34
36
|
breeds: @breeds.clone,
|
35
37
|
products: @products.clone,
|
36
|
-
hubspot_relationship: @hubspot_relationship.clone
|
38
|
+
hubspot_relationship: @hubspot_relationship.clone,
|
39
|
+
referrals: @referrals.clone
|
37
40
|
}
|
38
41
|
end
|
39
42
|
end
|
@@ -26,6 +26,18 @@ module BoundedContext
|
|
26
26
|
json_response 200, contracts
|
27
27
|
end
|
28
28
|
|
29
|
+
get '/v1/petparents/:key/referrals' do
|
30
|
+
json_response 200, referrals_by_pet_parent_key(params['key'])
|
31
|
+
end
|
32
|
+
|
33
|
+
post '/v1/petparents/:key/referrals' do
|
34
|
+
resource = JSON.parse(request.body.read)
|
35
|
+
resource = resource.merge 'key' => SecureRandom.uuid
|
36
|
+
resource = resource.merge 'referralKey' => params['key']
|
37
|
+
resource_state(:referrals) << resource
|
38
|
+
json_response 201, resource
|
39
|
+
end
|
40
|
+
|
29
41
|
put '/v1/petparents' do
|
30
42
|
params = JSON.parse(request.body.read)
|
31
43
|
existing_pet_parent = pet_parent_by_key(params) || pet_parent_by_email(params) || pet_parent_by_phone(params)
|
@@ -78,6 +90,10 @@ module BoundedContext
|
|
78
90
|
resource_state(:pets).select { |pet| pet['petParentKey'] == key }
|
79
91
|
end
|
80
92
|
|
93
|
+
def referrals_by_pet_parent_key(key)
|
94
|
+
resource_state(:referrals).select { |resource| resource['referralKey'] == key }
|
95
|
+
end
|
96
|
+
|
81
97
|
def same_email_but_different_phone_number?(previous, new)
|
82
98
|
(previous['email'] == new['email']) &&
|
83
99
|
((previous['phoneNumber'] != new['phoneNumber']) ||
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: barkibu-kb-fake
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.17.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: 2022-06-
|
11
|
+
date: 2022-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: barkibu-kb
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.17.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.17.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: countries
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -104,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
104
|
- !ruby/object:Gem::Version
|
105
105
|
version: '0'
|
106
106
|
requirements: []
|
107
|
-
rubygems_version: 3.
|
107
|
+
rubygems_version: 3.3.7
|
108
108
|
signing_key:
|
109
109
|
specification_version: 4
|
110
110
|
summary: Barkibu's Knowledge Base Fake API
|