-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebservice.js
More file actions
67 lines (63 loc) · 1.68 KB
/
webservice.js
File metadata and controls
67 lines (63 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
enyo.kind({
name: "Classic.WebService",
kind: enyo.Component,
published: {
cacheBust: true,
url: "",
method: "GET",
handleAs: "json",
postBody: "",
contentType: "application/x-www-form-urlencoded",
headers: null,
username: "",
password: ""
},
events: {
onSuccess: "",
onFailure: ""
},
call: function(parameters) {
this.service = new enyo.Ajax({cacheBust: this.cacheBust, url: this.url, handleAs: this.handleAs, method: this.method, headers: this.headers, contentType: this.contentType, username: this.username, password: this.password, postBody: this.postBody})
.response(this, "processResponse")
.error(this, "processFail")
.go(parameters)
;
},
processFail: function(inSender, inResponse) {
this.doFailure({response: inResponse, status: inSender.xhr.status});
},
processResponse: function(inSender, inResponse){
// you may get a status 0 positive response or it could mean that you don't have a connection: code appropriately
this.doSuccess({response: inResponse, status: inSender.xhr.status});
},
create: function() {
this.inherited(arguments);
if(this.published.cacheBust){
this.cacheBust = this.published.cacheBust;
}
if(this.published.handleAs) {
this.handleAs = this.published.handleAs;
}
if(this.published.url) {
this.url= this.published.url;
}
if(this.published.method) {
this.method = this.published.method;
}
if(this.published.headers) {
this.headers = this.published.headers;
}
if(this.published.contentType) {
this.contentType = this.published.contentType;
}
if(this.published.username) {
this.username = this.published.username;
}
if(this.published.password) {
this.password = this.published.password;
}
if(this.published.postBody){
this.postBody = this.published.postBody;
}
}
});