• Etienne Gaudry 5
  • NEWBIE
  • 20 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 3
    Replies
Hi all,

I have a wrapper like this :
public class EU_API_DT_Wrap {
    ...
    public List<Competitions> Competitions;

    public class Competitions {
        ...
        public List<Sessions> Sessions;
    }
    
    public class Sessions {
		public String DateSession;	
		...	
	}
}

How can I access my sessions in my apex methods?
I tried :
EU_API_DT_Wrap myWrap = getSessionsList(saisonId, sportId);

for (EU_API_DT_Wrap.Competitions.Sessions ss : myWrap.Competitions.Sessions){
...}

But it doesn't work.
I only manage to access the competitions like this :
 
EU_API_DT_Wrap myWrap = getSessionsList(saisonId, sportId);

        for (EU_API_DT_Wrap.Competitions comp : myWrap.Competitions){
...}

Thanks for your help :)

Hey :)

I need to set up an api connection. I get a public key which should allow me to encrypt (RSA encryption(OAEP Padding)) my login and my password to obtain a tokken. An idea to succeed in this?

My public key is like :
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDVM2aEf0F6jm34nQ5ovx8Om0UvDkSWSSXgwWwSE4+0y4+8X715konvQjb0XkB3PIV/DA6JAqjXqyxd6yGGXXMpLYuZnRYBuaeeDlDjJggq+CQnPcNpAiYTsXKAT/YG5rG1WT5x6vBUG6lTyZDwZce7rlk+caCY8R6Wl3hu7HWODwIDAQAB

I tried this method :
https://gist.github.com/karmats/4270441be5a34fff7062
but I don't understand the value I should give to modulus and exponent.

Ty for your help !

Hi, i need to create event on lead for a test apex.

The EndDateTime (or activityDate) of this event need to be past.

I have create a lead and event on this lead but i can't choose a negative EndDateTime.
How can i do ?

It's possible to set a date time on Start Test for launch the test in the futur? Ty

Hi, i try to test my wrapper class but i have actually 0% coverage.

My wrapper is like :

public class EU01AccountApiWrapper {

    public String code;
    public String name;
    public cls_status status;
    public String website;

...
In my test method i have try to create a wrapper 
EU01AccountApiWrapper wrapper= new EU01AccountApiWrapper();
    wrapper.code = 'Test Wrapper';
    wrapper.name = 'Test Wrapper';


But i have 0%. How can i do ? Ty :)

Hi, i try to make a post API call.
On Postman with the wrapper and the token of my method, my api call work. The endpoint is good too. But on apex i have 401 error.

I think my SetHeader is bad :

request.setHeader('Authorization', 'oAuth 2.0 ' + accToken);
request.setHeader('Content-Type', 'application/json');
request.setHeader('Accept','*/*');
request.setBody(JSON.serialize(resWrap));
request.setMethod('POST');
request.setEndpoint(endPoint);
HttpResponse hresponse = htt.send(request);
system.debug(hresponse);

i have this response, ty for helping :
System.HttpResponse[Status=Non-Autorisé, StatusCode=401]
Hi, 
I try have a wrapper like this (JSON)
public class myWrapper {

public String name;
public cls_status status;

class cls_status {
        public Integer id;	//0
        public String value;	//string
        public String href;	//string
    }
If i want to fill name, i can do
myWrapper resWrap = new myWrapper();
resWrap.name= 'David';

 But how can i fill value of status ? resWrap.status.value doesn't work.

Ty for help :)

Hi there,
I try to connect Salesforce to Everwin with API (when i create an account on salesforce, i need to create society on Everwin)

In my wrapper i have something like this :

public cls_region region;
class cls_region {
        public Integer id;	//0
        public String value;	//string
        public String href;	//string

How can i get id and href ?
And how can i populate value ?

I have try this in my method:

EU01AccountApiWrapper resWrap = new EU01AccountApiWrapper();
resWrap.region.value=acct.billingState;

But i have this error : Type is not visible: EU01AccountApiWrapper.cls_region

Ty :)

Hi there, 
I need to connect salesforce to everwin accounts on insert and update. I made the trigger. But I don't know if my method and my wrapper are correct. I don't have the API key yet but it should happen.
Thanks for your help and your advice :

public class EU01AccountApi {
    private string cKey = 'XXXXXXXXXXXXXXXXXXXXXXXXXXX';
    private string cSecret = 'XXXXXXXXXXXXXXXXXXXXXXXXXXX';
    private string uName = 'XXXXXXXXXXXXXXXXXXXXXXXXXXX';
    private string passwd = 'Password+SecurityToken';

    public class responseWrapper {
        public string id;
        public string access_token;
        public string instance_url;
    }
    public string getRequestToken() {
        string reqBody = 'grant_type=password&client_id=' + cKey + '&client_secret=' + cSecret + '&username=' + uName + '&password=' + passwd;
        Http h = new Http();
        HttpRequest req = new HttpRequest();
        req.setBody(reqBody);
        req.setMethod('POST');
        req.setEndpoint('https://login.salesforce.com/services/oauth2/token');
        HttpResponse hresp = h.send(req);
        responseWrapper wResp = (responseWrapper) JSON.deserialize(hresp.getBody(), responseWrapper.class);
        system.debug('Instance url' + wResp.instance_url);
        system.debug('session id' + wResp.access_token);
        return wResp.access_token;
    }
    @future(callout = true)
    public static void getAccountInsert(Set < id > accIdSet) {
        String accToken;
        string responseBody;
        string endPoint = 'https://ap5.salesforce.com/services/apexrest/createAccountRecord';
        EU01AccountApi obj = new EU01AccountApi();
        accToken = obj.getRequestToken();
        system.debug('access token' + accToken);
        if (accToken != '') {
            for (Account acc: [SELECT id,ID_Everwin__c,website,phone,billingstreet,billingpostalcode,
                            billingcity,billingcountry,billingregion,SIRET__c,SIREN__c,Name,
                            OwnerId,ParentId,Recommandation_compte__c,Statut_juridique__c,Raison_sociale__c,
                            Accepte_de_recevoir_les_emails__c,Code_NAF__c,Ownership 
                            FROM account WHERE id in: accIdSet]) {
                system.debug('JSON' + JSON.serialize(acc));
                Http h1 = new Http();
                HttpRequest req1 = new HttpRequest();
                req1.setHeader('Authorization', 'Bearer ' + accToken);
                req1.setHeader('Content-Type', 'application/json');
                //req1.setHeader('accept','application/json');
                req1.setMethod('POST');
                req1.setBody(JSON.serialize(acc));
                req1.setEndpoint(endPoint);
                HttpResponse hresp1 = h1.send(req1);
                system.debug('hresp1' + hresp1);
            }
        }
    }
    @future(callout = true)
    public static void getAccountUpdate(set < id > accIdSet) {
        for (Account acct: [SELECT id,ID_Everwin__c,website,phone,billingstreet,billingpostalcode,
                            billingcity,billingcountry,billingregion,SIRET__c,SIREN__c,Name,
                            OwnerId,ParentId,Recommandation_compte__c,Statut_juridique__c,Raison_sociale__c,
                            Accepte_de_recevoir_les_emails__c,Code_NAF__c,Ownership 
                            FROM account WHERE id in: accIdSet]) {
            wrapperParameter resWrap=new wrapperParameter();
            resWrap.id=acct.ID_Everwin__c;
            resWrap.website=acct.website;
            resWrap.phone=acct.phone;
            resWrap.address=acct.billingstreet;
            resWrap.postalCode=acct.billingpostalcode;
            resWrap.city=acct.billingcity;
            resWrap.country=acct.billingcountry;
            resWrap.region=acct.billingregion;
            resWrap.identifierNumber=acct.SIRET__c;
            resWrap.companyRegistrationNumber=acct.SIREN__c;
            resWrap.name=acct.Name;
            resWrap.accountManager=acct.OwnerId;
            resWrap.group=acct.ParentId;
            resWrap.providedby=acct.Recommandation_compte__c;
            resWrap.status=acct.Statut_juridique__c;
            resWrap.code=acct.Raison_sociale__c;
            resWrap.acceptEmailing=acct.Accepte_de_recevoir_les_emails__c;
            resWrap.ape=acct.Code_NAF__c;
            resWrap.legalStatus=acct.Ownership;
            String accToken;
            string responseBody;
            string endPoint = 'https://ap5.salesforce.com/services/apexrest/updateopportunityrecord/';
            EU01AccountApi obj = new EU01AccountApi();
            accToken = obj.getRequestToken();
            system.debug('access token' + accToken);
            if (accToken != '') {
                Http h1 = new Http();
                HttpRequest req1 = new HttpRequest();
                req1.setHeader('Authorization', 'Bearer ' + accToken);
                req1.setHeader('Content-Type', 'application/json');
                req1.setBody(JSON.serialize(resWrap));
                req1.setMethod('PUT');
                req1.setEndpoint(endPoint);
                HttpResponse hresp1 = h1.send(req1);
                //listWrap=(list<resultWrapper>) JSON.deserialize(hresp1.getBody(),list<resultWrapper>.class);
            }
        }
    }
    public class wrapperParameter{
        //public class items {
        public Integer id;
        public String website;
        public String phone;
        public String address;
        public String postalCode;
        public String city;
        public country country;
        public region region;
        public String identifierNumber;
        public String companyRegistrationNumber;
        public String name;
        public accountManager accountManager;
        public String group;
        public providedby providedby;
        public String status;
        public String code;
        public Integer acceptEmailing;
        public ape ape;
        public legalStatus legalStatus;
    //}
    }
}

Hi, i need to create event on lead for a test apex.

The EndDateTime (or activityDate) of this event need to be past.

I have create a lead and event on this lead but i can't choose a negative EndDateTime.
How can i do ?

It's possible to set a date time on Start Test for launch the test in the futur? Ty

Hi, i try to test my wrapper class but i have actually 0% coverage.

My wrapper is like :

public class EU01AccountApiWrapper {

    public String code;
    public String name;
    public cls_status status;
    public String website;

...
In my test method i have try to create a wrapper 
EU01AccountApiWrapper wrapper= new EU01AccountApiWrapper();
    wrapper.code = 'Test Wrapper';
    wrapper.name = 'Test Wrapper';


But i have 0%. How can i do ? Ty :)

Hi, 
I try have a wrapper like this (JSON)
public class myWrapper {

public String name;
public cls_status status;

class cls_status {
        public Integer id;	//0
        public String value;	//string
        public String href;	//string
    }
If i want to fill name, i can do
myWrapper resWrap = new myWrapper();
resWrap.name= 'David';

 But how can i fill value of status ? resWrap.status.value doesn't work.

Ty for help :)