I'm trying to find API method for Steam CSGO, which I can use to retreive all:
weapon categories;
wear;
exterior;
phase;
grade.
Any advice would be appreciated.
to retrieve the "Phase" of a item you would need to retrieve paintindex and check what "phase" said paintindex is.
to get the wear value, exterior etc you can simply use the "globaloffensive" npm module and then call the "inspectItem" function with the inspect_url for the item you want to get data for.
csgo.inspectItem("URL",function(item) {
let paintindex = item.paintindex; // ITEMS paintindex, used to identify phase...
let wear = item.paintwear; // "FLOAT VALUE".
let quality = item.quality;
//...
});
If you need a database for the "paintindex" you could check metjm.net.
Regards
Related
I am developing api with web flux.
#GetMapping(value = "/shipments/containernumbers")
#Operation(summary = "Returns a list of related container numbers", description = "Return related container numbers based on input")
public Flux<ContainerNumber> containerNumbers(final String searchTerm, final Pageable pageable) {
return shipmentService.containerNumbers(searchTerm, pageable)
.switchIfEmpty(Mono.error(new ResponseStatusException(HttpStatus.NOT_FOUND, "these is not container number with your input ")));
}
This will return list of objects with paging. But this will not tell front end how many object it has. The front end need know the total number of object to prepare pages.I checked some samples but did not find right way to do it.
What it the best way to realize this requirement means return list of object with paging function as well as total number of object with webflux?
thanks in advance.
The only way I can think of would be to create a second endpoint like:
#GetMapping(value = "/shipments/containernumbers/count")
#Operation(summary = "Returns a list of related container numbers", description = "Return related container numbers based on input")
public Mono<Long> containerNumbers(final String searchTerm) {
return shipmentService.containerNumbersCount(searchTerm)
.collectList()
.map(list -> list.size())
.switchIfEmpty(Mono.just(0L));
}
There is no other way if you want server side pagination. You need one endpoint to query the data. This endpoint will employ a Pageable parameter just as you did in your question above.
But to display the number of pages in the frontend, you need a full count of the objects. No big deal, just a few additional lines of code. I suggest a second endpoint for that as shown here.
The database query can be made even simpler if you use spring data. Then you create a countByXyz() query and don't need the collectList() and list.size() part of my code example.
Can someone explain the "status" and "visibility" fields on each product in the list obtained through Magento 2 REST API?
When calling the /products endpoint a list of products are returned but I'm having issues understanding the different fields. Sure, some fields are self explanatory like sku, name, etc. but others like status and visibility aren't.
Looking at the documentation, I can see both values are integers but no further explanation as to what values are allowed and what they actually mean? That makes the documentation kinda useless since I can probably just guess the type looking at the often related GET-request.
Documentation found here:
https://magento.redoc.ly/2.4.1-admin/tag/products#operation/catalogProductRepositoryV1GetListGet
I have no former experience with Magento :D
Maybe there is a reference list somewhere that explains each field?
Hope someone can help me!
If you have a look at four constants at the top of the class Visibility: https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/Catalog/Model/Product/Visibility.php
const VISIBILITY_NOT_VISIBLE = 1;
const VISIBILITY_IN_CATALOG = 2;
const VISIBILITY_IN_SEARCH = 3;
const VISIBILITY_BOTH = 4;
you will see what values are allowed and what they mean: IN_CATALOG means that the product will not be taken into account when user is using search, while IN_SEARCH means that the product will not show on product page and category page, but will be returned in search results, the other two (NOT_VISIBLE, BOTH) are a combination of these two both being false or both being true.
Now about status - have a look here: https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/Catalog/Model/Product/Attribute/Source/Status.php
Again, you have constants which are used to store the status:
/**
* Product Status values
*/
const STATUS_ENABLED = 1;
const STATUS_DISABLED = 2;
I hope this answers your question :)
I built my own simple REST API with Express and now I'm consuming it from my client (Vue.js)
So in my page I access all the data from this endpoint: GET /api/books, and it works fine
Now I also have a "sort by" button where I want to get the data by the latest entries. I don't know if that's a good way or if I have to handle this in the backend but what I do is calling the same endpoint which is GET /api/books and sorting the data to get them the right way
For ex:
sortByLatest() {
axios
.get("/api/books")
.then(res => {
const books = res.data;
const sortedBooks = books.sort((a, b) => b.createdAt > a.createdAt ? 1 : -1
);
this.books = sortedBooks;
})
// catch block
}
I do that for everything. If I need a limited number of results or a specific property from the data I have to write some logic in the axios .then block to sort or filter what I want. Is this bad practice?
But that's not my actual problem
My problem is, in addition of sorting by the latest entries, I also want to filter the results by a specific property. The problem is when I click the A button it's gonna filter the books by a specific property, and when I click the B button it's gonna sort them buy the latest entries, but not both at the same time!
And what if I want additionnal things like limit the number of results to 10, filter by other properties etc... I want to be able to create requests that ask all those things at once. How can I do that? Do I have to build that in the backend?
I saw some websites using url parameters to filter stuff, like /genre=horror&sort=latest, is that the key of doing it?
Thank you for your time
i have a DB that stores all local user contacts.
now i want to use the new framework (contact framework), my problem is that the CNContact have a new identifier now (no longer the auto-incretntal one) called "identifier" and i can't mach old entries in my DB with a potential update of a contact.
i have 2 questions:
in xcode debugger, i can see _iOSLegacyIdentifier(the old, auto-incremental one) as a property in CNContact, how can i get it without private API calls
i can't see "lastModifcationDate" for the CNContact (in ABAddressBook framework it is called kABPersonModificationDateProperty) how can i get it using the new framework.
thanks.
[EDIT]: i have open a ticket for Apple about this and here's the answer:
There are no plans to address this based on the following:
1) iOSLegacyIdentifier is private API for CNContact. 2) A modification
date is not offered on CNContact.
To migrate your DB you can to match contacts by name and disambiguate
by manually matching other properties like email addresses or phone
numbers.
We are now closing this report.
as you can see there's no real solution for this, we have to guess..
you can obtain ContactID (iOSLegacyIdentifier) with new Contact Framework. I use this in my app to find iOSLegacyIdentifier for specific contact, you can modify for your pleasure.
let predicate = CNContact.predicateForContacts(matchingName: "contactName")
let toFetch = [CNContactGivenNameKey, CNContactFamilyNameKey, CNContactIdentifierKey]
do{
let contacts = try self.contactStore.unifiedContacts(matching: predicate, keysToFetch: toFetch as [CNKeyDescriptor])
for contact in contacts{
var diccionario:[String : Any] = contact.dictionaryWithValues(forKeys: ["iOSLegacyIdentifier"])
//With this you can see/obtain iOSLegacyIdentifier
print(diccionario["iOSLegacyIdentifier"] as! Int)
return;
}
} catch let err{
print(err)
}
1.Doesn't exists. There is only private selector
[CNContact iOSLegacyIdentifier];
or you can get the same
[CNContainer CNContainerIOSLegacyIdentifierKey];
Mind that this is not compiled in framework. Use perform selector
2.There is no such property in the new framework. If you disassembly the Contact framework you can see that uniqueId is still used in predicates that touches underlaying core data. But that's a work for you and again dance with private selectors
(blame Apple, not me that there is no way). Take a look at internals of the framework.
Question
How do I return different results for the same resource?
Details
I have been searching for some time now about the proper way to build a RESTful API. Tons of great information out there. Now I am actually trying to apply this to my website and have run into a few snags. I found a few suggestions that said to base the resources on your database as a starting point, considering your database should be structured decently. Here is my scenario:
My Site:
Here is a little information about my website and the purpose of the API
We are creating a site that allows people to play games. The API is supposed to allow other developers to build their own games and use our backend to collect user information and store it.
Scenario 1:
We have a players database that stores all player data. A developer needs to select this data based on either a user_id (person who owns the player data) or a game_id (the game that collected the data).
Resource
http://site.com/api/players
Issue:
If the developer calls my resource using GET they will receive a list of players. Since there are multiple developers using this system they must specify some ID by which to select all the players. This is where I find a problem. I want the developer to be able to specify two kinds of ID's. They can select all players by user_id or by game_id.
How do you handle this?
Do I need two separate resources?
Lets say you have a controller name 'Players', then you'll have 2 methods:
function user_get(){
//get id from request and do something
}
function game_get(){
//get id from request and do something
}
now the url will look like: http://site.com/api/players/user/333, http://site.com/api/players/game/333
player is the controller.
user/game are the action
If you use phil sturgeon's framework, you'll do that but the url will look like:
http://site.com/api/players/user/id/333, http://site.com/api/players/game/id/333
and then you get the id using : $this->get('id');
You can limit the results by specifying querystring parameters, i.e:
http://site.com/api/players?id=123
http://site.com/api/players?name=Paolo
use phil's REST Server library: https://github.com/philsturgeon/codeigniter-restserver
I use this library in a product environment using oauth, and api key generation. You would create a api controller, and define methods for each of the requests you want. In my case i created an entirely seperate codeigniter instance and just wrote my models as i needed them.
You can also use this REST library to insert data, its all in his documentation..
Here is a video Phil threw together on the basics back in 2011..
http://philsturgeon.co.uk/blog/2011/03/video-set-up-a-rest-api-with-codeigniter
It should go noted, that RESTful URLs mean using plural/singular wording e.g; player = singular, players = all or more than one, games|game etc..
this will allow you to do things like this in your controller
//users method_get is the http req type.. you could use post, or put as well.
public function players_get(){
//query db for players, pass back data
}
Your API Request URL would be something like:
http://api.example.com/players/format/[csv|json|xml|html|php]
this would return a json object of all the users based on your query in your model.
OR
public function player_get($id = false, $game = false){
//if $game_id isset, search by game_id
//query db for a specific player, pass back data
}
Your API Request URL would be something like:
http://api.example.com/player/game/1/format/[csv|json|xml|html|php]
OR
public function playerGames_get($id){
//query db for a specific players games based on $userid
}
Your API Request URL would be something like:
http://api.example.com/playerGames/1/format/[csv|json|xml|html|php]