Google Calendar API - Missing End Time - google-calendar-api

Trying to use the Google Calendar API to get a list of events, getting returned with a 400 Error: Missing end time. Details below. Any suggestions?
Body
{"calendarId":"george.albrecht#xxx.com","timeMin":"2018-03-04T19:00:00+00:00","timeMax":"2018-03-07T19:00:00+00:00","timeZone":"America/New_York","showDeleted":true}
Headers
'Content-Type', 'application/json'
'Authorization', 'Bearer '+access_token
Endpoint & Method
Endpoint=https://www.googleapis.com/calendar/v3/calendars/george.albrecht%40xxx.com/events, Method=GET

startTime and endTime in body looks like these:
var event = {
'summary': 'This is a test Calendar invite using NodeJS',
'location': 'Under the Bridge',
'description': 'I dont ever wanna feel Like I did that day But take me to the place I love Take me all the way',
'start': {
'dateTime': '2018-02-25T12:58:05-07:00',
'timeZone': 'America/Los_Angeles',
},
'end': {
'dateTime': '2018-02-26T06:00:00-07:00',
'timeZone': 'America/Los_Angeles',
},
'recurrence': [
'RRULE:FREQ=DAILY;COUNT=2'
],
'attendees': [
{'email': 'rhcp#gmail.com'}
],
'reminders': {
'useDefault': true
}
};
If that solution still doesn't work, try downgrading the package:
googleapis#24.0.0 works --> with #25.0.0 i got the error ... and
google-auth-library#0.12.0 as mentioned in this SO
post.

Related

paypal not redirecting to the paypal site but inks are getting in the response in Meteor

I am new to Meteor and integrating Paypal(Which i never had done).
from Client side in meteor -
I am calling method on button click.
<MDBBtn onClick={(e) => callPaypal(e)} color="primary" type="submit">
Add and Continue to PayPal
</MDBBtn>
And this callpaypal() method ->
import { Link as ReactRouterLink } from 'react-router-dom'
const callPaypal = (e) => {
e.preventDefault();
Meteor.call('createPayalPayment', (err, res) => {
console.log(res[1].href) **FIRST CONSOLE**
if (res) {
let link = res[1];
if (link.href) {
return <ReactRouterLink to={`${link.href}`} />
}
}
})
}
Calling createPayalPayment method from server ->
import { Config } from "./paypal_config";
createPayalPayment() {
var data = {
"intent": "sale",
"payer": {
"payment_method": "paypal"
},
"redirect_urls": {
// "return_url": `${Meteor.absoluteUrl('/execute'), { "replaceLocalhost": "true" }}`,
"return_url": "http://127.0.0.1:3000/execute",
"cancel_url": "http://172.20.10.5:3000/cancel"
},
"transactions": [{
"amount": {
"currency": "USD",
"total": "1.00"
},
"description": "This is the payment description."
}]
};
paypal.configure(Config);
var ppCreate = Meteor.wrapAsync(paypal.payment.create.bind(paypal.payment));
var ppExecute = Meteor.wrapAsync(paypal.payment.execute.bind(paypal.payment));
var response = ppCreate(data);
if (response.state !== 'created') {
console.log('not created!!!!!!!!!!!!!!!!')
}
else {
console.log(response); **SECOND CONSOLE**
return response.links;
}
}
And here is my Paypal config ->
export const Config = {
'mode': 'sandbox',
'client_id': 'client_Id',
'client_secret': 'secret'
};
FIRST CONSOLE --> 'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-1HR12649X9688931M'
SECOND CONSOLE -->>
{ id: 'PAYID-L2IJO4I8GE24787GF168351L',
intent: 'sale',
state: 'created',
payer: { payment_method: 'paypal' },
transactions:
[ { amount: [Object],
description: 'This is the payment description.',
related_resources: [] } ],
create_time: '2020-04-10T15:57:37Z',
links:
[ { href: 'https://api.sandbox.paypal.com/v1/payments/payment/PAYID-L2IJO4I8GE24787GF168351L',
rel: 'self',
method: 'GET' },
{ href: 'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-1HR12649X9688931M',
rel: 'approval_url',
method: 'REDIRECT' },
{ href: 'https://api.sandbox.paypal.com/v1/payments/payment/PAYID-L2IJO4I8GE24787GF168351L/execute',
rel: 'execute',
method: 'POST' } ],
httpStatusCode: 201
}
As the links[2].href is the URL, where the paypal should be redirect here and user can login to the account. But It is not redirecting. So I am manually redirecting to this link in callPaypal() method just below the First console.
But Still the router is unable to redirect to the link maybe Outer Domain Issue or whatever even it's not showing error.
Please Is there any way that the paypal redirect itself to paypal login? I have already wasted my 2 days on this and still have nothing.
Thanks.
I added the Redirect URL in my paypal developer account for this project.
It looks like you're using an old, redirect-based PayPal integration, so my recommendation is trying the new in-context experience: https://developer.paypal.com/demo/checkout/#/pattern/server
Notice the two fetch calls to '/demo/..' placeholders, which would need to be replaced with actual routes on your server. The first should return a PayID (or newer v2/orders ID), and the second should execute/capture that ID.
This integration is superior because your site stays loaded in the background, and the buyer is able to checkout and pay without 'leaving' it.
On the server side, it looks like you may be using the old deprecated v1 PayPal-node-SDK, which there is no reason to do for a new integration. Instead, use the v2 Checkout-NodeJS-SDK

