Class: TokBoxer::Api

Inherits:
Object
  • Object
show all
Defined in:
lib/TokBoxer/Api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



5
6
7
# File 'lib/TokBoxer/Api.rb', line 5

def api_key
  @api_key
end

#api_server_urlObject (readonly)

Returns the value of attribute api_server_url.



5
6
7
# File 'lib/TokBoxer/Api.rb', line 5

def api_server_url
  @api_server_url
end

Instance Method Details

#add_comment(posterjabberId, vmailmessageid, commenttext, vmailcontentid) ⇒ Object

Feed API actions =================================================================================



62
63
64
65
66
67
# File 'lib/TokBoxer/Api.rb', line 62

def add_comment(posterjabberId, vmailmessageid, commenttext, vmailcontentid)
  method = "POST"
  call = "/vmail/addcomment"
  params = { :posterjabberId => posterjabberId, :vmailmessageid => vmailmessageid, :commenttext => commenttext, :vmailcontentid => vmailcontentid }
  result = request(method, call, params)
end

#add_contact(jabberId, remoteJabberId) ⇒ Object

Contacts API Actions =============================================================================



32
33
34
35
36
37
# File 'lib/TokBoxer/Api.rb', line 32

def add_contact(jabberId, remoteJabberId)
  method = "POST"
  call = "/contacts/request"
  params = { :jabberId => jabberId, :remoteJabberId => remoteJabberId }
  result = request(method, call, params)
end

#create_call(callerJabberId, callerName, persistent = false, features = "") ⇒ Object

Call API actions =================================================================================



9
10
11
12
13
14
# File 'lib/TokBoxer/Api.rb', line 9

def create_call(callerJabberId, callerName, persistent=false, features="")
  method = "POST"
  call = "/calls/create"
  params = { :callerJabberId => callerJabberId, :callerName => callerName, :persistent => persistent, :features => features }
  result = request(method, call, params)
end

#create_guest_userObject



152
153
154
155
156
157
158
159
160
161
162
# File 'lib/TokBoxer/Api.rb', line 152

def create_guest_user
  method = "POST"
  call = "/users/createGuest"
  params = { :partnerKey => @api_key }
  result = request(method, call, params, @api_secret)
  if result['error']
    raise UnknownException, result['error'].inspect
  else
    return create_user(result["createGuest"].first["jabberId"].first, result["createGuest"].first["secret"].first)
  end
end

#create_invite(callerJabberId, calleeJabberId, call_id) ⇒ Object



16
17
18
19
20
21
# File 'lib/TokBoxer/Api.rb', line 16

def create_invite(callerJabberId, calleeJabberId, call_id)
  method = "POST"
  call = "/calls/invite"
  params = { :callerJabberId => callerJabberId, :calleeJabberId => calleeJabberId, :call_id => call_id }
  result = request(method, call, params)
end

#create_user(jabberId, secret) ⇒ Object



148
149
150
# File 'lib/TokBoxer/Api.rb', line 148

def create_user(jabberId, secret)
  TokBoxer::User.new(jabberId, secret, self)
end

#delete_missed_call_from_feed(jabberId, invite_id) ⇒ Object



69
70
71
72
73
74
# File 'lib/TokBoxer/Api.rb', line 69

def delete_missed_call_from_feed(jabberId, invite_id)
  method = "POST"
  call = "/callevent/delete"
  params = { :jabberId => jabberId, :invite_id => invite_id }
  result = request(method, call, params)
end

#delete_vmail_from_feed(message_id, type) ⇒ Object



76
77
78
79
80
81
# File 'lib/TokBoxer/Api.rb', line 76

def delete_vmail_from_feed(message_id, type)
  method = "POST"
  call = "/vmail/delete"
  params = { :message_id => message_id, :type => type }
  result = request(method, call, params)
end

#forward_vmail(vmail_id, senderJabberId, text = "", tokboxRecipients = "", emailRecipients = "") ⇒ Object

VMail API actions ================================================================================



187
188
189
190
191
192
# File 'lib/TokBoxer/Api.rb', line 187

