hubrise_app 1.2.8 → 1.2.9

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: 507fec5ef715afdd2d0db010143e59becb723fc2c6fc64c87fdb95fdaa42a500
4
- data.tar.gz: 1090c5f41835de5c32fcbfa94b348c1040d24c147288844ae5130a2025f62570
3
+ metadata.gz: 2458e9e26ff8db33b82c81bd6645860608ee0c32182070a65c0856360eace16a
4
+ data.tar.gz: ecae617677e07633eec06553ea7a735c54be23bb5959fae99d80b25012d6cc4d
5
5
  SHA512:
6
- metadata.gz: c858a6cb42b8e9d3374388d6d1ee537f3e4f4c91f209a3201430360eece8c2db9ecd521782c0d7c0c696aa754e8b5955d4a0940856474c6108d71ce5c570bd05
7
- data.tar.gz: 9bfffefb6d02730073d0ba36884456ca89f87b8a5fc130f759d7a0ab343d9f10dc63b84ed231975b8b5f073e85c2bce91e392372c1437aa3d62a7bd0e268e571
6
+ metadata.gz: d8d23311c388131485c855b329e49e576ba30c85e9a4ccd623d0c319ea6787981cdbf71609530085a04bc94ff70c15ba4d9643f8d7753ad0391f26017db28186
7
+ data.tar.gz: 5b0865fa370921e2b73bb57f1c171157d971fad8875d71a9112d89d05ba1c12309b596fc41d55c75631a6bebf9237de36452127ab4d74818e3bf9d84586c2872
@@ -15,7 +15,7 @@ module HubriseApp
15
15
  }
16
16
  end
17
17
 
18
- def attributes_from_event(event_params)
18
+ def attributes_from_event(event_params, _api_client)
19
19
  {
20
20
  api_data: cleanup_api_data(
21
21
  if event_params["resource_type"] == "location"
@@ -22,17 +22,17 @@ module HubriseApp
22
22
  resource
23
23
  end
24
24
 
25
- def from_event(resource, event_params)
25
+ def from_event(resource, event_params, api_client)
26
26
  case event_params["resource_type"]
27
27
  when "account"
28
- HubriseApp::Refresher::Account.from_event(resource.account, event_params)
28
+ HubriseApp::Refresher::Account.from_event(resource.account, event_params, api_client)
29
29
  when "location"
30
- HubriseApp::Refresher::Location.from_event(resource.location, event_params)
31
- HubriseApp::Refresher::Account.from_event(resource.account, event_params)
30
+ HubriseApp::Refresher::Location.from_event(resource.location, event_params, api_client)
31
+ HubriseApp::Refresher::Account.from_event(resource.account, event_params, api_client)
32
32
  when "catalog"
33
- HubriseApp::Refresher::Catalog.from_event(resource.catalog, event_params)
33
+ HubriseApp::Refresher::Catalog.from_event(resource.catalog, event_params, api_client)
34
34
  when "customer_list"
35
- HubriseApp::Refresher::CustomerList.from_event(resource.customer_list, event_params)
35
+ HubriseApp::Refresher::CustomerList.from_event(resource.customer_list, event_params, api_client)
36
36
  end
37
37
  end
38
38
 
@@ -16,11 +16,11 @@ module HubriseApp
16
16
  end
17
17
  end
18
18
 
19
- def from_event(resource, event_params)
19
+ def from_event(resource, event_params, api_client)
20
20
  return if resource.nil?
21
21
 
22
22
  resource.update!(
23
- attributes_from_event(event_params).merge(
23
+ attributes_from_event(event_params, api_client).merge(
24
24
  refreshed_at: Time.now,
25
25
  )
26
26
  )
@@ -44,7 +44,7 @@ module HubriseApp
44
44
  {}
45
45
  end
46
46
 
47
- def attributes_from_event(event_params)
47
+ def attributes_from_event(event_params, _api_client)
48
48
  event_params
49
49
  end
50
50
 
@@ -5,22 +5,22 @@ module HubriseApp
5
5
  class << self
6
6
  def attributes_from_api_call(resource, api_client)
7
7
  {
8
- api_data: cleanup_api_data(
9
- api_client.get_catalog(resource.hr_id, hide_data: true).data
10
- ),
8
+ api_data: fetch_api_data(resource.hr_id, api_client),
11
9
  }
12
10
  end
13
11
 
14
- def attributes_from_event(event_params)
12
+ def attributes_from_event(event_params, api_client)
15
13
  {
16
- api_data: cleanup_api_data(event_params["new_state"]),
14
+ api_data:
15
+ # Catalog update events do not contain "new_state", so we need to fetch from the API
16
+ fetch_api_data(event_params["id"], api_client),
17
17
  }
18
18
  end
19
19
 
20
20
  private
21
21
 
22
- def cleanup_api_data(api_data)
23
- api_data.except("id")
22
+ def fetch_api_data(catalog_id, api_client)
23
+ api_client.get_catalog(catalog_id, hide_data: true).data.except("id")
24
24
  end
25
25
  end
26
26
  end
@@ -11,7 +11,7 @@ module HubriseApp
11
11
  }
12
12
  end
13
13
 
14
- def attributes_from_event(event_params)
14
+ def attributes_from_event(event_params, _api_client)
15
15
  {
16
16
  api_data: cleanup_api_data(event_params["new_state"]),
17
17
  }
@@ -9,7 +9,7 @@ module HubriseApp
9
9
  }
10
10
  end
11
11
 
12
- def attributes_from_event(event_params)
12
+ def attributes_from_event(event_params, _api_client)
13
13
  {
14
14
  api_data: cleanup_api_data(event_params["new_state"]),
15
15
  }
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module HubriseApp
3
- VERSION = "1.2.8"
3
+ VERSION = "1.2.9"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hubrise_app
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.8
4
+ version: 1.2.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Antoine Monnier