Google Calendar API. Patching sharedExtendedProperty for events - calendar

I have created event in my Google calendar. Most interesting part is:
{
// some event data;
"extendedProperties": {
"shared": {
"cases_1": "1",
"cases_2": "2"
}
}
}
Right now I need to PATCH existing event. In extendedProperties I do not need "cases_1":"1" any more. So I use developers endpoint to patch it. The PATCH request body is:
{
"extendedProperties": {
"shared": {
"cases_2": "2"
}
}
}
In response I see my both shared fields. How must my request body look like to remove from extendedProperties shared cases_1 field?

Try adding the line below to your request:
{
"extendedProperties": {
"shared": {
"cases_1": null,
"cases_2": "2"
}
}
}
It was shown in this documentation:
Any properties not included in an update request will be deleted, but
a better approach is to make a patch request to set the value to null
Hope this helps.

Related

Use data from graphql response in React

I guess this is a simple issue, but I am stuck here for a while, so any advice may be helpful!
I have a react app and I am calling a GraphQL api (with apollo). Inside an arrow function component I have:
const [executeQuery, { data }] = useLazyQuery(GET_ALL_TASKS);
const findId = (step) => {
executeQuery({
variables: {
"query": {
"state": "CREATED",
"taskDefinitionId": "something"
}
}
})
}
The query is successful and in the browser inspect panel I get this as the graphql response:
{
"data" : {
"tasks" : [ {
"id" : "2251",
"name" : "some_name",
"__typename" : "Task"
} ]
}
}
In my code I want to use the retrieved id. How can I isolate the id from the response? When I am trying to access the data I get an undefined error.
Thank you!
Not sure why you are wrapping your executeQuery in a function.
The data will be part of the response so you can get it like this:
const {data, loading} = executeQuery({
variables: {
"query": {
"state": "CREATED",
"taskDefinitionId": "something"
}
}
})
// may also need to check for the error state
if(loading){
console.log("Loading...")
}else{
/// the ids seem to be an array of objects
const ids = data.tasks.map((task)=> task.id)
console.log(ids)
}
For anyone who may have the same problem, I realized it is a caching error happening in apollo client. I couldn't figure out the solution. However, I temporarily solved it by downgrading the apollo client dependency to version 3.2.5

React Docusign Clickwrap Credentials

In my react application, when Im rendering the Docusign clickwrap, I need to supply the accountId and the clickwrapId. Is there a secure way to reference the accountId/clickwrapId without actually putting those values in. I dont want to expose those credentials in my react application
function App() {
React.useLayoutEffect(() => {
docuSignClick.Clickwrap.render({
environment: 'https://demo.docusign.net',
accountId: '...',
clickwrapId: '...',
onMustAgree(agreement) {
// Called when no users have previously agreed by the above client user ID for the most recent required Clickwrap version
},
onAgreed(agreement) {
// Called when either 1) the clientUserId has previously agreed 2) the clientUserId has clicked agree and completed successfully
},
onDeclined(agreement) {
// Called when the clientUserId has declined successfully
}
}, '#ds-clickwrap');
}, []);
return <div id="ds-clickwrap" />
}
Ah, you can use the server-side API to generate an agreement URL instead if that is desired.
POST /clickapi/v1/accounts/.../clickwraps/.../agreements:
Only the clientUserId is required to make this API call. You would do this from your server and then pass the URL from the response to the client.
{
"clientUserId": "..."
}
This would return an agreement URL to then be used in the snippet of JS:
{
...
"status": "created",
"agreementUrl": "https://...."
}
This agreementUrl could then be used in the snippet:
docuSignClick.render({
agreementUrl: '...agreementUrl from REST API response...',
onAgreed...
}, '#ds-clickwrap');

Submitting Data to Google Analytics from WPF

