How to differentiate between inventory in different sites? - amazon-mws

I'm using the ListInventorySupply action to get all my inventory
https://mws.amazonservices.co.uk/FulfillmentInventory/2010-10-01?AWSAccessKeyId ....
Now the response includes ALL my inventory for all European sites. How can I know which items are in .uk and which in .de etc?

I haven't worked with FBA, but it is my understanding that the FullfillmentInventory API call does not give you fulfillment center information and neither lets you specify a specific fulfillment center as query parameter.
There is another set of API calls from the Reports API that most probably do what you want. I suggest you look specifically at the _GET_AFN_INVENTORY_DATA_BY_COUNTRY_ report type.

Related

WordPress : make categories automatically match according to external API Value

I'm managing a company website, where we have to display our products. We however do not want to handle the admin edit for this CPT, nor offer the ability to access to the form. But we have to read some product data form the admin edit page. All has to be created or updated via our CRM platform automatically.
For this matter, I already setup a CPT (wprc_pr) and registered 6 custom hierarchical terms: 1 generic for the types (wprc_pr_type) and 5 targeting each types available: wprc_pr_rb, wprc_pr_sp, wprc_pr_pe, wprc_pr_ce and wprc_pr_pr. All those taxonomies are required for filtering purposes (was the old way of working, maybe not the best, opened to suggestions here). We happen to come out with archive pages links looking like site.tld/generic/specific-parent/specific-child/ which is what is desired here.
I have a internal tool, nodeJS based, to batch create products from our CRM. The job is simple: get all products not yet pushed to the website, format a new post, push it to the WP REST API, wait for response, updated CRM data in consequence, and proceed to next product. Handle about 1600 products today on trialn each gone fine
The issue for now is that in order for me to put the correct terms to the new post, I have to compute for each product the generic type and specific type children.
I handled that by creating 6 files, one for each taxonomy. Each file is basically a giant JS object with the id from the CRM as a key, and the term id as a value. My script handles the category assertion like that:
wp_taxonomy = [jsTaxonomyMapper[crm_id1][crm_id2]] // or [] if not found
I have to say it is working pretty well, and that I could stop here. But I will have to take that computing to the wp_after_insert_post hook, in order to reaffect the post to the desired category on updated if something changed on the CRM.
Not quite difficult, but if I happen to add category on the CRM, I'll have to manually edit my mappers to add the new terms, and believe me that's a hassle.
Not waiting for a full solution here, but a way to work the thing. Maybe a way to computed those mappers and store their values in the options table maybe, or have a mapper class, I don't know at all.
Additional information:
Data from the CRM comes as integers (ids corresponding to a label) and the mappers today consist of 6 arrays (nested or not), about 600 total entries.
If you have something for me, or even suggestions to simplify the process, I'll go with it.
Thanks.
EDIT :
Went with another approach, see comment below.

Watson RnR - Creating Ranker using REST API

I am trying out to create an Ranker using the REST API after successfully Adding documents to the collection.
Do I need to use train.py. If so then whats the use of create Ranker API. Also while trying to create RANKER, can you please tell me where do I need to specify cluster id and collection name. Do I need to specify it in metadata.json file.
Any help would be highly appreciated.
See here for an overview of the methods available for training a ranker: https://www.ibm.com/watson/developercloud/doc/retrieve-rank/training_data.html#methods. Using the REST API directly is described under the 'Manually training a ranker' section and is intended for advanced users that might be appending additional columns to the feature vectors that are generated automatically when you use train.py.
The create Ranker REST API call does not take 'cluster id' and 'collection names' as input parameters. It assumes that you've already used the /fcselect REST API call (which does take 'cluster id' and 'collection id') to pre-generate feature vectors similar to what train.py is doing internally. Again, in the advanced use case, you might take these feature vectors and then augment them using some other custom features as described in this blog post: https://medium.com/machine-learning-with-ibm-watson/developing-with-ibm-watson-retrieve-and-rank-part-3-custom-features-826fe88a5c63#.unfm2ocik

obtain demographic data with google analytics api

im trying to obtain some demographic data from the google analytics api, my intention is to integrate this on a cms to generate reports, etc... is this possible?
if it is, is there someone who knows a tutorial or something? i have used the examples provided and i get some sessions that have been in the last 7 day period. But nothing besides that. If that is not possible, what kind of things i can obtain with this api?
here is what i have tried:
function getResults(&$analytics, $profileId) {
return $analytics->data_ga->get(
'ga:' . $profileId,
'7daysAgo',
'today',
'ga:sessions');
}
thanks in advance.
You can obtain everything that's listed in the Dimensions and Metrics Reference. This includes ga:userAgeBracket and ga:userGender for demographic information.
To include additional metrics (numerical data) you put it as a parameter where you now have ga:sessions (separate multiple metrics with a comma). You need at least one metric for a query to work.
To add dimensions (i.e. categorical data) you need to pass an options array to your query that has a key/value pair for dimensions. This may also include additional options like filters or sort options, see the example here..
$optParams = array(
'dimensions' => 'ga:userAgeBracket,ga:userGender'
);
return $analytics->data_ga->get(
'ga:' . $profileId,
'7daysAgo',
'today',
'ga:sessions',
$optParams
);
This for version 3 of the API. If you are just getting started an have no legacy code to maintain you might as well start with there current version (v4).
To be able to get age and gender informations from analytics, you should Enable Demographics and Interests reports on your GA account.
doc : https://support.google.com/analytics/answer/2819948

