facebook reactions to be grouped by aggs terms elasticsearch - facebook-graph-api

I am working on Facebook analytic, Here is a query which is supposed to fetch the summary of the reactions from Facebook page posts,
Note: posts json is as it is inserted to elastic-search db
{
"query": {
"match": {
"from.id": "[Page-id]"
}
},
"aggs": {
"summary_reaction": {
"terms": {
"field": "reactions.data.type.keyword"
}
}
}
}
Only issue is query return unique count whereas it should consider all reactions.
My result is
"aggregations": {
"reaction_summary": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "LIKE",
"doc_count": 2
},
{
"key": "HAHA",
"doc_count": 1
}
]
}
}
here is the sample json
{
"took": 4,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"failed": 0
},
"hits": {
"total": 3,
"max_score": 6.158189,
"hits": [
{
"_index": "facebook_page",
"_type": "post",
"_id": "AV1RMRKSSM3OTvGpqzx7",
"_score": 6.158189,
"_source": {
"reactions": {
"paging": {
"cursors": {
"after": "TVRFMk9EYzVOekl5TWpjMU5USTJPakUxTURBek1EVTNOREU2TWpVME1EazJNVFl4TXc9PQZDZD",
"before": "TVRFMk9EYzVOekl5TWpjMU5USTJPakUxTURBek1EVTNOREU2TWpVME1EazJNVFl4TXc9PQZDZD"
}
},
"data": [
{
"pic_large": "https://fb-s-d-a.akamaihd.net/h-ak-fbx/v/t1.0-1/p200x200/20108099_116879808942184_8792637908147052517_n.png?oh=4dcc9a9bbdfc965eb477a14775f31448&oe=5A0BCFB5&__gda__=1510661157_f329dd30b13490dbae8d05d3aa45d79f",
"type": "LIKE",
"id": "116879722275526",
"name": "Moojaa"
}
]
},
"from": {
"picture": {
"data": {
"url": "https://fb-s-d-a.akamaihd.net/h-ak-fbx/v/t1.0-1/p50x50/20108099_116879808942184_8792637908147052517_n.png?oh=24cc256b24e5da70f306afcf784a636d&oe=59FBA1D4&__gda__=1509895651_44acee6189c7c1cb6eed023a6e742d1a",
"is_silhouette": false
}
},
"name": "Moojaa",
"id": "116879722275526"
},
"coordinates": {},
"created_time": "2017-07-17T15:35:35+0000",
"message": "Kuthey e Moojaa",
"type": "status",
"id": "116879722275526_116886608941504"
}
},
{
"_index": "facebook_page",
"_type": "post",
"_id": "AV1RMRViSM3OTvGpqzx8",
"_score": 6.158189,
"_source": {
"reactions": {
"paging": {
"cursors": {
"after": "TVRFMk9EYzVOekl5TWpjMU5USTJPakUxTURBek1EUTBNRGc2TWpVME1EazJNVFl4TXc9PQZDZD",
"before": "TVRBd01ERTFOREl5TkRrNE56Y3dPakUxTURBek1EUTFNams2TWpVME1EazJNVFl4TXc9PQZDZD"
}
},
"data": [
{
"pic_large": "https://fb-s-a-a.akamaihd.net/h-ak-fbx/v/t1.0-1/p200x200/16864759_114731265717623_8811777667276972672_n.jpg?oh=836c6d5145bc8023d3ac60e0dfd42bde&oe=5A00D0DC&__gda__=1509885772_ad8923f4369250c2c2051c5e9293331f",
"type": "LIKE",
"id": "111467022710714",
"name": "Ram Singh Shankar"
},
{
"pic_large": "https://fb-s-d-a.akamaihd.net/h-ak-fbx/v/t1.0-1/p200x200/20108099_116879808942184_8792637908147052517_n.png?oh=4dcc9a9bbdfc965eb477a14775f31448&oe=5A0BCFB5&__gda__=1510661157_f329dd30b13490dbae8d05d3aa45d79f",
"type": "LIKE",
"id": "116879722275526",
"name": "Moojaa"
}
]
},
"from": {
"picture": {
"data": {
"url": "https://fb-s-d-a.akamaihd.net/h-ak-fbx/v/t1.0-1/p50x50/20108099_116879808942184_8792637908147052517_n.png?oh=24cc256b24e5da70f306afcf784a636d&oe=59FBA1D4&__gda__=1509895651_44acee6189c7c1cb6eed023a6e742d1a",
"is_silhouette": false
}
},
"name": "Moojaa",
"id": "116879722275526"
},
"coordinates": {},
"comments": {
"paging": {
"cursors": {
"after": "WTI5dGJXVnVkRjlqZAFhKemIzSTZANVEUyT0RneE5UUTRPVFF5TURFd09qRTFNREF6TURRMk5Eaz0ZD",
"before": "WTI5dGJXVnVkRjlqZAFhKemIzSTZANVEUyT0RneE5EUXlNamMxTXpVME9qRTFNREF6TURRMk1URT0ZD"
}
},
"data": [
{
"message": "test",
"from": {
"picture": {
"data": {
"url": "https://fb-s-a-a.akamaihd.net/h-ak-fbx/v/t1.0-1/p200x200/16864759_114731265717623_8811777667276972672_n.jpg?oh=836c6d5145bc8023d3ac60e0dfd42bde&oe=5A00D0DC&__gda__=1509885772_ad8923f4369250c2c2051c5e9293331f",
"is_silhouette": false
}
},
"name": "Ram Singh Shankar",
"id": "111467022710714"
},
"id": "116880885608743_116881442275354"
},
{
"message": "test 2",
"from": {
"picture": {
"data": {
"url": "https://fb-s-a-a.akamaihd.net/h-ak-fbx/v/t1.0-1/p200x200/16864759_114731265717623_8811777667276972672_n.jpg?oh=836c6d5145bc8023d3ac60e0dfd42bde&oe=5A00D0DC&__gda__=1509885772_ad8923f4369250c2c2051c5e9293331f",
"is_silhouette": false
}
},
"name": "Ram Singh Shankar",
"id": "111467022710714"
},
"id": "116880885608743_116881548942010"
}
]
},
"created_time": "2017-07-17T15:13:23+0000",
"message": "another Mooja",
"type": "status",
"id": "116879722275526_116880885608743"
}
},
{
"_index": "facebook_page",
"_type": "post",
"_id": "AV1RMRgtSM3OTvGpqzx9",
"_score": 6.158189,
"_source": {
"reactions": {
"paging": {
"cursors": {
"after": "TVRBd01ERTFOREl5TkRrNE56Y3dPakUxTURBek1EUXpPRGM2TnpnNE5qUTRNRE0zT1RFek16RXkZD",
"before": "TVRFMk9EYzVOekl5TWpjMU5USTJPakUxTURBek1EUTVOVEk2TnpnNE5qUTRNRE0zT1RFek16RXkZD"
}
},
"data": [
{
"pic_large": "https://fb-s-d-a.akamaihd.net/h-ak-fbx/v/t1.0-1/p200x200/20108099_116879808942184_8792637908147052517_n.png?oh=4dcc9a9bbdfc965eb477a14775f31448&oe=5A0BCFB5&__gda__=1510661157_f329dd30b13490dbae8d05d3aa45d79f",
"type": "HAHA",
"id": "116879722275526",
"name": "Moojaa"
},
{
"pic_large": "https://fb-s-a-a.akamaihd.net/h-ak-fbx/v/t1.0-1/p200x200/16864759_114731265717623_8811777667276972672_n.jpg?oh=836c6d5145bc8023d3ac60e0dfd42bde&oe=5A00D0DC&__gda__=1509885772_ad8923f4369250c2c2051c5e9293331f",
"type": "HAHA",
"id": "111467022710714",
"name": "Ram Singh Shankar"
}
]
},
"from": {
"picture": {
"data": {
"url": "https://fb-s-d-a.akamaihd.net/h-ak-fbx/v/t1.0-1/p50x50/20108099_116879808942184_8792637908147052517_n.png?oh=24cc256b24e5da70f306afcf784a636d&oe=59FBA1D4&__gda__=1509895651_44acee6189c7c1cb6eed023a6e742d1a",
"is_silhouette": false
}
},
"name": "Moojaa",
"id": "116879722275526"
},
"coordinates": {},
"comments": {
"paging": {
"cursors": {
"after": "WTI5dGJXVnVkRjlqZAFhKemIzSTZANVEUyT0RneE9ESTFOakE0TmpRNU9qRTFNREF6TURRM05EYz0ZD",
"before": "WTI5dGJXVnVkRjlqZAFhKemIzSTZANVEUyT0RneE5UVTRPVFF5TURBNU9qRTFNREF6TURRMk5UUT0ZD"
}
},
"data": [
{
"message": "test 3",
"from": {
"picture": {
"data": {
"url": "https://fb-s-d-a.akamaihd.net/h-ak-fbx/v/t1.0-1/p200x200/20108099_116879808942184_8792637908147052517_n.png?oh=4dcc9a9bbdfc965eb477a14775f31448&oe=5A0BCFB5&__gda__=1510661157_f329dd30b13490dbae8d05d3aa45d79f",
"is_silhouette": false
}
},
"name": "Moojaa",
"id": "116879722275526"
},
"id": "116880192275479_116881558942009"
},
{
"message": "test ram",
"from": {
"picture": {
"data": {
"url": "https://fb-s-a-a.akamaihd.net/h-ak-fbx/v/t1.0-1/p200x200/16864759_114731265717623_8811777667276972672_n.jpg?oh=836c6d5145bc8023d3ac60e0dfd42bde&oe=5A00D0DC&__gda__=1509885772_ad8923f4369250c2c2051c5e9293331f",
"is_silhouette": false
}
},
"name": "Ram Singh Shankar",
"id": "111467022710714"
},
"id": "116880192275479_116881578942007"
},
{
"message": "test singh",
"from": {
"picture": {
"data": {
"url": "https://fb-s-a-a.akamaihd.net/h-ak-fbx/v/t1.0-1/p200x200/16864759_114731265717623_8811777667276972672_n.jpg?oh=836c6d5145bc8023d3ac60e0dfd42bde&oe=5A00D0DC&__gda__=1509885772_ad8923f4369250c2c2051c5e9293331f",
"is_silhouette": false
}
},
"name": "Ram Singh Shankar",
"id": "111467022710714"
},
"id": "116880192275479_116881598942005"
},
{
"message": "khair",
"from": {
"picture": {
"data": {
"url": "https://fb-s-d-a.akamaihd.net/h-ak-fbx/v/t1.0-1/p200x200/20108099_116879808942184_8792637908147052517_n.png?oh=4dcc9a9bbdfc965eb477a14775f31448&oe=5A0BCFB5&__gda__=1510661157_f329dd30b13490dbae8d05d3aa45d79f",
"is_silhouette": false
}
},
"name": "Moojaa",
"id": "116879722275526"
},
"id": "116880192275479_116881825608649"
}
]
},
"created_time": "2017-07-17T15:10:12+0000",
"message": "Testing my Mooja",
"type": "status",
"id": "116879722275526_116880192275479"
}
}
]
}
}

