Module: Syncthing::Helper::API

Defined in:
lib/syncthing/helper/api.rb,
lib/syncthing/helper/api/config.rb,
lib/syncthing/helper/api/updater.rb

Defined Under Namespace

Modules: Xml Classes: Config, DevicesUpdater, FoldersUpdater, UpdaterBase

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.firestoreObject

Returns the value of attribute firestore.



20
21
22
# File 'lib/syncthing/helper/api.rb', line 20

def firestore
  @firestore
end

Class Method Details

.api_key_from_xml(xml_file) ⇒ Object



30
31
32
# File 'lib/syncthing/helper/api.rb', line 30

def api_key_from_xml xml_file
  Xml::Config.from_xml(rio(xml_file).expand_path.read).gui.apikey
end

.init_firestore(project_id: nil, credentials: nil) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/syncthing/helper/api.rb', line 21

def init_firestore project_id: nil, credentials: nil
  @firestore ||= Google::Cloud::Firestore.new project_id: project_id, credentials: credentials
  const_set :Firestore, @firestore
  const_set :DB_FIELDS, {'devices' => [:device_id, :label],
                         'folders' => [:id, :path, :label]}
  const_set :DB_FIELDS_CONFIG_OBJ, {'devices' => 'deviceID',
                            'folders' => 'id'}
end