How to get statistics for all accounts(active and inactive)? - google-ads-api

At the moment I am getting stats this way:
$adWordsServices = new AdWordsServices();
$session = (new AdWordsSessionBuilder())->fromFile($this->account->token)->withOAuth2Credential($this->oAuth2Credential)
->build();
$managedCustomerService = $adWordsServices->get(
$session,
ManagedCustomerService::class
);
// Create selector.
$selector = new Selector();
$selector->setFields(['CustomerId', 'Name']);
$selector->setOrdering([new OrderBy('CustomerId', SortOrder::ASCENDING)]);
$selector->setPaging(new Paging(0, 100));
but how to get statistics for all accounts active and inactive? This code returns only list of active accounts.

It's unfortunately not possible to retrieve statistics for inactive / cancelled accounts.
You'll either receive a AuthorizationError.CUSTOMER_NOT_ENABLED error (in the Ads API) or a AuthorizationError.CUSTOMER_NOT_ACTIVE (in the Adwords API).

Related

Microsoft Graph API - CalendarView Delete Event

I'm trying to delete/cancel and event pulled from the CalendarView API for a given Conference Room. I have the Event ID and am trying the following:
graphClient.Users["conferenceroom#tenant.com"]
.CalendarView[eventId]
.Request(options)
.DeleteAsync()
Receiving the following error message:
Message: The OData request is not supported.
Is it not possible to delete/cancel associated from a CalendarView?
I've noticed when I create the event (under my user) it has a different ID than if I pull the same event from the CalendarView.
Thoughts? When pulling the CalendarView for each Conference Room I wouldn't have context to the organizers Events, correct?
To delete an event you need to use the /events segment, not /calendarview. You can get the ID from the calendar view, then just do:
graphClient.Users[""].Events[eventId].Request().DeleteAsync();
Basic Code Sample:
var query = new List<Microsoft.Graph.Option>()
{
new Microsoft.Graph.QueryOption("$filter", $"iCalUId eq '{eventId}'")
};
var events = await graphClient.Users[User.Identity.Name].Events.Request(query).GetAsync();
var evt = events.First();
await graphClient.Users[User.Identity.Name].Events[evt.Id].Request().DeleteAsync();

UCWA MyOnlineMeeting attendees requirements? External attendees

I'm currently trying to develop an application that creates Skype meetings.
I'm leveraging the C# UCWA SDK and developing against Skype for Business online.
Meeting creation works fine if I only include people from the tenant in attendees, as soon as I include people not from the tenant in the meeting I get this error message:
{"code":"BadRequest","subcode":"ParameterValidationFailure","message":"Please check what you entered and try again.","debugInfo":{"diagnosticsCode":"2"}}
Here is my code sample
var meeting = new MyOnlineMeeting()
{
AccessLevel = AccessLevel.Everyone,
Attendees = new string[] { $"sip:{Settings.SkypeUserEmail}" }, //Adding anybody else than the service account makes it fail for now
Subject = series.Subject,
ExpirationTime = DateTime.Now.AddDays(3),
AutomaticLeaderAssignment = AutomaticLeaderAssignment.SameEnterprise,
Leaders = series.Organizers.Select(x => $"sip:{x.EmailAddress}").ToArray(),
LobbyBypassForPhoneUsers = LobbyBypassForPhoneUsers.Enabled,
PhoneUserAdmission = PhoneUserAdmission.Disabled
};
var dialIn = await client.OnlineMeetings.GetPhoneDialInInformation();
var meetings = await client.OnlineMeetings.GetMyOnlineMeetings();
var result = await meetings.Create(meeting);
Adding external users to the organizers properties works fine though.
My question is: how can I add external attendees to the meeting I'm creating? Is there anything specific around attendees?
After a few exchanges on the Microsoft Skype for Business MVP's private distribution list, it appears that attendees have to be part of the organization or otherwise the call will fail.
Submitted a Pull Request to update the latest version of the documentation

Get Data from Odata service with Logged in User

I have one Odata service , which is providing me the data and I am able to display this data on table. We are going to deploy this application to Launchpad. Now we have this requirement in which logged in user must get the data according to his/her login ID. So If my user ID is XXXXX , I should get the records only for XXXXX. I am unable to understand the process flow. Shall we implement the logic in Odata itself or should I get all the data and filter the model on UI, before displaying it.
Regards,
MS
In oData itself you can access login user by sy-uname. using that user you can filter your data.
OR
In front end you can access login user by below code
var vUrl = "proxy/sap/bc/ui2/start_up";
var oxmlHttp = null;
oxmlHttp = new XMLHttpRequest();
oxmlHttp.onreadystatechange = function() {
if (oxmlHttp.readyState == 4 && oxmlHttp.status == 200) {
var oUserData = JSON.parse(oxmlHttp.responseText);
vUser = oUserData.id;
}
};
oxmlHttp.open( "GET", vUrl, false );
oxmlHttp.send(null);
You have to handle this in Odata only. Get User id from UI using
var storename = sap.ushell.Container.getService("UserInfo").getId();
and set it to Odata to filter and send back the results.
You should handle such requirements in the Service level (OData level), not in the UI.
In DPC_EXT class variable SY-UNAME gives you the logged in user. So you should filter your records by deriving more information from that.

