mirror of
https://github.com/retailcrm/api-client-dotnet.git
synced 2024-11-21 20:36:02 +03:00
Couriers references (#8)
This commit is contained in:
parent
a75db4fe7f
commit
b5261b02b0
@ -65,7 +65,7 @@ namespace Retailcrm.Versions.V5
|
||||
}
|
||||
|
||||
return Request.MakeRequest(
|
||||
$"/reference/cost-groups/{group["code"].ToString()}/edit",
|
||||
$"/reference/cost-groups/{@group["code"]}/edit",
|
||||
Request.MethodPost,
|
||||
new Dictionary<string, object>
|
||||
{
|
||||
@ -108,7 +108,7 @@ namespace Retailcrm.Versions.V5
|
||||
}
|
||||
|
||||
return Request.MakeRequest(
|
||||
$"/reference/cost-items/{item["code"].ToString()}/edit",
|
||||
$"/reference/cost-items/{item["code"]}/edit",
|
||||
Request.MethodPost,
|
||||
new Dictionary<string, object>
|
||||
{
|
||||
@ -145,7 +145,7 @@ namespace Retailcrm.Versions.V5
|
||||
}
|
||||
|
||||
return Request.MakeRequest(
|
||||
$"/reference/legal-entities/{entity["code"].ToString()}/edit",
|
||||
$"/reference/legal-entities/{entity["code"]}/edit",
|
||||
Request.MethodPost,
|
||||
new Dictionary<string, object>
|
||||
{
|
||||
@ -153,5 +153,42 @@ namespace Retailcrm.Versions.V5
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public Response Couriers()
|
||||
{
|
||||
return Request.MakeRequest(
|
||||
"/reference/couriers",
|
||||
Request.MethodGet
|
||||
);
|
||||
}
|
||||
|
||||
public Response CouriersCreate(Dictionary<string, object> courier)
|
||||
{
|
||||
return Request.MakeRequest(
|
||||
"/reference/couriers/create",
|
||||
Request.MethodPost,
|
||||
new Dictionary<string, object>
|
||||
{
|
||||
{ "courier", new JavaScriptSerializer().Serialize(courier) }
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public Response CouriersEdit(Dictionary<string, object> courier)
|
||||
{
|
||||
if (!courier.ContainsKey("id"))
|
||||
{
|
||||
throw new ArgumentException("Parameter `id` is missing");
|
||||
}
|
||||
|
||||
return Request.MakeRequest(
|
||||
$"/reference/couriers/{courier["id"]}/edit",
|
||||
Request.MethodPost,
|
||||
new Dictionary<string, object>
|
||||
{
|
||||
{ "courier", new JavaScriptSerializer().Serialize(courier) }
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -129,5 +129,80 @@ namespace RetailcrmUnitTest.V5
|
||||
Assert.IsInstanceOfType(response, typeof(Response));
|
||||
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void Couriers()
|
||||
{
|
||||
Response response = _client.Couriers();
|
||||
Assert.IsTrue(response.IsSuccessfull());
|
||||
Assert.IsTrue(response.GetStatusCode() == 200);
|
||||
Assert.IsInstanceOfType(response, typeof(Response));
|
||||
Assert.IsTrue(response.GetResponse().ContainsKey("couriers"));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void CouriersCreate()
|
||||
{
|
||||
string guid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 3);
|
||||
|
||||
Response response = _client.CouriersCreate(
|
||||
new Dictionary<string, object>
|
||||
{
|
||||
{ "firstName", $"CourierFirstName-{guid}"},
|
||||
{ "lastName", $"CourierLastName-{guid}" },
|
||||
{ "active", false},
|
||||
{ "email", $"{guid}@example.com"}
|
||||
}
|
||||
);
|
||||
|
||||
Debug.WriteLine(response.GetRawResponse());
|
||||
|
||||
Assert.IsTrue(response.IsSuccessfull());
|
||||
Assert.IsTrue(response.GetStatusCode() == 201);
|
||||
Assert.IsInstanceOfType(response, typeof(Response));
|
||||
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void CouriersEdit()
|
||||
{
|
||||
string guid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 3);
|
||||
|
||||
Response response = _client.CouriersCreate(
|
||||
new Dictionary<string, object>
|
||||
{
|
||||
{ "firstName", $"CourierFirstName-{guid}"},
|
||||
{ "lastName", $"CourierLastName-{guid}" },
|
||||
{ "active", false},
|
||||
{ "email", $"{guid}@example.com"}
|
||||
}
|
||||
);
|
||||
|
||||
Debug.WriteLine(response.GetRawResponse());
|
||||
|
||||
Assert.IsTrue(response.IsSuccessfull());
|
||||
Assert.IsTrue(response.GetStatusCode() == 201);
|
||||
Assert.IsInstanceOfType(response, typeof(Response));
|
||||
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
|
||||
|
||||
string id = response.GetResponse()["id"].ToString();
|
||||
|
||||
Response responseEdit = _client.CouriersEdit(
|
||||
new Dictionary<string, object>
|
||||
{
|
||||
{ "id", id},
|
||||
{ "firstName", "CourierFirstName"},
|
||||
{ "lastName", "CourierLastName" },
|
||||
{ "active", true}
|
||||
}
|
||||
);
|
||||
|
||||
Debug.WriteLine(responseEdit.GetRawResponse());
|
||||
|
||||
Assert.IsTrue(responseEdit.IsSuccessfull());
|
||||
Assert.IsTrue(responseEdit.GetStatusCode() == 200);
|
||||
Assert.IsInstanceOfType(response, typeof(Response));
|
||||
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user