Class: Wunderlist::Sync

Inherits:
Object
  • Object
show all
Defined in:
lib/wunderlist/sync.rb

Overview

Strongly based on js/backend/wunderlist.sync.js

This is where the ‘steps’ come from.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(email, password, options = {}) ⇒ Sync

Returns a new instance of Sync.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/wunderlist/sync.rb', line 15

def initialize email, password, options = {}
  @options = Wunderlist::DEFAULTS.merge(options)

  if @options[:app_name] == Wunderlist::DEFAULTS[:app_name]
    STDERR.write "%s:%d: %s\n" % [
      File.expand_path(__FILE__), __LINE__,
      'Please set :app_name and :app_version to non-default values.'
    ]
  end

  @email = email
  if options[:hashed_password]
    @password_md5 = password
  else
    @password_md5 = OpenSSL::Digest.hexdigest('md5', password)
  end
end

Instance Attribute Details

#listsObject



48
49
50
# File 'lib/wunderlist/sync.rb', line 48

def lists
  @lists ||= Array.new
end

#step_1_responseObject (readonly)

Debug only, may be removed without warning



12
13
14
# File 'lib/wunderlist/sync.rb', line 12

def step_1_response
  @step_1_response
end

#tasksObject



52
53
54
# File 'lib/wunderlist/sync.rb', line 52

def tasks
  @tasks ||= Array.new
end

#user_idObject (readonly)

Returns the value of attribute user_id.



13
14
15
# File 'lib/wunderlist/sync.rb', line 13

def user_id
  @user_id
end

Instance Method Details

#syncObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/wunderlist/sync.rb', line 33

def sync
  # Sends:
  # - Tasks & lists: already synced, id & version
  # - TODO: New lists
  # Receives:
  # - New and updated tasks
  # - New and updated lists
  # - TODO: delete_tasks
  # - Current user id
  run_step_1
  # Process step 1 data
  run_step_2
  nil
end