How to get Total Results using Google Analytics Embed API

I'm trying to simply pull the total number of pages on my site.
Using the GA Query Explorer (https://ga-dev-tools.appspot.com/query-explorer/), you can see the "Total results found" number when the results are displayed after running a query.
How can I apply this to GA Embed API query format? ...
var pageTitles = new gapi.analytics.googleCharts.DataChart({
reportType: 'ga',
query: {
'dimensions': 'ga:pageTitle',
'metrics': 'ga:pageviews',
'segment': 'gaid::-1',
'sort': '-ga:pageviews',
'filters': 'ga:pagePath!=/',
'max-results': '10',
'totalResults': 'integer',
},
chart: {
type: 'TABLE',
container: 'page-titles',
options: {
title: 'Top Pageviews',
width: '100%'
}
}
});
Thank you!!
If you add an event handler for successful queries, you can get access to the totals. Here's an example:
var pageTitles = new gapi.analytics.googleCharts.DataChart({
query: {
'dimensions': 'ga:pageTitle',
'metrics': 'ga:pageviews',
'segment': 'gaid::-1',
'sort': '-ga:pageviews',
'filters': 'ga:pagePath!=/',
'max-results': '10'
},
chart: {
type: 'TABLE',
container: 'page-titles',
options: {
title: 'Top Pageviews',
width: '100%'
}
}
});
pageTitles.on('success', function(result) {
// Print the total pageview count to the console.
console.log(result.response.totalsForAllResults['ga:pageviews']);
});
And here's the documentation for the parameters passed to the 'success' event:
https://developers.google.com/analytics/devguides/reporting/embed/v1/component-reference#datachart
Also note that you don't need the 'totalResults': 'integer' part that you have in your example, nor do you need the reportType: 'ga' part (it's optional).

dgrid JsonRest store not working

I have the following:
require([
"dojo/dom",
"dojo/on",
"dojo/store/Observable",
"dojo/store/JsonRest",
"dojo/store/Memory",
"dgrid/OnDemandGrid"
], function (dom, on, Observable, JsonRest, Memory, OnDemandGrid) {
var store = new JsonRest({
target: 'client/list',
idProperty: 'id'
});
var grid = new OnDemandGrid({
columns: {
"id": "ID",
"number": "Name",
"description": "Description"
},
sort: "lastName",
store: store
}, "grid");
});
client/list is a rest url returning a json object {data:[...]}, but the content of the list never shows up :/
I think the problem is caused by the async data loading, because with a json hard coded object the content show up
EDIT :
I've succeeded in achieving this by using a dojo/request, but the JsonRest shouldn't normally act the same way ? Can someone point me to the right direction ?
require([
'dojo/dom',
'dojo/on',
'dojo/store/Memory',
'dojo/request',
'dgrid/OnDemandGrid'
], function (dom, on, Memory, request, OnDemandGrid) {
request('client/list', {
handleAs: 'json'
}).then(function (response) {
// Once the response is received, build an in-memory store with the data
var store = new Memory({ data: response });
// Create an instance of OnDemandGrid referencing the store
var grid = new OnDemandGrid({
store: store,
sort: 'id', // Initialize sort on id, ascending
columns: {
'id': 'ID',
'number': 'Name',
'description': 'Description'
}
}, 'grid');
console.log(store);
on(dom.byId('queryForm'), 'input', function (event) {
event.preventDefault();
grid.set('query', {
// Pass a RegExp to Memory's SimpleQueryEngine
// Note: this code does not go out of its way to escape
// characters that have special meaning in RegExps
description: new RegExp(this.elements.last.value, 'i')
});
});
on(dom.byId('queryForm'), 'reset', function () {
// Reset the query when the form is reset
grid.set('query', {});
});
});
});
Ok problem found :/
My "client/list" url was returning a json object like this:
{data: [{id:"1", label: "test"}, {id:"2", label: "test"}]}
Turns out that the JsonRest object is already encapsulating data in a data node, so by returning a json like this:
{[{id:"1", label: "test"}, {id:"2", label: "test"}]}
everything worked fine :)

