hubtel / hubtel-sms-csharp

A C# SDK for developers to interact with the Hubtel SMS REST API.
2 stars 6 forks source link

New API endpoint changes "api.hubtel.com/..." to "smsc.hubtel.com/.." #4

Open Seesi opened 3 years ago

Seesi commented 3 years ago

Could you please update the host url and add ".../message/send" to the base url path? I had to make these changes manually

 public ApiHost()
  {
      Hostname = "smsc.hubtel.com";
      Port = -1;
      ContextPath = "v1";
      Timeout = 5000;
      EnabledConsoleLog = true;
      SecuredConnection = true;
      Auth = null;
  }

and

 public MessageResponse SendMessage(Message mesg)
  {
      if (mesg == null) throw new Exception("Parameter 'mesg' cannot be null");
      const string resource = "/messages/send";
      var stringWriter = new StringWriter();
      new JsonSerializer().Serialize(stringWriter, mesg);
      const string contentType = "application/json";
      HttpResponse response = RestClient.Post(resource, contentType, Encoding.UTF8.GetBytes(stringWriter.ToString()));
      if (response == null) throw new Exception("Request Failed. Unable to get server response");
      if (response.Status == Convert.ToInt32(HttpStatusCode.Created)) return new MessageResponse(JsonConvert.DeserializeObject<ApiDictionary>(response.GetBodyAsString()));
      string errorMessage = String.Format("Status Code={0}, Message={1}", response.Status, response.GetBodyAsString());
      throw new Exception("Request Failed : " + errorMessage);
  }
FranzQ commented 3 years ago

I was about to make the same comment. Took most of time. I hope they update it soon. Even some of the resource links are unavailable