public PersonalityForge(string secret, string key, int botId) { _apiInfo = new ApiInfo { Secret = secret, Key = key, BotId = botId }; _dataService = new PersonalityForgeDataService(new JsonHelper(), new Utils()); }
public Response Send(ApiInfo apiInfo, string username, string text) { Message message = CreateMessage(text, apiInfo.BotId); User user = CreateUser(username); Payload data = CreatePayload(message, user); string dataJson = _jsonHelper.ToJson<Payload>(data); string request = GetRequestUri(apiInfo, dataJson); try { return _jsonHelper.ToObject<Response>(MakeRequest(request)); } catch (Exception e) { throw new PersonalityForgeException(e.Message, e); } }
public Response Send(ApiInfo apiInfo, string username, string text) { Message message = CreateMessage(text, apiInfo.BotId); User user = CreateUser(username); Payload data = CreatePayload(message, user); string dataJson = _jsonHelper.ToJson <Payload>(data); string request = GetRequestUri(apiInfo, dataJson); try { return(_jsonHelper.ToObject <Response>(MakeRequest(request))); } catch (Exception e) { throw new PersonalityForgeException(e.Message, e); } }
private string GetRequestUri(ApiInfo apiInfo, string dataJson) { return string.Format("{0}?apiKey={1}&hash={2}&message={3}", _host, apiInfo.Key, _utils.GenerateSecret(apiInfo.Secret, dataJson), HttpUtility.UrlEncode(dataJson)); }
private string GetRequestUri(ApiInfo apiInfo, string dataJson) { return(string.Format("{0}?apiKey={1}&hash={2}&message={3}", _host, apiInfo.Key, _utils.GenerateSecret(apiInfo.Secret, dataJson), HttpUtility.UrlEncode(dataJson))); }