├── .gitignore ├── .rspec ├── Gemfile ├── LICENSE.txt ├── README.md ├── Rakefile ├── lib ├── wunderlist.rb └── wunderlist │ ├── api.rb │ ├── helper.rb │ ├── list.rb │ ├── note.rb │ ├── reminder.rb │ ├── subtask.rb │ ├── task.rb │ ├── task_comment.rb │ ├── user.rb │ ├── version.rb │ └── webhook.rb ├── spec ├── spec_helper.rb └── wunderlist │ ├── api_spec.rb │ ├── list_spec.rb │ ├── note_spec.rb │ ├── reminder_spec.rb │ ├── subtask_spec.rb │ ├── task_comment_spec.rb │ ├── task_spec.rb │ └── webhook_spec.rb └── wunderlist-api.gemspec /.gitignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | *.rbc 3 | *.swp 4 | *.swo 5 | .bundle 6 | .config 7 | .yardoc 8 | Gemfile.lock 9 | InstalledFiles 10 | _yardoc 11 | coverage 12 | doc/ 13 | lib/bundler/man 14 | pkg 15 | rdoc 16 | spec/reports 17 | test/tmp 18 | test/version_tmp 19 | tmp 20 | -------------------------------------------------------------------------------- /.rspec: -------------------------------------------------------------------------------- 1 | --format documentation 2 | --color 3 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | # Specify your gem's dependencies in wunderlist-api.gemspec 4 | gemspec 5 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015 shun3475 2 | 3 | MIT License 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Wunderlist::Api 2 | 3 | You can manage Your Wunderlist Data like ActiveRecord with Ruby 4 | 5 | ## Installation 6 | 7 | Add this line to your application's Gemfile: 8 | 9 | gem 'wunderlist-api' 10 | 11 | And then execute: 12 | 13 | $ bundle 14 | 15 | Or install it yourself as: 16 | 17 | $ gem install wunderlist-api 18 | 19 | You should require this gem like; 20 | 21 | ``` 22 | require 'wunderlist' 23 | ``` 24 | 25 | ## Usage 26 | 27 | ``` 28 | # You must create API CLIENT at first. 29 | wl = Wunderlist::API.new({ 30 | access_token: , 31 | client_id: 32 | }) 33 | 34 | # You can create Task 35 | task = wl.new_task(LIST_NAME, {title: 'Hello World', completed: false, due_date: '2015-03-25'}) 36 | => # 37 | task.save 38 | 39 | # You can delete Task 40 | task.destroy 41 | => # 42 | task.id 43 | => nil 44 | 45 | # You can get Wunderlist::List Object 46 | list = wl.list(LIST_NAME) 47 | => # 48 | 49 | # You can change List name 50 | list.title = "IMOKENPI" 51 | list.save 52 | 53 | # You can get Wunderlist::Task Object Wrapped by Array 54 | tasks = list.tasks 55 | => [#, #, ...] 56 | 57 | or 58 | 59 | tasks = wl.tasks([LIST_NAME_OR_ID_1, LIST_NAME_OR_ID_2]) 60 | => [#, #, ...] 61 | 62 | # You can get already completed tasks 63 | tasks = list.tasks(completed: true) 64 | => [#, #, ...] 65 | 66 | or 67 | 68 | tasks = wl.tasks([LIST_NAME_OR_ID_1, LIST_NAME_IR_ID_2], completed: true) 69 | => [#, #, ...] 70 | 71 | # You can create and update note. 72 | note = task.note 73 | => # 74 | note.content = "Hello World" 75 | note.save 76 | 77 | # You can create and update reminder. 78 | note = task.reminder 79 | => # 80 | reminder.date = "2015-07-22 17:00" 81 | reminder.save 82 | 83 | # You can create and update subtask. 84 | subtask = task.new_subtask({title: "Hello World"}) 85 | => # 86 | subtask.save 87 | 88 | # You can get Wunderlist::Subtask Object Wrapped by Array 89 | subtasks = taks.subtasks 90 | => [#, #, ...] 91 | 92 | 93 | ``` 94 | 95 | ## Contributing 96 | 97 | 1. Fork it ( http://github.com/sh8/wunderlist-api/fork ) 98 | 2. Create your feature branch (`git checkout -b my-new-feature`) 99 | 3. Commit your changes (`git commit -am 'Add some feature'`) 100 | 4. Push to the branch (`git push origin my-new-feature`) 101 | 5. Create new Pull Request 102 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require "bundler/gem_tasks" 2 | require "rspec/core/rake_task" 3 | 4 | RSpec::Core::RakeTask.new(:spec) 5 | 6 | task :default => :spec 7 | -------------------------------------------------------------------------------- /lib/wunderlist.rb: -------------------------------------------------------------------------------- 1 | require "wunderlist/version" 2 | require "wunderlist/api" 3 | 4 | module Wunderlist 5 | end 6 | -------------------------------------------------------------------------------- /lib/wunderlist/api.rb: -------------------------------------------------------------------------------- 1 | require "wunderlist/list" 2 | require "wunderlist/task" 3 | require "wunderlist/user" 4 | require "wunderlist/webhook" 5 | require "wunderlist/version" 6 | require 'faraday' 7 | require 'json' 8 | 9 | module Wunderlist 10 | class API 11 | 12 | attr_reader :access_token 13 | attr_reader :client_id 14 | 15 | attr_accessor :conn 16 | 17 | API_URL = "https://a.wunderlist.com" 18 | 19 | def initialize(options = {}) 20 | @access_token = options[:access_token] 21 | @client_id = options[:client_id] 22 | end 23 | 24 | def conn 25 | @conn ||= Faraday::Connection.new(:url => API_URL) do |builder| 26 | builder.use Faraday::Request::UrlEncoded 27 | builder.use Faraday::Adapter::NetHttp 28 | end 29 | end 30 | 31 | def new_list(list_name) 32 | list = Wunderlist::List.new('title' => list_name) 33 | list.api = self 34 | list 35 | end 36 | 37 | def list(list_name_or_id) 38 | list_id = get_list_ids(list_name_or_id).first 39 | 40 | res_list = self.request :get, "api/v1/lists/#{list_id}" 41 | list = Wunderlist::List.new(res_list) 42 | list.api = self 43 | 44 | list 45 | 46 | end 47 | 48 | def lists 49 | res_lists = self.request :get, 'api/v1/lists' 50 | lists = [] 51 | res_lists.each do |l| 52 | list = Wunderlist::List.new(l) 53 | list.api = self 54 | lists << list 55 | end 56 | 57 | lists 58 | 59 | end 60 | 61 | def webhooks(list_name_or_id) 62 | list_id = get_list_ids(list_name_or_id).first 63 | 64 | res_webhooks = self.request :get, 'api/v1/webhooks', { :list_id => list_id } 65 | res_webhooks.reduce([]) do |webhooks, webhook| 66 | webhook = Wunderlist::Webhook.new(webhook) 67 | webhook.api = self 68 | webhooks << webhook 69 | end 70 | end 71 | 72 | def tasks(list_names_or_ids = [], completed = false) 73 | list_ids = get_list_ids(list_names_or_ids) 74 | tasks = [] 75 | list_ids.each do |list_id| 76 | res_tasks = self.request :get, 'api/v1/tasks', {:list_id => list_id, :completed => completed} 77 | if !res_tasks.empty? 78 | res_tasks.each do |t| 79 | task = Wunderlist::Task.new(t) 80 | task.api = self 81 | tasks << task 82 | end 83 | end 84 | end 85 | 86 | tasks 87 | 88 | end 89 | 90 | 91 | def user() 92 | res_user = self.request :get, 'api/v1/user' 93 | user = Wunderlist::User.new(res_user) 94 | user.api = self 95 | 96 | user 97 | end 98 | 99 | def new_task(list_name, attrs = {}) 100 | attrs.stringify_keys 101 | list_name = [list_name] 102 | list_id = get_list_ids(list_name)[0] 103 | attrs['list_id'] = list_id 104 | task = Wunderlist::Task.new(attrs) 105 | task.api = self 106 | 107 | task 108 | 109 | end 110 | 111 | def new_webhook(list_name_or_id, attrs = {}) 112 | list_id = get_list_ids(list_name_or_id).first 113 | attrs.stringify_keys 114 | attrs['list_id'] = list_id 115 | task = Wunderlist::Webhook.new(attrs) 116 | task.api = self 117 | 118 | task 119 | 120 | end 121 | 122 | def request(method, url, options = {}) 123 | case method 124 | when :get then self.get(url, options) 125 | when :post then self.post(url, options) 126 | when :put then self.put(url, options) 127 | when :delete then self.delete(url, options) 128 | end 129 | end 130 | 131 | def get(url, options = {}) 132 | 133 | response = conn.get do |req| 134 | req.url url 135 | if options 136 | options.each do |k, v| 137 | req.params[k] = v 138 | end 139 | end 140 | req.headers = { 141 | 'X-Access-Token' => self.access_token, 142 | 'X-Client-ID' => self.client_id 143 | } 144 | end 145 | 146 | JSON.parse(response.body) 147 | 148 | end 149 | 150 | def post(url, options = {}) 151 | 152 | response = conn.post do |req| 153 | req.url url 154 | req.body = options.to_json 155 | req.headers = { 156 | 'X-Access-Token' => self.access_token, 157 | 'X-Client-ID' => self.client_id, 158 | 'Content-Type' => 'application/json', 159 | 'Content-Encoding' => 'UTF-8' 160 | } 161 | end 162 | 163 | JSON.parse(response.body) 164 | end 165 | 166 | def put(url, options = {}) 167 | 168 | response = conn.put do |req| 169 | req.url url 170 | req.body = options.to_json 171 | req.headers = { 172 | 'X-Access-Token' => self.access_token, 173 | 'X-Client-ID' => self.client_id, 174 | 'Content-Type' => 'application/json', 175 | 'Content-Encoding' => 'UTF-8' 176 | } 177 | end 178 | 179 | JSON.parse(response.body) 180 | end 181 | 182 | def delete(url, options = {}) 183 | 184 | response = conn.delete do |req| 185 | req.url url 186 | req.params[:revision] = options[:revision] 187 | req.headers = { 188 | 'X-Access-Token' => self.access_token, 189 | 'X-Client-ID' => self.client_id, 190 | 'Content-Encoding' => 'UTF-8' 191 | } 192 | end 193 | 194 | response.status 195 | 196 | end 197 | 198 | 199 | 200 | def get_list_ids(list_names = []) 201 | if list_names.is_a? Array and list_names.all? {|i| i.is_a?(Integer) } 202 | return list_names 203 | end 204 | return [list_names] if list_names.is_a? Integer 205 | list_names = [list_names] if list_names.is_a? String 206 | 207 | lists = self.lists 208 | if !list_names.empty? 209 | lists = lists.select{|elm| list_names.include?(elm.title)} 210 | end 211 | lists.map{|list| list.id} 212 | end 213 | 214 | end 215 | end 216 | -------------------------------------------------------------------------------- /lib/wunderlist/helper.rb: -------------------------------------------------------------------------------- 1 | module Wunderlist 2 | module Helper 3 | 4 | def to_hash 5 | i_vs = self.instance_variables 6 | i_vs.delete_if {|i_v| i_v.to_s == '@api'} 7 | hash = {} 8 | i_vs.each {|var| hash[var.to_s.delete("@")] = self.instance_variable_get(var) } 9 | 10 | hash 11 | 12 | end 13 | 14 | def update 15 | self.api.request :put, resource_path, self.to_hash 16 | end 17 | 18 | def create 19 | self.api.request :post, path, self.to_hash 20 | end 21 | 22 | def save 23 | if self.id.nil? 24 | res = self.create 25 | else 26 | res = self.update 27 | end 28 | set_attrs(res) 29 | end 30 | 31 | def destroy 32 | self.api.request :delete, resource_path, {:revision => self.revision} 33 | self.id = nil 34 | 35 | self 36 | end 37 | 38 | def resource_path 39 | "api/v1/#{plural_model_name}/#{self.id}" 40 | end 41 | 42 | def path 43 | "api/v1/#{plural_model_name}" 44 | end 45 | 46 | def model_name 47 | self.class.to_s.gsub('Wunderlist::',''). 48 | gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2'). 49 | gsub(/([a-z])([A-Z])/, '\1_\2'). 50 | downcase 51 | end 52 | 53 | def plural_model_name 54 | "#{model_name}s" 55 | end 56 | end 57 | end 58 | 59 | class Hash 60 | 61 | def stringify_keys 62 | self.replace(self.inject({}){|a,(k,v)| a[k.to_s] = v; a}) 63 | end 64 | 65 | end 66 | 67 | -------------------------------------------------------------------------------- /lib/wunderlist/list.rb: -------------------------------------------------------------------------------- 1 | require 'wunderlist/helper' 2 | 3 | module Wunderlist 4 | class List 5 | 6 | include Wunderlist::Helper 7 | 8 | attr_accessor :id, :title, :api, :created_at, :revision 9 | 10 | def initialize(attrs = {}) 11 | @api = attrs['api'] 12 | @id = attrs['id'] 13 | @title = attrs['title'] 14 | @created_at = attrs['created_at'] 15 | @revision = attrs['revision'] 16 | end 17 | 18 | def new_task(attrs = {}) 19 | self.api.new_task(self.title, attrs) 20 | end 21 | 22 | def tasks(completed: false) 23 | self.api.tasks([self.title], completed) 24 | end 25 | 26 | def webhooks 27 | self.api.webhooks(self.title) 28 | end 29 | private 30 | 31 | def set_attrs(attrs = {}) 32 | self.api = attrs['api'] 33 | self.id = attrs['id'] 34 | self.title= attrs['content'] 35 | self.created_at = attrs['created_at'] 36 | self.revision = attrs['revision'] 37 | end 38 | 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /lib/wunderlist/note.rb: -------------------------------------------------------------------------------- 1 | require 'wunderlist/helper' 2 | 3 | module Wunderlist 4 | class Note 5 | 6 | include Wunderlist::Helper 7 | 8 | attr_accessor :id, :content, :api, :task_id, :created_at, :updated_at, :revision 9 | 10 | def initialize(attrs = {}) 11 | @api = attrs['api'] 12 | @id = attrs['id'] 13 | @task_id = attrs['task_id'] 14 | @content = attrs['content'] 15 | @created_at = attrs['created_at'] 16 | @updated_at = attrs['updated_at'] 17 | @revision = attrs['revision'] 18 | end 19 | 20 | private 21 | 22 | def set_attrs(attrs = {}) 23 | self.api = attrs['api'] 24 | self.id = attrs['id'] 25 | self.task_id = attrs['task_id'] 26 | self.content = attrs['content'] 27 | self.created_at = attrs['created_at'] 28 | self.updated_at = attrs['updated_at'] 29 | self.revision = attrs['revision'] 30 | end 31 | 32 | end 33 | end 34 | -------------------------------------------------------------------------------- /lib/wunderlist/reminder.rb: -------------------------------------------------------------------------------- 1 | require 'wunderlist/helper' 2 | require 'time' 3 | 4 | module Wunderlist 5 | class Reminder 6 | 7 | include Wunderlist::Helper 8 | 9 | attr_accessor :id, :api, :task_id, :created_at, :updated_at, :date, :revision 10 | 11 | def initialize(attrs = {}) 12 | @id = attrs['id'] 13 | @api = attrs['api'] 14 | @task_id = attrs['task_id'] 15 | @created_at = attrs['created_at'] 16 | @updated_at = attrs['updated_at'] 17 | @date = attrs['date'] 18 | @revision = attrs['revision'] 19 | end 20 | 21 | def date=(value) 22 | @date = Time.parse(value).getlocal.iso8601 23 | end 24 | 25 | private 26 | 27 | def set_attrs(attrs = {}) 28 | self.id = attrs['id'] 29 | self.api = attrs['api'] 30 | self.task_id = attrs['task_id'] 31 | self.created_at = attrs['created_at'] 32 | self.updated_at = attrs['updated_at'] 33 | self.date = attrs['date'] 34 | self.revision = attrs['revision'] 35 | end 36 | 37 | end 38 | end 39 | -------------------------------------------------------------------------------- /lib/wunderlist/subtask.rb: -------------------------------------------------------------------------------- 1 | require 'wunderlist/helper' 2 | 3 | module Wunderlist 4 | class Subtask 5 | 6 | include Wunderlist::Helper 7 | 8 | attr_accessor :id, :api, :task_id, :created_at, :created_by_id, :revision, :title 9 | 10 | def initialize(attrs = {}) 11 | @id = attrs['id'] 12 | @api = attrs['api'] 13 | @task_id = attrs['task_id'] 14 | @created_at = attrs['created_at'] 15 | @created_by_id = attrs['created_by_id'] 16 | @revision = attrs['revision'] 17 | @title = attrs['title'] 18 | end 19 | 20 | private 21 | 22 | def set_attrs(attrs = {}) 23 | self.id = attrs['id'] 24 | self.api = attrs['api'] 25 | self.task_id = attrs['task_id'] 26 | self.created_at = attrs['created_at'] 27 | self.created_by_id = attrs['created_by_id'] 28 | self.revision = attrs['revision'] 29 | self.title = attrs['title'] 30 | end 31 | 32 | end 33 | end 34 | -------------------------------------------------------------------------------- /lib/wunderlist/task.rb: -------------------------------------------------------------------------------- 1 | require 'wunderlist/note' 2 | require 'wunderlist/task_comment' 3 | require 'wunderlist/subtask' 4 | require 'wunderlist/reminder' 5 | require 'wunderlist/helper' 6 | 7 | module Wunderlist 8 | class Task 9 | 10 | include Wunderlist::Helper 11 | 12 | attr_accessor :api, :title, :assignee_id, :completed, :revision, :recurrence_type, :recurrence_count, :due_date, :starred, :id, :list_id, :created_at, :completed_at, :completed_by_id 13 | 14 | def initialize(attrs = {}) 15 | @api = attrs['api'] 16 | @id = attrs['id'] 17 | @list_id = attrs['list_id'] 18 | @title = attrs['title'] 19 | @revision = attrs['revision'] 20 | @assignee_id = attrs['assignee_id'] 21 | @created_at = attrs['created_at'] 22 | @completed = attrs['completed'] 23 | @completed_at = attrs['completed_at'] 24 | @completed_by_id = attrs['completed_by_id'] 25 | @recurrence_type = attrs['recurrence_type'] 26 | @recurrence_count = attrs['recurrence_count'] 27 | @due_date = attrs['due_date'] 28 | @starred = attrs['starred'] 29 | end 30 | 31 | def task_comments 32 | res = self.api.request :get, 'api/v1/task_comments', {:task_id => self.id} 33 | task_comments = [] 34 | 35 | res.each do |t_c| 36 | task_comment = Wunderlist::TaskComment.new(t_c) 37 | task_comment.api = self.api 38 | task_comments << task_comment 39 | end 40 | 41 | task_comments 42 | 43 | end 44 | 45 | def new_task_comment(attrs = {}) 46 | attrs.stringify_keys 47 | t_c = Wunderlist::TaskComment.new(attrs) 48 | t_c.api = self.api 49 | t_c.task_id = self.id 50 | 51 | t_c 52 | 53 | end 54 | 55 | def note 56 | res = self.api.request :get, 'api/v1/notes', {:task_id => self.id} 57 | if !res[0].nil? 58 | note = Wunderlist::Note.new(res[0]) 59 | else 60 | note = Wunderlist::Note.new('task_id' => self.id) 61 | end 62 | 63 | note.api = self.api 64 | note.task_id = self.id 65 | 66 | note 67 | 68 | end 69 | 70 | def reminder 71 | res = self.api.request :get, 'api/v1/reminders', {:task_id => self.id} 72 | if !res[0].nil? 73 | reminder = Wunderlist::Reminder.new(res[0]) 74 | else 75 | reminder = Wunderlist::Reminder.new('task_id' => self.id) 76 | end 77 | 78 | reminder.api = self.api 79 | reminder.task_id = self.id 80 | 81 | reminder 82 | 83 | end 84 | 85 | def new_subtask(attrs = {}) 86 | attrs.stringify_keys 87 | s_t = Wunderlist::Subtask.new(attrs) 88 | s_t.api = self.api 89 | s_t.task_id = self.id 90 | 91 | s_t 92 | 93 | end 94 | 95 | def subtasks 96 | res = self.api.request :get, 'api/v1/subtasks', {:task_id => self.id} 97 | subtasks = [] 98 | res.each do |r| 99 | subtask = Wunderlist::Subtask.new(r) 100 | subtask.api = self 101 | subtasks << subtask 102 | end 103 | 104 | #This will return tasks in backwards order, so reverse them 105 | subtasks.reverse 106 | 107 | end 108 | 109 | private 110 | 111 | def set_attrs(attrs = {}) 112 | self.id = attrs['id'] 113 | self.title = attrs['title'] 114 | self.created_at = attrs['created_at'] 115 | self.completed = attrs['completed'] 116 | self.list_id = attrs['list_id'] 117 | self.starred = attrs['starred'] 118 | self.revision = attrs['revision'] 119 | end 120 | 121 | end 122 | end 123 | -------------------------------------------------------------------------------- /lib/wunderlist/task_comment.rb: -------------------------------------------------------------------------------- 1 | require 'wunderlist/helper' 2 | 3 | module Wunderlist 4 | class TaskComment 5 | 6 | include Wunderlist::Helper 7 | 8 | attr_accessor :text, :type, :id, :api, :task_id, :revision, :created_at 9 | 10 | def initialize(attrs = {}) 11 | @api = attrs['api'] 12 | @id = attrs['id'] 13 | @task_id = attrs['task_id'] 14 | @revision = attrs['revision'] 15 | @text = attrs['text'] 16 | @type = attrs['type'] 17 | @created_at = attrs['created_at'] 18 | end 19 | 20 | private 21 | 22 | def set_attrs(attrs = {}) 23 | self.api = attrs['api'] 24 | self.id = attrs['id'] 25 | self.task_id = attrs['task_id'] 26 | self.revision = attrs['revision'] 27 | self.text = attrs['text'] 28 | self.type = attrs['type'] 29 | self.created_at = attrs['created_at'] 30 | end 31 | 32 | end 33 | end 34 | -------------------------------------------------------------------------------- /lib/wunderlist/user.rb: -------------------------------------------------------------------------------- 1 | module Wunderlist 2 | class User 3 | 4 | include Wunderlist::Helper 5 | 6 | attr_accessor :api, :id, :name, :email, :created_at 7 | 8 | def initialize(attrs = {}) 9 | @id = attrs['id'] 10 | @name = attrs['name'] 11 | @email = attrs['email'] 12 | @created_at = attrs['created_at'] 13 | end 14 | 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /lib/wunderlist/version.rb: -------------------------------------------------------------------------------- 1 | module Wunderlist 2 | VERSION = "1.1.2" 3 | end 4 | -------------------------------------------------------------------------------- /lib/wunderlist/webhook.rb: -------------------------------------------------------------------------------- 1 | module Wunderlist 2 | class Webhook 3 | 4 | include Wunderlist::Helper 5 | 6 | attr_accessor :api, :id, :list_id, :created_by_id, :processor_type, :url, :configuration, :created_at 7 | 8 | def initialize(attrs = {}) 9 | @id = attrs['id'] 10 | @list_id = attrs['list_id'] 11 | @created_by_id = attrs['created_by_id'] 12 | @processor_type = attrs['processor_type'] 13 | @url = attrs['url'] 14 | @created_at = attrs['created_at'] 15 | @configuration = attrs['configuration'] 16 | end 17 | 18 | def destroy 19 | # Seems no revision id is needed, contrary to documentation 20 | self.api.request :delete, resource_path 21 | self.id = nil 22 | 23 | self 24 | end 25 | end 26 | end -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__) 2 | require 'wunderlist' 3 | -------------------------------------------------------------------------------- /spec/wunderlist/api_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe Wunderlist::API do 4 | it 'should have a version number' do 5 | expect(Wunderlist::VERSION).to_not be_nil 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/wunderlist/list_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe Wunderlist::List do 4 | let(:list) { described_class.new } 5 | 6 | describe "a list" do 7 | it "has a model name" do 8 | expect(list.model_name).to eq 'list' 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /spec/wunderlist/note_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe Wunderlist::Note do 4 | let(:note) { described_class.new } 5 | 6 | describe "a note" do 7 | it "has a model name" do 8 | expect(note.model_name).to eq 'note' 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /spec/wunderlist/reminder_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe Wunderlist::Reminder do 4 | let(:reminder) { described_class.new } 5 | 6 | describe "a reminder" do 7 | it "has a model name" do 8 | expect(reminder.model_name).to eq 'reminder' 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /spec/wunderlist/subtask_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe Wunderlist::Subtask do 4 | let(:subtask) { described_class.new } 5 | 6 | describe "a subtask" do 7 | it "has a model name" do 8 | expect(subtask.model_name).to eq 'subtask' 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /spec/wunderlist/task_comment_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe Wunderlist::TaskComment do 4 | let(:task_comment) { described_class.new } 5 | 6 | describe "a task_comment" do 7 | it "has a model name" do 8 | expect(task_comment.model_name).to eq 'task_comment' 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /spec/wunderlist/task_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe Wunderlist::Task do 4 | let(:api) { Wunderlist::API.new } 5 | let(:task) { described_class.new } 6 | 7 | describe "a task" do 8 | it 'has a hash representation' do 9 | expect(task.to_hash.keys).to include(*%w( 10 | id 11 | list_id 12 | title 13 | revision 14 | assignee_id 15 | created_at 16 | completed 17 | completed_at 18 | completed_by_id 19 | recurrence_type 20 | recurrence_count 21 | due_date 22 | starred 23 | ) 24 | ) 25 | end 26 | 27 | it "has a model name" do 28 | expect(task.model_name).to eq 'task' 29 | end 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /spec/wunderlist/webhook_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe Wunderlist::Webhook do 4 | let(:api) { Wunderlist::API.new } 5 | let(:webhook) { described_class.new } 6 | 7 | describe "a webhook" do 8 | it 'has a hash representation' do 9 | expect(webhook.to_hash.keys).to include(*%w( 10 | id 11 | list_id 12 | created_by_id 13 | processor_type 14 | url 15 | created_at 16 | configuration 17 | ) 18 | ) 19 | end 20 | 21 | it "has a model name" do 22 | expect(webhook.model_name).to eq 'webhook' 23 | end 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /wunderlist-api.gemspec: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | lib = File.expand_path('../lib', __FILE__) 3 | $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) 4 | require 'wunderlist/version' 5 | 6 | Gem::Specification.new do |spec| 7 | spec.name = "wunderlist-api" 8 | spec.version = Wunderlist::VERSION 9 | spec.authors = ["shun3475"] 10 | spec.email = ["imokenpi3475@gmail.com"] 11 | spec.summary = %q{WunderList Ruby API Client.} 12 | spec.description = %q{You can manage Your Wunderlist Data with Ruby} 13 | spec.homepage = "https://github.com/shun3475/wunderlist-api" 14 | spec.license = "MIT" 15 | 16 | spec.files = `git ls-files -z`.split("\x0") 17 | spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } 18 | spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) 19 | spec.require_paths = ["lib"] 20 | 21 | spec.add_development_dependency "bundler", "~> 1.5" 22 | spec.add_development_dependency "rake" 23 | spec.add_development_dependency "rspec" 24 | spec.add_dependency 'faraday', '~> 0.9.1' 25 | end 26 | --------------------------------------------------------------------------------