This will generate fake sms with all necessary attributes

 Options:

   * mobile: mobile number
   * code:   verification code
   * company: assigned company, format is【company】
170033
def build_fake_sms(mobile, code, company)
      {
        'sid'               => SecureRandom.uuid,
        'mobile'            => mobile,
        'send_time'         => Time.zone.now,
        'text'              => "您的验证码是#{code}。如非本人操作，请忽略本短信【#{company}】",
        'send_status'       => 'SUCCESS',
        'report_status'     => 'UNKNOWN',
        'fee'               => 1,
        'user_receive_time' => nil,
        'error_msg'         => nil
      }
    end
1354901
function checkMobile(s){
    var regu =/^[1][3][0-9]{9}$/;
    var re = new RegExp(regu);
    if (re.test(s)) {
        return true;
    }else{
        return false;
    }
}
53869
def send_sms(self, message, to, sender='elkme', options=[]):
        """"""
        sms = self.format_sms_payload(message=message,
            to=to,
            sender=sender,
            options=options)
        return self.query_api(sms)
1270555
public function generateVerifyCode(): string
    {
        if ($this->minLength > $this->maxLength) {
            $this->maxLength = $this->minLength;
        }
        if ($this->minLength < 3) {
            $this->minLength = 3;
        }
        if ($this->maxLength > 20) {
            $this->maxLength = 20;
        }
        $length = random_int($this->minLength, $this->maxLength);

        $letters = 'bcdfghjklmnpqrstvwxyz';
        $vowels = 'aeiou';
        $code = '';
        for ($i = 0; $i < $length; ++$i) {
            if (($i % 2 && random_int(0, 10) > 2) || (!($i % 2) && random_int(0, 10) > 9)) {
                $code .= $vowels[random_int(0, 4)];
            } else {
                $code .= $letters[random_int(0, 20)];
            }
        }

        return $code;
    }
614717
def request_two_factor_code_from_phone(phone_id, phone_number, code_length)
      # Request code
      r = request(:put) do |req|
        req.url("https://idmsa.apple.com/appleauth/auth/verify/phone")
        req.headers['Content-Type'] = 'application/json'
        req.body = { "phoneNumber" => { "id" => phone_id }, "mode" => "sms" }.to_json
        update_request_headers(req)
      end

      # we use `Spaceship::TunesClient.new.handle_itc_response`
      # since this might be from the Dev Portal, but for 2 step
      Spaceship::TunesClient.new.handle_itc_response(r.body)

      puts("Successfully requested text message to #{phone_number}")

      code = ask_for_2fa_code("Please enter the #{code_length} digit code you received at #{phone_number}:")

      return { "securityCode" => { "code" => code.to_s }, "phoneNumber" => { "id" => phone_id }, "mode" => "sms" }.to_json
    end
1159563
def parse_phone(parts, allow_multiple=False):
  
  
  # Get text substitutions (ex: 'three' -> '3')
  text_subs = misc.phone_text_subs()
  Small = text_subs['Small']
  Magnitude = text_subs['Magnitude']
  Others = text_subs['Others']

  phone_pattern = r'1?(?:[2-9][0-8][0-9])\s?(?:[2-9][0-9]{2})\s?(?:[0-9]{2})\s?(?:[0-9]{2})'
  phone_pattern_spaces = r'1?\W?[2-9]\W?[0-8]\W?[0-9]\W?[2-9]\W?[0-9]\W?[0-9]\W?[0-9]\W?[0-9]\W?[0-9]\W?[0-9]'

  found_phones = []
  return_parts = []
  # Check each part for phone # and remove from parts if found
  for part in parts:
    body = part
    # remove '420' references to avoid false positives
    body = re.sub(r'420 ?friendly', '', body)
    body = body.replace(' 420 ', '')
    body = body.replace('420 sp', '')

    # Replace all disguising characters in the body
    for key in Small:
      body = re.sub(r'-?'+re.escape(key)+r'-?', str(Small[key]), body)
    for key in Magnitude:
      body = re.sub(r'-?'+re.escape(key)+r'-?', str(Magnitude[key]), body)
    for key in Others:
      body = re.sub(r'-?'+re.escape(key)+r'-?', str(Others[key]), body)
    body = re.sub(r'\W', ' ', body)
    body = re.sub(r' +', ' ', body)

    if len(re.sub(r'\D', '', body)) < 10:
      # Less than 10 numeric digits in part - no phone number here
      return_parts.append(part)
      continue;

    phones = re.findall(phone_pattern, body)

    if len(phones) == 0:
      # No phone number in standard format
      phones = re.findall(phone_pattern_spaces, body)
      if len(phones) > 0:
        # Phone number had spaces between digits
        for found in phones:
          found_phones.append(re.sub(r'\D', '', found))

    else:
      # Found phone in standard format
      for found in phones:
        found_phones.append(re.sub(r'\D', '', found))

    if found_phones:
      # Phone has been found, remove from part)
      for found in found_phones:
        filtered_part = parser_helpers.remove_phone(part, found)
      if re.sub(r'\W', '', filtered_part):
        # get rid of now-empty parts
        return_parts.append(filtered_part)
    else:
      # Phone not found yet, add part to output
      return_parts.append(part)

  if not allow_multiple:
    # Get most commonly occurring phone
    found_phone = ''
    if len(found_phones) > 0:
      found_phone = max(set(found_phones), key=found_phones.count)

    # Return the phone along with the original parts (minus any occurrences of the phone number)
    return (found_phone, return_parts)
  else:
    # return all phones
    return (list(set(found_phones)), return_parts)
1109341
def data_filler_company(self, number_of_rows, db):
        '''
        '''

        try:
            company = db
            data_list = list()
            for i in range(0, number_of_rows):
                post_comp_reg = {
                    "id": rnd_id_generator(self),
                    "name": self.faker.company(),
                    "date": self.faker.date(pattern="%d-%m-%Y"),
                    "email": self.faker.company_email(),
                    "domain": self.faker.safe_email(),
                    "city": self.faker.city()
                }
                company.save(post_comp_reg)

            logger.warning('companies Commits are successful after write job!',
                           extra=d)
        except Exception as e:
            logger.error(e, extra=d)
451569
function SMSDataValidator(data) {
  MessagingUserStatus.call(this, 'sms validator');

  if(!helpers.validatePhoneNumber(data.to)) {
    // To phone number is invalid
    this.state.code = this.StatusCodes.INVALID;
    this.state.message = 'Invalid "to" phone number: ' + data.to;

  } else if(data.from && !helpers.validatePhoneNumber(data.from)) {
    // From phone number is invalid (if it is input through API)
    this.state.code = this.StatusCodes.INVALID;
    this.state.message = 'Invalid "from" phone number: ' + data.from;

  } else if(!helpers.validateMessage(data.message)) {
    // Message string is invalid
    this.state.code = this.StatusCodes.INVALID;
    this.state.message = 'Invalid message: ' + data.message;

  } else {
    // Input data is valid
    this.state.code = this.StatusCodes.VALID;
    this.state.message = 'Ok';
  }
}
81022
protected function generateKey()
    {
        $split = '.';
        $prefix = config('laravel-sms.storage.prefix', 'laravel_sms');
        $args = func_get_args();
        array_unshift($args, $this->token);
        $args = array_filter($args, function ($value) {
            return $value && is_string($value);
        });
        if (!(empty($args))) {
            $prefix .= $split . implode($split, $args);
        }

        return $prefix;
    }
712362
def signup_or_login_with_mobile_phone(cls, phone_number, sms_code):
        '''
        
        '''
        data = {
            'mobilePhoneNumber': phone_number,
            'smsCode': sms_code
        }
        response = client.post('/usersByMobilePhone', data)
        content = response.json()
        user = cls()
        user._update_data(content)
        user._handle_save_result(True)
        if 'smsCode' not in content:
            user._attributes.pop('smsCode', None)
        return user
1056874
def generate!(name = default_fauxture_name, attributes = {})
      name, attributes = default_fauxture_name, name if name.is_a? Hash
      Sweatshop.create!(self, name, attributes)
    end
1049780
def send_sms(message_body, phone_no, type = 1)
      request_body = {}
      request_body[:un] = ISMS.username
      request_body[:pwd] = ISMS.password
      request_body[:dstno] = phone_no
      request_body[:msg] = message_body
      request_body[:type] = type

      faraday_response = connection.post do |request|
        request.url SEND_SMS_URL
        request.body = request_body
      end

      parse_response(faraday_response.body)
    end
650141
def send_sms(to: sms_to, body: sms_body)
      [to, body]
      generate_token
      options = { body: {
                    body: body,
                    to: to
                  }.to_json,
                  headers: { "Content-Type" => "application/json", "Authorization" => "Bearer #{@token}" }}
      response = HTTParty.post("https://api.telstra.com/v1/sms/messages", options)
      return JSON.parse(response.body)
    end
1245991
def __build_sms_data(self, message):
        """"""

        attributes = {}

        attributes_to_translate = {
            'to' : 'To',
            'message' : 'Content',
            'client_id' : 'ClientID',
            'concat' : 'Concat',
            'from_name': 'From',
            'invalid_char_option' : 'InvalidCharOption',
            'truncate' : 'Truncate',
            'wrapper_id' : 'WrapperId'
        }

        for attr in attributes_to_translate:
            val_to_use = None
            if hasattr(message, attr):
                val_to_use = getattr(message, attr)
            if val_to_use is None and hasattr(self, attr):
                val_to_use = getattr(self, attr)
            if val_to_use is not None:
                attributes[attributes_to_translate[attr]] = str(val_to_use)

        return attributes
801686
protected function generateVerifyCode()
    {
        // alphabets ?
        if (!$this->useMbChars) {
            return parent::generateVerifyCode();
        }

        $seeds = $this->getCaptchaSeeds();
        $len = mb_strlen($seeds, 'UTF-8');

        for ($code = '', $i = 0; $i < $this->getCaptchaLength(); ++$i) {
            $code .= mb_substr($seeds, mt_rand(0, $len - 1), 1, 'UTF-8');
        }

        return $code;
    }
112591
def format_company(organization)
      {
        company_id: organization.id,
        name: organization.name,
        created_at: organization.created_at.to_i,
        custom_attributes: {
          industry: organization.industry,
          size: organization.size,
          credit_card_details: organization.has_credit_card_details?,
          credit_card_expiry: organization.credit_card.expiry_date,
          app_count: organization.app_instances.count,
          app_list: organization.app_instances.map(&:name).sort.to_sentence,
          user_count: organization.users.count
        }
      }
    end
425706
def fake!(fake_calls = [])
      @fake_calls = fake_calls
      @fake = true
      Quovo.config.token_storage = Object.new.tap do |o|
        def o.read(_)
          ['FAKE-TOKEN', (Time.now.utc + 1_000).iso8601].join('|')
        end
      end
    end