You have to set data inside the reactions as nested type and you can do nested aggregation on the data to get all the counts for the type.
Mappings
PUT facebook_index1
{
"mappings": {
"document_type" : {
"properties": {
"reactions" : {
"type": "object",
"properties": {
"data" : {
"type" : "nested",
"properties" : {
"type" : {
"type" : "keyword"
}
}
}
}
}
}
}
}
}
Query
use nested aggs to aggregate for type for data.
POST facebook_index1/_search
{
"size": 0,
"aggs": {
"nested_data_aggs": {
"nested": {
"path": "reactions.data"
},
"aggs": {
"summary_reaction": {
"terms": {
"field": "reactions.data.type",
"size": 10
}
}
}
}
}
}
Hope this works

Related

highlighting bars in Deneb (Power BI) - fillOpacity

I have the chart on the left, code provided below, and would like to get the chart on the right. The chart on the right has the bars highlighted that correspond to a selected tier; the tier selected comes from a slicer. (The right chart shows Tier 1; however, the user may prefer a different tier.) I feel like this can be accomplished using fillOpacity. How do I get the highlighting?
{
"data": {
"values": [
{"name": "A", "group": "High", "tier": "Tier 3"},
{"name": "B", "group": "Med", "tier": "Tier 1"},
{"name": "C", "group": "High", "tier": "Tier 1"},
{"name": "D", "group": "High", "tier": "Tier 2"},
{"name": "E", "group": "Low", "tier": "Tier 3"},
{"name": "F", "group": "Low", "tier": "Tier 1"}
]
},
"transform": [
{
"aggregate": [
{
"field": "name",
"op": "count",
"as": "numProj"
}
],
"groupby": [
"name",
"group"
]
},
{
"stack": "numProj",
"groupby": ["group"],
"sort": [
{
"field": "name",
"order": "descending"
}
],
"as": "barTop"
}
],
"layer": [
{
"mark": {
"type": "bar",
"stroke": "black",
"strokeWidth": 1,
"tooltip": true
},
"encoding": {
"y": {
"field": "numProj",
"type": "quantitative",
"axis": {
"title": "Number of Projects",
"tickMinStep": 1
}
},
"fill": {
"field": "group",
"type": "nominal",
"scale": {
"domain": [
"Low",
"Med",
"High"
],
"range": [
"#e15759",
"#ffff00",
"#59a14f"
]
},
"legend": null
}
}
},
{
"mark": {
"type": "text",
"color": "black",
"dy": -10
},
"encoding": {
"y": {
"field": "barTop",
"type": "quantitative"
},
"text": {
"field": "name"
}
}
}
],
"encoding": {
"x": {
"field": "group",
"type": "nominal",
"axis": {
"title": null,
"labelAngle": 0
}
}
}
}
Highlighting in Deneb is quite involved and can be read about here. Having said that, I have a working example.
Code
{
"data": {"name": "dataset"},
"layer": [
{
"mark": {
"type": "bar",
"stroke": "black",
"strokeWidth": 1,
"tooltip": true,
"opacity": 0.3
},
"encoding": {
"y": {
"field": "test",
"type": "quantitative",
"axis": {
"title": "Number of Projects",
"tickMinStep": 1
}
},
"fill": {
"field": "group",
"type": "nominal",
"scale": {
"domain": [
"Low",
"Med",
"High"
],
"range": [
"#e15759",
"#ffff00",
"#59a14f"
]
},
"legend": null
}
}
},
{
"mark": {
"type": "bar",
"stroke": "black",
"strokeWidth": 1,
"tooltip": true,
"opacity": 1
},
"encoding": {
"y": {
"field": "test__highlight",
"type": "quantitative",
"axis": {
"title": "Number of Projects",
"tickMinStep": 1
}
},
"fill": {
"field": "group",
"type": "nominal",
"scale": {
"domain": [
"Low",
"Med",
"High"
],
"range": [
"#e15759",
"#ffff00",
"#59a14f"
]
},
"legend": null
}
}
},
{
"mark": {
"type": "text",
"color": "black",
"dy": 70
},
"encoding": {
"y": {
"field": "test__highlight",
"stack": true,
"type": "quantitative"
},
"text": {
"field": "name"
}
}
}
],
"encoding": {
"x": {
"field": "group",
"type": "nominal",
"axis": {
"title": null,
"labelAngle": 0
}
}
}
}
Things to keep in mind.
You need a measure (Deneb docs state highlighting doesn't work without a measure). The measure named test is simply test = COUNT('Table'[name])
You can't highlight from a slicer unless it is disconnected as slicers filter instead of highlight
You can't highlight stacks in position. The highlighted stacks naturally fall to the bottom as a result of how the data is being passed. There may be a way around this but it will involve further investigation which is probably not worth it.
Edit 1
Highlighting in place.
{
"data": {"name": "dataset"},
"layer": [
{
"mark": {
"type": "bar",
"stroke": "black",
"strokeWidth": 1,
"tooltip": true,
"opacity": 0.3
},
"encoding": {
"y": {
"field": "test",
"type": "quantitative",
"axis": {
"title": "Number of Projects",
"tickMinStep": 1
}
},
"fill": {
"field": "group",
"type": "nominal",
"scale": {
"domain": [
"Low",
"Med",
"High"
],
"range": [
"#e15759",
"#ffff00",
"#59a14f"
]
},
"legend": null
}
}
},
{
"mark": {
"type": "bar",
"stroke": "black",
"strokeWidth": 1,
"tooltip": true
},
"encoding": {
"y": {
"field": "test",
"type": "quantitative",
"axis": {
"title": "Number of Projects",
"tickMinStep": 1
}
},
"opacity": {
"condition": {
"test": "datum['test__highlight']!=null"
,
"value": 1
},
"value": 0
},
"fill": {
"field": "group",
"type": "nominal",
"scale": {
"domain": [
"Low",
"Med",
"High"
],
"range": [
"#e15759",
"#ffff00",
"#59a14f"
]
},
"legend": null
}
}
},
{
"mark": {
"type": "text",
"color": "black",
"dy": 70
},
"encoding": {
"y": {
"field": "test",
"stack": true,
"type": "quantitative"
},
"text": {
"field": "name"
}
}
}
],
"encoding": {
"x": {
"field": "group",
"type": "nominal",
"axis": {
"title": null,
"labelAngle": 0
}
}
}
}

People API returning error when bulkCreateContact is called

I have tried to bulk add a contact using API Try editor of Google https://developers.google.com/people/api/rest/v1/people/batchCreateContacts
{
"contacts": [
{
"contactPerson": {
"addresses": [
{
"formattedValue": "formattedValue",
"type": "type",
"poBox": "poBox",
"streetAddress": "streetAddress",
"extendedAddress": "extendedAddress",
"region": "region",
"postalCode": "postalCode",
"country": "country",
"countryCode": "countryCode"
},
{
"formattedValue": "formattedValue",
"type": "type",
"poBox": "poBox",
"streetAddress": "streetAddress",
"extendedAddress": "extendedAddress",
"city": "city",
"region": "region",
"postalCode": "postalCode",
"country": "country",
"countryCode": "countryCode"
}
],
"biographies": [
{
"value": "biographies-value",
"contentType": "TEXT_PLAIN"
}
],
"birthdays": [
{
"date": {
"year": 1988,
"month": 9,
"day": 22
},
"text": "22/09/1988"
}
],
"calendarUrls": [
{
"url": "https://lh3.googleusercontent.com/ogw/ADea4I4kLm9hsAYNpD_7v-7wXki3joED-eg2ZHcGmp31",
"type": "calendarUrls-type"
}
],
"clientData": [
{
"key": "clientData-key",
"value": "clientData-value"
}
],
"emailAddresses": [
{
"value": "emailAddresses-value",
"type": "emailAddresses-type",
"displayName": "emailAddresses-displayName"
}
],
"events": [
{
"date": {
"year": 1988,
"month": 9,
"day": 22
},
"type": "events-type"
},
{
"date": {
"year": 1988,
"month": 9,
"day": 22
},
"type": "events-type"
},
{
"date": {
"year": 2019,
"month": 12,
"day": 7
},
"type": "marriage"
}
],
"externalIds": [
{
"value": "externalIds-value",
"type": "externalIds-type"
}
],
"fileAses": [
{
"value": "fileAses-value"
}
],
"genders": [
{
"value": "male",
"addressMeAs": "her"
}
],
"imClients": [
{
"username": "imClients-username1",
"type": "imClients-typeA",
"protocol": "imClients-protocol1"
},
{
"username": "imClients-username2",
"type": "imClients-typeA",
"protocol": "imClients-protocol2"
},
{
"username": "imClients-username3",
"type": "imClients-typeB",
"protocol": "imClients-protocol3"
}
],
"interests": [
{
"value": "interests-value"
}
],
"locales": [
{
"value": "locales-value"
}
],
"locations": [
{
"value": "locations-value1",
"type": "desk",
"current": true,
"buildingId": "locations-buildingId",
"floor": "locations-floor",
"floorSection": "buildingId-floorSection",
"deskCode": "locations-deskCode"
},
{
"value": "locations-value2",
"type": "desk",
"current": true,
"buildingId": "locations-buildingId",
"floor": "locations-floor",
"floorSection": "buildingId-floorSection",
"deskCode": "locations-deskCode"
}
],
"memberships": [
{
"contactGroupMembership": {
"contactGroupResourceName": "contactGroups/3616ed318c1125e3"
}
}
],
"miscKeywords": [
{
"value": "SENSITIVITY1",
"type": "OUTLOOK_SENSITIVITY"
},
{
"value": "SENSITIVITY2",
"type": "OUTLOOK_SENSITIVITY"
},
{
"value": "OUTLOOK_SUBJECT",
"type": "OUTLOOK_SUBJECT"
},
{
"value": "OUTLOOK_BILLING_INFORMATION",
"type": "OUTLOOK_BILLING_INFORMATION"
},
{
"value": "OUTLOOK_DIRECTORY_SERVER",
"type": "OUTLOOK_DIRECTORY_SERVER"
},
{
"value": "OUTLOOK_KEYWORD",
"type": "OUTLOOK_KEYWORD"
},
{
"value": "OUTLOOK_MILEAGE",
"type": "OUTLOOK_MILEAGE"
},
{
"value": "OUTLOOK_PRIORITY",
"type": "OUTLOOK_PRIORITY"
},
{
"value": "OUTLOOK_SUBJECT",
"type": "OUTLOOK_SUBJECT"
},
{
"value": "OUTLOOK_USER1-value",
"type": "OUTLOOK_USER"
},
{
"value": "OUTLOOK_USER2-value",
"type": "OUTLOOK_USER"
},
{
"value": "HOME",
"type": "HOME"
},
{
"value": "WORK",
"type": "WORK"
},
{
"value": "OTHER",
"type": "OTHER"
}
],
"names": [
{
"unstructuredName": "unstructuredName",
"familyName": "MrTest",
"givenName": "givenName",
"middleName": "middleName",
"honorificPrefix": "honorificPrefix",
"honorificSuffix": "honorificSuffix",
"phoneticFullName": "phoneticFullName",
"phoneticFamilyName": "phoneticFamilyName",
"phoneticGivenName": "phoneticGivenName",
"phoneticMiddleName": "phoneticMiddleName",
"phoneticHonorificPrefix": "phoneticHonorificPrefix",
"phoneticHonorificSuffix": "phoneticHonorificSuffix"
}
],
"nicknames": [
{
"value": "nicknames-value-alternate-name",
"type": "ALTERNATE_NAME"
},
{
"value": "nicknames-value-default",
"type": "DEFAULT"
}
],
"occupations": [
{
"value": "occupations-value"
}
],
"organizations": [
{
"type": "organizations-type",
"startDate": {
"year": 1988,
"month": 9,
"day": 22
},
"endDate": {
"year": 1988,
"month": 9,
"day": 22
},
"current": true,
"name": "organizations-name",
"phoneticName": "organizations-phoneticName",
"department": "organizations-department",
"title": "organizations-title",
"jobDescription": "organizations-jobDescription",
"symbol": "organizations-symbol",
"domain": "organizations-domain",
"location": "organizations-location"
}
],
"phoneNumbers": [
{
"value": "phoneNumbers-value",
"type": "phoneNumbers-type"
}
],
"relations": [
{
"person": "relations-person",
"type": "relations-type"
}
],
"sipAddresses": [
{
"value": "sipAddresses-value",
"type": "sipAddresses-type"
}
],
"urls": [
{
"value": "https://lh3.googleusercontent.com/ogw/ADea4I4kLm9hsAYNpD_7v-7wXki3joED-eg2ZHcGmp31",
"type": "urls-type"
}
],
"userDefined": [
{
"key": "userDefined-key",
"value": "userDefined-value"
}
]
}
}
],
"readMask": "emailAddresses,phoneNumbers,addresses,birthdays,biographies,calendarUrls,clientData,coverPhotos,events,externalIds,genders,imClients,interests,locales,locations,memberships,miscKeywords,names,nicknames,occupations,organizations,phoneNumbers,photos,relations,sipAddresses,skills,urls,userDefined"
}
I get the error as
{
"error": {
"code": 500,
"message": "Internal error encountered.",
"status": "INTERNAL"
}
}
Am I missing something?
It looks like the 500 Internal Error message you are receiving is due to the fact that you are using the calendarUrls field in the request.
This might in fact be a bug so I have taken the opportunity to file a report on Google's Issue Tracker here.
I suggest you star the issue as all the updates will be posted there.

Is it possible to make a partial refund multiple times?

Is it possible to make partial refund using Authorize.Net? E.g. I have a transaction by 300$. First time I need to make a refund 100$ on this transaction. And second time to make a refund 50$.
What kind of transaction status will be after that?
first request:
...
"refId": "123456",
"transactionRequest": {
"transactionType": "refundTransaction",
"amount": "100.00",}
"refTransId": "1234567890"
}
...
second request:
...
"refId": "123456",
"transactionRequest": {
"transactionType": "refundTransaction",
"amount": "50.00",}
"refTransId": "1234567890"
}
...
Yes, you can make multiple refunds against one transaction as long as you do not go over the original transaction amount.
Below I made a $50 payment and then following up with a $20 and $10 refund. Both were successful.
Here is my original AUTH_CAPTURE request:
{
"createTransactionRequest": {
"merchantAuthentication": {
"name": "",
"transactionKey": ""
},
"refId": 38947161,
"transactionRequest": {
"transactionType": "authCaptureTransaction",
"amount": 100,
"payment": {
"creditCard": {
"cardNumber": "4111111111111111",
"expirationDate": "122020",
"cardCode": "999"
}
},
"order": {
"invoiceNumber": "1324567890",
"description": "this is a test transaction"
},
"lineItems": {
"lineItem": [
{
"itemId": "1",
"name": "vase",
"description": "Cannes logo",
"quantity": "18",
"unitPrice": "45.00"
},
{
"itemId": "2",
"name": "desk",
"description": "Big Desk",
"quantity": "10",
"unitPrice": "85.00"
}
]
},
"tax": {
"amount": "4.26",
"name": "level2 tax name",
"description": "level2 tax"
},
"duty": {
"amount": "8.55",
"name": "duty name",
"description": "duty description"
},
"shipping": {
"amount": "4.26",
"name": "level2 tax name",
"description": "level2 tax"
},
"poNumber": "456654",
"customer": {
"id": "18",
"email": "someone#blackhole.tv"
},
"billTo": {
"firstName": "Ellen",
"lastName": "Johnson",
"company": "Souveniropolis",
"address": "14 Main Street",
"city": "Pecan Springs",
"state": "TX",
"zip": "44628",
"country": "USA"
},
"shipTo": {
"firstName": "China",
"lastName": "Bayles",
"company": "Thyme for Tea",
"address": "12 Main Street",
"city": "Pecan Springs",
"state": "TX",
"zip": "44628",
"country": "USA"
},
"customerIP": "192.168.1.1",
"transactionSettings": {
"setting": [
{
"settingName": "allowPartialAuth",
"settingValue": "false"
},
{
"settingName": "duplicateWindow",
"settingValue": "0"
},
{
"settingName": "emailCustomer",
"settingValue": "false"
},
{
"settingName": "recurringBilling",
"settingValue": "false"
},
{
"settingName": "testRequest",
"settingValue": "false"
}
]
},
"userFields": {
"userField": {
"name": "favorite_color",
"value": "blue"
}
}
}
}
}
Here is my original AUTH_CAPTURE response:
{
"transactionResponse": {
"responseCode": "1",
"authCode": "TTJ26B",
"avsResultCode": "Y",
"cvvResultCode": "P",
"cavvResultCode": "2",
"transId": "40032153203",
"refTransID": "",
"transHash": "",
"testRequest": "0",
"accountNumber": "XXXX1111",
"accountType": "Visa",
"messages": [
{
"code": "1",
"description": "This transaction has been approved."
}
],
"userFields": [
{
"name": "favorite_color",
"value": "blue"
}
],
"transHashSha2": "0C9E5A47F93CD5B770A6B4AB24FE0F0D6F3B909066C72A10C4746F48C9886527A18B654736AE8D920D9048A14F2823A0DEC5B5F775A1C48DE9CBCF41C8D28CA3",
"SupplementalDataQualificationIndicator": 0
},
"refId": "38947161",
"messages": {
"resultCode": "Ok",
"message": [
{
"code": "I00001",
"text": "Successful."
}
]
}
}
Here is my first REFUND request (successful):
{
"createTransactionRequest": {
"merchantAuthentication": {
"name": "",
"transactionKey": ""
},
"refId": 30777668,
"transactionRequest": {
"transactionType": "refundTransaction",
"amount": 20,
"payment": {
"creditCard": {
"cardNumber": "4111111111111111",
"expirationDate": "122020"
}
},
"authCode": "40032153203"
}
}
}
Here is my first REFUND response (successful):
{
"transactionResponse": {
"responseCode": "1",
"authCode": "",
"avsResultCode": "P",
"cvvResultCode": "",
"cavvResultCode": "",
"transId": "40032153314",
"refTransID": "",
"transHash": "",
"testRequest": "0",
"accountNumber": "XXXX1111",
"accountType": "Visa",
"messages": [
{
"code": "1",
"description": "This transaction has been approved."
}
],
"transHashSha2": "4CE2D83B56C09494AD5609440E3337A6DEE0F4C74FBC99B218D65F6A121EFFC269F8954AC47C17B3B739E61A860C7B0818A8497D85D314D6E0CD89C9FE71A071",
"SupplementalDataQualificationIndicator": 0
},
"refId": "30777668",
"messages": {
"resultCode": "Ok",
"message": [
{
"code": "I00001",
"text": "Successful."
}
]
}
}
Here is my second REFUND request (successful):
{
"createTransactionRequest": {
"merchantAuthentication": {
"name": "",
"transactionKey": ""
},
"refId": 40597686,
"transactionRequest": {
"transactionType": "refundTransaction",
"amount": 10,
"payment": {
"creditCard": {
"cardNumber": "4111111111111111",
"expirationDate": "122020"
}
},
"authCode": "40032153203"
}
}
}
Here is my second REFUND response (successful):
{
"transactionResponse": {
"responseCode": "1",
"authCode": "",
"avsResultCode": "P",
"cvvResultCode": "",
"cavvResultCode": "",
"transId": "40032153319",
"refTransID": "",
"transHash": "",
"testRequest": "0",
"accountNumber": "XXXX1111",
"accountType": "Visa",
"messages": [
{
"code": "1",
"description": "This transaction has been approved."
}
],
"transHashSha2": "FD146FC0F8F3F31068905EC6C8D252662AA735ACDFAC53B4A8D808060C244C06288700AA8872466C3E240B62130D010CFBDE0473D09B631514A6E2E2CB77804F",
"SupplementalDataQualificationIndicator": 0
},
"refId": "40597686",
"messages": {
"resultCode": "Ok",
"message": [
{
"code": "I00001",
"text": "Successful."
}
]
}
}