def forward_vmail(vmail_id, senderJabberId, text="", tokboxRecipients="", emailRecipients="")
  method = "POST"
  call = "/vmail/forward"
  params = { :vmail_id => vmail_id, :senderJabberId => senderJabberId, :text => text, :tokboxRecipients => tokboxRecipients, :emailRecipients => emailRecipients }
  result = request(method, call, params)
end

#forward_vmail_to_all_friends(vmail_id, senderJabberId, text = "") ⇒ Object



194
195
196
197
198
199
# File 'lib/TokBoxer/Api.rb', line 194

def forward_vmail_to_all_friends(vmail_id, senderJabberId, text="")
  method = "POST"
  call = "/vmail/forwardToFriends"
  params = { :vmail_id => vmail_id, :senderJabberId => senderJabberId, :text => text }
  result = request(method, call, params)
end

#get_access_token(jabberId, password) ⇒ Object

Token API actions ================================================================================



120
121
122
123
124
125
# File 'lib/TokBoxer/Api.rb', line 120

def get_access_token(jabberId, password)
  method = "POST"
  call = "/auth/getAccessToken"
  params = { :jabberId => jabberId, :password => password }
  result = request(method, call, params, @api_secret)
end

#get_all_of_the_comments_on_a_post(message_id, start = nil, count = nil) ⇒ Object



83
84
85
86
87
88
# File 'lib/TokBoxer/Api.rb', line 83

def get_all_of_the_comments_on_a_post(message_id, start = nil, count = nil)
  method = "POST"
  call = "/vmail/getcomments"
  params = { :message_id => message_id, :start => start, :count => count }
  result = request(method, call, params)
end

#get_feed(jabberId, filter = nil, start = nil, count = nil, sort = nil, dateRange = nil) ⇒ Object



90
91
92
93
94
95
# File 'lib/TokBoxer/Api.rb', line 90

def get_feed(jabberId, filter=nil, start=nil, count=nil, sort=nil, dateRange=nil)
  method = "POST"
  call = "/feed/getFeed"
  params = { :jabberId => jabberId, :filter => filter, :start => start, :count => count, :sort => sort, :dateRange => nil }
  result = request(method, call, params)
end

#get_feed_unread_count(jabberId) ⇒ Object



97
98
99
100
101
102
# File 'lib/TokBoxer/Api.rb', line 97

def get_feed_unread_count(jabberId)
  method = "POST"
  call = "/feed/unreadCount"
  params = { :jabberId => jabberId }
  result = request(method, call, params)
end

#get_request_token(callbackUrl) ⇒ Object



127
128
129
130
131
132
# File 'lib/TokBoxer/Api.rb', line 127

def get_request_token(callbackUrl)
  method = "POST"
  call = "/auth/getRequestToken"
  params = { :callbackUrl => callbackUrl }
  result = request(method, call, params, @api_secret)
end

#get_user_profile(jabberId) ⇒ Object



177
178
179
180
181
182
183
# File 'lib/TokBoxer/Api.rb', line 177

def (jabberId)
  @jabberId = jabberId
  method = "POST"
  call = "/users/getProfile"
  params = { :jabberId => jabberId }
  result = request(method, call, params)
end

#get_vmail(message_id) ⇒ Object



201
202
203
204
205
206
# File 'lib/TokBoxer/Api.rb', line 201

def get_vmail(message_id)
  method = "POST"
  call = "/vmail/getVmail"
  params = { :message_id => message_id }
  result = request(method, call, params)
end

#is_friend(jabberId, remoteJabberId) ⇒ Object



39
40
41
42
43
44
# File 'lib/TokBoxer/Api.rb', line 39

def is_friend(jabberId, remoteJabberId)
  method = "POST"
  call = "/contacts/getRelation"
  params = { :jabberId => jabberId, :remoteJabberId => remoteJabberId }
  result = request(method, call, params)
end

#join_call(invite_id) ⇒ Object



23
24
25
26
27
28
# File 'lib/TokBoxer/Api.rb', line 23

def join_call(invite_id)
  method = "POST"
  call = "/calls/join"
  params = { :invite_id => invite_id }
  result = request(method, call, params)
end

#login_user(jabberId, secret) ⇒ Object

User API actions =================================================================================



143
144
145
146
# File 'lib/TokBoxer/Api.rb', line 143

