gebirgslok / bricklinksharp Goto Github PK
View Code? Open in Web Editor NEWEasy-to-use C# client for the bricklink (LEGO) marketplace API.
Home Page: https://github.com/gebirgslok/BricklinkSharp
License: MIT License
Easy-to-use C# client for the bricklink (LEGO) marketplace API.
Home Page: https://github.com/gebirgslok/BricklinkSharp
License: MIT License
Hi there!
Thank you for the great work on the client, it works without hassle so far. But now I do run into a problem...
When I update a payment status through the IBricklinkClient.UpdatePaymentStatusAsync
method, I get a BricklinkHttpErrorException
telling me that status code 200 was expected, but 204 was received.
I checked the source code and I found that the method is using the PutEnsureNoResponseDataAsync
extension method, which in turn states that it expects the 200 status code.
I'm no expert in the Bricklink API and I'm not sure there are any endpoints that respond with a 200 for a PUT request. I can't change the expected code to 204 without knowing this, otherwise I would have submitted a PR.
Hope you can help!
Hello,
Task GetOrderAsync(int orderId, CancellationToken cancellationToken = default(CancellationToken));
the returned OrderDetails.Shipping.Address does not contain the Phone Number as detailed in the Bricklink docs here:
https://www.bricklink.com/v3/api.page?page=resource-representations-order
[shipping.address.phone_number] | String | The buyer's phone number
Thank you
Iain
sorry for this wild post, I just have no idea how to reach you differently.
Did you ever consider creating a BrickOwl adapter for .net? In case of yes, I'm volunteering to assist :)
Hi,
did you ever come across this return code 400 when updating inventory items:
System.AggregateException: One or more errors occurred. (Received unexpected HTTP status code for request 'PUT'
https://api.bricklink.com/api/store/v1/inventories/331747049:
Expected = 200, received = 400.
Description: A request has been made with a malformed JSON body., message: INVALID_REQUEST_BODY.)
---> BricklinkSharp.Client.BricklinkHttpErrorException: Received unexpected HTTP status code for request 'PUT' https://api.bricklink.com
/api/store/v1/inventories/331747049:
Expected = 200, received = 400.
Description: A request has been made with a malformed JSON body., message: INVALID_REQUEST_BODY.
at BricklinkSharp.Client.Extensions.JsonExtensions.GetData(JsonDocument document, Int32 expectedCode, String url, HttpMethod httpMethod)
at BricklinkSharp.Client.Extensions.HttpClientExtensions.ParseResponse[TData](String responseBody, Int32 expectedCode, String url, HttpMethod httpMethod)
at BricklinkSharp.Client.Extensions.HttpClientExtensions.ExecuteReadResponseAsync[TResponse](HttpClient httpClient, HttpMethod method, String url, Int32 expectedCode, Object body, JsonSerializerOptions jsonSerializerOptions, CancellationToken cancellationToken)
at BricklinkSharp.Client.BricklinkClient.UpdateInventoryAsync(Int32 inventoryId, UpdateInventory updateInventory, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Task.Wait()
The JSON object looks like this:
{"quantity":"unit_price":0.6000,"description":null,"remarks":"SPC.0015","bulk":null,"is_retain":null,"is_stock_room":false,"stock_room_id":null,"my_cost":null,"sale_rate":null,"tier_quantity1":null,"tier_quantity2":null,"tier_quantity3":null,"tier_price1":null,"tier_price2":null,"tier_price3":null}
I found it. quantity is empty!
With the quantity being optional:
could this be the problem:
The subsets function implements it with ?color_id parameter but supersets has color id just after / which is disregarded.
Can change to be like subsets function and fix:
public async Task<Superset[]> GetSupersetsAsync(ItemType type, string no, int colorId = 0)
{
var typeString = type.GetStringValueOrDefault();
var builder = new UriBuilder(new Uri(_baseUri, $"items/{typeString}/{no}/supersets"));
var query = HttpUtility.ParseQueryString(builder.Query);
query["color_id"] = colorId.ToString();
builder.Query = query.ToString();
var url = builder.ToString();
var method = HttpMethod.Get;
var responseBody = await ExecuteRequest(url, method);
var data = ParseResponse<Superset[]>(responseBody, 200, url, method);
return data;
}
In GetSupersetsDemo, example
var supersets = await client.GetSupersetsAsync(ItemType.Part, "40232", 8);
gets all supersets, not just color 8, works after changing
Race conditions with EnumExtensions has a race condition causing the thread safe IDictionary.Add method to throw an error.
If 2 threads both access Enum.ToStringOrDefaultValue() for the same value, both will pass the "is not present check" and both will then attempt to add the value. This causes a "The key already existed in the dictionary." exception.
I can't do a commit to this repo so I have attached a potential fix / refactor of enum extensions.
fail: The key already existed in the dictionary.
System.ArgumentException: The key already existed in the dictionary.
at System.Collections.Concurrent.ConcurrentDictionary`2.System.Collections.Generic.IDictionary<TKey,TValue>.Add(TKey key, TValue value)
at BricklinkSharp.Client.Extensions.EnumExtensions.GetStringValueOrDefault(Enum e)
at BricklinkSharp.Client.BricklinkClient.GetItemAsync(ItemType type, String no, CancellationToken cancellationToken)
Hi Jens,
I added an experimental API call event to the little sister library BrickOwlSharp using one of the oldest .net concepts, Events.
Is this what you also intended for BricklinkSharp:
stephanstapel/BrickOwlSharp@ecff57d
If yes, I volunteer to port this. If you have a better idea, it'd be great to discuss :)
Indicates that price will include VAT for the items of VAT enabled stores. Available values are:
See https://www.bricklink.com/v3/api.page?page=get-price-guide
Hi,
sorry for yet another usage question, I hope that this is alright for you.
digging through the inventory management API I found that updating inventory only allows to add/substract from stock, i.e. setting deltas, not set absolute stock quantity. Did you come across this by yourself and did you solve this for yourself?
Hi,
I was just wondering if you have any thoughts about the API call rate limit of 5,000 calls per day on Bricklink. Are you measuring the calls in your own application or are you just ignoring this limit?
The exchange rate api requires now an api token and is limited to 250 calls per day (free version). Therefore, requests will throw an exception.
The library requires a new concept dealing with that change.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.