-
Notifications
You must be signed in to change notification settings - Fork 3
/
BeesClient.m
145 lines (106 loc) · 3.96 KB
/
BeesClient.m
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
//
// BeesClient.m
// HudsonMobile
//
// Created by simone on 5/28/11.
// Copyright 2011 LMIT ltd. All rights reserved.
//
#import "BeesClient.h"
#import "AccountKeysResponse.h"
#import "ApplicationListResponse.h"
@implementation BeesClient
@synthesize delegate, onFinished;
- (id)init {
self = [self initWithApiKey:nil andSecret:nil];
if (self) {
}
return self;
}
-(id)initWithApiKey:(NSString*)_apikey andSecret:(NSString*)_secret{
self = [self initWithApiUrl:@"https://api.cloudbees.com/api" andApiKey:_apikey
andSecret:_secret andFormat:@"xml" andVersion:@"1.0"];
if (self) {
}
return self;
}
-(void)sayHello:(NSString*)message{
NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
[params setValue:message forKey:@"message"];
NSString* url = [super getRequestUrl:@"say.hello" andMethodParams:params];
[params release];
[self executeRequest: url withReceiver:self];
}
-(void) accountKeys:(NSString*) domain: (NSString*) user :(NSString*)password {
NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
[params setValue:user forKey:@"user"];
[params setValue:password forKey:@"password"];
if(domain!=nil){
[params setValue:domain forKey:@"domain"];
}
NSString* url = [super getRequestUrl:@"account.keys" andMethodParams:params];
[params release];
xmlDataParser = [[AccountKeysResponse alloc] init];
[xmlDataParser setCaller:self];
[xmlDataParser setOnLoadFinisched:@selector(onAccountKeyResponseLoadFinished)];
[self executeRequest: url withReceiver:self];
}
-(void) applicationList{
NSString* url = [super getRequestUrl:@"application.list" andMethodParams:nil];
xmlDataParser = [[ApplicationListResponse alloc] init];
[xmlDataParser setCaller:self];
[xmlDataParser setOnLoadFinisched:@selector(onApplicatonListResponseLoadFinished)];
[self executeRequest: url withReceiver:self];
}
-(void)onAccountKeyResponseLoadFinished{
if(delegate!=nil && onFinished!=nil){
[delegate performSelector:onFinished withObject:xmlDataParser];
}
}
-(void)onApplicatonListResponseLoadFinished{
if(delegate!=nil && onFinished!=nil){
[delegate performSelector:onFinished withObject:xmlDataParser];
}
}
-(void)receiveData:(NSData *)data{
NSXMLParser* xmlParser = [[NSXMLParser alloc] initWithData: data];
[xmlParser setDelegate: xmlDataParser];
[xmlParser setShouldResolveExternalEntities: YES];
[xmlParser parse];
[xmlParser release];
}
/*
public SayHelloResponse sayHello(String message) throws Exception {
}
public ApplicationListResponse applicationList() throws Exception {
}
public ApplicationInfo applicationInfo(String appId) throws Exception {
Map<String, String> params = new HashMap<String, String>();
params.put("app_id", appId);
String url = getRequestURL("application.info", params);
trace("API call: " + url);
ApplicationInfoResponse result = new ApplicationInfoResponse();
executeRequest(url, result);
return result.getApplicationInfo();
}
public AccountKeysResponse accountKeys(String domain, String user,
String password) throws Exception {
Map<String, String> params = new HashMap<String, String>();
params.put("user", user);
params.put("password", password);
if (domain != null)
params.put("domain", domain);
String url = getRequestURL("account.keys", params);
AccountKeysResponse result = new AccountKeysResponse();
executeRequest(url, result);
return result;
}
public AccountListResponse accountList() throws Exception {
Map<String, String> params = new HashMap<String, String>();
String url = getRequestURL("account.list", params);
trace("API call: " + url);
AccountListResponse result = new AccountListResponse();
executeRequest(url,result);
return result;
}
*/
@end