Converting a Review API call to html - api

I am sorry to trouble.
I am unable to convert an API call into html that can go on a web page.
The call is like this:
https://api.feefo.com/api/version/reviews/summaryall?merchant_identifier=example-retail-merchant
And it produces something like this:
{
"merchant": {
"identifier": "example-retail-merchant",
"name": "Example Retail Merchant",
"url": "http://www.exampleretailmerchant.co.uk",
"logo": "example-retail-merchant-logo.png",
"review_url": "http://www.feefo.com/en_GB/reviews/example-retail-merchant"
},
"meta": {
"count": 3878,
"pages": 194,
"page_size": 20
},
"rating": {
"min": 1,
"max": 5,
"rating": 4.9,
"service": {
"count": 3878,
"1_star": 8,
"2_star": 28,
"3_star": 0,
"4_star": 181,
"5_star": 3661
},
"product": {
"count": 6240,
"1_star": 55,
"2_star": 102,
"3_star": 0,
"4_star": 724,
"5_star": 5359
}
}
}
Can anyone please point me in the right directoion?
Thank you so much...

According to jQuery, you can use the following function to make API calls:
$(document).ready( function() {
var info;
var whitelisted;
var quantity;
$.get("https://api.guildwars2.com/v2/commerce/prices/24615",function(obj){
info = obj['id'];
whitelisted = obj["whitlelisted"]
quantity = obj.buys['quantity']
$("#id1").html("id :"+info);
$("#whitelist").html("whitelisted :"+whitelisted);
$("#quan").html("quantity :"+quantity);
});
});

Related

Prebid - Index video outstream configuration with multiple playerSize in bidders

