lib/tsks/cli.rb in tsks-0.0.8 vs lib/tsks/cli.rb in tsks-0.0.9

- old
+ new

@@ -91,15 +91,15 @@ if !File.directory? CLI.setup_folder return puts "tsks was not initialized yet." end begin - res = Tsks::Request.post "/register", {email: options[:email], + res = Tsks::Request.post "/signup", {email: options[:email], password: options[:password]} if res && res[:ok] == true - File.write File.join(CLI.setup_folder, "token"), res[:token] + File.write File.join(CLI.setup_folder, "token"), res[:auth_token] File.write File.join(CLI.setup_folder, "user_id"), res[:user_id] Tsks::Actions.update_tsks_with_uuid res[:user_id] puts "Succesfully registered." elsif res && res[:ok] == false puts "This e-mail is already registered." @@ -118,15 +118,15 @@ if !File.directory? CLI.setup_folder return puts "tsks was not initialized yet." end begin - res = Tsks::Request.post "/login", {email: options[:email], + res = Tsks::Request.post "/signin", {email: options[:email], password: options[:password]} if res && res[:ok] == true - File.write File.join(CLI.setup_folder, "token"), res[:token] + File.write File.join(CLI.setup_folder, "token"), res[:auth_token] File.write File.join(CLI.setup_folder, "user_id"), res[:user_id] Tsks::Actions.update_tsks_with_uuid res[:user_id] puts "Succesfully logged in." elsif res && res[:ok] == false puts "Invalid e-mail or password." @@ -166,10 +166,12 @@ end if get_res[:ok] == true local_tsks_to_post = local_tsks - remote_tsks if local_tsks_to_post.count > 0 - Tsks::Request.post "/tsks", token, {tsks: local_tsks_to_post} + for tsk in local_tsks_to_post + Tsks::Request.post "/tsks", token, {tsk: tsk} + end end remote_tsks_to_storage = remote_tsks - local_tsks if remote_tsks_to_storage.count > 0 Tsks::Storage.insert_many remote_tsks_to_storage