Get timestamp and member's email of Mailchimp campaign clicks - mailchimp

According to Mailchimp documentation, it is possible to get the timestamp plus the email address of members who opened a campaign email.
https://mailchimp.com/developer/marketing/api/open-reports/list-campaign-open-details/
members: An array of objects, each representing a list member who opened a campaign email. Each members object will contain information about the number of total opens by a single member, as well as timestamps for each open event.
{
"campaign_id": "string",
"list_id": "string",
"list_is_active": true,
"contact_status": "string",
"email_id": "string",
"email_address": "string",
"merge_fields": {
"property1": null,
"property2": null
},
"vip": true,
"opens_count": 0,
"opens": [
{
"timestamp": "2019-08-24T14:15:22Z"
}
],
"_links": [
{
"rel": "string",
"href": "string",
"method": "GET",
"targetSchema": "string",
"schema": "string"
}
]
}
However, it doesn't seem that the equivalent call clicks exists. The API endpoint that retrieves click information is inconsistent and doesn't have this information. (See below).
And so... How can I get timestamp plus the email address of members who clicked?
https://mailchimp.com/developer/marketing/api/link-clickers/list-clicked-link-subscribers/
members:
An array of objects, each representing a member who clicked a specific link within a campaign.
{
"email_id": "string",
"email_address": "string",
"merge_fields": {
"property1": null,
"property2": null
},
"vip": true,
"clicks": 0,
"campaign_id": "string",
"url_id": "string",
"list_id": "string",
"list_is_active": true,
"contact_status": "string",
"_links": [
{
"rel": "string",
"href": "string",
"method": "GET",
"targetSchema": "string",
"schema": "string"
}
]
}

The second API call doesnt have a timestamp field so you will not be able to get that data
{
"members": [
{
"email_id": "string",
"email_address": "string",
"merge_fields": {
"property1": null,
"property2": null
},
"vip": true,
"clicks": 0,
"campaign_id": "string",
"url_id": "string",
"list_id": "string",
"list_is_active": true,
"contact_status": "string",
"_links": [
{
"rel": "string",
"href": "string",
"method": "GET",
"targetSchema": "string",
"schema": "string"
}
]
}
],
"campaign_id": "string",
"total_items": 0,
"_links": [
{
"rel": "string",
"href": "string",
"method": "GET",
"targetSchema": "string",
"schema": "string"
}
]
}
So unfortunately you are only able to get the timestamp of when someone opens the email, but not the timestamp of when the link in the email is clicked

Related

Problem with schema validation using Postman

Body of my req:
[
{
"postId": 1,
"id": 1,
"name": "name abc",
"email": "Eliseo#gardner.biz",
"body": "something"
},
...
]
I am trying to validate it like below:
var schema = {
"type": "array",
"properties": {
"postId": {
"type": "integer"
},
"id": {
"type": "integer"
},
"name": {
"type": "string"
},
"email": {
"type": "string",
"pattern": "^[A-Z0-9._%+-]+#[A-Z0-9.-]+\.[A-Z]{2,}$"
},
"body": {
"type": "string"
}
},
"required": [
"postId",
"id",
"name",
"email",
"body"
]
};
pm.test('Schemat jest poprawny', function() {
pm.expect(tv4.validate(jsonData, schema)).to.be.true;
});
The test is ok even if I change for example id type for string or email pattern for invalid one.
What is wrong with that code?
I would recommend moving away from tv4 for schema validations and use the built-in jsonSchema function, as this uses AJV.
Apart from that, your schema didn't look right and was missing the validation against the object, it looks like it was doing it against the array.
This might help you out:
let schema = {
"type": "array",
"items": {
"type": "object",
"required": [
"postId",
"id",
"name",
"email",
"body"
],
"properties": {
"postId": {
"type": "integer"
},
"id": {
"type": "integer"
},
"name": {
"type": "string"
},
"email": {
"type": "string",
"pattern": "^[A-Z0-9._%+-]+#[A-Z0-9.-]+\.[A-Z]{2,}$"
},
"body": {
"type": "string"
}
}
}
}
pm.test("Schemat jest poprawny", () => {
pm.response.to.have.jsonSchema(schema)
})

Jolt spec for nifi - removing attributes

