How to get the returns data like Returned Date,Merchant SKU,ASIN etc ., - mws

I am newbie to MWS and working on returned items.
I have used Reports API .
$marketplaceIdArray = array("Id" => array('$MARKETPLACE_ID'));
$t1 = date("c", time()-437*24*60*60);
$t2 = date("c", time()-1*24*60*60);
// #TODO: set request. Action can be passed as
MarketplaceWebService_Model_ReportRequest
// object or array of parameters
$parameters = array (
'Merchant' => MERCHANT_ID,
'MarketplaceIdList' => $marketplaceIdArray,
'ReportType' => '_GET_FBA_FULFILLMENT_CUSTOMER_RETURNS_DATA_',
'ReportOptions' => 'ShowSalesChannel=true'
);
$request = new MarketplaceWebService_Model_RequestReportRequest($parameters);
$request = new MarketplaceWebService_Model_RequestReportRequest();
$request->setMarketplaceIdList($marketplaceIdArray);
$request->setStartDate($t1);
$request->setEndDate(t2);
$request->setMerchant(MERCHANT_ID);
$request->setReportType('_GET_FBA_FULFILLMENT_CUSTOMER_RETURNS_DATA_');
invokeRequestReport($service, $request);
the ouput was :
Service Response
RequestReportResponse
RequestReportResult
ReportRequestInfo
ReportRequestId
68409017536
ReportType
_GET_FBA_FULFILLMENT_CUSTOMER_RETURNS_DATA_
StartDate
2018-01-05T06:55:49Z
EndDate
2018-01-05T06:55:49Z
SubmittedDate
2018-01-05T06:55:49Z
ReportProcessingStatus
_SUBMITTED_
ResponseMetadata
RequestId
1ecdc803-b26c-47a2-af0e-e598a00d379d
ResponseHeaderMetadata: RequestId: 1ecdc803-b26c-47a2-af0e-e598a00d379d, ResponseContext: 0KH8lyC6JDI3d4zFp8/qpB5ZmQJx/IVxWhOq4BLHsmELEaNWGUBNKvPZpghwlK2Q1TjAQiX5bls=, Timestamp: 2018-01-05T06:55:49.488Z
but how to fetch the fields like product name, quality, reson,SKU , etc ...,

You have requested the report.
Now you can use that request ID to check when the report has finished running. (You can test it all here before writing the php code: https://mws.amazonservices.com/scratchpad/index.html )
Go to Reports and choose GetReportRequestList and type in your requestID. This will then tell you if the ReportProcessingStatus is done or still processing. When it is done you can then get the GeneratedReportId and request the GetReport using that id. That will then give you a CSV result with your returns for the given time period from the initial report request.
If all of that looks good then you will need to add steps in your PHP code to do all of that.
Once you have requested the report you will need to save the request id and periodically (depending on your order volume, maybe check every few seconds or every minute to see if the request is done. Then you would have something like this:
$reportId = $this->invokeGetReportList($service, $request);
$reportRequest = new MarketplaceWebService_Model_GetReportRequest();
$reportRequest->setMerchant(MERCHANT_ID);
$reportRequest->setReport(#fopen('php://memory', 'rw+'));
$reportRequest->setReportId($reportId);
$resultArray = $this->invokeGetReportAllOrderData($service, $reportRequest);

Related

Ruby GA4 Data API not returning empty rows in RunReportRequest

After running my code to retrieve a report with the Google Analytics Data gem, the response is not returning all the rows as I would expect. Instead it leaves out the empty rows and only returns ones with data in this case. This is the code I am running, the property and analytics account are models to store access to the account info to pass to the api.
property = my_analytics_property
analytics_account = property.google_analytics_account
analytics_data_service = Google::Analytics::Data.analytics_data do |config|
config.credentials = analytics_account.google_account_oauth.credentials
end
date_dimension = ::Google::Analytics::Data::V1beta::Dimension.new(name: "date")
bounce_rate = ::Google::Analytics::Data::V1beta::Metric.new(name: "bounceRate")
page_views = ::Google::Analytics::Data::V1beta::Metric.new(name: "screenPageViews")
avg_session_duration = ::Google::Analytics::Data::V1beta::Metric.new(name: "averageSessionDuration")
date_range = ::Google::Analytics::Data::V1beta::DateRange.new(start_date: 1.month.ago.to_date.to_s, end_date: Date.current.to_s)
request = ::Google::Analytics::Data::V1beta::RunReportRequest.new(
property: "properties/#{property.remote_property_id}",
metrics: [bounce_rate, page_views, avg_session_duration],
dimensions: [date_dimension],
date_ranges: [date_range],
keep_empty_rows: true
)
response = analytics_data_service.run_report request

cron job with php-ews to get only new emails from Exchange server

I need a cron job to obtain only the new emails received in a Exchange server since the last time it synchronized.
I coded the same with imap servers, and it was easy to get the emails since an ID. So I save the last ID at the end of the for cycle to the DB, and resume from that ID the next time the cron job executes.
I tried the same in Exchange, but I get the following error:
Failed to search for messages with "ErrorInvalidValueForProperty: El valor especificado no es válido para la propiedad."
To get the ItemId in Exchange I'm using the following code, with no error:
$item->ItemId->Id;
It returns something like:
AAMkADk3ZWRhY2VmLTdiY2UtNDkxYy04ZDMyLWZiZWIyYTQ4ZjQyMABGAAAAAAChH5wDkXAqTZaoH1oRodz8BwD8BvGliMkPTK/cnnmZJDPUAAAAvGXfAAD8BvGliMkPTK/cnnmZJDPUAAAAvJN5AAA=
To find the emails I'm trying the following code (with the error mentioned before):
$request = new FindItemType();
$request->ParentFolderIds = new NonEmptyArrayOfBaseFolderIdsType();
$request->Traversal = ItemQueryTraversalType::SHALLOW;
$greater_than = new IsGreaterThanOrEqualToType();
$greater_than->FieldURI = new PathToUnindexedFieldType();
$greater_than->FieldURI->FieldURI = UnindexedFieldURIType::ITEM_ID;
$greater_than->FieldURIOrConstant = new FieldURIOrConstantType();
$greater_than->FieldURIOrConstant->Constant = new ConstantValueType();
$greater_than->FieldURIOrConstant->Constant->Value = $UID;
Thanks!!
The EWS ItemId isn't a searchable property because it doesn't need to be eg you can just Bind to the Id in question to see if the Item exists. If it nolonger exists then you will get a specific error to tell you that. The SyncFolderItems operation is probably a more appropriate method to use however https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/syncfolderitems-operation.

How to get order username and provisionDate for all SoftLayer machines using Ruby?

Using Ruby I'm making a call like:
client = SoftLayer::Client.new(:username => user, :api_key => api_key, :timeout => 999999)
client['Account'].object_mask("mask[id, hostname, fullyQualifiedDomainName, provisionDate, datacenter[name], billingItem[recurringFee, associatedChildren[recurringFee], orderItem[description, order[userRecord[username], id]]], tagReferences[tagId, tag[name]], primaryIpAddress, primaryBackendIpAddress]").getHardware
But only some machines return a provisionDate and only some return orderItem information. How can I consistently get this information for each machine? What would cause one machine to return this data and another machine to not?
Example output:
{"fullyQualifiedDomainName"=>"<removed_by_me>",
"hostname"=>"<removed_by_me>",
"id"=>167719,
"provisionDate"=>"",
"primaryBackendIpAddress"=>"<removed_by_me>",
"primaryIpAddress"=>"<removed_by_me>",
"billingItem"=>
{"recurringFee"=>"506.78",
"associatedChildren"=>
[<removed_by_me>]},
"datacenter"=>{"name"=>"dal09"},
"tagReferences"=>
[{"tagId"=>139415, "tag"=>{"name"=>"<removed_by_me>"}},
{"tagId"=>139417, "tag"=>{"name"=>"<removed_by_me>"}},
{"tagId"=>140549, "tag"=>{"name"=>"<removed_by_me>"}}]}
To be clear, most machines return this data so I'm trying to understand why some do not.
Please see the following provisioning steps, below is a little flow to consider:
1. Order a Server
Result:
* An orderId is assigned to the server
* The createDate has a new value
* activeTransaction value is = Null
* provisionDate value is = Null
2. The order is approved
Result:
* activeTransaction value is <> Null
* provisionDate value = Null
3. Server is already provisioned
Result:
* activeTransaction value is = Null
* provisionDate value has a New value
* billingItem property has a new value
To see if your machines have still ”activeTransaction”, please execute:
https://[username]:[apikey]#api.softlayer.com/rest/v3/SoftLayer_Hardware_Server/[server_id]/getActiveTransaction
Method: GET
Now, after reviewing your example response, this server had some problems when completing the provisioning; for that reason this step was completed manually but the provisionDate was not set for any reason(please open a ticket if you want that the provisionDate can be set) . This is a special case. I can see that another server has a similar behavior. But the other servers that don’t have provisionDate, have still ”activeTransaction<>null” (it means that these server are not provisioned yet).
EDIT:
Other property can help you to know that your machine has been already provisioned although other kind of transaction is being executed, is “hardwareStatus”, it should have “ACTIVE” value.
https://[username]:[apikey]#api.softlayer.com/rest/v3/SoftLayer_Account/getHardware?objectMask=mask[id, hostname, fullyQualifiedDomainName, provisionDate,hardwareStatus]
Method: GET
The response should be something like this:
{
"fullyQualifiedDomainName": "myhostname.softlayer.com"
"hostname": " myhostname"
"id": 1234567
"provisionDate": "2015-06-29T00:21:39-05:00"
"hardwareStatus": {
"id": 5
"status": "ACTIVE"
}

Pushing Offline Leads using Adwords API

I am using the below function to push my offline leads to api, everything looks good and returns success but when I check adwords, it doesnt show any data saying it received. I have tried many leads and also waited for around 3-4 days now.
What am I doing wrong?
function UploadOfflineConversionsExample(AdWordsUser $user, $conversionName,$gClId, $conversionTime, $conversionValue)
{
// Get the services, which loads the required classes.
// $conversionTrackerService = $user->GetService('ConversionTrackerService', ADWORDS_VERSION);
$offlineConversionService = $user->GetService('OfflineConversionFeedService', ADWORDS_VERSION);
// Associate offline conversions with the upload conversion we created.
$feed = new OfflineConversionFeed();
$feed->conversionName = $conversionName;
$feed->conversionTime = $conversionTime;
$feed->conversionValue = $conversionValue;
$feed->googleClickId = $gClId;
$offlineConversionOperation = new OfflineConversionFeedOperation();
$offlineConversionOperation->operator = 'ADD';
$offlineConversionOperation->operand = $feed;
$offlineConversionOperations = array($offlineConversionOperation);
$result = $offlineConversionService->mutate($offlineConversionOperations);
$feed = $result->value[0];
return ("Uploaded offline conversion value of ". $feed->conversionValue.
" for Google Click ID = ". $feed->googleClickId." and Conversion Name " . $feed->conversionName);
}
In adwords reports this conversion will be shown in Conversions Column. and change the daterange to the date what you pushed as $conversionTime

VWAttachment added through API is not showing in CM 5.2

I have retrieved a workitem using API and changed the attachment fields using setParameterValue , After saving the work usingstepElement.doSave(true), I can see the added attachments in the process tracker through process administration console , but my problem is it is not showing up in case navigator and in workplaceXT also it is saying "Attachment may be corrupted or deleted"
below is the code i used to create attachment
tempAtt.setAttachmentName("check.png");
tempAtt.setAttachmentDescription("Added by code");
tempAtt.setType(VWAttachmentType.ATTACHMENT_TYPE_DOCUMENT);
tempAtt.setLibraryType(VWLibraryType.LIBRARY_TYPE_CONTENT_ENGINE);
tempAtt.setLibraryName("TOS");
tempAtt.setId(doc.getVersionSeries().getId());
tempAttA[0] = tempAtt;
stepElement.setParameterValue("Zip", tempAttA, true);
I dont understand where i am wrong , please suggest.
//Filenet p8 5.2 , Content Platform Engine
Got the solution after banging my head for a couple of hours , posting the entire code , may be helpful for others
//Connect to PE
//Query the queue with wobnum and get the workobject
queryIndex = "F_WobNum";
queryMin[0] = wob;
queryMax[0] = wob;
queryFlag = VWQueue.QUERY_MIN_VALUES_INCLUSIVE + VWQueue.QUERY_MAX_VALUES_INCLUSIVE;
queryType = VWFetchType.FETCH_TYPE_WORKOBJECT;
queryTypeStepElement = VWFetchType.FETCH_TYPE_STEP_ELEMENT;
queue = session.getQueue("Queue_Name");
query = queue.createQuery(queryIndex, queryMin, queryMax, queryFlag, null, null, queryType);
System.out.println("count " + query.fetchCount());
workObject = (VWWorkObject) query.next();
//get the stepelement
stepElement = workObject.fetchStepElement();
parameters = stepElement.getParameters(VWFieldType.ALL_FIELD_TYPES, VWStepElement.FIELD_USER_AND_SYSTEM_DEFINED);
//get the existing attachment value
tempAttA= (VWAttachment[]) stepElement.getParameterValue("attachment_field_name");
//attachment is VWAttachment array
attachment=tempAttA;
//lock the item for working
stepElement.doLock(true);
//set the new values for the new attachment to be added
tempAtt=new VWAttachment();
tempAtt.setAttachmentName("Attachment_name");
tempAtt.setAttachmentDescription("Added by code");
tempAtt.setType(VWAttachmentType.ATTACHMENT_TYPE_DOCUMENT);
tempAtt.setLibraryType(VWLibraryType.LIBRARY_TYPE_CONTENT_ENGINE);
tempAtt.setLibraryName("TOS");
//vs id of the existing CE document , note that adding attachment means refering a CE object , so the document u want to attach should be stored in CE before.
tempAtt.setId(doc.getVersionSeries().getId());
attachment=tempAttA;
//law is a arraylist of VWAttachment type , so u dont override any existing attachments
law.add(attachment[0]);
law.add(tempAtt);
//set the attchment field with new values
stepElement.setParameterValue("attachment_name", law.toArray(), true);

Resources