phone_number.proto 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. // Copyright 2021 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. syntax = "proto3";
  15. package google.type;
  16. option cc_enable_arenas = true;
  17. option go_package = "google.golang.org/genproto/googleapis/type/phone_number;phone_number";
  18. option java_multiple_files = true;
  19. option java_outer_classname = "PhoneNumberProto";
  20. option java_package = "com.google.type";
  21. option objc_class_prefix = "GTP";
  22. // An object representing a phone number, suitable as an API wire format.
  23. //
  24. // This representation:
  25. //
  26. // - should not be used for locale-specific formatting of a phone number, such
  27. // as "+1 (650) 253-0000 ext. 123"
  28. //
  29. // - is not designed for efficient storage
  30. // - may not be suitable for dialing - specialized libraries (see references)
  31. // should be used to parse the number for that purpose
  32. //
  33. // To do something meaningful with this number, such as format it for various
  34. // use-cases, convert it to an `i18n.phonenumbers.PhoneNumber` object first.
  35. //
  36. // For instance, in Java this would be:
  37. //
  38. // com.google.type.PhoneNumber wireProto =
  39. // com.google.type.PhoneNumber.newBuilder().build();
  40. // com.google.i18n.phonenumbers.Phonenumber.PhoneNumber phoneNumber =
  41. // PhoneNumberUtil.getInstance().parse(wireProto.getE164Number(), "ZZ");
  42. // if (!wireProto.getExtension().isEmpty()) {
  43. // phoneNumber.setExtension(wireProto.getExtension());
  44. // }
  45. //
  46. // Reference(s):
  47. // - https://github.com/google/libphonenumber
  48. message PhoneNumber {
  49. // An object representing a short code, which is a phone number that is
  50. // typically much shorter than regular phone numbers and can be used to
  51. // address messages in MMS and SMS systems, as well as for abbreviated dialing
  52. // (e.g. "Text 611 to see how many minutes you have remaining on your plan.").
  53. //
  54. // Short codes are restricted to a region and are not internationally
  55. // dialable, which means the same short code can exist in different regions,
  56. // with different usage and pricing, even if those regions share the same
  57. // country calling code (e.g. US and CA).
  58. message ShortCode {
  59. // Required. The BCP-47 region code of the location where calls to this
  60. // short code can be made, such as "US" and "BB".
  61. //
  62. // Reference(s):
  63. // - http://www.unicode.org/reports/tr35/#unicode_region_subtag
  64. string region_code = 1;
  65. // Required. The short code digits, without a leading plus ('+') or country
  66. // calling code, e.g. "611".
  67. string number = 2;
  68. }
  69. // Required. Either a regular number, or a short code. New fields may be
  70. // added to the oneof below in the future, so clients should ignore phone
  71. // numbers for which none of the fields they coded against are set.
  72. oneof kind {
  73. // The phone number, represented as a leading plus sign ('+'), followed by a
  74. // phone number that uses a relaxed ITU E.164 format consisting of the
  75. // country calling code (1 to 3 digits) and the subscriber number, with no
  76. // additional spaces or formatting, e.g.:
  77. // - correct: "+15552220123"
  78. // - incorrect: "+1 (555) 222-01234 x123".
  79. //
  80. // The ITU E.164 format limits the latter to 12 digits, but in practice not
  81. // all countries respect that, so we relax that restriction here.
  82. // National-only numbers are not allowed.
  83. //
  84. // References:
  85. // - https://www.itu.int/rec/T-REC-E.164-201011-I
  86. // - https://en.wikipedia.org/wiki/E.164.
  87. // - https://en.wikipedia.org/wiki/List_of_country_calling_codes
  88. string e164_number = 1;
  89. // A short code.
  90. //
  91. // Reference(s):
  92. // - https://en.wikipedia.org/wiki/Short_code
  93. ShortCode short_code = 2;
  94. }
  95. // The phone number's extension. The extension is not standardized in ITU
  96. // recommendations, except for being defined as a series of numbers with a
  97. // maximum length of 40 digits. Other than digits, some other dialing
  98. // characters such as ',' (indicating a wait) or '#' may be stored here.
  99. //
  100. // Note that no regions currently use extensions with short codes, so this
  101. // field is normally only set in conjunction with an E.164 number. It is held
  102. // separately from the E.164 number to allow for short code extensions in the
  103. // future.
  104. string extension = 3;
  105. }