I am newbie in NiFi. I am trying to remove some attributes (e.g. name in Swedish and Chinese, images from description, etc.) with JoltTransformJSON, with 'limited' success. Could you please help me? Many thanks in advance!
Alicia
Details as below:
JoltTransformJSON properties set as:
Jolt Transformation DSL: Remove
Jolt Specification: {"name": {"sv": "", "zh": ""}, "source_type": "", "description": {"image": {"url": "", "copyright_holder":"", "license_type": ""}}}
All the attributes:
[
{
"id": "string",
"name": {
"fi": "string",
"en": "string",
"sv": "string",
"zh": "string"
},
"source_type": {},
"info_url": "string",
"modified_at": "2019-12-27T16:34:17.896Z",
"location": {
"lat": {},
"lon": {},
"address": {
"street_address": "string",
"postal_code": "string",
"locality": "string"
}
},
"description": {
"intro": "string",
"body": "string",
"images": [
{
"url": "string",
"copyright_holder": "string",
"license_type": {}
}
]
},
"tags": [
{
"id": "string",
"name": "string"
}
],
"where_when_duration": {
"where_and_when": "string",
"duration": "string"
}
}
]
The problem is that transformation (removing specified fields) is not performed. The expected result should be:
"id": "string",
"name": {
"fi": "string",
"en": "string"
},
"info_url": "string",
"modified_at": "2019-12-27T16:34:17.896Z",
"location": {
"lat": {},
"lon": {},
"address": {
"street_address": "string",
"postal_code": "string",
"locality": "string"
}
},
"description": {
"intro": "string",
"body": "string"
}
]
},
"tags": [
{
"id": "string",
"name": "string"
}
],
"where_when_duration": {
"where_and_when": "string",
"duration": "string"
}
}
How can I remove unwanted fields?
Any help is highly appreciated.
According to your expected result, your wanted jolt specification is:
{
"name": {
"sv": "",
"zh": ""
},
"source_type": "",
"description": {
"images": ""
}
}

How can I get the current signed user info after the token has been receive in Magento 2 Rest API

After looking at the Magento 2 REST token-base Authentication System. upon Successful login, I received an authorization token but I don't know how to get the current customer details with the token so I can know the current user.
Here is the instruction to get te token I followed.
http://devdocs.magento.com/guides/v2.0/get-started/authentication/gs-authentication-token.html
you can use these methods to receive information about yourself (i guess you logged in as customer)
Retrieve default billing address for the given customerId:
GET http://Magento-2-0/index.php/rest/V1/customers/me/billingAddress
Retrieve default shipping address for the given customerId:
GET http://Magento-2-0/index.php/rest/V1/customers/me/shippingAddress
To retrieve common customer info you should use:
GET http://Magento-2-0/index.php/rest/V1/customers/me
response should be something like:
{
"id": 0,
"groupId": 0,
"defaultBilling": "string",
"defaultShipping": "string",
"confirmation": "string",
"createdAt": "string",
"updatedAt": "string",
"createdIn": "string",
"dob": "string",
"email": "string",
"firstname": "string",
"lastname": "string",
"middlename": "string",
"prefix": "string",
"suffix": "string",
"gender": 0,
"storeId": 0,
"taxvat": "string",
"websiteId": 0,
"addresses": [
{
"id": 0,
"customerId": 0,
"region": {
"regionCode": "string",
"region": "string",
"regionId": 0,
"extensionAttributes": {}
},
"regionId": 0,
"countryId": "string",
"street": [
"string"
],
"company": "string",
"telephone": "string",
"fax": "string",
"postcode": "string",
"city": "string",
"firstname": "string",
"lastname": "string",
"middlename": "string",
"prefix": "string",
"suffix": "string",
"vatId": "string",
"defaultShipping": true,
"defaultBilling": true,
"extensionAttributes": {},
"customAttributes": [
{
"attributeCode": "string",
"value": "string"
}
]
}
],
"disableAutoGroupChange": 0,
"extensionAttributes": {},
"customAttributes": [
{
"attributeCode": "string",
"value": "string"
}
]
}
Each call should have header "Authorization":"Bearer token"

How to get outer object in elasticsearch from highlightfield

I have some documents like this:
{
"content": "DocumentFile",
"title": "no title",
"post_id": "18",
"url": "http://localhost/wp/?p=18",
"attachments": [{
"content": "Hi this is extrach data of file",
"hash": "UPR9BC57IW3PUNTQ3LP79Q6UN0V3ZR7AAFJNUFGH",
"name": "file."
}],
"isDeleted": "false",
"__creationdDate": "1456758952671"}
and I initialize elastic Search mapping so:
{
"post": {
"properties": {
"content": {
"type": "string",
},
"title": {
"type": "string",
},
"url": {
"type": "string",
},
"post_id": {
"type": "string",
"fields": {
"raw": {
"type": "integer",
"index": "not_analyzed"
}
}
},
"attachments": {
"type": "nested",
"include_in_parent": true,
"properties": {
"hash": {
"type": "string",
"analyzer": "vira_analyzer"
},
"name": {
"type": "string",
"analyzer": "vira_analyzer"
},
"content": {
"type": "string",
"analyzer": "vira_analyzer"
}
}
},
"_uid": {
"type": "string",
"analyzer": "vira_analyzer"
}
}
}}
and I add title,content,attachments.name , attachments.content to highlightfields
I search data in this document
it is in attachments.content and elasticsearch find it
now i want to get hash code of this attachment, what should i do ?
is there any option that elastic search give me the block of the attachment that have search query in name or content ??
by this:
Text[] highlightFragments = hitHighLights.get(field).getFragments();
elastic search me just the content field of that attachment. I want all of that block, some thing like this:
{
"content": "Hi this is extrach data of file",
"hash": "UPR9BC57IW3PUNTQ3LP79Q6UN0V3ZR7AAFJNUFGH",
"name": "file."
}
(a way is to get source of that document and search in it but it is not good because the speed decrease a lot.)