Add event to Google Calendar via API v3 using OAuth 2.0 service account?

I am getting a forbidden (403) when trying to add an event to my calendar (API v3 & OAuth2), as follows:
var service = CalendarService();
CalendarListResource.ListRequest request = service.CalendarList.List();
IList<CalendarListEntry> calendarList = request.Execute().Items;
foreach (CalendarListEntry entry in calendarList)
{
Console.WriteLine(
"Summary:{0}\nLocation:{1}\nTimeZone:{2}",
entry.Summary, entry.Location, entry.TimeZone
);
}
var startDate = DateTime.Now.AddDays(1);
var endDate = startDate.AddDays(1);
var eventBody = new Google.Apis.Calendar.v3.Data.Event
{
Description = "Test 4 description",
Summary = "Test 4 summary",
Start = new EventDateTime
{
DateTime = startDate
},
End = new EventDateTime
{
DateTime = endDate
}
};
var insertRequest = service.Events.Insert(calendarId: calendarId_emailAddress, body: eventBody); //InsertRequest
insertRequest.Execute();
I have set up oauth2 service account, granted scopes, and shared the calendar. However, something I noticed on the calendar share part is that I am unable (no option available) to share for read/write. Only option is "freeBusyRead".
EDIT:
Let me add that calendarId_emailAddress = "my_email_address". I was able to add an event. No errors. And then iterate and find it. But it does not show up in my calendar. I seem to not be making the connection between the calendarId and the "actual calendar" in my user panel.
So how to do this. Any help appreciated. Thanks.
Your Google Apps domain probably limits the level of sharing to external accounts to free/busy only. Service accounts, even when created by a domain user, are always considered external to the domain.
The proper way to do this would be to authorize the service account to act on behalf of your domain users and then, authenticating as the service account and acting on behalf of the user, add the event to the user calendar. Domain-wide delegation of authority is discussed in the Drive API docs but can easily be applied to Calendar API also.
The trouble was in the authentication of the service. Scenarios...
1) ServiceAccountCredential with no user set, and calendarId = "primary" yields an entry into calendar. Which calendar? Who knows. I can't see the entry in my interface of that user, but I do find the entry in the Events.List("primary")
2) ServiceAccountCredential with user set to email of target calendar, and calendarId = "primary" yields an entry into calendar, which I do see in my interface of that user, and also find the entry in the Events.List("primary")
Scenario #1 really baffles me. No idea how to see that event in the calendar.
Any insight into this would be helpful. Thanks!

Monitoring a mailbox for new email message using EWS Managed API

I'm working on a task which I never worked in earlier.
Task: Monitor a specific mailbox inbox on exchange server 2007. Iterate through all email messages(Just email messages), do some processing and move to a specific folder under same mailbox.
Work I did
// Create the binding
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
//service.Credentials = new WebCredentials("mailbox", "password", "mailbox#something.com");
service.Credentials = new NetworkCredential(ConfigurationManager.AppSettings["ExchangeUsername"].ToString(), ConfigurationManager.AppSettings["ExchangePassword"].ToString(), "something/domain");
// Set the url.
//service.AutodiscoverUrl("mailbox#something.com");
service.Url = new Uri(ServiceUrl);
ItemView view = new ItemView(10);
view.Traversal = ItemTraversal.Shallow;
view.PropertySet = new PropertySet(BasePropertySet.IdOnly);
List<SearchFilter> searchFilterCollection = new List<SearchFilter>();
//searchFilterCollection.Add(new SearchFilter.ContainsSubstring(ItemSchema.ItemClass, "MessageType"));
searchFilterCollection.Add(new SearchFilter.ContainsSubstring(ItemSchema.Subject, "test to be deleted"));
SearchFilter searchFilter = new SearchFilter.SearchFilterCollection(LogicalOperator.Or, searchFilterCollection.ToArray());
FindItemsResults<Item> results = service.FindItems(WellKnownFolderName.Inbox, view);
For some reason i always get results.items.count = 9, but there is only one EmailMessage in Mailbox#something.com. Am i doing any thing wrong in searching. If inbox had 5 emails, then i should get count as 5 and loop through the 5 emails. Is there a way to query just the email messages? Any help is appreciated. Thank you.
I answered my own questiona a while ago, but forgot to update here. So when i said count was not matching, it was monitoring mailbox of impersonating account. Coincidentally, the impersonating account has a mailbox.

Resources