barkibu-kb 0.16.1 → 0.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/release.yaml +22 -0
- data/.gitignore +2 -1
- data/.rubocop.yml +7 -4
- data/CHANGELOG.md +62 -3
- data/Gemfile.lock +24 -27
- data/README.md +10 -0
- data/Rakefile +0 -1
- data/barkibu-kb-fake.gemspec +1 -1
- data/barkibu-kb.gemspec +1 -0
- data/lib/barkibu-kb.rb +0 -1
- data/lib/kb/client.rb +1 -1
- data/lib/kb/fake/api.rb +6 -3
- data/lib/kb/fake/bounded_context/pet_family/pet_parents.rb +16 -0
- data/lib/kb/models/base_model.rb +10 -0
- data/lib/kb/models/pet_contract.rb +3 -3
- data/lib/kb/models/pet_parent.rb +6 -0
- data/lib/kb/models/referral.rb +34 -0
- data/lib/kb/models.rb +1 -0
- data/lib/kb/version.rb +1 -1
- metadata +19 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ee4b2ec349cc4d1291d0e8ec58b55040ef144eb3f4524bfe9b7c3fe118225d9
|
4
|
+
data.tar.gz: 70983b7aaf88044333e7b42ab691519f97db4d42f8aa4feeb7bfd729a07e143f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b02676cc615a82d5a24e7dd447613d046f6f68a24ba76885797685adb88f4e6e19b1731218a657255c6d1ec37e41a435bd2e753e4f9144b06872b0c6ccde21e
|
7
|
+
data.tar.gz: 536d9e36b1ed11df391ea22c851d3effcd90fe5edc4950847ec524cda9f726d7777fa1a7de732f787620e4ba7f7f15fe7ee46657a444e8ae60283784f47df47b
|
@@ -0,0 +1,22 @@
|
|
1
|
+
name: Publish Gem
|
2
|
+
|
3
|
+
on:
|
4
|
+
workflow_dispatch:
|
5
|
+
|
6
|
+
jobs:
|
7
|
+
build:
|
8
|
+
runs-on: ubuntu-latest
|
9
|
+
|
10
|
+
steps:
|
11
|
+
- uses: actions/checkout@v3
|
12
|
+
|
13
|
+
- name: Github whoami
|
14
|
+
run: |
|
15
|
+
git config user.name 'Barkibot'
|
16
|
+
git config user.email 'dev+bot@barkibu.com'
|
17
|
+
- name: Release Gem
|
18
|
+
uses: cadwallion/publish-rubygems-action@master
|
19
|
+
env:
|
20
|
+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
21
|
+
RUBYGEMS_API_KEY: ${{secrets.RUBYGEMS_API_KEY}}
|
22
|
+
RELEASE_COMMAND: rake release
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -21,13 +21,13 @@ RSpec/FilePath:
|
|
21
21
|
Metrics/BlockLength:
|
22
22
|
Max: 15
|
23
23
|
Exclude:
|
24
|
-
-
|
25
|
-
-
|
26
|
-
-
|
24
|
+
- "spec/**/*.rb"
|
25
|
+
- "barkibu-kb.gemspec"
|
26
|
+
- "barkibu-kb-*.gemspec"
|
27
27
|
|
28
28
|
Naming/FileName:
|
29
29
|
Exclude:
|
30
|
-
-
|
30
|
+
- "lib/barkibu-kb*.rb"
|
31
31
|
|
32
32
|
Style/FrozenStringLiteralComment:
|
33
33
|
Enabled: false
|
@@ -43,3 +43,6 @@ Metrics/MethodLength:
|
|
43
43
|
|
44
44
|
Metrics/ModuleLength:
|
45
45
|
Max: 110
|
46
|
+
|
47
|
+
RSpec/ExampleLength:
|
48
|
+
CountAsOne: ["array", "heredoc", "hash"]
|
data/CHANGELOG.md
CHANGED
@@ -1,143 +1,201 @@
|
|
1
1
|
# Changelog
|
2
|
+
|
2
3
|
All notable changes to this project will be documented in this file.
|
3
4
|
|
4
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
7
|
|
8
|
+
## [0.18.0]
|
9
|
+
|
10
|
+
- add support for `payment_interval_months` attribute on `PetContract`
|
11
|
+
- add active-record like comparison for models
|
12
|
+
|
13
|
+
## [0.17.0]
|
14
|
+
|
15
|
+
- add `KB::Referral` model to create a referral on a PetParent
|
16
|
+
- add `PetParent#referrals` to get a list of referrals
|
17
|
+
|
18
|
+
## [0.16.2]
|
19
|
+
|
20
|
+
- Rename gems to barkibu-kb / barkibu-kb-fake
|
21
|
+
|
7
22
|
## [0.16.0]
|
23
|
+
|
8
24
|
- Add `Hubspot` model to retrieve information from [Hubspot Relationship endpoint](https://knowledge-base-staging.herokuapp.com/swagger-ui/index.html#/Hubspot)
|
9
25
|
- Change `husbpot_id` attribute on PetContract, now it comes from the Hubspot Relationship
|
10
26
|
|
11
27
|
## [0.15.1]
|
28
|
+
|
12
29
|
- Fix Cache invalidation deleting wrong key
|
13
30
|
|
14
31
|
## [0.15.0]
|
32
|
+
|
15
33
|
- Add `husbpot_id` attribute on PetContract
|
16
34
|
|
17
35
|
## [0.14.2]
|
36
|
+
|
18
37
|
- Fix Merged Pet Parent instanciation
|
19
38
|
|
20
39
|
## [0.14.1]
|
40
|
+
|
21
41
|
- Convert API exception into KB::Error for admin `merge!` endpoint
|
22
42
|
|
23
43
|
## [0.14.0]
|
44
|
+
|
24
45
|
- Add admin `merge!` method on PetParent
|
25
46
|
|
26
47
|
## [0.13.0]
|
27
|
-
|
48
|
+
|
49
|
+
- Add `affiliate_code` attribute on PetParent
|
28
50
|
|
29
51
|
## [0.12.0]
|
52
|
+
|
30
53
|
- Add `phone_number_verified` and `email_verified` attributes on PetParent
|
31
54
|
|
32
55
|
## [0.11.0]
|
56
|
+
|
33
57
|
- Expose product_key on PetContract
|
34
58
|
|
35
59
|
## [0.10.0]
|
60
|
+
|
36
61
|
- Add KB::Product Entity
|
37
62
|
|
38
63
|
## [0.9.0]
|
64
|
+
|
39
65
|
- Add conversion_utm_adgroup_id and conversion_utm_campaign_id to PetContract
|
40
66
|
|
41
67
|
## [0.8.0]
|
42
|
-
|
68
|
+
|
69
|
+
- Add conversion*utm*\* attributes to PetContract
|
43
70
|
|
44
71
|
## [0.7.2]
|
72
|
+
|
45
73
|
- Fix kb-fake pet parent upsert with partial identification
|
46
74
|
|
47
75
|
## [0.7.1]
|
76
|
+
|
48
77
|
- Fix dsl-configurable positional arg deprecated warning
|
49
78
|
|
50
79
|
## [0.7.0]
|
80
|
+
|
51
81
|
- Add new Error classes
|
52
82
|
- Emulate the same behavior on Pet Parent Upsert
|
53
83
|
|
54
84
|
## [0.6.0]
|
85
|
+
|
55
86
|
- Add price_discount_yearly PetContract attribute
|
56
87
|
|
57
88
|
## [0.5.0]
|
89
|
+
|
58
90
|
- Switch to consume petfamily based consultation endpoint
|
59
91
|
|
60
92
|
## [0.4.10]
|
93
|
+
|
61
94
|
- Add affiliate PetContract attributes
|
62
95
|
|
63
96
|
## [0.4.9]
|
97
|
+
|
64
98
|
- Fix ActiveModel dirty implementation
|
65
99
|
|
66
100
|
## [0.4.8]
|
101
|
+
|
67
102
|
- Fix KB::Error not accepting nil body
|
68
103
|
|
69
104
|
## [0.4.7]
|
105
|
+
|
70
106
|
- Breed - Add external_id field
|
71
107
|
|
72
108
|
## [0.4.6]
|
109
|
+
|
73
110
|
- PetParent - Add more KB fields
|
74
111
|
|
75
112
|
## [0.4.5]
|
113
|
+
|
76
114
|
- Breeds - Add server endpoint for tests on fake gem
|
77
115
|
|
78
116
|
## [0.4.4]
|
117
|
+
|
79
118
|
- Breeds - Adjust fields definition to petfamily domain ones
|
80
119
|
|
81
120
|
## [0.4.3]
|
121
|
+
|
82
122
|
- Breeds - Change client resolver template to use petfamily domain
|
83
123
|
|
84
124
|
## [0.4.2]
|
125
|
+
|
85
126
|
- Assessment - Parse time from date
|
86
127
|
|
87
128
|
## [0.4.1]
|
129
|
+
|
88
130
|
- Add Pet Upsert method
|
89
131
|
|
90
132
|
## [0.4.0]
|
133
|
+
|
91
134
|
- Add Upsert Endpoint
|
92
135
|
|
93
136
|
## [0.3.6]
|
137
|
+
|
94
138
|
- Add cache to client request method
|
95
139
|
|
96
140
|
## [0.3.5]
|
141
|
+
|
97
142
|
- Add Dry gem and setup config
|
98
143
|
- Add cache as gem config settings
|
99
144
|
- Add log level as gem config settings
|
100
145
|
- Improve KB Exceptions definitions
|
101
146
|
|
102
147
|
## [0.3.4]
|
148
|
+
|
103
149
|
- Fix planName attributes wrongly named on Plan
|
104
150
|
|
105
151
|
## [0.3.3]
|
152
|
+
|
106
153
|
- Fix buyable and planLifeInMonths attributes wrongly named on Plan
|
107
154
|
|
108
155
|
## [0.3.2]
|
156
|
+
|
109
157
|
- Exposes `KB::PetContract` entity
|
110
158
|
- Add `contracts` method to `KB::Pet` and `KB::PetParent`
|
111
159
|
|
112
160
|
## [0.3.1]
|
161
|
+
|
113
162
|
- Fix Fake Consultation wrong endpoint version
|
114
163
|
|
115
164
|
## [0.3.0]
|
165
|
+
|
116
166
|
- Extracted `kb-fake` gem for client test purposes
|
117
167
|
|
118
168
|
## [0.2.7]
|
169
|
+
|
119
170
|
- Fix missing deleted_at accessors on PetParent and Pet entities
|
120
171
|
|
121
172
|
## [0.2.6]
|
173
|
+
|
122
174
|
- Exposes `Destroyable` concerns on PetParent and Pet entities
|
123
175
|
|
124
176
|
## [0.2.5]
|
177
|
+
|
125
178
|
- Exposes `FindOrCreatable` concerns on PetParent and Pet entities
|
126
179
|
|
127
180
|
## [0.2.4]
|
181
|
+
|
128
182
|
- Fix Assessment not properly localized
|
129
183
|
|
130
184
|
## [0.2.3]
|
185
|
+
|
131
186
|
- Fix missing ActiveSupport dependency loading
|
132
187
|
|
133
188
|
## [0.2.2]
|
189
|
+
|
134
190
|
- Fix custom array types returning single element
|
135
191
|
- Test dependency extracted
|
136
192
|
|
137
193
|
## [0.2.1]
|
194
|
+
|
138
195
|
- Fix gem loading order for tests
|
139
196
|
|
140
197
|
## [0.2.0]
|
198
|
+
|
141
199
|
- Provide FakeApi for client implementation testing
|
142
200
|
- Add Pet entity
|
143
201
|
- Add `AsKBWrapper` concern for easy activerecord wrapping
|
@@ -145,9 +203,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
145
203
|
- `AsKBWrapper` - add `skip_callback` option
|
146
204
|
|
147
205
|
## [0.1.1] - 2020-01-12
|
206
|
+
|
148
207
|
- Init Version: Breeds and limited PetParents/Consultations
|
149
208
|
|
150
|
-
[
|
209
|
+
[unreleased]: https://github.com/barkibu/kb-ruby/compare/v0.10.0...HEAD
|
151
210
|
[0.10.0]: https://github.com/barkibu/kb-ruby/compare/v0.9.0...0.10.0
|
152
211
|
[0.9.0]: https://github.com/barkibu/kb-ruby/compare/v0.8.0...0.9.0
|
153
212
|
[0.8.0]: https://github.com/barkibu/kb-ruby/compare/v0.7.2...0.8.0
|
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.18.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.18.0)
|
14
|
+
barkibu-kb (= 0.18.0)
|
15
15
|
countries
|
16
16
|
sinatra
|
17
17
|
webmock
|
@@ -19,12 +19,12 @@ PATH
|
|
19
19
|
GEM
|
20
20
|
remote: https://rubygems.org/
|
21
21
|
specs:
|
22
|
-
activemodel (7.0.3)
|
23
|
-
activesupport (= 7.0.3)
|
24
|
-
activerecord (7.0.3)
|
25
|
-
activemodel (= 7.0.3)
|
26
|
-
activesupport (= 7.0.3)
|
27
|
-
activesupport (7.0.3)
|
22
|
+
activemodel (7.0.3.1)
|
23
|
+
activesupport (= 7.0.3.1)
|
24
|
+
activerecord (7.0.3.1)
|
25
|
+
activemodel (= 7.0.3.1)
|
26
|
+
activesupport (= 7.0.3.1)
|
27
|
+
activesupport (7.0.3.1)
|
28
28
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
29
29
|
i18n (>= 1.6, < 2)
|
30
30
|
minitest (>= 5.1)
|
@@ -34,8 +34,7 @@ GEM
|
|
34
34
|
ast (2.4.2)
|
35
35
|
byebug (11.1.3)
|
36
36
|
concurrent-ruby (1.1.10)
|
37
|
-
countries (5.
|
38
|
-
i18n_data (~> 0.16.0)
|
37
|
+
countries (5.1.2)
|
39
38
|
sixarm_ruby_unaccent (~> 1.1)
|
40
39
|
crack (0.4.5)
|
41
40
|
rexml
|
@@ -46,9 +45,9 @@ GEM
|
|
46
45
|
dry-configurable (0.15.0)
|
47
46
|
concurrent-ruby (~> 1.0)
|
48
47
|
dry-core (~> 0.6)
|
49
|
-
dry-core (0.
|
48
|
+
dry-core (0.8.1)
|
50
49
|
concurrent-ruby (~> 1.0)
|
51
|
-
faraday (1.10.
|
50
|
+
faraday (1.10.2)
|
52
51
|
faraday-em_http (~> 1.0)
|
53
52
|
faraday-em_synchrony (~> 1.0)
|
54
53
|
faraday-excon (~> 1.1)
|
@@ -81,7 +80,7 @@ GEM
|
|
81
80
|
ffi (>= 1.0.0)
|
82
81
|
rake
|
83
82
|
hashdiff (1.0.1)
|
84
|
-
http (5.0
|
83
|
+
http (5.1.0)
|
85
84
|
addressable (~> 2.8)
|
86
85
|
http-cookie (~> 1.0)
|
87
86
|
http-form_data (~> 2.2)
|
@@ -89,23 +88,21 @@ GEM
|
|
89
88
|
http-cookie (1.0.5)
|
90
89
|
domain_name (~> 0.5)
|
91
90
|
http-form_data (2.3.0)
|
92
|
-
i18n (1.
|
91
|
+
i18n (1.12.0)
|
93
92
|
concurrent-ruby (~> 1.0)
|
94
|
-
i18n_data (0.16.0)
|
95
|
-
simple_po_parser (~> 1.1)
|
96
93
|
llhttp-ffi (0.4.0)
|
97
94
|
ffi-compiler (~> 1.0)
|
98
95
|
rake (~> 13.0)
|
99
|
-
minitest (5.
|
96
|
+
minitest (5.16.3)
|
100
97
|
multipart-post (2.2.3)
|
101
|
-
mustermann (
|
98
|
+
mustermann (2.0.2)
|
102
99
|
ruby2_keywords (~> 0.0.1)
|
103
100
|
parallel (1.21.0)
|
104
101
|
parser (3.0.2.0)
|
105
102
|
ast (~> 2.4.1)
|
106
103
|
public_suffix (4.0.7)
|
107
|
-
rack (2.2.
|
108
|
-
rack-protection (2.2.
|
104
|
+
rack (2.2.4)
|
105
|
+
rack-protection (2.2.2)
|
109
106
|
rack
|
110
107
|
rainbow (3.0.0)
|
111
108
|
rake (13.0.6)
|
@@ -139,21 +136,20 @@ GEM
|
|
139
136
|
rubocop (~> 1.19)
|
140
137
|
ruby-progressbar (1.11.0)
|
141
138
|
ruby2_keywords (0.0.5)
|
142
|
-
simple_po_parser (1.1.6)
|
143
139
|
simplecov (0.21.2)
|
144
140
|
docile (~> 1.1)
|
145
141
|
simplecov-html (~> 0.11)
|
146
142
|
simplecov_json_formatter (~> 0.1)
|
147
143
|
simplecov-html (0.12.3)
|
148
144
|
simplecov_json_formatter (0.1.3)
|
149
|
-
sinatra (2.2.
|
150
|
-
mustermann (~>
|
145
|
+
sinatra (2.2.2)
|
146
|
+
mustermann (~> 2.0)
|
151
147
|
rack (~> 2.2)
|
152
|
-
rack-protection (= 2.2.
|
148
|
+
rack-protection (= 2.2.2)
|
153
149
|
tilt (~> 2.0)
|
154
150
|
sixarm_ruby_unaccent (1.2.0)
|
155
|
-
tilt (2.0.
|
156
|
-
tzinfo (2.0.
|
151
|
+
tilt (2.0.11)
|
152
|
+
tzinfo (2.0.5)
|
157
153
|
concurrent-ruby (~> 1.0)
|
158
154
|
unf (0.1.4)
|
159
155
|
unf_ext
|
@@ -177,6 +173,7 @@ DEPENDENCIES
|
|
177
173
|
rubocop
|
178
174
|
rubocop-rspec
|
179
175
|
simplecov
|
176
|
+
webmock
|
180
177
|
|
181
178
|
BUNDLED WITH
|
182
179
|
1.17.3
|
data/README.md
CHANGED
@@ -70,6 +70,8 @@ KB.config.log_level = :debugger # :info by default
|
|
70
70
|
- throws a `KB::Error` exception if something went wrong
|
71
71
|
- `contracts`
|
72
72
|
- returns all the KB::PetContract associated with this pet parent
|
73
|
+
- `referrals`
|
74
|
+
- returns all the KB::Referral associated with this pet parent
|
73
75
|
|
74
76
|
#### Assessment 📄
|
75
77
|
|
@@ -162,6 +164,14 @@ KB.config.log_level = :debugger # :info by default
|
|
162
164
|
- arg: `filters` hash of filters
|
163
165
|
- returns: and array of Cat Breed instances matching the filters
|
164
166
|
|
167
|
+
#### Referral
|
168
|
+
`KB::Referral` represets a referral resource
|
169
|
+
|
170
|
+
- `create`
|
171
|
+
- arg: `pet_parent_key`, `attributes` to initialize the entity
|
172
|
+
- returns: the raw attributes of the Referral instance
|
173
|
+
- throws an `KB::Error` exception if something went wrong
|
174
|
+
|
165
175
|
### Make an ActiveRecord wrap a KB entity
|
166
176
|
|
167
177
|
The `KB::Concerns::AsKBWrapper` concern has been created in order to easily make an ActiveRecord model wrap a KB model.
|
data/Rakefile
CHANGED
@@ -18,7 +18,6 @@ end
|
|
18
18
|
desc 'Tags version, pushes to remote, and pushes gem'
|
19
19
|
task release: :build do
|
20
20
|
sh 'git', 'tag', '-m', changelog, "v#{KB::VERSION}"
|
21
|
-
sh 'git push origin master'
|
22
21
|
sh "git push origin v#{KB::VERSION}"
|
23
22
|
sh 'ls pkg/*.gem | xargs -n 1 gem push'
|
24
23
|
end
|
data/barkibu-kb-fake.gemspec
CHANGED
@@ -34,8 +34,8 @@ Gem::Specification.new do |spec|
|
|
34
34
|
spec.require_paths = ['lib']
|
35
35
|
spec.required_ruby_version = '>= 2.6'
|
36
36
|
|
37
|
-
spec.add_runtime_dependency 'countries'
|
38
37
|
spec.add_runtime_dependency 'barkibu-kb', KB::VERSION
|
38
|
+
spec.add_runtime_dependency 'countries'
|
39
39
|
spec.add_runtime_dependency 'sinatra'
|
40
40
|
spec.add_runtime_dependency 'webmock'
|
41
41
|
end
|
data/barkibu-kb.gemspec
CHANGED
@@ -44,6 +44,7 @@ Gem::Specification.new do |spec|
|
|
44
44
|
spec.add_development_dependency 'rubocop'
|
45
45
|
spec.add_development_dependency 'rubocop-rspec'
|
46
46
|
spec.add_development_dependency 'simplecov'
|
47
|
+
spec.add_development_dependency 'webmock'
|
47
48
|
spec.add_runtime_dependency 'activemodel', '>= 4.0.2'
|
48
49
|
spec.add_runtime_dependency 'activerecord'
|
49
50
|
spec.add_runtime_dependency 'activesupport', '>= 3.0.0'
|
data/lib/barkibu-kb.rb
CHANGED
data/lib/kb/client.rb
CHANGED
@@ -8,7 +8,7 @@ module KB
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def request(sub_path, filters: nil, method: :get)
|
11
|
-
return connection.public_send(method, sub_path, filters).body if method != :get
|
11
|
+
return connection.public_send(method, sub_path, attributes_to_json(filters)).body if method != :get
|
12
12
|
|
13
13
|
cache_key = "#{@base_url}/#{sub_path}/#{(filters || {}).sort.to_h}"
|
14
14
|
KB::Cache.fetch(cache_key) do
|
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']) ||
|
data/lib/kb/models/base_model.rb
CHANGED
@@ -26,6 +26,16 @@ module KB
|
|
26
26
|
@persisted = true
|
27
27
|
end
|
28
28
|
|
29
|
+
# Copy-paste of ActiveRecord equality logic
|
30
|
+
# https://github.com/rails/rails/blob/main/activerecord/lib/active_record/core.rb
|
31
|
+
def ==(other)
|
32
|
+
super ||
|
33
|
+
(other.instance_of?(self.class) &&
|
34
|
+
!key.nil? &&
|
35
|
+
other.key == key)
|
36
|
+
end
|
37
|
+
alias eql? ==
|
38
|
+
|
29
39
|
def self.define_attribute_methods(*fields)
|
30
40
|
super
|
31
41
|
fields.each do |field|
|
@@ -23,11 +23,11 @@ module KB
|
|
23
23
|
conversion_utm_source conversion_utm_term
|
24
24
|
conversion_utm_adgroup_id conversion_utm_campaign_id].freeze
|
25
25
|
DATE_FIELDS = %i[policy_start_date policy_expiration_date].freeze
|
26
|
-
INTEGER_FIELDS = %i[
|
26
|
+
INTEGER_FIELDS = %i[
|
27
|
+
price_yearly price_monthly price_discount_yearly payment_interval_months
|
28
|
+
].freeze
|
27
29
|
FIELDS = [*STRING_FIELDS, *DATE_FIELDS, *INTEGER_FIELDS].freeze
|
28
30
|
|
29
|
-
IMMUTABLE_FIELDS = (FIELDS - %i[status contract_document policy_expiration_date]).freeze
|
30
|
-
|
31
31
|
define_attribute_methods(*FIELDS)
|
32
32
|
|
33
33
|
STRING_FIELDS.each do |field|
|
data/lib/kb/models/pet_parent.rb
CHANGED
@@ -0,0 +1,34 @@
|
|
1
|
+
module KB
|
2
|
+
class Referral < BaseModel
|
3
|
+
include Queryable
|
4
|
+
|
5
|
+
kb_api :pet_parent
|
6
|
+
|
7
|
+
def self.attributes_from_response(response)
|
8
|
+
response.transform_keys(&:underscore).transform_keys(&:to_sym).slice(*FIELDS)
|
9
|
+
end
|
10
|
+
|
11
|
+
private_class_method :attributes_from_response
|
12
|
+
|
13
|
+
STRING_FIELDS = %i[key referral_key referred_key type].freeze
|
14
|
+
DATE_FIELDS = %i[joined_at].freeze
|
15
|
+
FIELDS = [*STRING_FIELDS, *DATE_FIELDS].freeze
|
16
|
+
|
17
|
+
define_attribute_methods(*FIELDS)
|
18
|
+
|
19
|
+
STRING_FIELDS.each do |field|
|
20
|
+
attribute field, :string
|
21
|
+
end
|
22
|
+
|
23
|
+
DATE_FIELDS.each do |field|
|
24
|
+
attribute field, :date
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.create(pet_parent_key, attributes)
|
28
|
+
response = kb_client.request("#{pet_parent_key}/referrals", filters: attributes, method: :post)
|
29
|
+
attributes_from_response(response)
|
30
|
+
rescue Faraday::Error => e
|
31
|
+
raise KB::Error.from_faraday(e)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/kb/models.rb
CHANGED
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.18.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-
|
11
|
+
date: 2022-09-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-configurable
|
@@ -122,6 +122,20 @@ dependencies:
|
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: webmock
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
140
|
name: activemodel
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -229,6 +243,7 @@ extensions: []
|
|
229
243
|
extra_rdoc_files: []
|
230
244
|
files:
|
231
245
|
- ".env.example"
|
246
|
+
- ".github/workflows/release.yaml"
|
232
247
|
- ".gitignore"
|
233
248
|
- ".rspec"
|
234
249
|
- ".rubocop.yml"
|
@@ -290,6 +305,7 @@ files:
|
|
290
305
|
- lib/kb/models/pet_parent.rb
|
291
306
|
- lib/kb/models/plan.rb
|
292
307
|
- lib/kb/models/product.rb
|
308
|
+
- lib/kb/models/referral.rb
|
293
309
|
- lib/kb/models/symptom.rb
|
294
310
|
- lib/kb/type/array_of_conditions_type.rb
|
295
311
|
- lib/kb/type/array_of_strings_type.rb
|
@@ -318,7 +334,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
318
334
|
- !ruby/object:Gem::Version
|
319
335
|
version: '0'
|
320
336
|
requirements: []
|
321
|
-
rubygems_version: 3.
|
337
|
+
rubygems_version: 3.3.7
|
322
338
|
signing_key:
|
323
339
|
specification_version: 4
|
324
340
|
summary: Barkibu's Knowledge Base API sdk
|