def (jabberId, secret)
  @jabberId = jabberId
  @secret = secret
end

#mark_missed_call_as_read_in_feed(jabberId, invite_id) ⇒ Object



104
105
106
107
108
109
# File 'lib/TokBoxer/Api.rb', line 104

def mark_missed_call_as_read_in_feed(jabberId, invite_id)
  method = "POST"
  call = "/callevent/markasviewed"
  params = { :jabberId => jabberId, :invite_id => invite_id }
  result = request(method, call, params)
end

#mark_vmail_as_read(message_id) ⇒ Object



111
112
113
114
115
116
# File 'lib/TokBoxer/Api.rb', line 111

def mark_vmail_as_read(message_id)
  method = "POST"
  call = "/vmail/markasviewed"
  params = { :message_id => message_id }
  result = request(method, call, params)
end

#post_public_vmail(vmail_id, scope, senderJabberId, text) ⇒ Object



208
209
210
211
212
213
# File 'lib/TokBoxer/Api.rb', line 208

def post_public_vmail(vmail_id, scope, senderJabberId, text)
  method = "POST"
  call = "/vmail/postPublic"
  params = { :vmail_id => vmail_id, :scope => scope, :senderJabberId => senderJabberId, :text => text }
  result = request(method, call, params)
end

#register_user(firstname, lastname, email) ⇒ Object



164
165
166
167
168
169
170
171
172
173
174
175
# File 'lib/TokBoxer/Api.rb', line 164

def register_user(firstname,lastname,email)
  method = "POST"
  call = "/users/register"
  params = { :firstname => firstname, :lastname => lastname, :email => email }
  result = request(method, call, params, @api_secret)
  if result['error']
    raise EmailAlreadyInUseException if result['error'].first['content'] == "That email is already in use" # error
    raise UnknownException, result['error'].inspect
  else
    return create_user(result["registerUser"].first["jabberId"].first, result["registerUser"].first["secret"].first)
  end
end

#reject_contact(jabberId, remoteJabberId) ⇒ Object



53
54
55
56
57
58
# File 'lib/TokBoxer/Api.rb', line 53

def reject_contact(jabberId, remoteJabberId)
  method = "POST"
  call = "/contacts/reject"
  params = { :jabberId => jabberId, :remoteJabberId => remoteJabberId }
  result = request(method, call, params)
end

#remove_contact(jabberId, remoteJabberId) ⇒ Object



46
47
48
49
50
51
# File 'lib/TokBoxer/Api.rb', line 46

def remove_contact(jabberId, remoteJabberId)
  method = "POST"
  call = "/contacts/remove"
  params = { :jabberId => jabberId, :remoteJabberId => remoteJabberId }
  result = request(method, call, params)
end

#send_vmail(vmail_id, senderJabberId, text = "", tokboxRecipients = "", emailRecipients = "") ⇒ Object



215
216
217
218
219
220
# File 'lib/TokBoxer/Api.rb', line 215

def send_vmail(vmail_id, senderJabberId, text="", tokboxRecipients="", emailRecipients="")
  method = "POST"
  call = "/vmail/send"
  params = { :vmail_id => vmail_id, :senderJabberId => senderJabberId, :text => text, :tokboxRecipients => tokboxRecipients, :emailRecipients => emailRecipients }
  result = request(method, call, params)
end

#send_vmail_to_alL_friends(vmail_id, senderJabberId, text = "") ⇒ Object



222
223
224
225
226
227
# File 'lib/TokBoxer/Api.rb', line 222

def send_vmail_to_alL_friends(vmail_id, senderJabberId, text="")
  method = "POST"
  call = "/vmail/sendToFriends"
  params = { :vmail_id => vmail_id, :senderJabberId => senderJabberId, :text => text }
  result = request(method, call, params)
end

#validate_access_token(jabberId, accessSecret) ⇒ Object



134
135
136
137
138
139
# File 'lib/TokBoxer/Api.rb', line 134

def validate_access_token(jabberId, accessSecret)
  method = "POST"
  call = "/auth/validateAccessToken"
  params = { :jabberId => jabberId, :accessSecret => accessSecret }
  result = request(method, call, params, @api_secret)
end