Code Monkey home page Code Monkey logo

bricklinksharp's People

Contributors

aspin-fvdmolen avatar cleargreen avatar gebirgslok avatar norberto5 avatar stephanstapel avatar xramcire avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

bricklinksharp's Issues

UpdatePaymentStatusAsync expects wrong HTTP status code

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!

Brickowl question

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 :)

Exception updating inventory items

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:

grafik

could this be the problem:

grafik

Get Supersets does not use color id, just gets all supersets

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

Error with EnumExtensions

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)

BricklinkSharp.zip

Measuring API call rate

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 :)

Question on inventory management

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?

Thoughts about the API call rate limit

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?

Exchange rate service not public anymore

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.