Where can I find kiwi tcms parameters information about json-rpc? - kiwi-tcms

I practice to use json-rpc to create test case, and I want to assoicate a test paln with test case, but I don't know the parameter of the plan.
Can anyone give me some suggestions?? Thanks.
My example like this
Test plan ID : 3
Test plan name: test
Using postman request
{
"jsonrpc":"2.0",
"method":"TestCase.create",
"params":{"values":{"summary":"jsonrpctest","case_status":2,"category":2,"priority":1,"text":"20201005test","plan":[3,"test"]}},
"id":1
}
Response
{
"id": 1,
"jsonrpc": "2.0",
"result": {
"id": 191,
"create_date": "2020-10-06 04:44:13",
"is_automated": false,
"script": "",
"arguments": "",
"extra_link": null,
"summary": "jsonrpctest",
"requirement": null,
"notes": "",
"text": "20201005test",
"case_status_id": 2,
"case_status": "CONFIRMED",
"category_id": 2,
"category": "--default--",
"priority_id": 1,
"priority": "P1",
"author_id": 1,
"author": "ardyn",
"default_tester_id": null,
"default_tester": null,
"reviewer_id": null,
"reviewer": null,
"plan": [],
"component": [],
"tag": []
}
}

https://kiwitcms.readthedocs.io/en/latest/api/index.html says
"Server side RPC methods are documented in tcms.rpc.api."
Which is
https://kiwitcms.readthedocs.io/en/latest/modules/tcms.rpc.api.html
And there is the TestPlan.add_case() method:
https://kiwitcms.readthedocs.io/en/latest/modules/tcms.rpc.api.testplan.html#tcms.rpc.api.testplan.add_case

Related

How can I insert contract with ShippingAddress?

I want to register a new Contract Object.
However, when I try to register it together with ShippingAddress, I get an error.
How do I add a ShippingAddress with a Contract Object?
■ Field is not writeable: Contract.ShippingAddres
Contract cont = (Contract) parser.readValueAsStrict(Contract.class);
Address a = new Address();
a.country = 'Japan';
a.city = 'Tokyo';
cont.ShippingAddress = a;
insert cont;
I ran New Contract in the GUI, and the second of the arrays has ShippingAddress registered.
I would like to do this with the Apex API as well.
■ The ShippingAddress of the second record is registered.
[
{
"attributes": {
"type": "Contract",
"url": "/services/data/v56.0/sobjects/Contract/8000T000000223IQAQ"
},
"Id": "8000T000000223IQAQ",
"AccountId": "0010T00000Ox7sSQAR",
"BillingAddress": null,
"ShippingAddress": null,
"OwnerId": "0055g00000GRB5vAAH",
"Status": "Draft",
"StatusCode": "Draft",
"IsDeleted": false,
"ContractNumber": "00000114",
"CreatedDate": "2022-11-15T10:03:42.000+0000",
"CreatedById": "0055g00000GRB5vAAH",
"LastModifiedDate": "2022-11-15T10:03:42.000+0000",
"LastModifiedById": "0055g00000GRB5vAAH",
"SystemModstamp": "2022-11-15T10:03:42.000+0000",
"LastViewedDate": "2022-11-15T10:03:42.000+0000",
"LastReferencedDate": "2022-11-15T10:03:42.000+0000"
},
{
"BillingStreet": "西新宿1丁目",
"BillingCity": "新宿区",
"BillingState": "東京都",
"BillingPostalCode": "163-0590",
"BillingCountry": "日本",
"BillingAddress": {
"city": "新宿区",
"country": "日本",
"geocodeAccuracy": null,
"latitude": null,
"longitude": null,
"postalCode": "163-0590",
"state": "東京都",
"street": "西新宿1丁目"
},
"ShippingStreet": "西新宿1丁目",
"ShippingCity": "新宿区",
"ShippingState": "東京都",
"ShippingPostalCode": "163-0590",
"ShippingCountry": "日本",
"ShippingAddress": {
"city": "新宿区",
"country": "日本",
"geocodeAccuracy": null,
"latitude": null,
"longitude": null,
"postalCode": "163-0590",
"state": "東京都",
"street": "西新宿1丁目"
},
.....
}
]
https://developer.salesforce.com/docs/atlas.en-us.238.0.object_reference.meta/object_reference/compound_fields_address.htm
Standard address compound fields are read-only, and are only
accessible using the SOAP and REST APIs. See Compound Field
Considerations and Limitations for additional details of the
restrictions this imposes.
Instead set single fields inside the address.
cont.ShippingCountry = 'Japan';
cont.ShippingCity = 'Tokyo';
insert cont;

