Fix import script

This commit is contained in:
Nemo 2019-08-12 18:56:52 +05:30
parent f8c659b28b
commit beed823d63
3 changed files with 13 additions and 3 deletions

View File

@ -54,7 +54,7 @@ remote_collection_name = ARGV[1]
# Create a root collection
CLIENT = Outliner::Client.new ENV['OUTLINE_BASE_URI']
root_collection_id = find_or_create_collection(CLIENT, remote_collection_name)
root_collection_id = CLIENT.find_or_create_collection(remote_collection_name)
begin
create_documents_recursively(local_directory, root_collection_id)

View File

@ -10,10 +10,20 @@ module Outliner
@token = ENV['OUTLINE_TOKEN']
end
def find_or_create_collection(name)
collections = self.collections_list(limit: 100)['data']
collections.filter!{|c|c['name'] == name}
if collections.size >= 1
collections[0]['id']
else
self.collections_create(name: name, description: 'Imported Collection')['data']['id']
end
end
def method_missing(method_name, params = {})
method_name = '/' + method_name.to_s.sub('_', '.')
body = {token: @token}.merge(params).to_json
options = {
options = {
body: body,
headers: {
'Accept'=>'application/json',

View File

@ -1,3 +1,3 @@
module Outliner
VERSION = "0.2.0"
VERSION = "0.2.1"
end