class WipApi::Todo

Public Class Methods

new(client = Client.new) click to toggle source
# File lib/wip_api/todo.rb, line 3
def initialize(client = Client.new)
  @client = client
end

Public Instance Methods

complete(todo_id) click to toggle source
# 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 = {}) click to toggle source
# 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

Private Instance Methods

serialize_attributes(attributes) click to toggle source
# File lib/wip_api/todo.rb, line 37
def serialize_attributes(attributes)
  attributes.collect do |k,v|
    "#{k}: \"#{v}\""
  end.join(", ")
end