What is the right way to select records from mongodb document

I"m new in mongodb and I really like the idea of noSql.
I"m trying to build a blog where on each comment people can click on rate buttons and rate the person comment.
Inside each comment I have a array of votes where there is a vote type and unique IP.
Each user click on button will insert line (once per IP).
At the end I want to query documents/posts and get the information in the following structure, CalculatedVotes, distinct VoteType, Caption and count
The result that I want to retrieve
{
PostTitle:"This is a blog post",
Posted:"12/12/2012",
ByUsertId:"2",
Body:"This is a simple body"
Comments:
[
{
PostedBy:"someUser",
Text:"Hi There!",
CalculatedVotes:
[
{
VoteType:"AGREE",
Caption="I agree!",
Count:2
},
{
VoteType:"NOT_AGREE",
Caption="No Way!",
Count:1
},
]
},
{
PostedBy:"someUser2",
Text:"Whats up?",
CalculatedVotes:
[
{
VoteType:"AGREE",
Caption="I agree!",
Count:1
},
{
VoteType:"NOT_AGREE",
Caption="No Way!",
Count:2
},
]
}
]
}
Document structure
{
PostTitle:"This is a blog post",
Posted:"12/12/2012",
ByUsertId:2,
Body:"This is a simple body"
Comments:
[
{
PostedBy:"someUser",
Text:"Hi There!",
Votes:
[
{
VoteType:"AGREE",
Caption="I agree!",
IP:"1.1.1.1"
},
{
VoteType:"NOT_AGREE",
Caption="No Way!",
IP:"2.2.2.2"
},
{
VoteType:"AGREE",
Caption="I agree!",
IP:"3.3.3.3"
}
]
},
{
PostedBy:"someUser2",
Text:"Whats up?",
Votes:
[
{
VoteType:"NOT_AGREE",
Caption="No Way!",
IP:"1.1.1.1"
},
{
VoteType:"NOT_AGREE",
Caption="No Way!",
IP:"2.2.2.2"
},
{
VoteType:"AGREE",
Caption="I agree!",
IP:"3.3.3.3"
}
]
}
]
}
I would say that best is to reconsider your schema. A good example of storing hierarchy is described here.
In your schema you will run into multiple issues, not the least of them that if a discussion gets very long you will end up with a huge document that will eventually exceed maximum document size (16MB). In addition you will need to fetch only some of the document but you will always be getting the huge complete discussion even when you don't want it (and it will be difficult to filter on the bases of depth of embedded structure).
Last but not least, the best way to handle counting is to be incrementing the vote count in real time as you are recording the votes to avoid the overhead of recalculating them and that has the added benefit that you can order by votes or even index by votes if needed.

Remote paging grid in extjs

You are my last chance :(. Im trying do work a paging grid with mvc pattern.
The grid show the fisrt 21 records, but not refresh when click "next" pagingtoolbar icon.
All my codes are detailed below:
The Store:
Ext.define('CRUDManantiales.store.grid.AbmUsuarios', {
extend: 'Ext.data.Store',
model: 'CRUDManantiales.model.grid.AbmUsuarios',
proxy: {
type: 'ajax',
url: 'resources/bundles/usuarios/generarJsonTodos.php',
reader: {
type: 'json',
root: 'data',
successProperty: 'success',
totalProperty: 'total'
}
}
});
The main view code:
Ext.define('CRUDManantiales.view.grid.AbmUsuarios', {
// [..........]
initComponent: function () {
this.store = 'grid.AbmUsuarios';
this.dockedItems = [{
xtype: 'pagingtoolbar',
store: this.store,
beforePageText: 'Página',
afterPageText: 'de {0}',
displayMsg: 'Mostrando {0} - {1} de {2} registros',
emptyMsg: 'No hay datos que mostrar',
dock: 'bottom',
displayInfo: true,
pageSize: 21
}];
this.callParent(arguments);
}
});
I wasted four days in this code, appreciate your assistance. Thanks !!
Thanks for all. The problem has been resolute. The fail was that i was using POST array in my PHP script and needed use GET method. :)

Resources