barkibu-kb 0.27.0 → 0.30.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: be4768b7d24f774209a31733ac0e00209831fca472439774979b825a7cd10de3
4
- data.tar.gz: be8447d966156578a51670ca233894505a1c416be5e5a18d831910e565d10367
3
+ metadata.gz: 31b4c4159fcdafcabc4bc31880b9218f8f1bd9089684087e784f27a11ee7d7c9
4
+ data.tar.gz: 467a1e6ed91ce5d9d9c2b821f5238ff3ff4366788bb221e376d80b4f6cf23bdb
5
5
  SHA512:
6
- metadata.gz: f16f6ffef3e44bc152ded87d4d5a091029b46823369a6c71adbbf2bc5919fe4c001415061fe43758a2a679d23375b3936dcecf80479f8425ec23cbabe6cd4686
7
- data.tar.gz: 53e00f26cd104a280881721cd53cc628beb668859c631cad50bd47462b3f17d49ced01e923392bbddb3e933c16e07d138f908c41a7d39d06755942546edb922a
6
+ metadata.gz: 6021d1226207ab48134597e144ed7a78d00f646cd09d91bef104e163f299fb7f2b7426433d364d28a9665dda32b4a97f9114b33cf3dd42ab0d0cc190289d823b
7
+ data.tar.gz: 0d0a5a42cf3ac7a93036cfede055a1689697567ad9a8c12696bf291731c05d7cfb8b774fd5aeac5c570222f3e176cbdeb7881c4710986666350c4f6610044ce6
data/.gitignore CHANGED
@@ -19,3 +19,4 @@
19
19
  # intellij
20
20
  /.idea
21
21
  .env
22
+ .claude/worktrees/
data/CHANGELOG.md CHANGED
@@ -6,7 +6,16 @@ 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.26...HEAD
9
+ - See diff: https://github.com/barkibu/kb-ruby/compare/v0.30.0...HEAD
10
+
11
+ ## [0.30.0]
12
+ - Add `KB::Pet.transfer` to call `POST /v1/pets/transfer`; add fake API route
13
+
14
+ ## [0.29.0]
15
+ - Add `created_at` field to PetParent DATE_FIELDS
16
+
17
+ ## [0.28.0]
18
+ - [Breaking changes] Remove Hubspot models
10
19
 
11
20
  # [0.27.0]
12
21
  - Add configuration option for request timeout
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- barkibu-kb (0.27.0)
4
+ barkibu-kb (0.30.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.27.0)
14
- barkibu-kb (= 0.27.0)
13
+ barkibu-kb-fake (0.30.0)
14
+ barkibu-kb (= 0.30.0)
15
15
  countries
16
16
  sinatra
17
17
  webmock
@@ -33,10 +33,6 @@ module KB
33
33
  call :petfamily, :products
34
34
  end
35
35
 
36
- def hubspot
37
- call :petfamily, :hubspot
38
- end
39
-
40
36
  def call(*args, **kwargs, &block)
41
37
  new(*args, **kwargs, &block).call
42
38
  end
data/lib/kb/fake/api.rb CHANGED
@@ -3,17 +3,15 @@ require 'kb/fake/bounded_context/pet_family/pet_parents'
3
3
  require 'kb/fake/bounded_context/pet_family/pets'
4
4
  require 'kb/fake/bounded_context/pet_family/products'
5
5
  require 'kb/fake/bounded_context/pet_family/pet_contracts'
6
- require 'kb/fake/bounded_context/pet_family/hubspot_relationship'
7
6
 
8
7
  module KB
9
8
  module Fake
10
9
  class ApiState
11
- attr_accessor :petparents, :pets, :consultations, :petcontracts, :plans, :breeds, :products,
12
- :hubspot_relationship, :referrals
10
+ attr_accessor :petparents, :pets, :consultations, :petcontracts, :plans, :breeds, :products, :referrals
13
11
 
14
12
  # rubocop:disable Metrics/ParameterLists
15
13
  def initialize(petparents: [], pets: [], consultations: [], petcontracts: [], plans: [], breeds: [],
16
- products: [], hubspot_relationship: [], referrals: [])
14
+ products: [], referrals: [])
17
15
  @petparents = petparents
18
16
  @pets = pets
19
17
  @consultations = consultations
@@ -21,7 +19,6 @@ module KB
21
19
  @plans = plans
22
20
  @breeds = breeds
23
21
  @products = products
24
- @hubspot_relationship = hubspot_relationship
25
22
  @referrals = referrals
26
23
  end
27
24
  # rubocop:enable Metrics/ParameterLists
@@ -35,7 +32,6 @@ module KB
35
32
  plans: @plans.clone,
36
33
  breeds: @breeds.clone,
37
34
  products: @products.clone,
38
- hubspot_relationship: @hubspot_relationship.clone,
39
35
  referrals: @referrals.clone
40
36
  }
41
37
  end
@@ -47,7 +43,6 @@ module KB
47
43
  include BoundedContext::PetFamily::PetParents
48
44
  include BoundedContext::PetFamily::PetContracts
49
45
  include BoundedContext::PetFamily::Products
50
- include BoundedContext::PetFamily::HubspotRelationship
51
46
 
52
47
  set :state, ApiState.new
53
48
 
@@ -45,6 +45,21 @@ module BoundedContext
45
45
  json_response 200, contracts
46
46
  end
47
47
 