Deutschebahn API for departureboard not showing destination station

From this link:
https://developer.deutschebahn.com/store/apis/info?name=Fahrplan-Free&version=v1&provider=DBOpenData#!/default/get_departureBoard_id
I can successfully call the ARRIVALboard information:
[
{
"name": "ICE 1689",
"type": "ICE",
"boardId": null,
"stopId": 8000152,
"stopName": "Hannover Hbf",
"dateTime": "2021-01-19T00:00",
"origin": "Hamburg-Altona",
"track": "8",
"detailsId": "78642%2F27599%2F82706%2F15139%2F80%3fstation_evaId%3D8000152"
}
, which is complete.
However, when I call the DEPARTUREboard information I get everything apart from the 'destination' JSON field.
{
"name": "ICE 272",
"type": "ICE",
"boardId": null,
"stopId": 8000152,
"stopName": "Hannover Hbf",
"dateTime": "2021-01-19T00:05",
"track": "7",
"detailsId": "972312%2F330581%2F159824%2F244192%2F80%3fstation_evaId%3D8000152"
}
, i.e., the 'destination' field is missing according to the Model schema
I guess this is a user error but I can't work out how to fix this!

Calling parse function in swift fails

I am working on a food delivery app, which uses parse as its backend. I am facing a problem while calling the placeOrder API through
PFCloud.callFunction(inBackground: PlaceOrder, withParameters: params) { (data, err) in}
Please have a look at the JSON which I need to post below.
{
"source": "card_1EVYuOEynlyM6L4SHgBMJYRQ",
"userId": "YjSZYSXEp7",
"data": {
"menuItems": [{
"id": "QSYa2JDcIm",
"title": "Rice With Tibss(Beef)",
"menuTitle": "Rice With Tibss",
"submenuItem": [{
"id": "zaOo6G4KSV",
"name": "Beef",
"price": 12,
"desc": "Fillings?"
}],
"price": 24,
"qty": 1,
"storeId": "yqBCDmzaDP",
"storeName": "Ibex Ethiopian Cusine and Bar",
"orderType": "takeout",
"taxState": 0.0925,
"storeInfo": {
"cart_storeId": "yqBCDmzaDP",
"cart_storeName": "Ibex Ethiopian Cusine and Bar",
"cart_storeImage": "https://res.cloudinary.com/http-get-tolofood-com/image/upload/c_scale,h_199,q_auto,w_270/v1461575640/Ibex_lopx38.jpg",
"cart_storeCuisine": "Ethiopian",
"cart_storeDescription": "We always serve a quality food. We always serve a quality food. We always serve a quality food. We always serve a quality food.",
"cart_storeRating": 3.33,
"cart_storeDelivery": false,
"takeout": true,
"address": "12255 Greenville Ave,Dallas, TX 75243",
"slugname": "TX_DAL_ibex_ethiopian_cuisine_and_bar",
"multiple_location": false,
"cart_storeDeliveryFee": 15,
"cart_storeServes": "Lunch,Dinner",
"busy": false,
"cart_storeSeoSlug": "ibex-ethiopian-cusine-and-bar"
},
"enable": true,
"voice_read_mi_label": "fbgcb",
"voice_read_mi_option": false,
"menuTypeName": "Standard"
}],
"lastOrderType": "takeout",
"searchedAddress": "takeout",
"timeData": {
"day": "06-05-2019",
"time": "12:55 am",
"tz": "America/Los_Angeles"
}
},
"unavailable_option": "restaurant_recommendation"
}
And below is the Swift code which I have used to make pass it.
let storeInfo: Dictionary = [CartStoreId: self.cartStoreId, CartStoreName: self.cartRestaurantName, CartStoreImage: self.cartStoreImage, CartStoreCuisine: self.cartStoreCuisine, CartStoreDescription: self.cartStoreDescription, CartStoreRating: self.cartStoreRating, CartStoreDelivery: self.cartStoreDelivery, Takeout: self.takeOut, Address: self.address, Slugname: self.slugName, MultipleLocation: self.multipleLocation, CartStoreDeliveryFee: self.cartStoreDelivery, CartStoreServes: self.cartStoreServes, Busy: self.busy, CartStoreSeoSlug: self.cartStoreSeoSlug] as Dictionary
let subMenuItem = ["id": "zaOo6G4KSV", "name": "Beef", "price": 12, "desc": "Fillings?", "voice_read_submi_label":"bf", "voice_read_submi_option":false, "disabled": false] as [String: Any]
let ordersDictionary = [
"id" : "1234",
"title" : "Test",
"menuTitle" : "MenuName",
"price" : 23,
"qty" : 2,
"storeId" : 23,
"orderType" : "standard",
"taxState" : 0.22,
"enable" : true,
"menuTypeName" : "Type Name",
"voice_read_mi_label":"fdfs",
"voice_read_mi_option":"false",
"submenuitem": subMenuItem,
"storeInfo": storeInfo
] as Dictionary
let timeData = ["day" : 17-06-2019, "time": "11:00 AM", "tz": "America/Los_Angeles"] as Dictionary
let data = ["menuItems": ordersDictionary, "lastOrderType": "takeout", "searchedAddress": "takeout", "timeData" : timeData] as Dictionary
let params = [UserId: self.userId, "source":"card_1EVYuOEynlyM6L4SHgBMJYRQ", "data": data, "unavailable_option":"restaurant_recommendation","_ApplicationId":"6EuadToYoFGJhI1sX8XnuFBz9tp9l3yH6HxzzXZO", "_JavaScriptKey":"rQkALu9saFtF2oq9yCibyw6mEcs3PVqct3uuP6vg", "_ClientVersion":"js1.6.14", "_InstallationId":"444ec64d-5fcc-7b8e-596e-6be627892c2a",
"_SessionToken":"r:c966376120c8eca77aa63c29d5bebe1a"] as Dictionary
After all this is done I call the parse function like below.
PFCloud.callFunction(inBackground: PlaceOrder, withParameters: params) { (data, err) in
if err != nil {
print(err!)
} else {
print(data!)
}
}
But this gives me error after a few seconds saying
"Error Domain=NSCocoaErrorDomain Code=3840 "JSON text did not start with array or object and option to allow fragments not set." UserInfo={NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.}"
I have searched the web with the error and made fixes accordingly but still no success. Please help me guys.
I noticed that your params var is not compatible with the JSON you sent, there are more fields and also missing fields. Moreover, menuItems and submenuItem are an Array in your JSON and an Object in your code. It is probably making the cloud code function to fail and you are therefore not receiving back a valid JSON. Try the following and check if it works. In the case it works, just replace the values by your vars.
let params = [
"source": "card_1EVYuOEynlyM6L4SHgBMJYRQ",
"userId": "YjSZYSXEp7",
"data": [
"menuItems": [[
"id": "QSYa2JDcIm",
"title": "Rice With Tibss(Beef)",
"menuTitle": "Rice With Tibss",
"submenuItem": [[
"id": "zaOo6G4KSV",
"name": "Beef",
"price": 12,
"desc": "Fillings?"
]],
"price": 24,
"qty": 1,
"storeId": "yqBCDmzaDP",
"storeName": "Ibex Ethiopian Cusine and Bar",
"orderType": "takeout",
"taxState": 0.0925,
"storeInfo": [
"cart_storeId": "yqBCDmzaDP",
"cart_storeName": "Ibex Ethiopian Cusine and Bar",
"cart_storeImage": "https://res.cloudinary.com/http-get-tolofood-com/image/upload/c_scale,h_199,q_auto,w_270/v1461575640/Ibex_lopx38.jpg",
"cart_storeCuisine": "Ethiopian",
"cart_storeDescription": "We always serve a quality food. We always serve a quality food. We always serve a quality food. We always serve a quality food.",
"cart_storeRating": 3.33,
"cart_storeDelivery": false,
"takeout": true,
"address": "12255 Greenville Ave,Dallas, TX 75243",
"slugname": "TX_DAL_ibex_ethiopian_cuisine_and_bar",
"multiple_location": false,
"cart_storeDeliveryFee": 15,
"cart_storeServes": "Lunch,Dinner",
"busy": false,
"cart_storeSeoSlug": "ibex-ethiopian-cusine-and-bar"
],
"enable": true,
"voice_read_mi_label": "fbgcb",
"voice_read_mi_option": false,
"menuTypeName": "Standard"
]],
"lastOrderType": "takeout",
"searchedAddress": "takeout",
"timeData": [
"day": "06-05-2019",
"time": "12:55 am",
"tz": "America/Los_Angeles"
]
],
"unavailable_option": "restaurant_recommendation"
]

How to display nested objects and or arrays in angular 2

I am getting json data from the back-end(api). And i want to display this with ngFor. I got an error message like: "Cannot find a differ supporting object '[object Object]'" from the console.
later I tried this:
#Pipe({
name: 'mapToIterable'
})
export class MapToIterable implements PipeTransform{
transform(map: {}, args: any[] = null): any {
if (!map)
return null;
return Object.keys(map)
.map((key) => ({ 'key': key, 'value': map[key] }));
}
}
and then in my view:
<li *ngFor="let detail of getEventDetails | mapToIterable">
Creator Email: {{detail.creator.email}}
</li>
this time i didn't get an error but there is no display values of {{detail.creator.email}}
Data from back-end
{
"banner_image": null,
"categories": [],
"creator": {
"email": "email#email.com",
"first_name": "Prince",
"gender": true,
"id": 15,
"last_name": "Odame",
"subscribed_categories": [],
"watchlist": []
},
"creator_id": 15,
"description": "Learn how to install solar panels in 3 days and make real money all your lifetime",
"faqs": [],
"id": 6,
"is_verified": true,
"max_tickets_per_user": 1,
"shows": [
{
"address": "Engineering Auditorium, College of Engineering, KNUST, Kumasi",
"city": "Kumasi",
"country": "Ghana",
"end_time": "2016-08-03T14:30:00+00:00",
"event_id": 6,
"id": 5,
"is_online": false,
"start_time": "2016-08-01T08:30:00+00:00",
"state": "Ashanti",
"ticket_types": [],
"venue": "Engineering Auditorium"
}
],
"tags": [],
"title": "Solar Panels Installation Workshop"
}
Thanks in advance
You probably just want to do this:
<li>Creator Email: {{getEventDetails.creator.email}}</li>
And for the arrays:
<li *ngFor="let show of getEventDetails?.shows">
Show ID: {{show.id}}
</li>

