<commit_before>package com.jos.dem.vetlog.service.impl

import org.springframework.stereotype.Service
import org.springframework.beans.factory.annotation.Value
import org.springframework.beans.factory.annotation.Autowired

import com.jos.dem.vetlog.model.Pet
import com.jos.dem.vetlog.model.User
import com.jos.dem.vetlog.command.Command
import com.jos.dem.vetlog.enums.PetStatus
import com.jos.dem.vetlog.service.PetService
import com.jos.dem.vetlog.service.RestService
import com.jos.dem.vetlog.service.TelephoneService
import com.jos.dem.vetlog.repository.PetRepository

@Service
class TelephoneServiceImpl implements TelephoneService {

  @Autowired
  PetService petService
  @Autowired
  PetRepository petRepository
  @Autowired
  RestService restService

  @Value('${template.adoption.name}')
  String adoptionTemplate


  void save(Command command, User adopter){
    Pet pet = petService.getPetByUuid(command.uuid)
    pet.status = PetStatus.ADOPTED
    pet.adopter = adopter
    petRepository.save(pet)
    createAdoptionDataMessage(command, pet)
  }

  private createAdoptionDataMessage(Command command, Pet pet){
    User owner = pet.user
    User adopter = pet.adopter
    Command command = new MessageCommand(
      email:owner.email,
      name:pet.name,
      contactName: "${adopter.firstname adopter.lastname}",
      emailContact: adopter.email,
      message:adopter.mobile,
      template: adoptionTemplate
    )
    restService.sendCommand(command)
  }

}<commit_msg>#53 Adding mobile to the saving adoption<commit_after>package com.jos.dem.vetlog.service.impl

import org.springframework.stereotype.Service
import org.springframework.beans.factory.annotation.Value
import org.springframework.beans.factory.annotation.Autowired

import com.jos.dem.vetlog.model.Pet
import com.jos.dem.vetlog.model.User
import com.jos.dem.vetlog.command.Command
import com.jos.dem.vetlog.enums.PetStatus
import com.jos.dem.vetlog.service.PetService
import com.jos.dem.vetlog.service.RestService
import com.jos.dem.vetlog.service.TelephoneService
import com.jos.dem.vetlog.repository.PetRepository

@Service
class TelephoneServiceImpl implements TelephoneService {

  @Autowired
  PetService petService
  @Autowired
  PetRepository petRepository
  @Autowired
  RestService restService

  @Value('${template.adoption.name}')
  String adoptionTemplate


  void save(Command command, User adopter){
    Pet pet = petService.getPetByUuid(command.uuid)
    pet.status = PetStatus.ADOPTED
    adopter.mobile = command.mobile
    pet.adopter = adopter
    petRepository.save(pet)
    createAdoptionDataMessage(command, pet)
  }

  private createAdoptionDataMessage(Command command, Pet pet){
    User owner = pet.user
    User adopter = pet.adopter
    Command command = new MessageCommand(
      email:owner.email,
      name:pet.name,
      contactName: "${adopter.firstname adopter.lastname}",
      emailContact: adopter.email,
      message:adopter.mobile,
      template: adoptionTemplate
    )
    restService.sendCommand(command)
  }

}
{'fraction_non_alphanumeric': 0.0901612372490951, 'fraction_numerical': 0.0006581112207963146, 'mean_word_length': 4.352112676056338, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4335332', 'n_tokens_mistral': 904, 'n_tokens_neox': 906, 'n_words': 172}