nexo 0.1.3 → 0.1.4

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: bf53f0b9f6a1041943a11b96d6688fc0506528d29d855615fb651f56d7dfdb81
4
- data.tar.gz: 1b707625c9f1f621daf84912c2bb2de01e008f4b7d7024c31dae0c7fa6019448
3
+ metadata.gz: 8e9cc07511456093aa96d53df983acf4bfc770ba3de05df5bacfb683f80840ca
4
+ data.tar.gz: 5b1918e753e917ac5e0331aa5d49fe03a5d0fcb87d64fc36bab85af638b79246
5
5
  SHA512:
6
- metadata.gz: 536a191c758d2ac7ccab8a5780a1d568820723571b9682382b71b5324de83109179882a1777b2a7380061e8289efec8c9c0e470c8f758ba2ec26a1c57117e575
7
- data.tar.gz: 2f5509307f988bcf11bd57e7582713f7d2dd187f53a6e915ca43050c476363ea427c43cd811ce7a968c90422bf560e79f530aec7f4d4a4fcb001856a2e448514
6
+ metadata.gz: 973db6311a60eb0534b3ca072976190bb3b5be953bc3b8f6cbb6e39207ba127b54711dd5ec0adbcc3f2c5cc4c4272302ca558ad0572c687f6864402e7bec4bde
7
+ data.tar.gz: 79ba89ed8a6dbbd17bdf8c6c055df802fb9ec4cca686075d2f5e2653c776d1b38599371158bd58fb3779aef6dffd8718bd9ea8b5c42e2403a30d917a5aa72505
data/README.md CHANGED
@@ -21,6 +21,11 @@ Or install it yourself as:
21
21
  $ gem install nexo
22
22
  ```
23
23
 
24
+ Install good_job
25
+ Configure good_job
26
+ max_threads:
27
+ queues:
28
+
24
29
  ## Contributing
25
30
  Contribution directions go here.
26
31
 
@@ -4,6 +4,8 @@ module Nexo
4
4
  if folder.external_identifier.present?
5
5
  protocol_service = ServiceBuilder.instance.build_protocol_service(folder)
6
6
  response = protocol_service.remove_calendar(folder)
7
+ else
8
+ Rails.logger.info("Folder doesn't have external_identifier: #{folder.to_gid}")
7
9
  end
8
10
  end
9
11
  end
@@ -1,10 +1,12 @@
1
1
  module Nexo
2
2
  class FolderSyncJob < BaseJob
3
3
  def perform(folder)
4
+ protocol_service = ServiceBuilder.instance.build_protocol_service(folder)
4
5
  if folder.external_identifier.blank?
5
- protocol_service = ServiceBuilder.instance.build_protocol_service(folder)
6
6
  response = protocol_service.insert_calendar(folder)
7
7
  folder.update(external_identifier: response.id)
8
+ else
9
+ protocol_service.update_calendar(folder)
8
10
  end
9
11
 
10
12
  policies = PolicyService.instance.policies_for(folder)
@@ -3,8 +3,10 @@ module Nexo
3
3
  #
4
4
  # @raise [Google::Apis::ClientError] possible messages:
5
5
  # - duplicate: The requested identifier already exists.
6
- # - notFound: Not Found
7
- # - forbidden: Forbidden (cuando se intenta updatear un evento que ya fue borrado)
6
+ # - notFound: Not Found (calendar not exists or was deleted)
7
+ # - forbidden: Forbidden (event to update was deleted)
8
+ #
9
+ # TODO! when event to update was deleted, create a new one and warn
8
10
  class GoogleCalendarService < CalendarService
9
11
  # Create an event in a Google Calendar
10
12
  #
@@ -44,6 +46,13 @@ module Nexo
44
46
  ApiResponse.new(payload: response.to_json, status: :ok, etag: response.etag, id: response.id)
45
47
  end
46
48
 
49
+ # Create a Google calendar
50
+ def update_calendar(folder)
51
+ cal = build_calendar(folder)
52
+ response = client.update_calendar(cal)
53
+ ApiResponse.new(payload: response.to_json, status: :ok, etag: response.etag, id: response.id)
54
+ end
55
+
47
56
  def remove_calendar(folder)
48
57
  client.delete_calendar(folder.external_identifier)
49
58
  ApiResponse.new(status: :ok)
@@ -10,7 +10,7 @@ module Nexo
10
10
  end
11
11
 
12
12
  def build_protocol_service(folder)
13
- service_klass_name = "#{folder.integration.client.service}_#{folder.protocol}_service".camelcase
13
+ service_klass_name = "#{folder.integration.client.service}_#{folder.nexo_protocol}_service".camelcase
14
14
  build_service(service_klass_name, folder.integration)
15
15
  end
16
16
 
@@ -62,7 +62,7 @@ module Nexo
62
62
  def update_from!(element_version)
63
63
  transaction do
64
64
  # TODO: parse the element_version.payload
65
- # and set the Synchronizable fields according to the Folder#protocol
65
+ # and set the Synchronizable fields according to the Folder#nexo_protocol
66
66
 
67
67
  new_sequence = increment_sequence!
68
68
  element_version.update_sequence!(new_sequence)
@@ -18,14 +18,14 @@ module Nexo
18
18
  has_many :elements, class_name: "Nexo::Element"
19
19
 
20
20
  if respond_to?(:enumerize)
21
- enumerize :protocol, in: { calendar: 0, dummy_calendar: 1 }
21
+ enumerize :nexo_protocol, in: { calendar: 0, dummy_calendar: 1 }
22
22
  else
23
- enum :protocol, calendar: 0, dummy_calendar: 1
23
+ enum :nexo_protocol, calendar: 0, dummy_calendar: 1
24
24
  end
25
25
 
26
26
  scope :kept, -> { where(discarded_at: nil) }
27
27
 
28
- validates :protocol, :name, presence: true
28
+ validates :nexo_protocol, :name, presence: true
29
29
 
30
30
  # TODO!: find better name
31
31
  # maybe policy_applies?
@@ -21,6 +21,11 @@ module Nexo
21
21
  belongs_to :user
22
22
  belongs_to :client, class_name: "Nexo::Client"
23
23
  has_many :tokens, class_name: "Nexo::Token"
24
+ has_many :folders, class_name: "Nexo::Folder"
25
+
26
+ before_validation do
27
+ self.scope = scope.select(&:present?)
28
+ end
24
29
 
25
30
  validates :scope, presence: true
26
31
 
@@ -2,7 +2,7 @@ class CreateNexoFolders < ActiveRecord::Migration[7.2]
2
2
  def change
3
3
  create_table :nexo_folders do |t|
4
4
  t.references :integration, null: false, foreign_key: { to_table: :nexo_integrations }
5
- t.integer :protocol, null: false
5
+ t.integer :nexo_protocol, null: false
6
6
  t.string :external_identifier
7
7
  t.string :name
8
8
  t.string :description
data/lib/nexo/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # :nocov: non-viable
2
2
  module Nexo
3
- VERSION = "0.1.3"
3
+ VERSION = "0.1.4"
4
4
  end
5
5
  # :nocov:
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nexo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martín Rosso
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-05-21 00:00:00.000000000 Z
11
+ date: 2025-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails