Closed AnilaBazi closed 3 years ago
Hello @AnilaBazi
Currently, it's only designed for you to load into each specific account (customer ids) as such
$bingAds = LaravelAds::bingAds()->with('CLIENT_ID');
But I do like the idea of adding that feature such as ->getAccounts()
, I will look into this. If you know a way to do it feel free to add a pull request.
+1 to add this for Google and Bing
I haven't been able to install your package in the project I am working on but I have been able to use some of it as a base to something I am working on.
One of the things I need to be able to do is allow the user to auth with my application to et the refresh_token (which I have done). Then I need to be able to allow the user to pick an account to link to. It looks like that before I am able to show them a list of accounts to pick from I first need to get a list of customers (custoemr_id).
I have tried to hash this out a little but I'm not getting anywhere.
$request = new SearchCustomersRequest();
$predicate = new Predicate();
$predicate->Field = 'AccountLifeCycleStatus';
$predicate->Operator = PredicateOperator::Equals;
$predicate->Value = 'Active';
$request->Predicates = [$predicate];
$ordering = new OrderBy;
$ordering->Field = 'Name';
$ordering->Order = 'Ascending';
$request->Ordering = $ordering;
$paging = new Paging();
$paging->Index = 0;
$paging->Size = 1000;
$request->PageInfo = $paging;
try {
$items = $serviceCall->GetService()->SearchCustomers($request);
} catch (\SoapFault $e) {
var_dump($e->detail);
}
dd($items);
One way I have been able to list the available accounts for the user is by doing this
$serviceCall = $this->call(ServiceClientType::CustomerManagementVersion13);
$request = new GetLinkedAccountsAndCustomersInfoRequest();
$request->CustomerId = 'XXXXXXXXXXX';
$items = $serviceCall->GetService()->GetLinkedAccountsAndCustomersInfo($request);
$resultCollection = collect();
foreach ($items->AccountsInfo as $item) {
foreach ($item as $account) {
$resultCollection->push([
'id' => $account->Id,
'name' => $account->Name,
'status' => Str::lower($account->AccountLifeCycleStatus),
]);
}
}
dump($resultCollection->where('status', '=', 'active'));
Update
This gets a list of the 'cusomters'
$serviceCall = $this->call(ServiceClientType::CustomerManagementVersion13);
$request = new GetCustomersInfoRequest();
$request->CustomerNameFilter = '';
$request->TopN = 100;
try {
$items = $serviceCall->GetService()->GetCustomersInfo($request);
} catch (\SoapFault $e) {
var_dump($e->detail);
}
dd($items);
example
{#727
+"CustomersInfo": {#726
+"CustomerInfo": array:2 [
0 => {#725
+"Id": XXXX
+"Name": "XXXX"
}
1 => {#724
+"Id": XXXX
+"Name": "XXXX"
}
]
}
}
@jamesmills Sorry I missed your comments, were you able to install the package? I believe we had a few issues with GoogleAds version which caused monolog to fail, which was fixed. Just checking in on this. Thanks.
In Microsoft account i have a list of accounts to choose , how can i get the id of all of them .