48
+ post '/v1/pets/transfer' do
49
+ body = JSON.parse(request.body.read)
50
+ pet = find_resource(:pets, body['petKey'])
51
+ return json_response 404, {} if pet.nil?
52
+
53
+ destination_parent = find_resource(:petparents, body['destinationPetParentKey'])
54
+ return json_response 422, {} if destination_parent.nil?
55
+
56
+ unless pet['petParentKey'] == body['destinationPetParentKey']
57
+ update_resource_state(:pets, pet.merge('petParentKey' => body['destinationPetParentKey']))
58
+ end
59
+
60
+ json_response 204, nil
61
+ end
62
+
48
63
  put '/v1/pets' do
49
64
  params = JSON.parse(request.body.read)
50
65
  pet_parent = find_resource(:petparents, params['petParentKey'])
data/lib/kb/models/pet.rb CHANGED
@@ -51,6 +51,14 @@ module KB
51
51
  freeze
52
52
  end
53
53
 
54
+ def self.transfer(pet_key:, destination_pet_parent_key:)
55
+ kb_client.request('transfer', filters: { pet_key: pet_key,
56
+ destination_pet_parent_key: destination_pet_parent_key },
57
+ method: :post)
58
+ rescue Faraday::Error => e
59
+ raise KB::Error.from_faraday(e)
60
+ end
61
+
54
62
  def contracts
55
63
  self.class.kb_client.request("#{key}/contracts").map do |contract|
56
64
  PetContract.from_api(contract)
@@ -60,11 +60,5 @@ module KB
60
60
  def pet
61
61
  @pet ||= Pet.find(pet_key)
62
62
  end
63
-
64
- def hubspot_id
65
- @hubspot_id ||= KB::HubspotRelationship.find('policies', key).hubspot_id
66
- rescue KB::ResourceNotFound
67
- nil
68
- end
69
63
  end
70
64
  end
@@ -43,7 +43,7 @@ module KB
43
43
 
44
44
  STRING_FIELDS = %i[key partner_name first_name last_name prefix_phone_number phone_number email country address
45
45
  zip_code nif affiliate_code city iban_last4].freeze
46
- DATE_FIELDS = %i[birth_date deleted_at].freeze
46
+ DATE_FIELDS = %i[birth_date deleted_at created_at].freeze
47
47
  BOOLEAN_FIELDS = %i[phone_number_verified email_verified].freeze
48
48
  FIELDS = [*STRING_FIELDS, *DATE_FIELDS, *BOOLEAN_FIELDS].freeze
49
49
 
data/lib/kb/models.rb CHANGED
@@ -12,6 +12,5 @@ require 'kb/models/product'
12
12
  require 'kb/models/plan'
13
13
  require 'kb/models/breed'
14
14
 
15
- require 'kb/models/hubspot_relationship'
16
15
  require 'kb/models/referral'
17
16
  require 'kb/models/search_result'
data/lib/kb/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module KB
2
- VERSION = '0.27.0'.freeze
2
+ VERSION = '0.30.0'.freeze
3
3
  end
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.27.0
4
+ version: 0.30.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-07-30 00:00:00.000000000 Z
11
+ date: 2026-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-configurable
@@ -279,7 +279,6 @@ files:
279
279
  - lib/kb/fake/api.rb
280
280
  - lib/kb/fake/bounded_context/paginable.rb
281
281
  - lib/kb/fake/bounded_context/pet_family/breeds.rb
282
- - lib/kb/fake/bounded_context/pet_family/hubspot_relationship.rb
283
282
  - lib/kb/fake/bounded_context/pet_family/pet_contracts.rb
284
283
  - lib/kb/fake/bounded_context/pet_family/pet_parents.rb
285
284
  - lib/kb/fake/bounded_context/pet_family/pets.rb
@@ -302,7 +301,6 @@ files:
302
301
  - lib/kb/models/concerns/updatable.rb
303
302
  - lib/kb/models/concerns/upsertable.rb
304
303
  - lib/kb/models/condition.rb
305
- - lib/kb/models/hubspot_relationship.rb
306
304
  - lib/kb/models/pet.rb
307
305
  - lib/kb/models/pet_contract.rb
308
306
  - lib/kb/models/pet_parent.rb
@@ -1,17 +0,0 @@
1
- require 'kb/fake/bounded_context/rest_resource'
2
-
3
- module BoundedContext
4
- module PetFamily
5
- module HubspotRelationship
6
- extend ActiveSupport::Concern
7
-
8
- included do
9
- include RestResource
10
-
11
- get '/v1/hubspot/:model/:key/relationship' do
12
- resource_by_key(:hubspot_relationship, params['key'])
13
- end
14
- end
15
- end
16
- end
17
- end
@@ -1,29 +0,0 @@
1
- module KB
2
- class HubspotRelationship < BaseModel
3
- include Queryable
4
-
5
- kb_api :hubspot
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[kb_key hubspot_id].freeze
14
- DATE_FIELDS = %i[last_updated_at].freeze
15
- FIELDS = [*STRING_FIELDS, *DATE_FIELDS].freeze
16
-
17
- define_attribute_methods(*FIELDS)
18
-
19
- define_attributes STRING_FIELDS, :string
20
- define_attributes DATE_FIELDS, :date
21
-
22
- def self.find(model, model_key)
23
- response = kb_client.request("#{model}/#{model_key}/relationship")
24
- new(attributes_from_response(response))
25
- rescue Faraday::Error => e
26
- raise KB::Error.from_faraday(e)
27
- end
28
- end
29
- end