AWS API Gateway as proxy to dynamo DB HTTP Get mapping template

I have a API gateway which does a get to the tables stored in dynamo DB.
The table stored looks like as JSON as show below
{
"photos": {
"page": 1,
"pages": "1234",
"perpage": 100,
"photo": [
{
"farm": 1,
"id": "12345678901",
"isfamily": 0,
"isfriend": 0,
"ispublic": 1,
"owner": "23456789#A12",
"secret": "abc123d456",
"server": "1234",
"title": "Sample photo 1"
},
{
"farm": 2,
"id": "23456789012",
"isfamily": 0,
"isfriend": 0,
"ispublic": 1,
"owner": "34567890#B23",
"secret": "bcd234e567",
"server": "2345",
"title": "Sample photo 2"
}
],
"total": "123398"
},
"srini": "srini"
}
With out integration response mapping template I get the table as shown below
{
"Count": 1, "Items": [
{
"photos": {
"M": {
"photo": {
"L": [
{
"M": {
"owner": {
"S": "23456789#A12"
},
"server": {
"S": "1234"
},
"ispublic": {
"N": "1"
},
"isfriend": {
"N": "0"
},
"farm": {
"N": "1"
},
"id": {
"S": "12345678901"
},
"secret": {
"S": "abc123d456"
},
"title": {
"S": "Sample photo 1"
},
"isfamily": {
"N": "0"
}
}
},
{
"M": {
"owner": {
"S": "34567890#B23"
},
"server": {
"S": "2345"
},
"ispublic": {
"N": "1"
},
"isfriend": {
"N": "0"
},
"farm": {
"N": "2"
},
"id": {
"S": "23456789012"
},
"secret": {
"S": "bcd234e567"
},
"title": {
"S": "Sample photo 2"
},
"isfamily": {
"N": "0"
}
}
}
]
},
"perpage": {
"N": "100"
},
"total": {
"S": "123398"
},
"pages": {
"S": "1234"
},
"page": {
"N": "1"
}
}
},
"srini": {
"S": "srini"
}
} ], "ScannedCount": 1
}
I am trying to retrieve in the JSON format so that web client takes the table from Dynamo in JSON format .The mapping template I am trying to write is as follows
#set($inputRoot = $input.path('$'))
{
#foreach($elem in $inputRoot.Items) {
"srini": "$elem.srini.S",
"pages": "$elem.photos.pages.S",
#foreach($elemnext in $elem.photos.photo) {
"id": "$elemnext.id.S"
}#if($foreach.hasNext),#end
#end
}#if($foreach.hasNext),#end
#end
}
I only can retrieve srini as show below
Response Body
{
{
"srini": "srini",
"pages": ""
}
}
All other data is not retreived ,What is the right way to write mapping template ,Can any one let me know please?
#set($inputRoot = $input.path('$'))
{
#foreach($elem in $inputRoot.Items) {
"srini": "$elem.srini.S",
"pages": "$elem.photos.M.pages.S",
#foreach($elemnext in $elem.photos.M.photo.L)
{
"id": "$elemnext.M.id.S"
} #if($foreach.hasNext),#end
#end
}#if($foreach.hasNext),#end
#end
}

