public KnetikApiResponse Register( string username, string password, string email, string fullname, Action<KnetikApiResponse> cb = null ) { // Login as a guest KnetikApiResponse loginResponse = GuestLogin (); if (loginResponse.Status != KnetikApiResponse.StatusType.Success) { Debug.LogError("Guest login failed"); return loginResponse; } Debug.Log ("Guest login successful"); // Then register the new user JSONObject j = new JSONObject (JSONObject.Type.OBJECT); j.AddField ("username", username); j.AddField ("password", password); j.AddField ("email", email); j.AddField ("fullname", fullname); String body = j.Print (); KnetikRequest req = CreateRequest(RegisterEndpoint, body); KnetikApiResponse registerResponse = new KnetikApiResponse(this, req, cb); return registerResponse; }
public KnetikApiResponse ListStorePage( int page = 1, int limit = 10, List<string> terms = null, List<string> related = null, bool useCatalog = true, Action<KnetikApiResponse> cb = null ) { JSONObject j = new JSONObject (JSONObject.Type.OBJECT); j.AddField ("page", page); j.AddField ("limit", limit); if (terms != null) { j.AddField ("terms", JSONObject.Create(terms)); } if (related != null) { j.AddField ("related", JSONObject.Create(related)); } j.AddField("useCatalog", useCatalog); String body = j.Print (); KnetikRequest req = CreateRequest(ListStorePageEndpoint, body); KnetikApiResponse response = new KnetikApiResponse(this, req, cb); return response; }
private KnetikApiResponse OnRefresh(KnetikApiResponse res) { if (res.IsSuccess) { Value = res.Body ["result"] [Key].Value; } return res; }
public KnetikApiResponse Register( string username, string password, string email, string fullname, Action<KnetikApiResponse> cb = null ) { JSONObject j = new JSONObject (JSONObject.Type.OBJECT); j.AddField ("username", username); j.AddField ("password", password); j.AddField ("email", email); j.AddField ("fullname", fullname); String body = j.Print (); KnetikRequest req = CreateRequest(RegisterEndpoint, body); KnetikApiResponse res; if(cb != null) { res = new KnetikApiResponse(this, req, (resp) => { Debug.Log(resp.Body); if(resp.Status == KnetikApiResponse.StatusType.Success) { Login(username, password, cb); } else { if (OnRegisterFailed != null) { OnRegisterFailed(resp.ErrorMessage); } } cb(resp); }); } else { res = new KnetikApiResponse(this, req, null); Debug.Log(res.Body); if(res.Status == KnetikApiResponse.StatusType.Success) { Debug.Log(res.Body); res = Login(username, password, null); } else { if (OnRegisterFailed != null) { OnRegisterFailed(res.ErrorMessage); } } } return res; }
private KnetikApiResponse OnSave(KnetikApiResponse res) { if (res.IsSuccess) { // API doesn't return an ID, but we're persisted now so // we dont want to keep calling Create endpoint ID = 0; } return res; }
public KnetikApiResponse entitlementCheck(JSONObject j,Action<KnetikApiResponse> cb = null ) { String body = j.Print (); KnetikRequest req = CreateRequest(EntitlementEndpoint, body); KnetikApiResponse response = new KnetikApiResponse(this, req, cb); return response; }
public KnetikApiResponse verifyGooglePayment(JSONObject j,Action<KnetikApiResponse> cb = null ) { String body = j.Print (); KnetikRequest req = CreateRequest(GooglePaymentEndpoint, body); KnetikApiResponse response = new KnetikApiResponse(this, req, cb); return response; }
public KnetikApiResponse GetUserInfoWithProduct(string productIdentifier, Action<KnetikApiResponse> cb = null) { JSONObject j = new JSONObject (JSONObject.Type.OBJECT); j.AddField ("productId", productIdentifier); String body = j.Print (); KnetikRequest req = CreateRequest(GetUserInfoWithProductEndpoint, body); KnetikApiResponse res = new KnetikApiResponse(this, req, cb); return res; }
public KnetikApiResponse PutUserInfo(string name, string value, Action<KnetikApiResponse> cb = null) { JSONObject j = new JSONObject (JSONObject.Type.OBJECT); j.AddField ("configName", name); j.AddField ("configValue", value); String body = j.Print (); KnetikRequest req = CreateRequest(PutUserInfoEndpoint, body); KnetikApiResponse res = new KnetikApiResponse(this, req, cb); return res; }
public KnetikApiResponse GuestRegister( Action<KnetikApiResponse> cb = null ) { JSONObject j = new JSONObject (JSONObject.Type.OBJECT); String body = j.Print (); KnetikRequest req = CreateRequest(GuestRegisterEndpoint, body); KnetikApiResponse registerResponse = new KnetikApiResponse(this, req, cb); return registerResponse; }
public KnetikApiResponse GuestLogin( Action<KnetikApiResponse> cb = null ) { KnetikApiResponse res = new KnetikApiResponse(KnetikClient.Instance, null); res.Status = KnetikApiResponse.StatusType.Error; if (cb != null) { cb(res); } return res; }
public KnetikApiResponse CartCountries( Action<KnetikApiResponse> cb = null ) { JSONObject j = new JSONObject (JSONObject.Type.OBJECT); String body = j.Print (); KnetikRequest req = CreateRequest(CartCountriesEndpoint, body); KnetikApiResponse response = new KnetikApiResponse(this, req, cb); return response; }
public KnetikApiResponse GetRelationships(int ancestorDepth, int descendantDepth, bool includeSiblings, Action<KnetikApiResponse> cb = null) { JSONObject j = new JSONObject (JSONObject.Type.OBJECT); j.AddField ("ancestorDepth", ancestorDepth); j.AddField ("descendantDepth", descendantDepth); j.AddField ("includeSiblings", includeSiblings); String body = j.Print (); KnetikRequest req = CreateRequest(UserGetRelationshipsEndpoint, body); KnetikApiResponse res = new KnetikApiResponse(this, req, cb); return res; }
public KnetikApiResponse CustomCall( string serviceEndpoint, Dictionary<string, string> parameters, Action<KnetikApiResponse> cb = null ) { JSONObject json = new JSONObject(parameters); string body = json.Print(); KnetikRequest req = CreateRequest(serviceEndpoint, body, "POST", -1, ""); KnetikApiResponse res = new KnetikApiResponse(this, req, cb); return res; }
public KnetikApiResponse CartAddDiscount( string sku, Action<KnetikApiResponse> cb = null ) { JSONObject j = new JSONObject (JSONObject.Type.OBJECT); j.AddField ("sku", sku); String body = j.Print (); KnetikRequest req = CreateRequest(CartAddDiscountEndpoint, body); KnetikApiResponse response = new KnetikApiResponse(this, req, cb); return response; }
public KnetikApiResponse GetGameOption( int gameId, string optionName, Action<KnetikApiResponse> cb = null ) { JSONObject j = new JSONObject (JSONObject.Type.OBJECT); j.AddField ("productId", gameId); j.AddField ("optionName", optionName); String body = j.Print (); KnetikRequest req = CreateRequest(GetGameOptionEndpoint, body); KnetikApiResponse response = new KnetikApiResponse(this, req, cb); return response; }
public KnetikApiResponse FireEvent( string eventName, Dictionary<string, string> parameters, Action<KnetikApiResponse> cb = null ) { JSONObject j = new JSONObject (JSONObject.Type.OBJECT); j.AddField ("eventName", eventName); j.AddField ("params", JSONObject.Create(parameters)); String body = j.Print (); KnetikRequest req = CreateRequest(FireEventEndpoint, body); KnetikApiResponse response = new KnetikApiResponse(this, req, cb); return response; }
public KnetikApiResponse ListUserAchievements( int page = 1, int perPage = 25, Action<KnetikApiResponse> cb = null ) { JSONObject j = new JSONObject (JSONObject.Type.OBJECT); j.AddField ("page_index", page); j.AddField ("page_size", perPage); String body = j.Print (); KnetikRequest req = CreateRequest(ListUserAchievementsEndpoint, body); KnetikApiResponse response = new KnetikApiResponse(this, req, cb); return response; }
/*JSAPI2 Function Add Item to A Cart @params int catalogId @params int catalogSkuId @params int quantity @params Action<KnetikApiResponse> cb */ public KnetikApiResponse CartAdd(string cartNumber,int catalogId, int catalogSkuId, int quantity, Action<KnetikApiResponse> cb = null ) { JSONObject j = new JSONObject (JSONObject.Type.OBJECT); j.AddField ("catalog_id", catalogId); j.AddField ("catalog_sku_id", catalogSkuId); j.AddField ("quantity", quantity); String body = j.Print (); StringBuilder CartItemsEndpointBuilder = new StringBuilder(); CartItemsEndpointBuilder.AppendFormat(CartItemsEndpoint,cartNumber); KnetikRequest req = CreateRequest(CartItemsEndpointBuilder.ToString(), body); KnetikApiResponse response = new KnetikApiResponse(this, req, cb); return response; }
public KnetikApiResponse CartAdd( int catalogId, int catalogSkuId, int quantity, Action<KnetikApiResponse> cb = null ) { JSONObject j = new JSONObject (JSONObject.Type.OBJECT); j.AddField ("catalog_id", catalogId); j.AddField ("catalog_sku_id", catalogSkuId); j.AddField ("quantity", quantity); String body = j.Print (); KnetikRequest req = CreateRequest(CartAddEndpoint, body); KnetikApiResponse response = new KnetikApiResponse(this, req, cb); return response; }
public KnetikApiResponse UpgradeFromRegisteredGuest( string username, string password, string email, string fullname, Action<KnetikApiResponse> cb = null ) { JSONObject j = new JSONObject (JSONObject.Type.OBJECT); j.AddField ("username", username); j.AddField ("password", password); j.AddField ("email", email); j.AddField ("fullname", fullname); String body = j.Print (); KnetikRequest req = CreateRequest(UpgradeFromRegisteredGuestEndpoint, body); KnetikApiResponse registerResponse = new KnetikApiResponse(this, req, cb); return registerResponse; }
public KnetikApiResponse GuestRegister( Action<KnetikApiResponse> cb = null ) { // Login as a guest KnetikApiResponse loginResponse = GuestLogin (); if (loginResponse.Status != KnetikApiResponse.StatusType.Success) { Debug.LogError("Guest login failed"); return loginResponse; } Debug.Log ("Guest login successful"); // Then register the new user JSONObject j = new JSONObject (JSONObject.Type.OBJECT); String body = j.Print (); KnetikRequest req = CreateRequest(GuestRegisterEndpoint, body); KnetikApiResponse registerResponse = new KnetikApiResponse(this, req, cb); return registerResponse; }
private KnetikResult<RelationshipsQuery> OnLoad(KnetikApiResponse res) { var result = new KnetikResult<RelationshipsQuery> { Response = res }; if (!res.IsSuccess) { return result; } Response = res; if (res.Body ["result"].Value != "null") { this.Deserialize(res.Body ["result"]); } else { Relationships = new Dictionary<String, UserHierarchy>(); } result.Value = this; return result; }
public KnetikApiResponse ListStorePage( int page = 1, int limit = 10, List<string> terms = null, List<string> related = null, bool useCatalog = true, Action<KnetikApiResponse> cb = null ) { JSONObject j = new JSONObject (JSONObject.Type.OBJECT); StringBuilder storeBuilder = new StringBuilder(); storeBuilder.Append (ListStorePageEndpoint); storeBuilder.Append ("?"); storeBuilder.Append ("page="+page); storeBuilder.Append ("&limit="+limit); // j.AddField ("limit", limit); if (terms != null) { storeBuilder.Append ("&terms="+string.Join(",", terms.ToArray())); // j.AddField ("terms", string.Join(",", terms.ToArray())); } if (related != null) { storeBuilder.Append ("&related="+string.Join(",", related.ToArray())); // j.AddField ("related", string.Join(",",related.ToArray())); } // j.AddField("useCatalog", useCatalog); storeBuilder.Append ("&useCatalog="+useCatalog); String body = j.Print (); KnetikRequest req = CreateRequest(storeBuilder.ToString(), body,"GET"); KnetikApiResponse response = new KnetikApiResponse(this, req, cb); return response; }
private KnetikResult<AchievementsQuery> OnLoad(KnetikApiResponse res) { var result = new KnetikResult<AchievementsQuery> { Response = res }; if (!res.IsSuccess) { return result; } Response = res; if (res.Body["result"].Value != "null") { this.Deserialize(res.Body ["result"]); } else { Achievements = new List<Achievement> (); HasMore = false; } result.Value = this; return result; }
public KnetikApiResponse CartShippingAddress( ShippingAddress address, Action<KnetikApiResponse> cb = null ) { JSONObject j = new JSONObject (JSONObject.Type.OBJECT); j.AddField ("first_name", address.FirstName); j.AddField ("last_name", address.FirstName); j.AddField ("address_line_1", address.AddressLine1); j.AddField ("address_line_1", address.AddressLine2); j.AddField ("city", address.City); j.AddField ("postal_state", address.PostalState); j.AddField ("zip", address.Zip); j.AddField ("country", address.Country); j.AddField ("email", address.Email); String body = j.Print (); KnetikRequest req = CreateRequest(CartShippingAddressEndpoint, body); KnetikApiResponse response = new KnetikApiResponse(this, req, cb); return response; }
private KnetikResult<Game> OnLoadWithGame(KnetikApiResponse res) { var result = new KnetikResult<Game> { Response = res }; if (!res.IsSuccess) { return result; } Response = res; if (res.Body["result"]["product_item"].AsObject == null) { result.Response.Status = KnetikApiResponse.StatusType.Error; result.Response.ErrorMessage = "Item not found"; return result; } Game game = new Game(Client); result.Value = game; this.Deserialize(res.Body["result"]); game.Deserialize(res.Body["result"]["product_item"]); return result; }
private KnetikResult<UserInfo> OnLoad(KnetikApiResponse res) { var result = new KnetikResult<UserInfo> { Response = res }; if (!res.IsSuccess) { return result; } Response = res; this.Deserialize(res.Body ["result"]); result.Value = this; return result; }
public KnetikApiResponse teamRockRegister(Dictionary<string,string> parameters, Action<KnetikApiResponse> cb = null ) { JSONObject j = KnetikApiUtil.buildJSONObjectFromDictionary (parameters); String body = j.Print (); KnetikRequest req = CreateRequest(TeamRockRegisterEndpoint, body); KnetikApiResponse registerResponse = new KnetikApiResponse(this, req, cb); return registerResponse; }
public KnetikApiResponse GetUserInfo(Action<KnetikApiResponse> cb = null) { KnetikRequest req = CreateRequest(GetUserInfoEndpoint); KnetikApiResponse res = new KnetikApiResponse(this, req, cb); return res; }