Is there any Coupa API to retrive object views? - coupa

I want to retrieve view data for "Purchase Order Line" Object.
I am able to retrieve list of purchase order lines object.
But I want information specific to views.

Related

how can one user modify a data in firestore which will not affect other user data in the app?

I am new to flutter(and coding),I don't know if I specified the question clearly but what I want is for when a user "Follows" or "subscribe" to a product it goes to a listview but it changing the data globally in firestore, so in every user's listview has the same data subscribed. I want make it personalized for that specific user only, other can change the data too which will only affect that specific user only,
think of it as ecommerce cart function where every user has different thing in the cart
I did make a collection for "product" but every user getting data from same collection and it changing globally.
how can I make common subscribed data personalized for each user which will not conflict with others data.
how can I make common subscribed data personalized for each user which will not conflict with others data.
Every Firebase user has an id, you can use the user's id and set/query documents based on that.
For example, to set the data:
.collection('bla').doc(USER_ID).set({"name": "John"})
and to retrieve the data based on the id:
final snapshot = await Firestore.instance
.collection('bla')
.doc(USER_ID)
.get();
See also
How to get the current user id from Firebase in Flutter

How to minimize Firestore data? Mutiple fields with boolean type or one Map field type?

I'm making a social media app using flutter and firebase.
I'm making push notifications to alert users on certain actions like somebody is following or send a comment or press like button. Also, there will be a push notification settings page.
I want to let users to choose to turn on and off push notifications on certain actions. For example, a user only wants to get push notification when someone is following on him. Then, the user can just turn off all the other push notifications except following push notification.
What I did was make every fields of every push notifications on certain actions.
For example, I made 4 data fields in user's firebase document for each certain push notifications.
I have a different idea which is making one field of Map type data that contains multiple push notifications like this.
Which way would be the better idea to minimize the size of Firestore data and reduce the cost?
Thank you so much for reading this and if you have other ideas, please let me know :)
Better have different fields - anyway you will receive one dataset, and you don't need to make another "dataset" in this (in same situation you will receive more long response because of additional string markup for inner json)
Also, if you have different fields you can more efficient query it if you need, with less data exchange between client and server

REST API Designs with categories

Let's say there is a SINGLE mobile application which receives various types of notifications (like WhatsApp notifications, Facebook Messenger notifications ,etc). What would be a better REST API structure for this?
/users/test#abc.com/notifications //Gives all the notifications
There is a confusion between the below two formats on how .
/users/test#abc.com/notifications?category=whatsapp,facebook //Gives all the notifications
vs
/users/test#abc.com/notifications/whatsapp //Gives only whatsapp notification
/users/test#abc.com/notifications/facebook //Gives only facebook notification
To access an individual notification resource
/users/test#abc.com/notifications/facebook/{notification-id}
vs
/users/test#abc.com/notifications/{notification-id}
If a resource has a unique ID then it should be directly accessible from that, so in my opinion
/notifications/{id}
Would make most sense. In terms of filtering, this is probably more about preference than anything. Here's what I think would be the most idiomatic approach
/notifications // fetch all notifications
/notifications/facebook // fetch all Facebook messages
/notifications/whatsapp // fetch all WhatsApp messages
/users/{id}/notifications // fetch user notifications
/users/{id}/notifications/facebook // fetch user Facebook notifications
/users/{id}/notifications/whatsapp // fetch user WhatsApp messages
It really depends on how you define a notification resource and the relation with its category type (whatsapp, facebook...).
Non category dependent
If the structure of a notification is not dependent on its category, then you want to access it without any category context:
/users/test#abc.com/notifications/{notification-id}
And you can use the category as a filter to a collection of notifications:
/users/test#abc.com/notifications?category=whatsapp,facebook
category dependent
Otherwise, if a notification is structurally dependent on its category (e.g., if you want to define different actions when you deal with whatsapp notifications than when you deal with facebook notifications), then you might want to distinguish a notification according to its category:
/users/test#abc.com/notifications/whatsapp/{whatsapp-notification-id}
/users/test#abc.com/notifications/facebook/{facebook-notification-id}
In this case, you could have:
/users/test#abc.com/notifications/whatsapp/1
/users/test#abc.com/notifications/facebook/1
That define 2 different notifications (although it uses the same identifier).
Now requesting a collection of this kind of notifications is a bit different than the previous "non category dependent" case.
If you only want to have whatsapp notifications then simply call the category resource does the job:
/users/test#abc.com/notifications/whatsapp
But if you want to search on different categories, then you cannot apply your request to a specific category resource. Indeed, it makes no sense to ask for facebook notifications when you deal with whatsapp ones:
/users/test#abc.com/notifications/whatsapp?category=facebook # weird
One solution would be to make as many requests as there are categories requested:
/users/test#abc.com/notifications/whatsapp
/users/test#abc.com/notifications/facebook
But you will have to merge your results later.
Another solution would be to apply your query directly from
/users/test#abc.com/notifications?category=whatsapp,facebook
But the result will be different than the "non category dependent" case. Indeed, you won't be able to directly have your list of notifications, but a list of categories to access to your list of notifications.

zend acl for list of records to view

I've got a list of trades (lets say some records) made by different users in my Zend framework based application.
I want to allow users to view only their trades, and if they try to view another user's trade by changing the url by themselves. They would get a message that they don't have permission to view or change anything.
Kindly help me figure out how can I do this using Zend, ACL, or another better way.
In this situation I wouldn't use ACL for restricting access to the list of trades. Instead in controller's action, which get list of trades and pass them to the view, I would check who is owner of each list and compare this owner with a logged in user.

Core Data convert a superclass instance into a subclass instance?

What's the best way to programmatically convert an NSManagedObject-subclass (User) instance into an instance of its subclass (AccountUser)?
Setup
AccountUser inherits from User : NSManagedObject
When I sign up or log into the app for the first time, I become an AccountUser. Then, I download all of my friends and store them as User objects.
Both User & AccountUser have attributes firstName, lastName, etc. AccountUser has some extra things, like accessToken.
Problem
My friend John logs in on my device. Since he's my friend, he's already stored as a User. But now, I want to convert him into an AccountUser. What's the best way to do this programmatically? I have lots of attributes and relationships to preserve, so creating a new AccountUser object from a User object and then deleting the original User object is a lot to do. If I just create an AccountUser without deleting the User, things get messy. E.g. when I fetch User by ID, I get two objects back: one is the AccountUser, the other is the User.
One way to do it is to simply create a new AccountUser object and copy the relevant fields from the existing User object into it. Then deal with the old User object appropriately -- delete it, save it, whatever makes sense. It'd make sense to give AccountUser an initializer that takes an instance of User, like -initWithUser:.
Another (probably better) option would involve using a single class (User) for all users. If there's additional information to be stored for some users (currently AccountUsers), create a new Account class and associate an instance of Account with the users that require it. So the User objects that represent you and your friend John would each have associated Account objects, and all the other users wouldn't. When one of your other friends logs into your phone, you can create a new Account object for that person and associate it with their existing User object.
Maybe you can do it this way
Add the User entity a boolean property called "is_account_user".
Set a relationship between User and account user.
if a user has an account user, create the AcountUser entity and relate it to the User.
If the user has no account info then the "is_account_user" will be NO;
When you fetch for a user you can check if is_account_user is YES, and if so you can get his AcountUser with the relationship.
Hope it helps