Elasticsearch MapperParsingException

I am trying to index following data to elasticsearch,
{
"_id": "5619578c1983757a72efef15",
"aseg": {},
"cs": {
"source": "None",
"ss": "In Transit",
"sr": "Weight Captured",
"act": "+B",
"pid": "BAG21678106",
"st": "UD",
"dest": "Bharatpur_DC (Rajasthan)",
"u": "J",
"sl": "Jaipur_Hub (Rajasthan)",
"ud": "2015-10-12T14:59:44.270000",
"sd": "2015-10-12T14:59:44.270000"
},
"nsl": [
{
"dt": [
2015,
10,
10
],
"code": "X-PPONM"
},
{
"dt": [
2015,
10,
11
],
"code": "X-UCI"
},
]
}
but in return i am getting this error
MapperParsingException[failed to parse [cs.nsl]]; nested: ElasticsearchIllegalArgumentException[unknown property [dt]];
I checked the mapping, mapping is correct, nsl nested inside cs dict has a different mapping than nsl at root level.
"cs": {
"properties": {
"act": {
"type": "string"
},
"add": {
"type": "string"
},
"asr": {
"type": "string"
},
"bucket": {
"type": "string"
},
"dest": {
"type": "string",
"index": "not_analyzed"
},
"dwbn": {
"type": "string"
},
"lcld": {
"type": "string"
},
"lat": {
"type": "string"
},
"lon": {
"type": "string"
},
"loc": {
"type": "double"
},
"nsl": {
"type": "string",
"index": "not_analyzed"
},
"ntd": {
"type": "date",
"format": "dateOptionalTime"
},
"pbs": {
"type": "string"
},
"pid": {
"type": "string"
},
"pupid": {
"type": "string"
},
"sd": {
"type": "date",
"format": "dateOptionalTime"
},
"sl": {
"type": "string",
"index": "not_analyzed"
},
"source": {
"properties": {
"source": {
"type": "string"
},
"source_id": {
"type": "string"
},
"source_type": {
"type": "string"
}
}
},
"sr": {
"type": "string"
},
"ss": {
"type": "string",
"index": "not_analyzed"
},
"st": {
"type": "string"
},
"u": {
"type": "string",
"index": "not_analyzed"
},
"ud": {
"type": "date",
"format": "dateOptionalTime"
},
"vh": {
"type": "string"
}
}
},
and for nsl at root level mapping is as follow
"nsl": {
"properties" : {
"code" : {
"type" : "string",
"index": "not_analyzed"
},
"dt" : {
"type" : "string",
"index": "not_analyzed"
}
}
},
this is happening for only a few records, rest all are syncing fine.
there isn't any changes in payload.
Futher nsl is a sparse key inside cs.
In your mapping nsl is as follows -
"nsl": {
"type": "string",
"index": "not_analyzed"
},
As per mapping , Elasticsearch is expecting a concrete string value to the nsl field but its a object array in the document you have provided.
Elasticsearch once it has a mapping , its definite. You cant insert an object data into a string field.
I tried your document without pre-setting any mapping as follows:
{
"aseg": {},
"cs": {
"source": "None",
"ss": "In Transit",
"sr": "Weight Captured",
"act": "+B",
"pid": "BAG21678106",
"st": "UD",
"dest": "Bharatpur_DC (Rajasthan)",
"u": "J",
"nsl":"foo",
"sl": "Jaipur_Hub (Rajasthan)",
"ud": "2015-10-12T14:59:44.270000",
"sd": "2015-10-12T14:59:44.270000"
},
"nsl": [
{
"dt": [
2015,
10,
10
],
"code": "X-PPONM"
},
{
"dt": [
2015,
10,
11
],
"code": "X-UCI"
}
]
}
And the ES created the mapping as follows:
"nsl": {
"properties": {
"dt": {
"type": "long"
},
"code": {
"type": "string"
}
}
}
As you can see ES put the "dt" type as "long" which is the internal representation of a date type. So, may be need to change that type?
Also, without seeing the successful document it is difficult to guess but I believe those documents do not have the "dt" field value.
Of course, you are free to put "not_analyzed" as you see fit for any field.

Resources