Module: TodoableWrapper::Client::List

Included in:
TodoableWrapper::Client
Defined in:
lib/todoable_wrapper/list.rb

Instance Method Summary collapse

Instance Method Details

#create_list(list_name) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/todoable_wrapper/list.rb', line 29

def create_list(list_name)
  validate_token
  list = { list: {name: list_name} }
  options = { body: list.to_json, headers: {"Authorization" => "Token token=\"#{@token}\""} }
  response = self.class.post("/lists", options)
  response.code
end

#delete_list(id) ⇒ Object



45
46
47
48
49
50
# File 'lib/todoable_wrapper/list.rb', line 45

def delete_list(id)
  validate_token
  options = { headers: {"Authorization" => "Token token=\"#{@token}\""} }
  response = self.class.delete("/lists/#{id}", options)
  response.code
end

#get_list_by_id(id) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/todoable_wrapper/list.rb', line 18

def get_list_by_id(id)
  validate_token
  options = { headers: {"Authorization" => "Token token=\"#{@token}\""} }
  response = self.class.get("/lists/#{id}", options)
  if response.success?
    JSON.parse(response.body)
  else
    response
  end
end

#lists(options = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/todoable_wrapper/list.rb', line 7

def lists(options = {})
  validate_token
  options = { headers: {"Authorization" => "Token token=\"#{@token}\""} }
  response = self.class.get('/lists', options)
  if response.success?
    JSON.parse(response.body)
  else
    response
  end
end

#update_list(id, list_name) ⇒ Object



37
38
39
40
41
42
43
# File 'lib/todoable_wrapper/list.rb', line 37

def update_list(id, list_name)
  validate_token
  list = { list: {name: list_name} }
  options = { body: list.to_json, headers: {"Authorization" => "Token token=\"#{@token}\""} }
  response = self.class.patch("/lists/#{id}", options)
  response.code
end