Class: WipApi::Todo

Inherits:
Object
  • Object
show all
Defined in:
lib/wip_api/todo.rb

Instance Method Summary collapse

Constructor Details

#initialize(client = Client.new) ⇒ Todo

Returns a new instance of Todo.



3
4
5
# File 'lib/wip_api/todo.rb', line 3

def initialize(client = Client.new)
  @client = client
end

Instance Method Details

#complete(todo_id) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/wip_api/todo.rb', line 21

def complete(todo_id)
  query = %{
  mutation completeTodo {
    completeTodo(id: #{todo_id}) {
      id
      body
      completed_at
    }
  }
}
  json = @client.make_request(query)
  json["data"]["completeTodo"]
end

#create(attributes = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/wip_api/todo.rb', line 7

def create(attributes = {})
  query = %{
  mutation createTodo {
    createTodo(input: {#{serialize_attributes(attributes)}}) {
      id
      body
      completed_at
    }
  }
}
  json = @client.make_request(query)
  json["data"]["createTodo"]
end