Manipulating Soundcloud Stream with Chrome Extension Content Script

I am writing a Chrome extension using AngularJS to add functionality to the Soundcloud stream page. I want to allow the user to create groups of artists so that they may only see a stream with tracks/shares/playlists from that group of artists.
For example, I follow 500 artists, but I want to quickly see a stream from my favorite 10 artists or from the artists I follow that are on the same label.
I am looking for advice on how I could go about making this as seamless as possible. As of right now, my approach involves getting the tracks with the Soundcloud API and using angular's ng-repeat to display the tracks in a view injected into where the stream normally goes. I realized using the Soundcloud widget was too slow and can't be customized to resemble the native stream items, so I copy/pasted the HTML that an actual stream item uses, but obviously the waveform/comment canvas and button functionality don't work.
What are my options as far as how I can approach this? Am I going to need to write my own players that look like the native Soundcloud ones? Any suggestions would be greatly appreciated.
You should use the SoundCloud API which is very well documented.
If you have already the id's of the tracks / artist, you just have to request the url
GET
http://api.soundcloud.com/tracks/ID_OF_TRACK.json?client_id=YOUR_CLIENT_ID
to get all the informations you need about this track, like the waveform_url, and for the comments you was talking about :
GET
http://api.soundcloud.com/tracks/ID_OF_TRACK/comments.json?client_id=YOUR_CLIENT_ID
To reproduce the behaviour of the comments :
POST http://api.soundcloud.com/tracks/ID_OF_TRACK/comments.json?client_id=YOUR_CLIENT_ID
(with a body param which represents the text and a timestamp in ms since the beginnin of the song, note that you must be connected)
If you don't have the id of the track, you could also use the resolve which give you all the info about a ressource if you have only the URL :
GET
http://api.soundcloud.com/resolve.json?url=https://soundcloud.com/poldoore/pete-rock-c-l-smooth-they&client_id=YOUR_CLIENT_ID

Show Opportunity related Contacts in Custom Object Field

I have the next issue.
I have a custom object called 'Application', and I have this requirement:
"Show all Contacts related to an Application. Create a field on Application object, must be read only".
I solve it with apex code. 'Application' has a lookup to Opportunity, Opportunity to Account, and all my contacts have AccountId, so this way, I get all the contacts using apex code in a trigger.
But, I've been ask to change this to a Formula field in Application object.
So, my issue is next. I'm not able to get all contacts with advance formula editor, because they're not part of any object. I have no master-detail relationship.
Does any one know how can I achieve this using configuration? I should not use apex code for this req.
Thank in advance guys.
I don't think you can do it.
In formulas / merge fields syntax there's no way to go "up, up then down" (Application -> Opportunity -> Account -> down to Contacts related list). There's also nothing that would let you loop through Contacts (and display what? Ids? Names? Emails?). Roughly speaking you can only go up through dots.
You might want to explore path of "cross object workflow" rules but I imagine that when I add a new Contact to Account it should somehow "spread itself" to all related Applications? There's no straight way to fire a workflow on delete too - so you'd eventually end up with inaccurate list.
I'd say trigger was a good solution. Maybe it ws unoptimized but if it has to be in a field - tough.
There might be a fairly simple way of achieving that by embedding a visualforce page within Application page layout.
This should be doable with pure Visualforce (so technically there will be no Apex code ;))
Something as simple as
<apex:relatedList list="Contacts" subject="Application__c.Opportunity__r.AccountId" />
would be a good start (if you want your own layout and not a rel. list - you should be still able to pull it off with <apex:repeat> or <apex:pageBlockTable>.
There's one BUT here: it's not a field, just a display trick. Forget about using it in reports, mobile applications etc.
Another way - would it be acceptable to be 1 click away from these contacts? You could make a report "Account with Contacts", filter it by Id of one Account and later use "URL hacking" to change the filter depending on from which Application you'll click it. This link could be either a formula field or a real custom button/link. Technically - it's pure config, no apex & VF.
You can read more about URL hacking at Ray Dehler's excellent post and specifically about dynamic Reports here or here.

Resources