Can`t create a new conversation by skype bot - java

I trying to create a new conversation with person or group of persons, so I create a Bearer token for authentication and add it to header as bearer token (in postman).
So on the next step I create a json script that, theoretically, can create a new conversation. I trying to create a conversation with several person or with only one (for it I added a several person to members or one and change flag isGroup to true or false).
This is a example of json for 1 person:
{
"bot": {
"id": "<app id>",
"name": "<bot name>"
},
"isGroup": false,
"members": [
{
"id": "<member id>",
"name": "<member name>"
}
],
"topicName": "Hello there!"
}
Member id is correct for all members that I trying to add in a new conversation.
And the next response I get always:
{
"id": "8:live:<skype account name>"
}
For group conversation I get the this live skype name for first person that I added. All requests was send to https://skype.botframework.com/v3/conversations or https://smba.trafficmanager.net/apis/v3/conversations and response always same.
Can someone tell me what I'm doing wrong?
Also if I add Activity in body like:
"activity":
{
"type": "message",
"from":
{
"id": "<app-id>",
"name": "<bot name>"
},
"recipient":
{
"id": "<member id>",
"name": "<member name>"
},
"text": "HI"
}
I get next response:
{
"error":
{
"code": "ServiceError",
"message": "Unknown"
}
}

Because Skype only allows one conversation between any two given users, what looks like a simple user ID is actually enough for the Bot Framework to identify the conversation. Some channels, Skype included, allow more than one ID format. In the case of Skype, each conversation can be identified in two ways:
< number >:< Skype screen name >
< number >:< base64 string >
For example, when I create a conversation in Skype, I get the ID 8:kyle-delaney. I can use that to send a message to the conversation with the following endpoint:
https://smba.trafficmanager.net/apis/v3/conversations/8:kyle-delaney/activities
However, when my bot receives a message from the user, both the conversation ID and the "from" ID will be 29:1CpqzpVMMhfi_2nyS1g2mfHaCxnvGL0sF8LbnGadyR_Y. So I can also send a message to the same conversation using this endpoint:
https://smba.trafficmanager.net/apis/v3/conversations/29:1CpqzpVMMhfi_2nyS1g2mfHaCxnvGL0sF8LbnGadyR_Y/activities

Related

Generate models and serializers from JSON with null value and missing attributes?

i am trying to generate a class model from an APIs JSON response (List), i use some service for auto-generation, and everything seems to work fine until the response JSON start returning attributes with a null value and the other thing is that some attributes are missing when i call the APIs. EX:
response JSON:
[
{
"persone": {
"name": "To John",
"age": 15
},
"group": "ipsum"
},
{
"persone": {
"name": "To John",
"age": null
},
"group": "ipsum"
},
{
"persone": {
"name": "To John"
}
}
]
in the above example, the age attribute is null, and the group attribute is missing in the last object of the list.
My question is how do you create an appropriate class model in that case handling the null and the missing attribute?

Ripple Transaction from one local wallet to exchange wallet(example : crex24) gives error code tecDST_TAG_NEEDED using java

i installed ripple wallet on my local server. i created one wallet and activate it with 20 XRP.
Now when i send coin from my active account to account(of crex24.com) then it gives tecDST_TAG_NEEDED error code
Ripple : http://127.0.0.1:5005
Code (using submit method):
RestTemplate template = new RestTemplate();
Map<String,Object> mainMap = new HashMap<>();
mainMap.put("secret", "sxxxxxxxxxxx");
mainMap.put("Fee", "1000"); // in drops
Map<String,String> subMap = new HashMap<>();
subMap.put("Account", "raxxxxxxxxx"); // amount will be deducted from this account
subMap.put("Amount", "1000000"); // in drops
subMap.put("Destination", "rdxxxxxxxxx"); // receiver address
subMap.put("TransactionType", "Payment"); // since we are making a payment request
mainMap.put("tx_json", subMap);
JSONObject json = new JSONObject();
json.put("method", "submit");
json.put("params", new JSONArray(mainMap));
String requestData = json.toString();
System.out.println(requestData);
String response = template.postForObject("http://127.0.0.1:5005", requestData,String.class);
System.out.println(response);
Error
{
"status": 200,
"message": "Transaction achieved successfully.",
"data": {
"result": {
"deprecated": "Signing support in the 'submit' command has been deprecated and will be removed in a future version of the server. Please migrate to a standalone signing tool.",
"engine_result": "tecDST_TAG_NEEDED",
"engine_result_code": 143,
"engine_result_message": "A destination tag is required.",
"status": "success",
"tx_blob": "120000228000000024000000096140000000000F424068400000000000000A7321036CB83FF75DAxxxxxxxxxxxxxxxxxx",
"tx_json": {
"Account": "raxxxxxxxxx",
"Amount": "1000000",
"Destination": "rdxxxxxxxxx",
"Fee": "10",
"Flags": 214482148,
"Sequence": 9,
"SigningPubKey": "036Cxxxxxxxxxxxxxxx6",
"TransactionType": "Payment",
"TxnSignature": "txxxxxxxxx",
"hash": "hxxxxxxxxxx"
}
}
},
"path": "/api/ripple_wallet/makeTransaction"
}
Your account on crex24.com requires a destination tag.
XRPL uses account model similar to ETH. Unlike BTC which uses an UTXO model.
The reason some exchanges require destination tag is that you might be sharing that address with some other person on the exchange. e.g:
Person1's deposit address is: Addr1
Person2's deposit address is also Addr1
Somebody deposits 100XRP to Addr1.
In the case above the exchange wouldn't be able to differentiate if it was Person1's or Person2's.
So the XRPL introduced destination tag which would look something similar to this:
Exchange sets tfRequireDestTag flag of the Addr1 to true using accountSet transaction
Person1's deposit address is: Addr1:1234
Person2's deposit address is also Addr1:1235
Somebody deposits 100XRP to Addr1. XRPL refuses due to tfRequireDestTag being set to true /This is your case/
Someone sends 50XRP to Addr1:1234. <-- this one succeeds!

Separate each name-value pair in a JSON string to separate lines in a java string

I have a Java Spring MVC Web Application. I am trying to implement a form submission where the user will be submitting the form and an email would be sent to the user with the form data. I will receive the form data as JSON string. But the email sent with this data doesn't look readable. I have tried the following code to make the data more readable, but doesn't seem to make much difference:
Gson gson = new GsonBuilder().setPrettyPrinting().create();
JsonParser jp = new JsonParser();
JsonElement je = jp.parse(jsonData);
String message = gson.toJson(je);
My JSON String looks something like below:
[ { "name": "FirstName", "value": "Abcd" }, { "name": "LastName", "value": "Efgh" }, { "name": "Email", "value": "test.mail#test.com" }, { "name": "PhoneNumber", "value": "9876543210" }, { "name": "Selected Locations", "value": " loc1, loc2, loc3" }, { "name": "Message", "value": "Hi" }, { "name": "g-recaptcha-response", "value": "03AMPJSYULxjYiDRiNxcOSVYxXR9F8dX5pqIYAZ6_F2igAwGvanS4Vh1Lm47ByS2qGELQ9W1h" } ]
I am looking for an option at least to bring name-value pair into separate lines so that it is in some readable manner when received through an email. Is there any way to do this. The form can be generic, SO I may not be able to map this string to any Java object.
I have already tried the following link and the solution does not work for me:
Pretty-Print JSON in Java
I also don't see many helpful details online regarding this. I am trying to put each name-value pair in a new line of the generated string to send the data as email.

How to get registration id of failure push notification on android device using Java GCM API

I have implemented below code in java using GCM API to send notification on Android device.
Sender sender = new Sender(GCM_API_KEY);
Message.Builder builder = new Message.Builder();
builder.collapseKey(collpaseKey);
builder.timeToLive(TTL_HOURS * 3600);
if (data != null) {
for (PushData messageData : data) {
builder.addData(messageData.getKey(), messageData.getValue());
}
}
if (StreamType.CALL == type) {
for (PushData pushData : message) {
builder.addData(pushData.getKey(), pushData.getValue());
}
}
Message msg = builder.build();
try {
System.out.println(msg.toString());
MulticastResult result = sender.send(msg, pushId, MAX_RETRY);
log.infof("result %s", result.toString());
return true;
}
here pushId is type of List, which contain all device's push id, at which, notification to be sent.
Problem is that, result does not contain failure push Id or any device identification so that i can identify which device has not received notification.
Note:- I don't want to send notification one by one
Response - result
MulticastResult(multicast_id=7588781423174816193,total=5,success=1,failure=4,canonical_ids=0,results:
[[ errorCode=NotRegistered ], [
messageId=0:1505731620878025%f02bfbe47eeff668 ], [
errorCode=NotRegistered ], [ errorCode=NotRegistered ], [
errorCode=NotRegistered ]]
which does not contain any registration id or something so that i could identify the device in db.
Please suggest,
Thanks in Advance.
The response tells you indirectly with push ids failed.
In your example:
[[ errorCode=NotRegistered ],
[ messageId=0:1505731620878025%f02bfbe47eeff668 ],
[ errorCode=NotRegistered ],
[ errorCode=NotRegistered ],
[ errorCode=NotRegistered ]]
you can see that the 1st, 3rd, 4th and 5th push IDs failed. Since you are supposed to know in which order you sent the push IDs in your request, you should know which push IDs failed.
Here's a relevant example from the documentation:
Here are JSON results for 6 recipients (IDs 4, 8, 15, 16, 23, and 42
respectively) with 3 messages successfully processed, 1 canonical
registration token returned, and 3 errors:
{ "multicast_id": 216, "success": 3, "failure": 3, "canonical_ids": 1, "results": [
{ "message_id": "1:0408" },
{ "error": "Unavailable" },
{ "error": "InvalidRegistration" },
{ "message_id": "1:1516" },
{ "message_id": "1:2342", "registration_id": "32" },
{ "error": "NotRegistered"} ] }
In this example:
First message: success, not required.
Second message: should be resent (to registration token 8).
Third message: had an unrecoverable error (maybe the value got corrupted in the database).
Fourth message: success, nothing required.
Fifth message: success, but the registration token should be updated in the server database (from 23 to 32).
Sixth message: registration token (42) should be removed from the server database because the application was uninstalled from the
device.

Merchant authentication using JSON request - Authorize.Net

This Doc Click here clearly tells me about the merchant authentication. However they only provide the content type : text/xml. Api end point for it is https://apitest.authorize.net/xml/v1/request.api ( sandbox account ).
How can I send a JSON request with name and transaction key as the keys? Also, what is the End Point to which I should send this request for mechant authentication?
Official DOC doesn't help. :'( Was hoping you could. DHC or HttpClientRequester doesn't help too. Getting error.
Authorize.net now works with JSON.
Following is a valid JSON string that you could send to Authorize using whatever platform you use and your own login and secret key.
I should note that even though JSON normally doesn't care which order the values are sent in, Authorize uses a kludgy method to internally convert JSON to XML, so order is in fact, important.
{
"createTransactionRequest": {
"merchantAuthentication": {
"name": "yourLoginKey",
"transactionKey": "yourSecretKey"
},
"refId": "12345",
"transactionRequest": {
"transactionType": "authCaptureTransaction",
"amount": "3.99",
"payment": {
"creditCard": {
"cardNumber": "4111111111111111",
"expirationDate": "0522",
"cardCode": "123"
}
},
"customer": {
"id": "John Doe"
},
"billTo": {
"firstName": "John",
"lastName": "Doe",
"address": "123 My Street",
"city": "Chicago",
"state": "IL",
"zip": "60007",
"country": "USA"
}
}
}
}

Categories