I would like to create an adUnit video outstream with multiple playserSizes for Index (documentation there
At first I thought to put the playerSize at the adUnit level, but because I want to define multiple playerSizes, I decided to move it at bidder level in params > video > playerSize. Nonetheless it does not work whereas in the documentation it is written
If you are using Index’s outstream player and have placed the video object at the bidder level, you must include the Index required parameters at the bidder level``` (link above)
Here is my prebid configuration
```javascript
{
"code": slotCode,
"sizes": [[1,1],[300,250],[160,600],[300,600],[640,360]],
"bids": [
{
"bidder": "criteo",
"params": {
"networkId": networkId,
"video": {
"playerSize": [640, 480],
"skip": 0,
"playbackmethod": 1,
"placement": 1,
"mimes": [
"video/mp4"
],
"maxduration": 30,
"api": [
1,
2
],
"protocols": [
2,
3
]
}
},
"userId": {...},
"userIdAsEids": [...],
"crumbs": {...}
},
{
"bidder": "index",
"params": {
"siteId": siteId,
"size": [
640,
360
],
"video": {
"playerSize": [640, 480],
"h": 640,
"w": 360,
"protocols": [
2,
3,
5,
6
],
"minduration": 5,
"maxduration": 30,
"mimes": [
"video/mp4",
"application/javascript"
],
"playerSize": [
640,
360
]
}
},
"userId": {... },
"userIdAsEids": [...],
"crumbs": {...}
}
],
"mediaTypes": {
"video": {
"context": "outstream"
}
},
"pubstack": {...}
}
If I use this configuration, I got this error
ERROR: IX Bid Adapter: bid size is not included in ad unit sizes or player size.
Even if my playerSize for index ([640, 360]) is in the adUnit sizes.
I wonder if it is possible for an adUnit to have multiple payerSizes?

(CoinMarketCap) Different response from API call

Before the API was working properly but now it does not work well, its response got change and I don't know why
Previous response seems understandable:
Which the 2782 read as AUD and its name is properly assigned and does not return object on data property.
{
"status": {
"timestamp": "2021-04-20T00:35:36.456Z",
"error_code": 0,
"error_message": null,
"elapsed": 7,
"credit_count": 1,
"notice": null
},
"data": {
"id": 2782,
"symbol": "AUD",
"name": "Australian Dollar",
"amount": 88,
"last_updated": "2019-08-30T18:51:00.000Z",
"quote": {
"USDT": {
"price": 58.995907552127,
"last_updated": "2019-08-30T18:51:12.000Z"
}
}
}
}
Newer Response:
On this response the data property got a result of object which parent is the converted or symbol then its information, notice that the id and name does not match with 2782 (AUD). it became random string or something and also the conversion rate seems like not reasonable at all.
{
"status": {
"timestamp": "2021-05-20T08:25:05.561Z",
"error_code": 0,
"error_message": null,
"elapsed": 1,
"credit_count": 1,
"notice": null
},
"data": {
"AUD": {
"symbol": "AUD",
"id": "kg7up6o9tzp",
"name": "kz7fw7rlj8",
"amount": 88,
"last_updated": "2021-05-20T08:25:05.561Z",
"quote": {
"BTC": {
"price": 5691,
"last_updated": "2021-05-20T08:25:05.561Z"
}
}
}
}
}
This are the parameters I sent bot previous and newer call
{
"amount": 12,
"convert": "BTC",
"id": 2782 # AUD
}
UPDATE::
At some point when using the production version of API URL the result backs to normal
I don't know yet the explanation regarding on this issue, is there something limit on the sandbox api or so?

Karate: I get missing property in path $['data'] while using json filter path

I have gone through karate documentation and questions asked on stack overflow. There are 2 json arrays under resp.response.data. I am trying to retrieve and assert "bId": 81 in below json from the resp.response.data[1] but I get this missing property error while retrieving id value 81. Could you please help if I am missing something ?
* def resp =
"""
{
"response": {
"data": [
{
"aDetails": {
"aId": 15,
"aName": "Test",
"dtype": 2
},
"values": [
{
"bId": 45,
"value": "red"
}
],
"mandatory": false,
"ballId": "1231231414"
},
{
"aDetails": {
"aId": 25,
"aName": "Description",
"dtype": 2
},
"values": [
{
"bId": 46,
"value": "automation"
},
{
"bId": 44,
"value": "NESTED ARRAY"
},
{
"bId": 57,
"value": "sfERjuD"
},
{
"bId": 78,
"value": "zgSyPdg"
},
{
"bId": 79,
"value": "NESTED ARRAY"
},
{
"bId": 80,
"value": "NESTED ARRAY"
},
{
"bId": 81,
"value": "NESTED ARRAY"
}
],
"mandatory": true,
"ballId": "1231231414"
}
],
"corId": "wasdf-242-efkn"
}
}
"""
* def expectedbID=81
* def RespValueId = karate.jsonPath(resp, "$.data[1][?(#.bId == '" + expectedbID + "')]")
* match RespValueId[0] == expectedbID
Maybe you are over-complicating things ?
* match resp.response.data[1].values contains { bId: 81, value: 'NESTED ARRAY' }

Right way to use function field() in yii2

I am writing REST API for my project.
field() function in my Model:
public function fields()
{
$fields = parent::fields();
// remove fields that contain sensitive information
unset($fields['media'], $fields['content']);
return $fields;
}
I have a 2 action:
/api/resources - get all resources lists
This api return:
"items":
[
{
"ID": 1,
"category_id": 1,
"title": "tset",
"image": "1437537044.png",
"ins_date": "2015-07-22 00:00:00",
"count": 20
},
{
"ID": 2,
"category_id": 1,
"title": "tset",
"image": "1437537176.png",
"ins_date": "2015-07-22 00:00:00",
"count": 0
},
/api/resources/view?id=1 - get all information about resource ID=1
{
"ID": 1,
"category_id": 1,
"title": "tset",
"image": "1437537044.png",
"ins_date": "2015-07-22 00:00:00",
"count": 21
}
I get all resources, but I want to get all fields when I call actionView($id) like this:
{
"ID": 1,
"category_id": 1,
"title": "tset", // I want to get response with this
"content": "test", //and this fields
"media": "test",
"image": "1437537044.png",
"ins_date": "2015-07-22 00:00:00",
"count": 22
}
HOw can solve this problem? Help me?
use subclass of models with different fields()
use Yii::$app->controller->action->uniqueId
public function fields()
{
if(Yii::$app->controller->action->uniqueId == 'controller/action'){
return ['field_1','field_2','field_3','field_4'];
}else{
return ['field_1','field_3'];
}
}
Extended yii\rest\Serializer change init() and getRequestedFields()

Restify very simple JSONClient returns empty json

I just started using restify and tries to build a very simple JSONClient and fails on the first step.
var restify = require('restify');
var client = restify.createJsonClient({
url: 'http://api.bgm.tv'
});
client.get('/calendar', function(err, req, res, obj) {
console.log('%j', obj);
});
This pieces of code returns {} with a status code 200
If you check http://api.bgm.tv/calendar in browser or curl it seems to be a legit json GET Rest API and does not require auth or anything else.
I tried other API such as stackoverflow api it works perfectly, so I assume something wrong with the server side?
If anyone can try to run it and help me point out what might went wrong would be very appreciated.
I runned your example node code and got a proper response (the same you get when browsing).
You probably have some version problem or a console.log size limitation.
Try using: console.log(obj[0]); it should print only the first object in the json.
I'm using node v0.8.9 and restify v2.4.1 on a mac.
Yeah, when I use the Postman plugin for Chrome and do a GET request to http://api.bgm.tv/calendar I get:
[
{
"weekday": {
"en": "Mon",
"cn": "星期一",
"ja": "月耀日",
"id": 1
},
"items": [
{
"id": 46458,
"url": "http://bgm.tv/subject/46458",
"type": 0,
"name": "アイカツ! -アイドルカツドウ!-",
"name_cn": "偶像活动",
"summary": "",
"eps": 0,
"air_date": "2012-10-08",
"air_weekday": 1,
"images": {
"large": "http://lain.bgm.tv/pic/cover/l/db/7f/46458_8mM39.jpg",
"common": "http://lain.bgm.tv/pic/cover/c/db/7f/46458_8mM39.jpg",
"medium": "http://lain.bgm.tv/pic/cover/m/db/7f/46458_8mM39.jpg",
"small": "http://lain.bgm.tv/pic/cover/s/db/7f/46458_8mM39.jpg",
"grid": "http://lain.bgm.tv/pic/cover/g/db/7f/46458_8mM39.jpg"
},
"collection": {
"wish": 0,
"collect": 0,
"doing": 44,
"on_hold": 0,
"dropped": 0
}
},
{
"id": 57150,
"url": "http://bgm.tv/subject/57150",
"type": 0,
"name": "LINE OFFLINE ~サラリーマン~",
"name_cn": "离线LINE - 上班族 -",
"summary": "",
"eps": 0,
"air_date": "2013-01-07",
"air_weekday": 1,
"images": {
"large": "http://lain.bgm.tv/pic/cover/l/71/28/57150_Kz171.jpg",
"common": "http://lain.bgm.tv/pic/cover/c/71/28/57150_Kz171.jpg",
"medium": "http://lain.bgm.tv/pic/cover/m/71/28/57150_Kz171.jpg",
"small": "http://lain.bgm.tv/pic/cover/s/71/28/57150_Kz171.jpg",
"grid": "http://lain.bgm.tv/pic/cover/g/71/28/57150_Kz171.jpg"
},
"collection": {
"wish": 0,
"collect": 0,
"doing": 206,
"on_hold": 0,
"dropped": 0
}
},
{
"id": 58709,
"url": "http://bgm.tv/subject/58709",
"type": 0,
"name": "ハヤテのごとく! Cuties",
"name_cn": "旋风管家 Cuties",
"summary": "",
"eps": 0,
"air_date": "2013-04-08",
"air_weekday": 1,
"images": {
"large": "http://lain.bgm.tv/pic/cover/l/15/28/58709_H7uj8.jpg",
"common": "http://lain.bgm.tv/pic/cover/c/15/28/58709_H7uj8.jpg",
"medium": "http://lain.bgm.tv/pic/cover/m/15/28/58709_H7uj8.jpg",
"small": "http://lain.bgm.tv/pic/cover/s/15/28/58709_H7uj8.jpg",
"grid": "http://lain.bgm.tv/pic/cover/g/15/28/58709_H7uj8.jpg"
},
"collection": {
"wish": 0,
"collect": 0,
"doing": 219,
"on_hold": 0,
"dropped": 0
}
},
...and a bunch more, but the body limit to answers on SO is 30,000 characters.