I am trying to send data to Google Analytics from a WPF application. I can't find any resource online which clearly defines how to do that. I know that there are numerous NuGet packages available, but I'm not sure which to use, nor how to implement them. I also know that there are some third-party "helper" libraries available (see Using Google Analytics from a .NET desktop application), which I'm not interested in. It also looks like most instructions online are showing how to "pull" data from GA, not how to push. Not looking for "maybe"'s or workarounds but what the normal straightforward way to do this is. This shouldn't be complicated. Just need a "Hello World".
Can you please point me in the right direction? Thanks,
This worked for me:
var request = (HttpWebRequest)WebRequest.Create("http://www.google-analytics.com/collect");
request.Method = "POST";
// the request body we want to send
var postData = new Dictionary<string, string>
{
{ "v", "1" }, //analytics protocol version
{ "tid", "UA-XXXXXXXX-X" }, //analytics tracking property id
{ "cid", "XXXX"}, //unique user identifier
{ "t", "event" }, //event type
{ "ec", category },
{ "ea", action },
};
var postDataString = postData
.Aggregate("", (data, next) => string.Format("{0}&{1}={2}", data, next.Key,
Uri.EscapeDataString(next.Value)))
.TrimEnd('&');
// set the Content-Length header to the correct value
request.ContentLength = Encoding.UTF8.GetByteCount(postDataString);
// write the request body to the request
using (var writer = new StreamWriter(request.GetRequestStream()))
{
writer.Write(postDataString);
}
var webResponse = (HttpWebResponse)request.GetResponse();
if (webResponse.StatusCode != HttpStatusCode.OK)
{
throw new Exception($"Google Analytics tracking did not return OK 200. Returned: {webResponse.StatusCode}");
}

on_message is not working in python

I am working on aws iot and able to get the shadow state updated by the terminal via shell script .But i am able to get root#raspberrypi:~# ./aws_subscribe.py Connected with result code 0 and also in aws iot home i am getting out of sync error
and i am following this blog
The 'Shadow status' field on the AWS console merely shows if the 'reported' and 'desired' states are the same, it has no functional impact.
This is an example that would show the status as out of sync:
{
"reported": {
"locked": true
},
"desired": {
"locked": false
}
}
Where as this example would show them as in sync.
{
"reported": {
"locked": true
},
"desired": {
"locked": true
}
}
That's really all there is to it. You can completely remove the 'desired' state by sending the following JSON, if you do this it will always show as in sync.
{
"desired": null
}

Re-execute relayjs query

I'm working on a chat feature on my website which I am developing with Reactjs and Relayjs.
I can successfully query and display the relevant data (chat messages) in my view. However, the view remains static even if the chat partner sends a new message.
I'm looking for ways to implement this, either by checking for database changes or executing the same query on intervals and then fetching the changes, if any.
The relay documentation doesn't seem to describe how to do this. I was first thinking of creating a dummy mutation that doesn't do anything, so that the data is re-fetched which would update the view. However, not only does this seem like a bad implementation, but it would probably not work as the mutation would only return the changes, and not the entire resultset.
I'd rather not use 3rd party libraries, if possible.
Here's my relay container:
export default Relay.createContainer(StartConversationModal, {
prepareVariables() {
return {
limit: 1000,
};
},
fragments: {
conversation: () => Relay.QL`
fragment on Conversation {
id,
title,
type,
conversationDataList(last: $limit) {
edges {
node {
last_read_message_id,
member {
id,
user {
firstname,
lastname
}
}
}
}
},
messageList(last: $limit) {
edges {
node {
id,
message,
sent_on,
member {
id,
role,
user {
firstname,
lastname
}
}
}
}
},
task {
title,
},
${AddMessageMutation.getFragment('conversation')},
}
`,
},
});
To refetch all the fragments for a container, you can use the imperative forceFetch API given by RelayContainer, see docs
Basically inside StartConversationModal you could set up a poller that calls forceFetch off this.props.relay. Note that this will refetch the entire connection which might not be what you want, you'd have to experiment with it.

Resources