Open benpackard opened 8 years ago
hmm. I ran the response data thru a JSON validator and sirenlint
. Both passed with no problems.
Just to check it's nothing on my end, what happens when you plug the URI into the app?
I ran my sample and the zettaios/zetta app and both had devices appear. Network level thing?
-Matt
-- Matthew Dobson | apigee https://apigee.com/ | m: +1.734.634.5472 | twitter @mdobs http://twitter.com/mdobs @apigee https://twitter.com/apigee | Apigee Community http://community.apigee.com/ for answers, ideas and support!
On Thu, Mar 3, 2016 at 10:27 AM, brian mulloy notifications@github.com wrote:
hmm. I ran the response data thru a JSON validator and sirenlint. Both passed with no problems.
— Reply to this email directly or view it on GitHub https://github.com/zettajs/ZettaKit/issues/22#issuecomment-191814276.
@landlessness You're seeing the same in the app? Devices are listed for http://demo.zettaapi.org/servers/detroit
?
I'm able to read the response in Postman so pretty sure it's not an access thing. And am accessing it via the app using the same WiFi network. Other API is loading just fine. Weird.
@benpackard
this fails: http://demo.zettaapi.org/servers/detroit
this works: http://demo.zettaapi.org
perhaps we need an enhancement request so that on the iOS side, Zetta still works even if the user 'over specifies' the URL? @mdobson thoughts?
We handle this in the Zetta browser by using the Siren class values to route to the correct view. On Thu, Mar 3, 2016 at 7:49 AM brian mulloy notifications@github.com wrote:
@benpackard https://github.com/benpackard
this fails: http://demo.zettaapi.org/servers/detroit
this works: http://demo.zettaapi.org
perhaps we need an enhancement request so that on the iOS side, Zetta still works even if the user 'over specifies' the URL? @mdobson https://github.com/mdobson thoughts?
— Reply to this email directly or view it on GitHub https://github.com/zettajs/ZettaKit/issues/22#issuecomment-191822225.
@kevinswiber can you elaborate on this a little? Which class values do you intercept and how do you handle them? Do you and/or @mdobson think it's something I can do client-side, or should be added to ZettaKit? Thanks.
Time for a quick google hangout Ben? Easier to talk through.
-- Matthew Dobson | apigee https://apigee.com/ | m: +1.734.634.5472 | twitter @mdobs http://twitter.com/mdobs @apigee https://twitter.com/apigee | Apigee Community http://community.apigee.com/ for answers, ideas and support!
On Thu, Mar 3, 2016 at 11:42 AM, Ben Packard notifications@github.com wrote:
@kevinswiber https://github.com/kevinswiber can you elaborate on this a little? Which class values do you intercept and how do you handle them? Do you and/or @mdobson https://github.com/mdobson think it's something I can do client-side, or should be added to ZettaKit? Thanks.
— Reply to this email directly or view it on GitHub https://github.com/zettajs/ZettaKit/issues/22#issuecomment-191846332.
Nvm. Have other things coming up.
Class is apart of the Siren spec. It essentially dictates the context of an entity over the api. In the case of zetta some classes are root,* server, and device*. I'll throw together a code sample that you can use to interpret the class of an entity and make proper adjustments.
-Matt
-- Matthew Dobson | apigee https://apigee.com/ | m: +1.734.634.5472 | twitter @mdobs http://twitter.com/mdobs @apigee https://twitter.com/apigee | Apigee Community http://community.apigee.com/ for answers, ideas and support!
On Thu, Mar 3, 2016 at 11:43 AM, Matthew Dobson mdobson@apigee.com wrote:
Time for a quick google hangout Ben? Easier to talk through.
-- Matthew Dobson | apigee https://apigee.com/ | m: +1.734.634.5472 | twitter @mdobs http://twitter.com/mdobs @apigee https://twitter.com/apigee | Apigee Community http://community.apigee.com/ for answers, ideas and support!
On Thu, Mar 3, 2016 at 11:42 AM, Ben Packard notifications@github.com wrote:
@kevinswiber https://github.com/kevinswiber can you elaborate on this a little? Which class values do you intercept and how do you handle them? Do you and/or @mdobson https://github.com/mdobson think it's something I can do client-side, or should be added to ZettaKit? Thanks.
— Reply to this email directly or view it on GitHub https://github.com/zettajs/ZettaKit/issues/22#issuecomment-191846332.
Thanks, I have that part down, but I think I'm limited to simply sending the user-entered URL into the sharedSession
and monitoring its signal for devices and servers. I'm not sure how I can use the class to tweak the original URL since I'll never get anything back from the signal.
@benpackard Don't change the URL. The way I've built UI-based hypermedia clients in the past is to change the view based on the contents of the API response.
class
array.root
, server
, or device
.Does that make sense?
This is one way you could inspect the response with ZettaKit.
NSURL *url = [NSURL URLWithString:@"http://zetta-cloud-2.herokuapp.com/"];
ZIKSession *session = [ZIKSession sharedSession];
RACSignal *request = [session load:url];
RACSignal *remapped = [request map:^id(NSDictionary *value) {
NSLog(@"value %@", value);
if ([value[@"class"] indexOfObject:@"root"] != NSNotFound) {
return [ZIKRoot initWithDictionary:value];
} else if([value[@"class"] indexOfObject:@"server"] != NSNotFound) {
return [ZIKServer initWithDictionary:value];
} else if([value[@"class"] indexOfObject:@"device"] != NSNotFound) {
return [ZIKDevice initWithDictionary:value];
} else {
return value;
}
}];
[remapped subscribeNext:^(id x) {
NSLog(@"Entity: %@", x);
}];
@benpackard
@kevinswiber It does, but I don't have any access to the HTTP response. That's all abstracted nicely by ZettaKit.
@benpackard
You can also use subscribe to get the entity as well.
NSURL *url = [NSURL URLWithString:self.apiEndpoint];
ZIKSession *session = [ZIKSession sharedSession];
RACSignal *request = [session load:url];
[request subscribeNext:^(id x) {
NSDictionary *value = (NSDictionary *)x;
if ([value[@"class"] indexOfObject:@"root"] != NSNotFound) {
NSLog(@"Is root");
} else if([value[@"class"] indexOfObject:@"server"] != NSNotFound) {
NSLog(@"Is server");
} else if([value[@"class"] indexOfObject:@"device"] != NSNotFound) {
NSLog(@"Is device");
} else {
NSLog(@"Is %@", value[@"class"][0]);
}
}];
I'm not sure if there is an issue in the API content that ZettaKit is stumbling over or some other cause, but I can't receive any devices from
http://demo.zettaapi.org/servers/detroit
. @landlessness added a new property, but otherwise I don't see any significant differences.