Class: StreamClient

Inherits:
Object
  • Object
show all
Defined in:
lib/omnifocus/attask.rb

Constant Summary collapse

PATH_LOGIN =
"/login"
PATH_LOGOUT =
"/logout"
PATH_SEARCH =
"/search"

Instance Method Summary collapse

Constructor Details

#initialize(apiURL) ⇒ StreamClient

Returns a new instance of StreamClient.



128
129
130
131
132
# File 'lib/omnifocus/attask.rb', line 128

def initialize(apiURL)
  @apiURL = apiURL
  @sessionID = nil
  @userID = nil;
end

Instance Method Details

#delete(objCode, objID, force = false) ⇒ Object

delete



175
176
177
# File 'lib/omnifocus/attask.rb', line 175

def delete(objCode, objID, force=false)
  request("/#{objCode}/#{objID}", {'force' => force}, nil, "DELETE")
end

#get(objCode, objID, fields = nil) ⇒ Object

retrieve



170
171
172
# File 'lib/omnifocus/attask.rb', line 170

def get(objCode, objID, fields=nil)
  request("/#{objCode}/#{objID}", nil, fields, "GET")
end

#getList(objCode, ids, fields = nil) ⇒ Object



155
156
157
# File 'lib/omnifocus/attask.rb', line 155

def getList(objCode, ids, fields=nil)
  request("/#{objCode}", {'id' => ids.join(',')}, fields, "GET")
end

#login(username, password) ⇒ Object



138
139
140
141
142
143
# File 'lib/omnifocus/attask.rb', line 138

def (username, password)
  data = request(PATH_LOGIN,
                 {'username' => username, 'password' => password}, nil, "GET")
  @sessionID = data['sessionID']
  @userID = data['userID']
end

#logoutObject



145
146
147
148
149
# File 'lib/omnifocus/attask.rb', line 145

def logout
  request(PATH_LOGOUT, {'sessionID' => @sessionID}, nil, "GET")
  @sessionID = nil
  @userID = nil
end

#post(objCode, message, fields = nil) ⇒ Object

create



160
161
162
# File 'lib/omnifocus/attask.rb', line 160

def post(objCode, message, fields=nil)
  request("/#{objCode}", message, fields, "POST")
end

#put(objCode, objID, message, fields = nil) ⇒ Object

update



165
166
167
# File 'lib/omnifocus/attask.rb', line 165

def put(objCode, objID, message, fields=nil)
  request("/#{objCode}/#{objID}", message, fields, "PUT")
end

#search(objCode, query, fields = nil) ⇒ Object



151
152
153
# File 'lib/omnifocus/attask.rb', line 151

def search(objCode, query, fields=nil)
  request("/#{objCode}#{PATH_SEARCH}", query, fields, "GET")
end

#userIDObject



134
135
136
# File 'lib/omnifocus/attask.rb', line 134

def userID
  @userID
end