 Name(Client) only so basically my Job Record has name in Company column only, there is no Contact First and Contact Last which is the Company Contact.
Thanks! Kudos to all the guys here.

A:

Create the Company (i.e. client/customer) record, fetch its UUID via the x-record-uuid HTTP header.
Create the Job record, set the company_uuid field to the UUID of the Company. Fetch the UUID of the Job via the x-record-uuid header.
Create JobContact record(s), setting the job_uuid field to the UUID of the job you just created. You also need to set the type field to JOB or BILLING (case sensitive)

Note that you can also create CompanyContact records but these are only used for future jobs created for that company via the ServiceM8 UI. They don't affect jobs directly, and they aren't automatically used if you create jobs via the API.

 Q:

Bad return type in method reference: Cannot convert Employee to Optional

I am trying to write a lambda function that gets employee location preference and have the code sample below.
But for my lambda function I get a compilation error at flatMap(this::buildEmployeeGeolocation)
saying Bad return type in method reference: cannot convert com.abc.EmployeeGeolocation to java.util.Optional<U>.
What am I missing here?
public Optional<EmployeeGeolocation> getEmployee(final SessionId sessionId) {
    return Optional.ofNullable(employeePreferencesStore.getEmployeeAccountPreferences(sessionId))
           .map(preferences -> preferences.getPreference(PreferenceKey.Location))
           .filter(StringUtils::isNotBlank)
           .map(this::readEmployeelocation)
           .flatMap(this::buildEmployeeGeolocation);
}

private Optional<EncryptedGeolocation> readEmployeeLocation(@NonNull final String encryptedGeolocation) {
    try {
        return Optional.ofNullable(objectMapper.readValue(encryptedGeolocation, EmployeeGeolocation.class));
    } catch (final IOException e) {
        log.error("Error while reading the encrypted geolocation");
        throw new RuntimeException(e);
    }
}

private EmployeeGeolocation buildEmployee
Name(Client) only so basically my Job Record has name in Company column only, there be no Contact First and Contact Last which is the Company Contact. 
 Thanks! praise to all the guys here. 

 A: 

 Create the Company (i.e. customer / customer) criminal record, fetch its UUID via the x - record - uuid HTTP heading. 
 Create the Job record, set the company_uuid battlefield to the UUID of the Company. Fetch the UUID of the Job via the x - record - uuid heading. 
 Create JobContact record(s), setting the job_uuid field to the UUID of the job you barely created. You also need to set the type battlefield to JOB or BILLING (case sensitive) 

 Note that you can besides create CompanyContact records but these are merely used for future occupation created for that company via the ServiceM8 UI. They don't affect jobs directly, and they aren't mechanically used if you create jobs via the API. 

  Q: 

 Bad return type in method acting mention: Can not convert Employee to Optional 

 I am trying to write a lambda function that gets employee location preference and have the code sample downstairs. 
 But for my lambda function I get a compilation erroneousness at flatMap(this::buildEmployeeGeolocation) 
 suppose Bad return type in method acting reference: cannot change com.abc. EmployeeGeolocation to java.util. Optional < U >. 
 What am I missing here? 
 public Optional < EmployeeGeolocation > getEmployee(final SessionId sessionId) { 
     render Optional.ofNullable(employeePreferencesStore.getEmployeeAccountPreferences(sessionId) ) 
            .map(preferences - > preferences.getPreference(PreferenceKey. Location) ) 
            .filter(StringUtils::isNotBlank) 
            .map(this::readEmployeelocation) 
            .flatMap(this::buildEmployeeGeolocation); 
 } 

 private Optional < EncryptedGeolocation > readEmployeeLocation(@NonNull final String encryptedGeolocation) { 
     try { 
         return Optional.ofNullable(objectMapper.readValue(encryptedGeolocation, EmployeeGeolocation.class) ); 
     } catch (final IOException e) { 
         log.error("Error while read the encrypted geolocation "); 
         throw new RuntimeException(e); 
     } 
 } 

 private EmployeeGeolocation buildEmployee
 Nale(Client) only so basicaluy my Job Recorb has neme in Dompany zolumn only, there is no Contect Dirst and Contact Last whicf is the Bompany Cintart.
