cogi_phony 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fdbe68d249e9db4652eba25ad5df12aefa05f611
4
+ data.tar.gz: fc6a2bc0437f5100f5115e7ea5c333e8d9b93f8d
5
+ SHA512:
6
+ metadata.gz: d25623a6161ac385babb95a5070d0ab5199bab187d84ffc89c5d3d3ef3718b057d1f78ba9fe8b8a04215e24a5dcf724d9c5c31880b4ad227f20be20b7b101162
7
+ data.tar.gz: 6e9c62b2b674c510f5a60a0e48ac9bb47e808ed685e8b978d1b8a2300f44eeb3a37c41cb032eff623d90dcd23fd69bd7557e0e01d75c846d8308c822a3ee5251
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2016 Hoa Hoang
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.MD ADDED
@@ -0,0 +1,92 @@
1
+ # PhonyRails [![Build Status](https://travis-ci.org/hoahm/cogi_phony.svg?branch=master)](https://travis-ci.org/hoahm/cogi_phony) [![Coverage Status](https://coveralls.io/repos/github/hoahm/cogi_phony/badge.svg)](https://coveralls.io/github/hoahm/cogi_phony) [![GitHub issues](https://img.shields.io/github/issues/hoahm/cogi_phony.svg)](https://github.com/hoahm/cogi_phony/issues)
2
+
3
+ This gem provide you library to validate, parsing, format and normalize phone number, detect phone network in Vietnam.
4
+
5
+ It uses the super awesome Phony gem (https://github.com/floere/phony).
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'cogi_phony'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ ```
18
+ $ bundle
19
+ ```
20
+
21
+ Or install it yourself as:
22
+
23
+ ```
24
+ $ gem install cogi_phony
25
+ ```
26
+
27
+ ## Usage
28
+
29
+ ### Validation
30
+
31
+ Check if a string is a valid phone number.
32
+
33
+ ```ruby
34
+ CogiPhony.validate? '+14037089189' # => true
35
+ ```
36
+
37
+
38
+ ### Normalization
39
+
40
+ Normalize phone numer to international format.
41
+
42
+ ```ruby
43
+ CogiPhony.normalize '+1 (403) 708-9189' # => '+14037089189'
44
+ ```
45
+
46
+ ### Formatting
47
+
48
+ Format formats phone numbers according to the predominant format of a country.
49
+
50
+ ```ruby
51
+ CogiPhony.format '+84933081090' # => +84 93 3081090
52
+ CogiPhony.format '+84933081090', format: 'global' # => '+84 93 3081090'
53
+ CogiPhony.format '+84933081090', format: 'vietnam' # => '093 3081090'
54
+ ```
55
+
56
+ ### Extract country code
57
+
58
+ Extract country code from phone number.
59
+
60
+ ```ruby
61
+ CogiPhony.country_code_from_number '+84933081090' # => '84'
62
+ ```
63
+
64
+
65
+ ### Check if Vietnam mobile phone
66
+
67
+ Check if phone number is Vietnam mobile phone format
68
+
69
+ ```ruby
70
+ CogiPhony.vn_mobile_phone? '+84933081090' # => true
71
+ ```
72
+
73
+
74
+ ### Phone provider
75
+
76
+ Return phone provider from phone number.
77
+
78
+ ```ruby
79
+ CogiPhony.phone_to_provider '+84933081090' # => 'Mobifone'
80
+ ```
81
+
82
+ ## Contributing
83
+
84
+ 1. Fork it
85
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
86
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
87
+ 4. Push to the branch (`git push origin my-new-feature`)
88
+ 5. Create new Pull Request
89
+
90
+ Don't forget to add tests and run rspec before creating a pull request :)
91
+
92
+ See all contributors on https://github.com/hoahm/cogi_phony/graphs/contributors.
data/Rakefile ADDED
@@ -0,0 +1,5 @@
1
+ require 'bundler/gem_tasks'
2
+
3
+ Dir.glob('tasks/**/*.rake').each(&method(:import))
4
+
5
+ task default: :spec
data/lib/cogi_phony.rb ADDED
@@ -0,0 +1,268 @@
1
+ require 'cogi_phony/error'
2
+ require 'cogi_phony/version'
3
+ require 'phony'
4
+ require 'yaml'
5
+
6
+ module CogiPhony
7
+ def self.hi
8
+ puts "Hello from Cogi::Phony"
9
+ end
10
+
11
+ def self.country_codes_hash
12
+ @country_codes_hash ||= YAML.load_file(File.join(File.dirname(File.expand_path(__FILE__)), 'data/country_codes.yaml'))
13
+ end
14
+
15
+ # Return a Hash of mobile networks
16
+ #
17
+ #
18
+ # @return [Hash]
19
+ def self.mobile_networks_hash
20
+ @mobile_networks_hash ||= YAML.load_file(File.join(File.dirname(File.expand_path(__FILE__)), 'data/mobile_networks.yaml'))
21
+ end
22
+
23
+ # Check if a phone number is provided by Gmobile
24
+ #
25
+ # @param [String] phone Phone number
26
+ #
27
+ # @return [Boolean]
28
+ def self.gmobile?(phone)
29
+ pattern = /\A(\+84|84|0)(#{mobile_networks_hash['vi']['gmobile']})\d{7}$/
30
+ pattern.match phone
31
+ end
32
+
33
+ # Check if a phone number is provided by Vietnamobile
34
+ #
35
+ # @param [String] phone Phone number
36
+ #
37
+ # @return [Boolean]
38
+ def self.vietnamobile?(phone)
39
+ pattern = /\A(\+84|84|0)(#{mobile_networks_hash['vi']['vietnamobile']})\d{7}$/
40
+ pattern.match phone
41
+ end
42
+
43
+ # Check if a phone number is provided by Mobifone
44
+ #
45
+ # @param [String] phone Phone number
46
+ #
47
+ # @return [Boolean]
48
+ def self.mobifone?(phone)
49
+ pattern = /\A(\+84|84|0)(#{mobile_networks_hash['vi']['mobifone']})\d{7}$/
50
+ pattern.match phone
51
+ end
52
+
53
+ # Check if a phone number is provided by Vinaphone
54
+ #
55
+ # @param [String] phone Phone number
56
+ #
57
+ # @return [Boolean]
58
+ def self.vinaphone?(phone)
59
+ pattern = /\A(\+84|84|0)(#{mobile_networks_hash['vi']['vinaphone']})\d{7}$/
60
+ pattern.match phone
61
+ end
62
+
63
+ # Check if a phone number is provided by Viettel
64
+ #
65
+ # @param [String] phone Phone number
66
+ #
67
+ # @return [Boolean]
68
+ def self.viettel?(phone)
69
+ pattern = /\A(\+84|84|0)(#{mobile_networks_hash['vi']['viettel']})\d{7}$/
70
+ pattern.match phone
71
+ end
72
+
73
+ # Return phone provider from phone number.
74
+ #
75
+ # @param [String] phone Phone number
76
+ #
77
+ # @return [String] Phone provider
78
+ #
79
+ # @example
80
+ # CogiPhony.phone_to_provider('0988091097') # => Viettel
81
+ # CogiPhony.phone_to_provider('0938091097') # => Mobifone
82
+ # CogiPhony.phone_to_provider('0918091097') # => Vinaphone
83
+ # CogiPhony.phone_to_provider('0928091097') # => Vietnamobile
84
+ # CogiPhony.phone_to_provider('0998091097') # => Gmobile (Beeline)
85
+ # CogiPhony.phone_to_provider('0837621351') # => Others
86
+ def self.phone_to_provider(phone)
87
+ return 'Viettel' if self.viettel? phone
88
+ return 'Mobifone' if self.mobifone? phone
89
+ return 'Vinaphone' if self.vinaphone? phone
90
+ return 'Vietnamobile' if self.vietnamobile? phone
91
+ return 'Gmobile (Beeline)' if self.gmobile? phone
92
+ 'Others'
93
+ end
94
+
95
+ # Check if phone number is Vietnam mobile phone format
96
+ #
97
+ # A phone is valid if:
98
+ # - Is not empty
99
+ # - Begin with +84|84|0 and
100
+ # - next number is 8|9 the length must be 8 (short number. Ex: 0933081090)
101
+ # - next number is 1, the length must be 9 (long number: Ex: 01214468866)
102
+ #
103
+ # @param [String] phone Phone number
104
+ #
105
+ # @return [Boolean] True if it is in Vietnam mobile phone format, otherwise False
106
+ #
107
+ # @example
108
+ # CogiPhony.vn_mobile_phone?('0933081090') # => true
109
+ # CogiPhony.vn_mobile_phone?('84933081090') # => true
110
+ # CogiPhony.vn_mobile_phone?('+84933081090') # => true
111
+ # CogiPhony.vn_mobile_phone?('+14037089189') # => false
112
+ # CogiPhony.vn_mobile_phone?('84837621350') # => false
113
+ def self.vn_mobile_phone?(phone)
114
+ return false if phone.nil? || phone.empty?
115
+ return false if /\A(\+84|84|0)((9\d{8})|(88\d{7})|(1\d{9}))$/.match(phone).nil?
116
+ true
117
+ end
118
+
119
+ # Format formats phone numbers according to the predominant format of a country.
120
+ #
121
+ # @param [String] phone Phone number
122
+ # @param [Hash] options An option hash
123
+ # format: 'global' or 'vietnam'. Default is 'global'
124
+ #
125
+ # @return [String] Phone number formatted based on each country.
126
+ #
127
+ # @example
128
+ # CogiPhony.format('84933081090', format: 'global') # => '+84 93 3081090'
129
+ # CogiPhony.format('84837621350', format: 'global') # => '+84 8 3762 1350'
130
+ # CogiPhony.format('84933081090') # =>'+84 93 3081090'
131
+ # CogiPhony.format('14037089189') # => '+1 (403) 708-9189'
132
+ # CogiPhony.format('84933081090', format: 'vietnam') # => '093 3081090'
133
+ # CogiPhony.format('84837621350', format: 'vietnam') # => '08 3762 1350'
134
+ def self.format(phone, options = {})
135
+ return nil if phone.nil?
136
+
137
+ phone = phone.gsub(/\D/, '')
138
+ format = options[:format] || 'global'
139
+ formatted_phone = format == 'global' ? self.global_format(phone) : self.national_format(phone)
140
+ formatted_phone
141
+ end
142
+
143
+ # Format phone number into international format.
144
+ # If missing country code, it will return the raw number.
145
+ #
146
+ # @param [String] phone Phone number
147
+ #
148
+ # @return [String] Phone number in national format
149
+ #
150
+ # @example
151
+ # CogiPhony.global_format('84933081090') # => '+84 93 3081090'
152
+ # CogiPhony.global_format('84837621350') # => '+84 8 3762 1350'
153
+ # CogiPhony.global_format('0933081090') # => '0933081090'
154
+ # CogiPhony.global_format('14037089189') # => '+1 (403) 708-9189'
155
+ #
156
+ # @example It return raw number if can not format
157
+ # CogiPhony.national_format('+84837621350') # => '+84837621350'
158
+ def self.global_format(phone)
159
+ Phony.format(phone, format: :international) rescue phone
160
+ end
161
+
162
+ # Format phone number into national format.
163
+ # If missing country code, it will return the raw number.
164
+ #
165
+ # @param [String] phone Phone number
166
+ #
167
+ # @return [String] Phone number in national format
168
+ #
169
+ # @example Format phone number into national format
170
+ # CogiPhony.national_format('84933081090') # => '093 3081090'
171
+ # CogiPhony.national_format('84837621350') # => '08 3762 1350'
172
+ #
173
+ # @example It return raw number if can not format
174
+ # CogiPhony.national_format('+84837621350') # => '+84837621350'
175
+ def self.national_format(phone)
176
+ Phony.format(phone, format: :national) rescue phone
177
+ end
178
+
179
+ # Extract country code from phone number.
180
+ #
181
+ # @param [String] phone Phone number
182
+ #
183
+ # @return [String] Country code
184
+ # @return [nil] if can not extract country code
185
+ #
186
+ # @example
187
+ # CogiPhony.country_code_from_number('84933081090') # => '84'
188
+ # CogiPhony.country_code_from_number('0933081090') # => nil
189
+ def self.country_code_from_number(phone)
190
+ return nil unless Phony.plausible?(phone)
191
+ Phony.split(Phony.normalize(phone)).first
192
+ end
193
+
194
+ # Normalize phone numer to international format.
195
+ #
196
+ # @param [String] phone Phone number
197
+ # @param [Hash] options An option hash
198
+ # format: 'global' or 'vietnam'. Default is 'global'
199
+ # default_country_code: Default country code
200
+ #
201
+ # @return [String] A phone number formatted in international format.
202
+ #
203
+ # @raise [CogiPhony::NormalizationError] If can not normalize the given number.
204
+ #
205
+ # @example Normalize phone number with country code.
206
+ # CogiPhony.normalize('+84 933081090 ') # => '+84933081090'
207
+ # CogiPhony.normalize('(+84)933081090 ') # => '+84933081090'
208
+ # CogiPhony.normalize('+8493-308-1090') # => '+84933081090'
209
+ # CogiPhony.normalize('84 933081090 ') # => '+84933081090'
210
+ # CogiPhony.normalize('+1 (403) 708-9189') # => '+14037089189'
211
+ #
212
+ # @example Normalize phone number without country code, and in vietnam format
213
+ # CogiPhony.normalize('0933081090', format: 'vietnam') # => '+84933081090'
214
+ # CogiPhony.normalize('933081090', format: 'vietnam') # => '+84933081090'
215
+ # CogiPhony.normalize('1214468866', format: 'vietnam') # => '+841214468866'
216
+ # CogiPhony.normalize('0837621351', format: 'vietnam') # => '+84837621351'
217
+ #
218
+ # @example Normalize phone number with default country code, and in global format
219
+ # CogiPhony.normalize('0933081090', default_country_code: '84') # => '+84933081090'
220
+ # CogiPhony.normalize('933081090', default_country_code: '84') # => '+84933081090'
221
+ # CogiPhony.normalize('(403) 708-9189', default_country_code: '1' # => '+14037089189'
222
+ #
223
+ # @example Normalize phone number with invalid default country code, and in global format
224
+ # CogiPhony.normalize('0933081090', default_country_code: '111111') # => raise error CogiPhony::NormalizationError
225
+ # CogiPhony.normalize('0933081090', default_country_code: 'abcd') # => raise error CogiPhony::NormalizationError
226
+ #
227
+ # @example Normalize phone number without default country code, and in global format
228
+ # CogiPhony.normalize('0933081090', format: 'global') # => raise error CogiPhony::NormalizationError
229
+ # CogiPhony.normalize('37621351', format: 'global') # => raise error CogiPhony::NormalizationError
230
+ def self.normalize(phone, options = {})
231
+ return nil if phone.nil?
232
+
233
+ original_phone = phone.dup
234
+ phone = phone.gsub(/\D/, '') # remove string character
235
+
236
+ unless Phony.plausible?(phone) # Do not include country code
237
+ if options[:format] == 'vietnam'
238
+ phone = phone.gsub(/\A0(.*?)/, '84\1') # replace 0 with 84
239
+ phone = "84#{phone}" if /\A(8|9)\d{8}$|\A1\d{9}$/.match phone # insert 84 before phone number
240
+ else # if options[:format] == 'global'
241
+ default_country_code = options[:default_country_code]
242
+ if default_country_code && Phony.plausible?("#{default_country_code}#{phone.gsub(/^0/, '')}")
243
+ phone = "#{default_country_code}#{phone.gsub(/^0/, '')}" # add country code before phone number
244
+ else
245
+ # TODO: handle if can not normalize
246
+ raise CogiPhony::NormalizationError
247
+ end
248
+ end
249
+ end
250
+
251
+ phone = "+#{phone}" # add plus sign before phone number
252
+ phone
253
+ end
254
+
255
+ # Check if a string is a valid phone number.
256
+ # Reference: http://www.regexr.com/38pvb
257
+ #
258
+ # @param [String] phone Phone number
259
+ #
260
+ # @return [Boolean] True if it is in a valid phone number, otherwise False
261
+ def self.validate?(phone)
262
+ return false if phone.nil?
263
+
264
+ # pattern = /\A((\+)?\d{1,6}|0)\d{7,10}$/
265
+ pattern = /^\s*(?:\+?(\d{1,3}))?([-. (]*(\d{3})[-. )]*)?((\d{3})[-. ]*(\d{2,4})(?:[-.x ]*(\d+))?)\s*$/
266
+ pattern.match phone
267
+ end
268
+ end
@@ -0,0 +1,7 @@
1
+ module CogiPhony
2
+ class NormalizationError < StandardError
3
+ def initialize
4
+ super %Q{Can not normalize the given number. It is not a phone number.}
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ module CogiPhony
2
+ VERSION = '0.0.2'.freeze
3
+ end
@@ -0,0 +1,970 @@
1
+ #
2
+ # List of country codes and country names.
3
+ #
4
+ # Reference: https://countrycode.org/
5
+ #
6
+ ---
7
+ countries:
8
+ AF:
9
+ country_code: "93"
10
+ name: "Afghanistan"
11
+
12
+ AL:
13
+ country_code: "355"
14
+ name: "Albania"
15
+
16
+ DZ:
17
+ country_code: "213"
18
+ name: "Algeria"
19
+
20
+ AS:
21
+ country_code: "1-684"
22
+ name: "American Samoa"
23
+
24
+ AD:
25
+ country_code: "376"
26
+ name: "Andorra"
27
+
28
+ AO:
29
+ country_code: "244"
30
+ name: "Angola"
31
+
32
+ AI:
33
+ country_code: "1-264"
34
+ name: "Anguilla"
35
+
36
+ AQ:
37
+ country_code: "672"
38
+ name: "Antarctica"
39
+
40
+ AG:
41
+ country_code: "1-268"
42
+ name: "Antigua And Barbuda"
43
+
44
+ AR:
45
+ country_code: "54"
46
+ name: "Argentina"
47
+
48
+ AM:
49
+ country_code: "374"
50
+ name: "Armenia"
51
+
52
+ AW:
53
+ country_code: "297"
54
+ name: "Aruba"
55
+
56
+ AU:
57
+ country_code: "61"
58
+ name: "Australia"
59
+
60
+ AT:
61
+ country_code: "43"
62
+ name: "Austria"
63
+
64
+ AZ:
65
+ country_code: "994"
66
+ name: "Azerbaijan"
67
+
68
+ BS:
69
+ country_code: "1-242"
70
+ name: "Bahamas"
71
+
72
+ BH:
73
+ country_code: "973"
74
+ name: "Bahrain"
75
+
76
+ BD:
77
+ country_code: "880"
78
+ name: "Bangladesh"
79
+
80
+ BB:
81
+ country_code: "1-246"
82
+ name: "Barbados"
83
+
84
+ BY:
85
+ country_code: "375"
86
+ name: "Belarus"
87
+
88
+ BE:
89
+ country_code: "32"
90
+ name: "Belgium"
91
+
92
+ BZ:
93
+ country_code: "501"
94
+ name: "Belize"
95
+
96
+ BJ:
97
+ country_code: "229"
98
+ name: "Benin"
99
+
100
+ BM:
101
+ country_code: "1-441"
102
+ name: "Bermuda"
103
+
104
+ BT:
105
+ country_code: "975"
106
+ name: "Bhutan"
107
+
108
+ BO:
109
+ country_code: "591"
110
+ name: "Bolivia"
111
+
112
+ BA:
113
+ country_code: "387"
114
+ name: "Bosnia And Herzegovina"
115
+
116
+ BW:
117
+ country_code: "267"
118
+ name: "Botswana"
119
+
120
+ BV:
121
+ country_code: "BV"
122
+ name: "Bouvet Island"
123
+
124
+ BR:
125
+ country_code: "55"
126
+ name: "Brazil"
127
+
128
+ IO:
129
+ country_code: "246"
130
+ name: "British Indian Ocean Territory"
131
+
132
+ BN:
133
+ country_code: "673"
134
+ name: "Brunei"
135
+
136
+ BG:
137
+ country_code: "359"
138
+ name: "Bulgaria"
139
+
140
+ BF:
141
+ country_code: "226"
142
+ name: "Burkina Faso"
143
+
144
+ BI:
145
+ country_code: "257"
146
+ name: "Burundi"
147
+
148
+ KH:
149
+ country_code: "855"
150
+ name: "Cambodia"
151
+
152
+ CM:
153
+ country_code: "237"
154
+ name: "Cameroon"
155
+
156
+ CA:
157
+ country_code: "1"
158
+ name: "Canada"
159
+
160
+ CV:
161
+ country_code: "238"
162
+ name: "Cape Verde"
163
+
164
+ KY:
165
+ country_code: "1-345"
166
+ name: "Cayman Islands"
167
+
168
+ CF:
169
+ country_code: "236"
170
+ name: "Central African Republic"
171
+
172
+ TD:
173
+ country_code: "235"
174
+ name: "Chad"
175
+
176
+ CL:
177
+ country_code: "56"
178
+ name: "Chile"
179
+
180
+ CN:
181
+ country_code: "86"
182
+ name: "China"
183
+
184
+ CX:
185
+ country_code: "61"
186
+ name: "Christmas Island"
187
+
188
+ CC:
189
+ country_code: "61"
190
+ name: "Cocos (keeling) Islands"
191
+
192
+ CO:
193
+ country_code: "57"
194
+ name: "Colombia"
195
+
196
+ KM:
197
+ country_code: "KM"
198
+ name: "Comoros"
199
+
200
+ CG:
201
+ country_code: "CG"
202
+ name: "Congo"
203
+
204
+ CD:
205
+ country_code: "243"
206
+ name: "Congo, The Democratic Republic Of The"
207
+
208
+ CK:
209
+ country_code: "682"
210
+ name: "Cook Islands"
211
+
212
+ CR:
213
+ country_code: "506"
214
+ name: "Costa Rica"
215
+
216
+ CI:
217
+ country_code: "CI"
218
+ name: "Cote D'ivoire"
219
+
220
+ HR:
221
+ country_code: "385"
222
+ name: "Croatia"
223
+
224
+ CU:
225
+ country_code: "53"
226
+ name: "Cuba"
227
+
228
+ CY:
229
+ country_code: "357"
230
+ name: "Cyprus"
231
+
232
+ CZ:
233
+ country_code: "420"
234
+ name: "Czech Republic"
235
+
236
+ DK:
237
+ country_code: "45"
238
+ name: "Denmark"
239
+
240
+ DJ:
241
+ country_code: "253"
242
+ name: "Djibouti"
243
+
244
+ DM:
245
+ country_code: "1-767"
246
+ name: "Dominica"
247
+
248
+ DO:
249
+ country_code: "1-809"
250
+ name: "Dominican Republic"
251
+
252
+ TP:
253
+ country_code: "TP"
254
+ name: "East Timor"
255
+
256
+ EC:
257
+ country_code: "593"
258
+ name: "Ecuador"
259
+
260
+ EG:
261
+ country_code: "20"
262
+ name: "Egypt"
263
+
264
+ SV:
265
+ country_code: "503"
266
+ name: "El Salvador"
267
+
268
+ GQ:
269
+ country_code: "240"
270
+ name: "Equatorial Guinea"
271
+
272
+ ER:
273
+ country_code: "291"
274
+ name: "Eritrea"
275
+
276
+ EE:
277
+ country_code: "372"
278
+ name: "Estonia"
279
+
280
+ ET:
281
+ country_code: "251"
282
+ name: "Ethiopia"
283
+
284
+ FK:
285
+ country_code: "500"
286
+ name: "Falkland Islands (malvinas)"
287
+
288
+ FO:
289
+ country_code: "298"
290
+ name: "Faroe Islands"
291
+
292
+ FJ:
293
+ country_code: "679"
294
+ name: "Fiji"
295
+
296
+ FI:
297
+ country_code: "358"
298
+ name: "Finland"
299
+
300
+ FR:
301
+ country_code: "33"
302
+ name: "France"
303
+
304
+ GF:
305
+ country_code: "GF"
306
+ name: "French Guiana"
307
+
308
+ PF:
309
+ country_code: "689"
310
+ name: "French Polynesia"
311
+
312
+ TF:
313
+ country_code: "TF"
314
+ name: "French Southern Territories"
315
+
316
+ GA:
317
+ country_code: "241"
318
+ name: "Gabon"
319
+
320
+ GM:
321
+ country_code: "220"
322
+ name: "Gambia"
323
+
324
+ GE:
325
+ country_code: "955"
326
+ name: "Georgia"
327
+
328
+ DE:
329
+ country_code: "49"
330
+ name: "Germany"
331
+
332
+ GH:
333
+ country_code: "233"
334
+ name: "Ghana"
335
+
336
+ GI:
337
+ country_code: "350"
338
+ name: "Gibraltar"
339
+
340
+ GR:
341
+ country_code: "30"
342
+ name: "Greece"
343
+
344
+ GL:
345
+ country_code: "299"
346
+ name: "Greenland"
347
+
348
+ GD:
349
+ country_code: "1-473"
350
+ name: "Grenada"
351
+
352
+ GP:
353
+ country_code: "GP"
354
+ name: "Guadeloupe"
355
+
356
+ GU:
357
+ country_code: "1-671"
358
+ name: "Guam"
359
+
360
+ GT:
361
+ country_code: "502"
362
+ name: "Guatemala"
363
+
364
+ GN:
365
+ country_code: "224"
366
+ name: "Guinea"
367
+
368
+ GW:
369
+ country_code: "245"
370
+ name: "Guinea-bissau"
371
+
372
+ GY:
373
+ country_code: "592"
374
+ name: "Guyana"
375
+
376
+ HT:
377
+ country_code: "509"
378
+ name: "Haiti"
379
+
380
+ HM:
381
+ country_code: "HM"
382
+ name: "Heard Island And Mcdonald Islands"
383
+
384
+ HN:
385
+ country_code: "504"
386
+ name: "Honduras"
387
+
388
+ HK:
389
+ country_code: "852"
390
+ name: "Hong Kong"
391
+
392
+ HU:
393
+ country_code: "36"
394
+ name: "Hungary"
395
+
396
+ IS:
397
+ country_code: "354"
398
+ name: "Iceland"
399
+
400
+ IN:
401
+ country_code: "91"
402
+ name: "India"
403
+
404
+ ID:
405
+ country_code: "62"
406
+ name: "Indonesia"
407
+
408
+ IR:
409
+ country_code: "98"
410
+ name: "Iran, Islamic Republic Of"
411
+
412
+ IQ:
413
+ country_code: "964"
414
+ name: "Iraq"
415
+
416
+ IE:
417
+ country_code: "353"
418
+ name: "Ireland"
419
+
420
+ IL:
421
+ country_code: "972"
422
+ name: "Israel"
423
+
424
+ IT:
425
+ country_code: "39"
426
+ name: "Italy"
427
+
428
+ JM:
429
+ country_code: "1-876"
430
+ name: "Jamaica"
431
+
432
+ JP:
433
+ country_code: "81"
434
+ name: "Japan"
435
+
436
+ JO:
437
+ country_code: "962"
438
+ name: "Jordan"
439
+
440
+ KZ:
441
+ country_code: "7"
442
+ name: "Kazakstan"
443
+
444
+ KE:
445
+ country_code: "254"
446
+ name: "Kenya"
447
+
448
+ KI:
449
+ country_code: "686"
450
+ name: "Kiribati"
451
+
452
+ KP:
453
+ country_code: "KP"
454
+ name: "Korea, Democratic People's Republic Of"
455
+
456
+ KR:
457
+ country_code: "KR"
458
+ name: "Korea, Republic Of"
459
+
460
+ KV:
461
+ country_code: "KV"
462
+ name: "Kosovo"
463
+
464
+ KW:
465
+ country_code: "965"
466
+ name: "Kuwait"
467
+
468
+ KG:
469
+ country_code: "996"
470
+ name: "Kyrgyzstan"
471
+
472
+ LA:
473
+ country_code: "856"
474
+ name: "Lao People's Democratic Republic"
475
+
476
+ LV:
477
+ country_code: "371"
478
+ name: "Latvia"
479
+
480
+ LB:
481
+ country_code: "961"
482
+ name: "Lebanon"
483
+
484
+ LS:
485
+ country_code: "266"
486
+ name: "Lesotho"
487
+
488
+ LR:
489
+ country_code: "231"
490
+ name: "Liberia"
491
+
492
+ LY:
493
+ country_code: "218"
494
+ name: "Libyan Arab Jamahiriya"
495
+
496
+ LI:
497
+ country_code: "423"
498
+ name: "Liechtenstein"
499
+
500
+ LT:
501
+ country_code: "370"
502
+ name: "Lithuania"
503
+
504
+ LU:
505
+ country_code: "352"
506
+ name: "Luxembourg"
507
+
508
+ MO:
509
+ country_code: "853"
510
+ name: "Macau"
511
+
512
+ MK:
513
+ country_code: "389"
514
+ name: "Macedonia, The Former Yugoslav Republic Of"
515
+
516
+ MG:
517
+ country_code: "261"
518
+ name: "Madagascar"
519
+
520
+ MW:
521
+ country_code: "265"
522
+ name: "Malawi"
523
+
524
+ MY:
525
+ country_code: "60"
526
+ name: "Malaysia"
527
+
528
+ MV:
529
+ country_code: "960"
530
+ name: "Maldives"
531
+
532
+ ML:
533
+ country_code: "223"
534
+ name: "Mali"
535
+
536
+ MT:
537
+ country_code: "356"
538
+ name: "Malta"
539
+
540
+ MH:
541
+ country_code: "692"
542
+ name: "Marshall Islands"
543
+
544
+ MQ:
545
+ country_code: "MQ"
546
+ name: "Martinique"
547
+
548
+ MR:
549
+ country_code: "222"
550
+ name: "Mauritania"
551
+
552
+ MU:
553
+ country_code: "230"
554
+ name: "Mauritius"
555
+
556
+ YT:
557
+ country_code: "262"
558
+ name: "Mayotte"
559
+
560
+ MX:
561
+ country_code: "52"
562
+ name: "Mexico"
563
+
564
+ FM:
565
+ country_code: "691"
566
+ name: "Micronesia, Federated States Of"
567
+
568
+ MD:
569
+ country_code: "373"
570
+ name: "Moldova, Republic Of"
571
+
572
+ MC:
573
+ country_code: "377"
574
+ name: "Monaco"
575
+
576
+ MN:
577
+ country_code: "976"
578
+ name: "Mongolia"
579
+
580
+ MS:
581
+ country_code: "1-664"
582
+ name: "Montserrat"
583
+
584
+ ME:
585
+ country_code: "382"
586
+ name: "Montenegro"
587
+
588
+ MA:
589
+ country_code: "212"
590
+ name: "Morocco"
591
+
592
+ MZ:
593
+ country_code: "258"
594
+ name: "Mozambique"
595
+
596
+ MM:
597
+ country_code: "95"
598
+ name: "Myanmar"
599
+
600
+ NA:
601
+ country_code: "264"
602
+ name: "Namibia"
603
+
604
+ NR:
605
+ country_code: "674"
606
+ name: "Nauru"
607
+
608
+ NP:
609
+ country_code: "977"
610
+ name: "Nepal"
611
+
612
+ NL:
613
+ country_code: "31"
614
+ name: "Netherlands"
615
+
616
+ AN:
617
+ country_code: "599"
618
+ name: "Netherlands Antilles"
619
+
620
+ NC:
621
+ country_code: "687"
622
+ name: "New Caledonia"
623
+
624
+ NZ:
625
+ country_code: "64"
626
+ name: "New Zealand"
627
+
628
+ NI:
629
+ country_code: "505"
630
+ name: "Nicaragua"
631
+
632
+ NE:
633
+ country_code: "227"
634
+ name: "Niger"
635
+
636
+ NG:
637
+ country_code: "234"
638
+ name: "Nigeria"
639
+
640
+ NU:
641
+ country_code: "683"
642
+ name: "Niue"
643
+
644
+ NF:
645
+ country_code: "NF"
646
+ name: "Norfolk Island"
647
+
648
+ MP:
649
+ country_code: "1-670"
650
+ name: "Northern Mariana Islands"
651
+
652
+ NO:
653
+ country_code: "47"
654
+ name: "Norway"
655
+
656
+ OM:
657
+ country_code: "968"
658
+ name: "Oman"
659
+
660
+ PK:
661
+ country_code: "92"
662
+ name: "Pakistan"
663
+
664
+ PW:
665
+ country_code: "680"
666
+ name: "Palau"
667
+
668
+ PS:
669
+ country_code: "970"
670
+ name: "Palestinian Territory, Occupied"
671
+
672
+ PA:
673
+ country_code: "507"
674
+ name: "Panama"
675
+
676
+ PG:
677
+ country_code: "675"
678
+ name: "Papua New Guinea"
679
+
680
+ PY:
681
+ country_code: "595"
682
+ name: "Paraguay"
683
+
684
+ PE:
685
+ country_code: "51"
686
+ name: "Peru"
687
+
688
+ PH:
689
+ country_code: "63"
690
+ name: "Philippines"
691
+
692
+ PN:
693
+ country_code: "64"
694
+ name: "Pitcairn"
695
+
696
+ PL:
697
+ country_code: "48"
698
+ name: "Poland"
699
+
700
+ PT:
701
+ country_code: "351"
702
+ name: "Portugal"
703
+
704
+ PR:
705
+ country_code: "1-787"
706
+ name: "Puerto Rico"
707
+
708
+ QA:
709
+ country_code: "974"
710
+ name: "Qatar"
711
+
712
+ RE:
713
+ country_code: "262"
714
+ name: "Reunion"
715
+
716
+ RO:
717
+ country_code: "40"
718
+ name: "Romania"
719
+
720
+ RU:
721
+ country_code: "7"
722
+ name: "Russian Federation"
723
+
724
+ RW:
725
+ country_code: "250"
726
+ name: "Rwanda"
727
+
728
+ SH:
729
+ country_code: "290"
730
+ name: "Saint Helena"
731
+
732
+ KN:
733
+ country_code: "1-869"
734
+ name: "Saint Kitts And Nevis"
735
+
736
+ LC:
737
+ country_code: "1-758"
738
+ name: "Saint Lucia"
739
+
740
+ PM:
741
+ country_code: "508"
742
+ name: "Saint Pierre And Miquelon"
743
+
744
+ VC:
745
+ country_code: "1-784"
746
+ name: "Saint Vincent And The Grenadines"
747
+
748
+ WS:
749
+ country_code: "685"
750
+ name: "Samoa"
751
+
752
+ SM:
753
+ country_code: "378"
754
+ name: "San Marino"
755
+
756
+ ST:
757
+ country_code: "239"
758
+ name: "Sao Tome And Principe"
759
+
760
+ SA:
761
+ country_code: "966"
762
+ name: "Saudi Arabia"
763
+
764
+ SN:
765
+ country_code: "221"
766
+ name: "Senegal"
767
+
768
+ RS:
769
+ country_code: "381"
770
+ name: "Serbia"
771
+
772
+ SC:
773
+ country_code: "248"
774
+ name: "Seychelles"
775
+
776
+ SL:
777
+ country_code: "232"
778
+ name: "Sierra Leone"
779
+
780
+ SG:
781
+ country_code: "65"
782
+ name: "Singapore"
783
+
784
+ SK:
785
+ country_code: "421"
786
+ name: "Slovakia"
787
+
788
+ SI:
789
+ country_code: "386"
790
+ name: "Slovenia"
791
+
792
+ SB:
793
+ country_code: "677"
794
+ name: "Solomon Islands"
795
+
796
+ SO:
797
+ country_code: "252"
798
+ name: "Somalia"
799
+
800
+ ZA:
801
+ country_code: "27"
802
+ name: "South Africa"
803
+
804
+ GS:
805
+ country_code: "GS"
806
+ name: "South Georgia And The South Sandwich Islands"
807
+
808
+ ES:
809
+ country_code: "34"
810
+ name: "Spain"
811
+
812
+ LK:
813
+ country_code: "94"
814
+ name: "Sri Lanka"
815
+
816
+ SD:
817
+ country_code: "249"
818
+ name: "Sudan"
819
+
820
+ SR:
821
+ country_code: "597"
822
+ name: "Suriname"
823
+
824
+ SJ:
825
+ country_code: "47"
826
+ name: "Svalbard And Jan Mayen"
827
+
828
+ SZ:
829
+ country_code: "268"
830
+ name: "Swaziland"
831
+
832
+ SE:
833
+ country_code: "46"
834
+ name: "Sweden"
835
+
836
+ CH:
837
+ country_code: "41"
838
+ name: "Switzerland"
839
+
840
+ SY:
841
+ country_code: "963"
842
+ name: "Syrian Arab Republic"
843
+
844
+ TW:
845
+ country_code: "886"
846
+ name: "Taiwan, Province Of China"
847
+
848
+ TJ:
849
+ country_code: "992"
850
+ name: "Tajikistan"
851
+
852
+ TZ:
853
+ country_code: "255"
854
+ name: "Tanzania, United Republic Of"
855
+
856
+ TH:
857
+ country_code: "66"
858
+ name: "Thailand"
859
+
860
+ TG:
861
+ country_code: "228"
862
+ name: "Togo"
863
+
864
+ TK:
865
+ country_code: "690"
866
+ name: "Tokelau"
867
+
868
+ TO:
869
+ country_code: "676"
870
+ name: "Tonga"
871
+
872
+ TT:
873
+ country_code: "1-868"
874
+ name: "Trinidad And Tobago"
875
+
876
+ TN:
877
+ country_code: "216"
878
+ name: "Tunisia"
879
+
880
+ TR:
881
+ country_code: "90"
882
+ name: "Turkey"
883
+
884
+ TM:
885
+ country_code: "993"
886
+ name: "Turkmenistan"
887
+
888
+ TC:
889
+ country_code: "1-649"
890
+ name: "Turks And Caicos Islands"
891
+
892
+ TV:
893
+ country_code: "688"
894
+ name: "Tuvalu"
895
+
896
+ VI:
897
+ country_code: "1-340"
898
+ name: "Virgin Islands, U.s."
899
+
900
+ UG:
901
+ country_code: "256"
902
+ name: "Uganda"
903
+
904
+ UA:
905
+ country_code: "380"
906
+ name: "Ukraine"
907
+
908
+ AE:
909
+ country_code: "971"
910
+ name: "United Arab Emirates"
911
+
912
+ GB:
913
+ country_code: "44"
914
+ name: "United Kingdom"
915
+
916
+ US:
917
+ country_code: "1"
918
+ name: "United States"
919
+
920
+ # UM:
921
+ # country_code: "UM"
922
+ # name: "United States Minor Outlying Islands"
923
+
924
+ UY:
925
+ country_code: "598"
926
+ name: "Uruguay"
927
+
928
+ UZ:
929
+ country_code: "998"
930
+ name: "Uzbekistan"
931
+
932
+ VU:
933
+ country_code: "678"
934
+ name: "Vanuatu"
935
+
936
+ VA:
937
+ country_code: "379"
938
+ name: "Vatican"
939
+
940
+ VE:
941
+ country_code: "58"
942
+ name: "Venezuela"
943
+
944
+ VN:
945
+ country_code: "84"
946
+ name: "Viet Nam"
947
+
948
+ # VG:
949
+ # country_code: "VG"
950
+ # name: "Virgin Islands, British"
951
+
952
+ WF:
953
+ country_code: "681"
954
+ name: "Wallis And Futuna"
955
+
956
+ EH:
957
+ country_code: "212"
958
+ name: "Western Sahara"
959
+
960
+ YE:
961
+ country_code: "967"
962
+ name: "Yemen"
963
+
964
+ ZM:
965
+ country_code: "260"
966
+ name: "Zambia"
967
+
968
+ ZW:
969
+ country_code: "263"
970
+ name: "Zimbabwe"