wunderlist-api 0.0.1 → 0.0.2

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
  SHA1:
3
- metadata.gz: 7e1da6d56e6a2b7a2e2ca66caf2495d8e059fb95
4
- data.tar.gz: 358af9890f09d8c158df0e35cc7342684cebbd4d
3
+ metadata.gz: e0e09c6b046a20429837db1b03ba46148d4fadfb
4
+ data.tar.gz: 3c60354c7d22ff9c05e23d6378d42e7cf639e927
5
5
  SHA512:
6
- metadata.gz: 3beba88ae6f289d0871754a4ec5ca0390df50878f978509e0328148c791c84dd9249edf77952339476af0b054dc0f3634dc6525ba9f2ea2c5e59317580479699
7
- data.tar.gz: e9207c4a235b0c740f98899f6b8e25258dc409530844f6e44c5c822213620a830ccdca5a1dd1eed4d00a6bb7f80f5af78464814aeaf014dcefb24efcf5561daa
6
+ metadata.gz: 988e3091a85eb60631ce1a78fa499b6766ac3c943dda7c7ff0e399708e7d9a307bb9fede62ebf118b1b44e81adedba5d48ab396a37f63df3ff708f1f6a853192
7
+ data.tar.gz: d732fc1c2fadd0502ee722662a29a3d5c97aaee673c1709f1c90f74f39e60f097831302b78efa8e167043bc329eebe0d6029e05cd4c37590294b23ee4420887e
data/README.md CHANGED
@@ -25,20 +25,22 @@ wl = Wunderlist::API.new({
25
25
  :client_id => <your client id>
26
26
  })
27
27
 
28
+
28
29
  # You can create Task
29
- wl.create_task(LIST_NAME, {'title' => 'Hello World', 'completed' => true, 'due_date' => '2015-03-25' })
30
+ task = wl.new_task(LIST_NAME, {'title' => 'Hello World', 'completed' => true, 'due_date' => '2015-03-25' })
31
+ task.save
30
32
 
31
- # You can get Wunderlist::Task Object
32
- task = wl.tasks([LIST_NAME])[0]
33
- => #<Wunderlist::Task:0x00000000000>
34
33
 
35
- # You can create and update note.
36
- task.notes.each do |note|
37
- note.content = "Hello World"
38
- note.update
39
- end
34
+ # You can get Wunderlist::Task Object Wrapped by Array
35
+ tasks = wl.tasks([LIST_NAME1, LIST_NAME2])
36
+ => [#<Wunderlist::Task:0x00000000000>, #<Wunderlist::Task:0x11111111111>, ...]
37
+
40
38
 
39
+ # You can create and update note.
40
+ note = task.note
41
41
  => #<Wunderlist::Note:0x00000000000>
42
+ note.content = "Hello World"
43
+ note.save
42
44
 
43
45
  ```
44
46
 
@@ -49,4 +51,6 @@ end
49
51
  3. Commit your changes (`git commit -am 'Add some feature'`)
50
52
  4. Push to the branch (`git push origin my-new-feature`)
51
53
  5. Create new Pull Request
54
+
52
55
  # wunderlist-api
56
+
@@ -43,13 +43,12 @@ module Wunderlist
43
43
 
44
44
  end
45
45
 
46
- def create_task(list_name, attrs = {})
46
+ def new_task(list_name, attrs = {})
47
47
  list_name = [list_name]
48
48
  list_id = get_list_ids(list_name)[0]
49
49
  attrs['list_id'] = list_id
50
50
  attrs['api'] = self
51
51
  @task = Wunderlist::Task.new(attrs)
52
- @task.save
53
52
  end
54
53
 
55
54
  def request(method, url, options = {})
@@ -6,8 +6,7 @@ module Wunderlist
6
6
 
7
7
  include Wunderlist::Helper
8
8
 
9
- attr_accessor :content, :api
10
- attr_reader :id, :task_id, :created_at, :updated_at, :revision
9
+ attr_accessor :id, :content, :api, :task_id, :created_at, :updated_at, :revision
11
10
 
12
11
  def initialize(options = {})
13
12
  @api = options['api']
@@ -20,15 +19,26 @@ module Wunderlist
20
19
  end
21
20
 
22
21
  def update
22
+ self.api.request :put, "api/v1/notes/#{self.id}", self.to_hash
23
+ end
24
+
25
+ def save
23
26
  if self.id.nil?
24
- self.create
27
+ res = self.api.request :post, "api/v1/notes", self.to_hash
25
28
  else
26
- self.api.request :put, "api/v1/notes/#{self.id}", self.to_hash
29
+ res = self.update
27
30
  end
31
+ self.set_attrs(res)
28
32
  end
29
33
 
30
- def create
31
- puts self.api.request :post, "api/v1/notes", self.to_hash
34
+ def set_attrs(res)
35
+ self.api = res['api']
36
+ self.id = res['id']
37
+ self.task_id = res['task_id']
38
+ self.content = res['content']
39
+ self.created_at = res['created_at']
40
+ self.updated_at = res['updated_at']
41
+ self.revision = res['revision']
32
42
  end
33
43
 
34
44
  end
@@ -7,8 +7,7 @@ module Wunderlist
7
7
 
8
8
  include Wunderlist::Helper
9
9
 
10
- attr_accessor :api, :title, :assignee_id, :completed, :recurrence_type, :recurrence_count, :due_date, :starred
11
- attr_reader :id, :list_id
10
+ attr_accessor :api, :title, :assignee_id, :completed, :revision, :recurrence_type, :recurrence_count, :due_date, :starred, :id, :list_id, :created_at
12
11
 
13
12
  def initialize(options = {})
14
13
  @api = options['api']
@@ -24,7 +23,8 @@ module Wunderlist
24
23
  end
25
24
 
26
25
  def save
27
- self.api.request :post, 'api/v1/tasks', self.to_hash
26
+ res = self.api.request :post, 'api/v1/tasks', self.to_hash
27
+ self.set_attrs(res)
28
28
  end
29
29
 
30
30
  def task_comments
@@ -41,24 +41,29 @@ module Wunderlist
41
41
 
42
42
  end
43
43
 
44
- def notes
44
+ def note
45
45
  res = self.api.request :get, 'api/v1/notes', {:task_id => self.id}
46
- notes = []
47
-
48
- res.each do |note|
49
- note = Wunderlist::Note.new(note)
50
- note.api = self.api
51
- notes << note
52
- end
53
-
54
- if notes.empty?
46
+ if !res[0].nil?
47
+ note = Wunderlist::Note.new(res[0])
48
+ else
55
49
  note = Wunderlist::Note.new('task_id' => self.id)
56
- note.api = self.api
57
- notes << note
58
50
  end
59
51
 
60
- notes
52
+ note.api = self.api
53
+ note.task_id = self.id
54
+
55
+ note
56
+
57
+ end
61
58
 
59
+ def set_attrs(res)
60
+ self.id = res['id']
61
+ self.title = res['title']
62
+ self.created_at = res['created_at']
63
+ self.completed = res['completed']
64
+ self.list_id = res['list_id']
65
+ self.starred = res['starred']
66
+ self.revision = res['revision']
62
67
  end
63
68
 
64
69
  end
@@ -1,3 +1,3 @@
1
1
  module Wunderlist
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wunderlist-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - shun3475
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-22 00:00:00.000000000 Z
11
+ date: 2015-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler