public void getFiles() { Hammock.Authentication.OAuth.OAuthCredentials credentials = OAuthWorkFlow.createOAuthCredentials(OAuthType.ProtectedResource, ApiCredentials.TOKEN.token, ApiCredentials.TOKEN.secret, null, null); Hammock.RestClient client = new Hammock.RestClient() { Authority = "", Credentials = credentials }; Hammock.RestRequest request = new Hammock.RestRequest() { Path = links["files"].uri }; request.AddHeader("Accept", "application/vnd.deere.axiom.v3+json"); Hammock.RestResponse response = client.Request(request); CollectionPageDeserializer ds = new CollectionPageDeserializer(); files = ds.deserialize <SampleApp.Sources.generated.v3.File>(response.Content); Console.WriteLine("done"); }
private async Task <TagCollection <T> > fetchNewResourcesWithETag <T>(string path, string tag) where T : DataContracts.Resource { Logger.Log("RESOURCE", "fetchNewResourcesWithETag"); var response = await SecuredApiGetRequest(path, true, tag); Logger.Log(response); CollectionPageDeserializer ds = new CollectionPageDeserializer(); //CollectionPage<T> resources = null; TagCollection <T> tagCollection = new TagCollection <T>(); tagCollection.Tag = tag; tagCollection.CollectionPage = null; var content = await response.Content.ReadAsStringAsync(); if (response.StatusCode == HttpStatusCode.Forbidden) { return(tagCollection); } if (response.StatusCode == System.Net.HttpStatusCode.NotModified) { return(tagCollection); } else if (!string.IsNullOrEmpty(content)) { tagCollection.Tag = response.Headers.GetValues("x-deere-signature").FirstOrDefault(); tagCollection.CollectionPage = ds.deserialize <T>(content); } return(tagCollection); }
private async Task <CollectionPage <T> > fetchResources <T>(string path) where T : DataContracts.Resource { var response = await SecuredApiGetRequest(path); Logger.Log("RESOURCE", "fetchResources"); Logger.Log(response); CollectionPageDeserializer ds = new CollectionPageDeserializer(); CollectionPage <T> resources = null; string content = await response.Content.ReadAsStringAsync(); if (!string.IsNullOrEmpty(content)) { resources = ds.deserialize <T>(content); } return(resources); }
public void getUserOrganizations() { Hammock.RestClient client = getRestClient(); Hammock.RestRequest request = new Hammock.RestRequest() { Path = userOrganizations }; request.AddHeader("Accept", "application/vnd.deere.axiom.v3+json"); Hammock.RestResponse response = client.Request(request); CollectionPageDeserializer ds = new CollectionPageDeserializer(); CollectionPage <Organization> organizations = ds.deserialize <SampleApp.Sources.generated.v3.Organization>(response.Content); Dictionary <String, Link> linksFromFirst = OAuthWorkFlow.linksFrom(organizations.page[0]); fileUploadLink = linksFromFirst["uploadFile"]; }