Elasticsearch mapping not updated after inserting new document via tire (mongoid4, rails4)

Recently I've encountered a strange behaviour regarding elasticsearch with rails4/mongoid4/tire. I managed to do a temporary fix, but I want to know if there is a cleaner solution and where exactly the problem lies (is it an elasticsearch issue?)
Relevant part of my Gemfile
gem 'rails', '4.0.0'
gem "mongoid", github: 'mongoid/mongoid'
gem 'tire'
Elasticsearch version:
"version" : {
"number" : "0.90.2",
"snapshot_build" : false,
"lucene_version" : "4.3.1"
}
My model:
relevant part of my model consists of Ad class:
class Ad
include Mongoid::Document
field :title, type: String
[... other stuff...]
end
and Ad subclasses, one of which is:
class AdInAutomotiveAutomobile < Ad
field :make
field :model
field :body_type
tire.index_name 'ads'
[... other stuff ...]
end
using inheritance doesn't seem to have any importance, but I'm mentioning it just for the record
The problem
Inserting new Ad doesn't update the mapping of 'ads' index
{
"ads": {
"ad_in_automotive_automobile": {
"properties": {
"$oid": {
"type": "string"
}
}
}
}
}
Logs output, trimmed down:
# 2013-08-02 15:40:58:387 [ad_in_automotive_automobile/51fbb6b26f87e9ab1d000001] ("ads")
#
curl -X POST "http://localhost:9200/ads/ad_in_automotive_automobile/51fbb6b26f87e9ab1d000001" -d '{
"_id": {
"$oid": "51fbb6b26f87e9ab1d000001"
},
"active": null,
"body_type": "hatchback",
"c_at": "2013-08-02T13:40:57.647Z",
"category_id": {
"$oid": "51e8020c6f87e9b8e0000001"
},
"color": null,
"description": null,
"engine_displacement": null,
"expire_at": null,
"fuel_type": null,
"locale": null,
"make": "ford",
"meta": {},
"mileage": null,
"model": "focus",
"power": null,
"price": null,
"title": "foo",
"transmission": null,
"u_at": "2013-08-02T13:40:57.647Z",
"year": null,
"category_slug": "automotive-automobile"
}'
# 2013-08-02 15:40:58:388 [201]
#
#
{
"ok": true,
"_index": "ads",
"_type": "ad_in_automotive_automobile",
"_id": "51fbb6b26f87e9ab1d000001",
"_version": 1
}
The solution
Somehow, this:
"_id":{"$oid":"51fbb6b26f87e9ab1d000001"}
is stopping elasticsearch from updating the mapping
So I've 'fixed' this in #to_indexed_json method:
def to_indexed_json
to_json(methods: [:category_slug]).gsub( /\{\"\$oid\"\:(\".{24}\")\}/ ) { $1 }
end
Which results in:
# 2013-08-02 15:50:08:689 [ad_in_automotive_automobile/51fbb8fb6f87e9ab1d000002] ("ads")
#
curl -X POST "http://localhost:9200/ads/ad_in_automotive_automobile/51fbb8fb6f87e9ab1d000002" -d '{
"_id": "51fbb8fb6f87e9ab1d000002",
"active": null,
"body_type": "hatchback",
"c_at": "2013-08-02T13:50:08.593Z",
"category_id": "51e8020c6f87e9b8e0000001",
"color": null,
"description": null,
"engine_displacement": null,
"expire_at": null,
"fuel_type": null,
"locale": null,
"make": "ford",
"meta": {},
"mileage": null,
"model": "focus",
"power": null,
"price": null,
"title": "foo",
"transmission": null,
"u_at": "2013-08-02T13:50:08.593Z",
"year": null,
"category_slug": "automotive-automobile"
}'
# 2013-08-02 15:50:08:690 [201]
#
#
{
"ok": true,
"_index": "ads",
"_type": "ad_in_automotive_automobile",
"_id": "51fbb8fb6f87e9ab1d000002",
"_version": 1
}
And now the mapping is OK:
{
"ads": {
"ad_in_automotive_automobile": {
"properties": {
"$oid": {
"type": "string"
},
"body_type": {
"type": "string"
},
"c_at": {
"type": "date",
"format": "dateOptionalTime"
},
"category_id": {
"type": "string"
},
"category_slug": {
"type": "string"
},
"make": {
"type": "string"
},
"meta": {
"type": "object"
},
"model": {
"type": "string"
},
"title": {
"type": "string"
},
"u_at": {
"type": "date",
"format": "dateOptionalTime"
}
}
}
}
}
The question(s), once again
Why does it happen?
What part of stack is responsible for that?
Can it be fixed in cleaner way?
I'm the guy from the comment, it looks like this is fixed in tire HEAD, look at this issue https://github.com/karmi/tire/issues/775. I havent verified the fix since I monkey patched the class. This is the patch in case you want to go that way:
require "tire"
module Tire
class Index
def get_id_from_document(document)
case
when document.is_a?(Hash)
document[:_id] || document['_id'] || document[:id] || document['id']
when document.respond_to?(:id) && document.id != document.object_id
document.id.to_s # was document.id.as_json
end
end
end
end

Resources