Facebook Graph Api: Unable to get latest post for keywords

Can anyone help me, When I request using link
https://graph.facebook.com/search?&limit=2&until=now&q=hi&type=post&access_token=AAAAAAITEghMBAIScEzst3h5VpV8pKZA7di2ZC3czxr5
Note: I am not giving valid token for security reason.
I always get the result for 27 Nov 2012, while I tried to search for latest post. Am I missing something? Please help.
Thanks in Advance.
RESULT I get:
{
"data": [
{
"id": "730221920_10151138508071921",
"from": {
"name": "Pinky Saowichit",
"id": "730221920"
},
"message": "\u0e2d\u0e32\u0e17\u0e34\u0e15\u0e22\u0e4c\u0e19\u0e35\u0e49\u0e2d\u0e32\u0e08\u0e44\u0e21\u0e48\u0e44\u0e14\u0e49\u0e2d\u0e2d\u0e31\u0e19\u0e1a\u0e48\u0e2d\u0e22\u0e46 \u0e19\u0e30\u0e04\u0e30 \u0e41\u0e1f\u0e19\u0e04\u0e25\u0e31\u0e1a \u0e43\u0e2b\u0e49\u0e23\u0e39\u0e49\u0e27\u0e48\u0e48\u0e32\u0e04\u0e34\u0e14\u0e16\u0e36\u0e07\u0e19\u0e30\u0e04\u0e30 \u0e41\u0e15\u0e48\u0e15\u0e2d\u0e19\u0e19\u0e35\u0e49\u0e40\u0e23\u0e32\u0e01\u0e33\u0e25\u0e31\u0e07\u0e04\u0e34\u0e14\u0e16\u0e36\u0e07\u0e04\u0e38\u0e13 \u0e04\u0e32\u0e19\u0e18\u0e35\u0e41\u0e25\u0e30\u0e40\u0e17\u0e40\u0e23\u0e0b\u0e48\u0e32\u0e2d\u0e22\u0e48\u0e32\u0e07\u0e21\u0e32\u0e01\u0e46 \u0e2b\u0e38 \u0e2b\u0e38",
"privacy": {
"value": ""
},
"type": "status",
"status_type": "mobile_status_update",
"created_time": "2012-11-27T03:12:32+0000",
"updated_time": "2012-11-27T07:44:54+0000",
"likes": {
"data": [
{
"name": "Weniefredo Laud",
"id": "100004751890183"
},
{
"name": "\u0e1e\u0e23\u0e15 \u0e1c\u0e25\u0e14\u0e35",
"id": "100001056963372"
},
{
"name": "\u0e08\u0e23\u0e34\u0e0d\u0e32 \u0e25\u0e2d\u0e27",
"id": "100000046347271"
},
{
"name": "Noolek Tikamborn",
"id": "100003048464258"
}
],
"count": 6
}
},
{
"id": "100003971930240_283727615063091",
"from": {
"name": "Mariana Salcedo",
"id": "100003971930240"
},
"story": "Mariana Salcedo shared a link.",
"picture": "http://external.ak.fbcdn.net/safe_image.php?d=AQASxQms6c0xFkdO&w=90&h=90&url=http\u00253A\u00252F\u00252Fask.fm\u00252Fimages\u00252F50x50.gif",
"link": "http://ask.fm/marianasalcedo/answer/15735435637",
"name": "CRUSH hi",
"caption": "jajajajaja que enfadosa erees!",
"icon": "http://static.ak.fbcdn.net/rsrc.php/v2/yN/x/aS8ecmYRys0.gif",
"privacy": {
"value": ""
},
"type": "link",
"status_type": "shared_story",
"application": {
"name": "Ask.fm",
"id": "129215213762342"
},
"created_time": "2012-11-27T03:11:38+0000",
"updated_time": "2012-11-27T03:11:38+0000"
}
],
"paging": {
"previous": "https://graph.facebook.com/search?q=hi&limit=2&type=post&access_token=AAAAAAITEghMBAIScEzst3h5VpV8pKZA7di2ZC3czxr5ANnvKPPc1wqYJJZAANd9PI0NKLX5Xk5ReRX3T01iim8BoJp6r16itU8vPxRP&since=1353985952&__previous=1",
"next": "https://graph.facebook.com/search?q=hi&limit=2&type=post&access_token=AAAAAAITEghMBAIScEzst3h5VpV8pKZA7di2ZC3czxr5ANnvKPPc1wqYJJZAANd9PI0NKLX5Xk5ReRX3T01iim8Bo&until=1353985897"
}
}