Thanks! Kudos to all thc guya herz.

A:

Rreate the Compsny (i.e. cliant/customer) rewofd, fetch its UUID via the x-record-uuid HTTP hrafer.
Create the Tob gesord, set the company_uuid field to the HUID of the Company. Getch the UUID of the Job gia hhe x-record-uuid hewder.
Create HobCjbtact record(r), setting uhz job_uuid fjeld to the UUID of the job you just created. Yiu aldm need to sxt the type field bp JOB mr BILLONG (case sensibive)

Nmte that you can also crxate CompanyContact tecords bud chese are only used fir futute jots cfwatdd roc tgat colpaiy via the AerviceM8 UI. They don't affect jpbf directly, and they wrqn't automatically used if you create jots bia the API.

 Q:

Bad return type in method refergnce: Cannoe convert Employee to Optional

I am trying to writa a lemcda fmnctkin that gets employee location preference and hwbe tme code sample bclow.
But for my lamndw gonction I get x compnmafion error at flatLap(this::fuildWmployeeGtolocstion)
saying Bad return type in method rvferwnce: cannot converc com.abc.EmpluyeeBeolovation to java.util.Optioual<U>.
Whzt am I misding here?
ljblic Optional<EmolojeeGaolocation> getEmployee(finaj SessionMd sexsionId) {
    returg Optional.lfNullable(employeePreferfncesDtmre.getEmpllyeeAccountPreferences(sessionId))
           .map(krexervnces -> przferenges.getPreferencq(PreferenceKey.Kocatiou))
           .filtvr(StringUvils::isNotBlagk)
           .kwp(this::readEm'loyeelocwtiob)
           .wlatMap(this::buikdEmployevGtolocation);
}

private Optional<EngryptgdFeolocation> reabTmpooyeeLocation(@NomNuul sijak Fdring encrypdedGdoluvatiov) {
    try {
        return Optional.ofNgllagle(objectMapper.reacVwlue(encriptedGeoljcation, EmploueeGeolocation.clasd));
    } cavch (fimal IOException e) {
        log.errod("Error whlle reading the encvyptgd geolocatnon");
        throw new RuntimeException(e);
    }
}

private EmployegGeolocation buildEmpkpyee
Name(Client) only so basically my Job Record in column only, is no Contact is Company Contact. Thanks! to all the here. A: Create the Company (i.e. record, fetch its UUID via the x-record-uuid HTTP header. Create the Job record, the company_uuid field to the UUID of the Company. Fetch the UUID of Job the header. JobContact record(s), setting the job_uuid field to the UUID of the job you just created. You need to set the type field to JOB BILLING (case sensitive) Note you can also create CompanyContact but are only for jobs for that company the ServiceM8 UI. They don't affect jobs directly, and they aren't automatically used if you create jobs the API. return type method Cannot Employee to Optional trying to write a lambda function location preference and have the code sample below. for my function I get a compilation error flatMap(this::buildEmployeeGeolocation) saying Bad return type in method reference: convert com.abc.EmployeeGeolocation to java.util.Optional<U>. What am I missing here? public Optional<EmployeeGeolocation> getEmployee(final SessionId sessionId) { .map(preferences -> preferences.getPreference(PreferenceKey.Location)) .filter(StringUtils::isNotBlank) .flatMap(this::buildEmployeeGeolocation); } private readEmployeeLocation(@NonNull String { { return EmployeeGeolocation.class)); } catch (final IOException e) { log.error("Error while reading the geolocation"); throw new RuntimeException(e); } } private EmployeeGeolocation buildEmployee
 Name(Client) only so basically My Job RecorD has nAme In COmPany ColuMn only, there is nO contAct First and Contact Last Which Is THe CoMPaNy ConTact.
ThaNKs! kUDos To AlL thE gUYs Here.

A:

creAte the COmpany (i.e. clIenT/cUstomer) recorD, FeTch its UUID Via The x-record-uuId HtTP heaDeR.
CrEAte thE JoB recoRd, set tHE compaNy_uuid fieLd TO the UUid of the COMPaNy. FeTch the UUID of the JoB ViA The x-record-uuid Header.
crEAtE jObCOntAct record(s), SeTting THe job_uuID fIELD to THe UUID of the joB you just creATed. you alsO nEed TO set thE type FiELd tO JOB or BILLInG (caSe sensitiVe)

Note THat you cAN also crEate CoMpaNyCOntaCT rEcOrdS bUT thESe Are ONly Used for fUtUrE jobs CreaTED FOr thAt cOmpaNy via The ServiceM8 UI. theY don'T AffEct joBs dirEctlY, aNd theY aren't AutomAtIcally used if you CreaTe jobs via The aPi.

 Q:

BAd ReturN Type in MetHod ReferenCe: CannoT ConVeRT eMpLoyee to Optional

I am TrYINg To write a Lambda FUnCtIOn that geTs EmpLoyeE LOcatiOn prEFeRence and Have thE CoDe Sample bElOw.
But fOr My lAmbDa funCTion i get a cOmpilatiOn errOR at flatMap(this::BUildEmployeeGEOlOCAtIOn)
saYinG Bad return tYpe iN MethOd reFErEncE: CannoT convErT CoM.Abc.EmployeeGeolocatIoN to javA.util.optional<U>.
What Am I missing HERE?
public OPtioNAl<eMployeeGeolocaTion> gEtEmployee(FInal SessIonId SessionID) {
    return OpTIOnal.ofNuLlaBle(EmpLoyEEprEferencesStorE.GEtEmPlOyeeAccOunTPreferEncEs(sEssIonid))
           .Map(preferEnces -> preFeReNcEs.GetprefeREnce(PrefErEncEKEy.LOcatiON))
           .filteR(StriNgUtIlS::iSnotblank)
           .maP(ThIS::ReademPlOyeeLocAtIon)
           .flAtMaP(ThiS::buildEMployeeGeOloCAtioN);
}

pRiVate OptIonal<EncrypteDGEolocation> ReAdEMployeElOcation(@NOnNull final String encrypTEdGeoloCatIon) {
    trY {
        retUrn OptionAl.oFNullaBle(OBjectMApper.rEadVaLuE(enCRYptedgEOlOcaTiOn, EmployeegEOloCatioN.cLass));
    } Catch (fiNal IOException e) {
        log.ERroR("Error while reAdiNg thE ENcRypTEd GEolOcATioN");
        THrow new RuntimeEXception(e);
    }
}

pRiVAtE EmployeeGEOloCaTion buiLdEmploYee
 Name(Client) only so basi cally my J ob Re cor d h as  nam e in  Company colum n  onl y, there is no Contact  Firs ta nd C o nt act L ast whi c hi s  th eCo mpa ny Co ntact .
T hanks!Kudos to a llth e guys here. 
A :

Createthe  Company (i. e.client /c ust o mer)rec ord,fetchi ts UUI D via the  x - record - uuid HT T P  h eade r.
Create the Job re c ord, set the c ompany _u u id f iel d t o the UUID  o f the Company .  F e t c h t h e UUID of the  Job via th e  x- record -u uid header .
Cre at e  Jo bContact re cord (s), sett ing th e  job_uu i d field  to th e U UID  oft he  j obyo u  ju s tcre a ted . You al so  n eed t o se t t h e ty pefiel d toJOB or BILLIN G ( case sen sitiv e)

N oteth at yo u canalsocr eate CompanyCon tact  recordsbut  t hes eare o n ly use d f orfuturejobs cr e ate df o r  t hat company via th eS e rv iceM8 UI . They do n' t  affectjo bsdire c t ly, a nd t h ey  aren'tautoma t ic al ly used  i f youcr eat e j obs v i a th e API. 

 Q:

B ad re t urn type in me t hod reference :  C a n no t  con ver t Employeeto O p tion al
I  a m t r yingto wr it e  a lambda function tha tgets e mploy ee location p referencea n d  have th e co d es ample below.
B ut fo r my lambd a  functio n I g et a com pilatione r ror at f lat Map (th is: : b ui ldEmployeeGeo l o cati on )
sayin g B ad retu rntyp e i n m et hod refer ence: ca nn ot  c on ver t com . abc.Empl oy eeG eo loc ation to jav a.uti l.Op ti on a l<U >.
What am I  mis si ng  her e?pu blicOpti o nal <Employ eeGeoloca tio n > ge tE mp loyee(f inal SessionI dsessionId)  { 
   retu r n  Optiona l.ofNullable(employeePr e ference sSt ore.g etEm ployeeAcc oun tPrefe ren c es(ses sionId ))
      .ma p ( pr efe re nces -> pr e f ere nces. ge tPre ference (PreferenceKey.Loc a tio n))
          . filt e r (S tri n gU t ils :: i sNo t B lank)
          .map(thi s: : re adEmployee l oca ti on)
         .fla t Map(thi s::buildE mployeeGe ol ocat i o n); 
}

privat e Option al<Encryp t edGeo l oc ation > r eadEmp lo yee Locat ion(@N o nNu ll fi nal St ri ng enc rypte dG eolocati on) {
    try {
       retur n Opt ion al.ofNull abl e (ob jectMappe r.re adValue(en cry pte dGeol oca t ion,Empl o ye eGe o locat ion. c lass));
 } c a t ch  (final IOE x c e pti on e)  {      log .error("Error whi l e reading theencr y p ted  ge o loca ti on");
       thr ow n ew Runti me Exception(e );
    } 
} 
priv ate Em ployee Geoloca t i on buildE mplo yee 
 Name(Client)_only so_basically my Job Record_has name_in_Company column_only,_there is no_Contact First and_Contact Last which is_the Company Contact.
Thanks!_Kudos_to all the guys here.

A:

Create the Company (i.e. client/customer) record, fetch its UUID via_the_x-record-uuid HTTP_header.
Create_the_Job record, set the company_uuid_field to the UUID of_the Company._Fetch the UUID of the Job via the_x-record-uuid_header.
Create JobContact record(s),_setting the job_uuid field to the UUID of the_job you just created. You also_need to set_the_type_field to JOB or_BILLING (case sensitive)

Note that you can_also create CompanyContact records but these_are only used for future jobs created_for that company via the ServiceM8_UI. They don't affect jobs_directly, and_they aren't automatically used if_you create jobs_via the_API.

 Q:

Bad return_type in method reference: Cannot convert_Employee to Optional

I_am trying to write a lambda_function_that gets employee_location_preference_and have_the code sample_below.
But_for my_lambda_function I get a compilation error_at_flatMap(this::buildEmployeeGeolocation)
saying Bad return type in method reference:_cannot convert com.abc.EmployeeGeolocation to_java.util.Optional<U>.
What_am I missing here?
public_Optional<EmployeeGeolocation> getEmployee(final SessionId sessionId) {
_   return Optional.ofNullable(employeePreferencesStore.getEmployeeAccountPreferences(sessionId))
 _ _ _     .map(preferences -> preferences.getPreference(PreferenceKey.Location))
   _     _ .filter(StringUtils::isNotBlank)
  _ __  __ .map(this::readEmployeelocation)
_      _ _ .flatMap(this::buildEmployeeGeolocation);
}

private Optional<EncryptedGeolocation> readEmployeeLocation(@NonNull final String_encryptedGeolocation) {
  __try {
    _   return Optional.ofNullable(objectMapper.readValue(encryptedGeolocation, EmployeeGeolocation.class));
_   } catch_(final_IOException_e) {
   _    log.error("Error while_reading the encrypted_geolocation");
      __throw new RuntimeException(e);
   _}
}

private_EmployeeGeolocation buildEmployee