SuiteCRM: getting account email addresses using API v8 - suitecrm

I'm trying to get the email addresses associated with a specific Account, using the new JSON v8 API.
I can get my access token and use it to fetch the Account, now I'd like to get its email addresses too (I know that this particular account has two email addresses).
I've tried calling the
api/v8/modules/Accounts/{ACCOUNTID}/relationships/email_addresses
endpoint, here's the data I'm receiving back:
[{'id': '1ee15ac7-18d3-96d7-035d-5b3f3c3dba94',
'links': {'href': 'http://devcrm/api/v8/modules/Accounts/1ee15ac7-18d3-96d7-035d-5b3f3c3dba94'},
'meta': {'middle_table': {'data': {'attributes': {'bean_id': 'a5ec312f-b1dc-d401-d3be-5b23b3058722',
'bean_module': 'Accounts',
'date_created': '2018-07-06 09:53:48',
'date_modified': '2018-07-06 09:53:48',
'deleted': '0',
'email_address_id': '1ee15ac7-18d3-96d7-035d-5b3f3c3dba94',
'id': '1ee15ac7-18d3-96d7-035d-5b3f3c3dba94',
'primary_address': '0',
'reply_to_address': '0'},
'id': '',
'type': 'Link'}}},
'type': 'EmailAddresses'},
{'id': '8f42881c-d788-9a69-15b3-5b3f3be9705f',
'links': {'href': 'http://devcrm/api/v8/modules/Accounts/8f42881c-d788-9a69-15b3-5b3f3be9705f'},
'meta': {'middle_table': {'data': {'attributes': {'bean_id': 'a5ec312f-b1dc-d401-d3be-5b23b3058722',
'bean_module': 'Accounts',
'date_created': '2018-07-06 09:49:13',
'date_modified': '2018-07-06 09:49:13',
'deleted': '0',
'email_address_id': '8f42881c-d788-9a69-15b3-5b3f3be9705f',
'id': '8f42881c-d788-9a69-15b3-5b3f3be9705f',
'primary_address': '0',
'reply_to_address': '0'},
'id': '',
'type': 'Link'}}},
'type': 'EmailAddresses'}]
As you can see, there are two "branches", one for each email address, but the REAL addresses (x#y.com) are nowhere to be seen, only the email_address_ids. Is this normal? Should I use the email_address_ids to make another call to the server? I'm not sure against which module I should do that though.

It looks like the module to use is "EmailAddresses", so in this case:
GET api/v8/modules/EmailAddresses/1ee15ac7-18d3-96d7-035d-5b3f3c3dba94
GET api/v8/modules/EmailAddresses/8f42881c-d788-9a69-15b3-5b3f3be9705f

Related

Validate Laravel Nested Rules in Array

I'm with Laravel and I want to write elegant validation rules :) With this Framework its really easy, but I don't know how to approach this when facing 1:n relationships.
I have two Resources, User and Contact. An User can have multiple Contacts.
So, I want a Form where you can fill all User's fields AND all Contact's information.
To do that, I would like to write a Request like this:
UserRequest:
public function rules()
return [
'name' => 'required|string',
'email' => 'required|email|unique:exists:users,id',
'contacts' => 'array',
'contacts.*' => new ContactRequest() // This is the problem
]
My question is: How can I apply this type of validation? Specifically when using array, how can I make a Modular Validation to apply validations of nested Resources? Or should I develop a ContactRule instead?
Edit:
I want that front end send form like this:
` // POST: users
{
'name': 'UserName',
'email': 'user#mail.com'
'contacts': [
[
'email' => 'contac_1#mail.com',
'contact_type_id => 1
],
[
'email' => 'contac_2#mail.com',
'contact_type_id => 2
],
}
`
Thats all,
Thx!
We have an API with 100's of results in each request or perhaps post/patch.
We still use:
'data.relationships.users.data.*.id' => [
'string',
'unique:api_groups,name,' . ($this->route('group')->id ?? 0),
]
So for you
'contacts.*.email' => 'required|email|unique:exists:users,id'
Works perfectly. It doesn't get more complex or anything.

Handling big data with angular-meteor and handsontable

So, here's the situation:
I am creating a web app in angular-meteor ( which is a project that allows to create meteor apps in angular ). The app is a little bit like a database app. So first I have collections:
{ _id: '12jbhb1', name: 'users' }
Then these collections have columns:
{ _id: '23jjh1j23', name: 'Full Name', collectionId: '12jbhb1' }
Lastly I have records for each collection:
{ _id: '2321hwerueh', collectionId: '12jbhb1', data: { '23jjh1j23': 'John Doe' } }
{ _id: '23f3rueh', collectionId: '12jbhb1', data: { '23jjh1j23': 'Jane Doe' } }
{ _id: '23f3r123eh', collectionId: '12jbhb1', data: { '23jjh1j23': 'Mike Doe' } }
NOTE: data's keys corresponds to the columnId
But the requirement is to implement handsontable. But handsontable won't expect data like this. So, I would have to encode it to work with hansontable but once I encode it in this way and someone edits any cell I would again have to decode it. The encoding part is done but I can't decode it. Can somebody help me. If somebody wants I can show how I encode it but it would be best if somebody can show me how he/she would go about encoding and decoding this mongo data for hansontable because this is my first project with handsontable. Please help me!

Encrypt all data with nodejs + angularjs + mongoose

I would like to encrypt all the datas that is being saved in mongoose. Do you know some plugins or some moduls, in nodejs, that does this ? And how could i do it efficiently with angularjs in frontend ?
For example : i'm using a chat system, using socket.io. And i store the messages in this model :
var messageSchema = new Schema({
type: {
type: String,
required: false
},
user: {
type: String,
default: '',
trim: true
},
content: {
type: String,
default: '',
trim: true
},
slug: {
type: String,
lowercase: true,
trim: true
},
created: Date,
updated: [Date],
roomCreator: {
type: Schema.ObjectId,
ref: 'Room'
},
});
I want all this data to be encrypted in the most secure way as possible, so nobody should be able to see any of the contents of the messages.
Thanks in advance
There is this:
ChatSafe
Though I am not sure how I feel about it though. It has the ability to use different cipher keys, but it has no inherent way to get keys from one client to the other, which is necessary to decrypt messages (apparently you have to send them a url, which is how other clients get the cipher key). It is cool that it does all the encryption client-side though.
I think I would work this one though: Implement AES Strength Encryption With JavaScript
It shows you how to build a client-side angular based encryption service.
Encrypt everything client side > shoot it to node > save/do whatever > send it to other clients > decrypt client side.

How to add contact from a rails app to salesforce using restforce gem?

I am using restforce gem to connect to salesforce api. I have successfully connected to it and initialised the client using username/password like below
client = Restforce.new :username => 'foo',
:password => 'bar',
:security_token => 'security token',
:client_id => 'client_id',
:client_secret => 'client_secret'
I am able to create Account in saleforce using the command that is given in gem docs
client.create('Account', Name: 'Foobar Inc.')
Now i want to know how to create contacts? I tried
client.create('Contact', Email: 'demo#example.com')
but it returns false.
I tried
client.create!('Contact', Email: 'demo#example.com')
which showed me the error that LastName is a required field as specified in the comment.
So the solution is to specify LastName also like shown below:
client.create('Contact', Email: 'demo#example.com', LastName: 'Bar')
Thanks and Happy Coding.

What is the difference between idParam, idProperty and clientIdProperty

I am curios about the implementations of the idProperty one in the model and one in the reader
and then a idParam for the proxy and a clientIdProperty on the model
How do we I use them in a right way?
if you get this as a response from the server:
{data: [{userid: 1234, username: "foo"}, {userid: 1235, username: "bar"}]}
so in your UserModel you will have idProperty: "userid" this will tell ExtJS which field to use for functions like getId(), getById(). You could also define this in the reader to share between some models, but usually you should define the idProperty in the model.
idParam seems very unclear to me, it is used only 2 time in the whole framework. is only used to modify the request id parameter send to the server. I don't think this is a parameter you will ever need to change.
clientIdProperty is needed for create operations if proxy.batchActions == true. For example: model.clientIdProperty = "extid" this will send to the server if we create 2 users:
{data: [
{extid: "ext-user-1", username: "foo"},
{extid: "ext-user-2", username: "bar"}
]}
server response:
{data: [
{extid: "ext-user-1", userid: 1234, username: "foo"},
{extid: "ext-user-2", userid: 1235, username: "bar"}
]}
this will tell ExtJS how to map the server ids to the pre-generated ext ids.
(if clientIdProperty is null, ExtJS assumes the same order of request and response for the mapping)

Resources