greip 1.2.0 → 2.0.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f8c59f45fed262b5dec564b79eddcda055f2c8b714fd4c3d79df432296fb7ad0
4
- data.tar.gz: a1a1009b2fbd440443c6bbdbc5e3ec03d15be2c0ad3f1501b376943b6f2cc545
3
+ metadata.gz: b6138b9669c579236bb13e4ca603163807914a205b84173eaf1d7eae9edbb71b
4
+ data.tar.gz: 0b779c30a6f05d927acd148fc917ee8d9fd0dadb60595d4688314c478b2c93cc
5
5
  SHA512:
6
- metadata.gz: 0e2aee7bb65c8ae5f8a0cc34962f428db920fd44109271f1d632355b657fc8baea11cb769a7bafdc8f489b11f36c2abb45a3a47566dcf59c18d3948083214018
7
- data.tar.gz: 4a59299b8dcc5724c0a49c7c0702e40858ffb0c8dba241b19ad76c4dd62f3b5cc522c4d775dcad9bea1abaa595206431af5d5ddba1c0f78b7029c28843713230
6
+ metadata.gz: 06550601fd83ef3a3e90892f76c33cee38b95808f695cb0cca42bb5fa859cc68624ea817b72ffa5076d33245c989045a5f38f38a6450aaf81884ec270298a780
7
+ data.tar.gz: c134d01fa0b94e7dc1bb63a762594e4ef945158688995550f32d64ce910f7c06e32193d1274742e35e1ceb047937f5d75dcc0e057049740b9f2ed9e009b40406
data/CHANGELOG.md ADDED
@@ -0,0 +1,14 @@
1
+ # Changelog
2
+
3
+ ## 2.0.0 — 2026-03-19
4
+
5
+ ### Breaking
6
+
7
+ - **Greip API v2** endpoints and `https://v2.greipapi.com` base URL.
8
+ - **Authorization: Bearer** token; v2 success envelope handling.
9
+ - REST path changes (lookup, score, country, ASN, IBAN, email, phone, profanity POST, payments POST).
10
+ - Returned hashes use v2 keys (`ip` → nested `address`, `geo.country_code`, `is_valid`, `risk_level`, ASN `number`).
11
+
12
+ ### Changed
13
+
14
+ - Minitest suite updated for live v2 responses.
data/README.md CHANGED
@@ -15,7 +15,7 @@ The official Ruby Gem of Greip API
15
15
   
16
16
  [![License: MIT](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/license/apache-2-0)
17
17
   
18
- ![API Status](https://img.shields.io/website?down_color=orange&down_message=down&label=API%20status&up_color=green&up_message=up&url=https%3A%2F%greipapi.com)
18
+ ![API Status](https://img.shields.io/website?down_color=orange&down_message=down&label=API%20status&up_color=green&up_message=up&url=https%3A%2F%2Fgreipapi.com)
19
19
 
20
20
  ---
21
21
 
@@ -264,3 +264,7 @@ You can find the full guide of this package by visiting our
264
264
 
265
265
  - [Greip Developers](https://greip.io)
266
266
  - [All Contributors](https://github.com/Greipio/ruby/graphs/contributors)
267
+
268
+ ## Repo Activity
269
+
270
+ ![Alt](https://repobeats.axiom.co/api/embed/a0962cabc24202852458927d5c8abc987b5c0b47.svg "Repobeats analytics image")
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Greip
4
- BASE_URL = "https://greipapi.com"
4
+ BASE_URL = "https://v2.greipapi.com"
5
5
 
6
6
  AVAILABLE_LANGUAGES = %w[EN AR DE FR ES JA ZH RU].freeze
7
7
  AVAILABLE_GEOIP_PARAMS = %w[location security timezone currency device].freeze
data/lib/greip/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Greip
4
- VERSION = "1.2.0"
4
+ VERSION = "2.0.0"
5
5
  end
data/lib/greip.rb CHANGED
@@ -11,6 +11,7 @@ require_relative "greip/version"
11
11
  require_relative "greip/constants"
12
12
  require_relative "greip/error_messages"
13
13
 
14
+ require "cgi"
14
15
  require "json"
15
16
  require "net/http"
16
17
  require "uri"
@@ -48,7 +49,7 @@ module Greip
48
49
  # Validate the mode variable
49
50
  mode != "live" && mode != "test" && (raise StandardError, ErrorMessages::MODE)
50
51
 
51
- url = URI(BASE_URL + "/IPLookup?ip=#{ip}&params=#{params.join(",")}&lang=#{lang}&mode=#{mode}&source=Ruby-Gem")
52
+ url = URI(BASE_URL + "/lookup/ip/#{CGI.escape(ip)}?params=#{params.join(",")}&lang=#{lang}&mode=#{mode}&source=Ruby-Gem")
52
53
 
53
54
  http = Net::HTTP.new(url.host, url.port)
54
55
  http.use_ssl = (url.scheme == "https")
@@ -62,7 +63,7 @@ module Greip
62
63
 
63
64
  parsed_response = JSON.parse(response.body)
64
65
 
65
- raise StandardError, "Error: #{parsed_response["description"]}" unless parsed_response["status"] == "success"
66
+ raise StandardError, "Error: #{parsed_response["description"]}" unless parsed_response["success"] == true
66
67
 
67
68
  parsed_response["data"]
68
69
  end
@@ -77,7 +78,7 @@ module Greip
77
78
  # Validate the mode variable
78
79
  mode != "live" && mode != "test" && (raise StandardError, ErrorMessages::MODE)
79
80
 
80
- url = URI(BASE_URL + "/threats?ip=#{ip}&mode=#{mode}&source=Ruby-Gem")
81
+ url = URI(BASE_URL + "/score/ip/#{CGI.escape(ip)}?mode=#{mode}&source=Ruby-Gem")
81
82
 
82
83
  http = Net::HTTP.new(url.host, url.port)
83
84
  http.use_ssl = (url.scheme == "https")
@@ -91,7 +92,7 @@ module Greip
91
92
 
92
93
  parsed_response = JSON.parse(response.body)
93
94
 
94
- raise StandardError, "Error: #{parsed_response["description"]}" unless parsed_response["status"] == "success"
95
+ raise StandardError, "Error: #{parsed_response["description"]}" unless parsed_response["success"] == true
95
96
 
96
97
  parsed_response["data"]
97
98
  end
@@ -125,7 +126,7 @@ module Greip
125
126
  # Validate the mode variable
126
127
  mode != "live" && mode != "test" && (raise StandardError, ErrorMessages::MODE)
127
128
 
128
- url = URI("#{BASE_URL}/BulkLookup?ips=#{ips.join(",")}&params=#{params.join(",")}&lang=#{lang}&mode=#{mode}")
129
+ url = URI("#{BASE_URL}/geo/ip/bulk?ips=#{ips.join(",")}&params=#{params.join(",")}&lang=#{lang}&mode=#{mode}&source=Ruby-Gem")
129
130
 
130
131
  http = Net::HTTP.new(url.host, url.port)
131
132
  http.use_ssl = (url.scheme == "https")
@@ -139,7 +140,7 @@ module Greip
139
140
 
140
141
  parsed_response = JSON.parse(response.body)
141
142
 
142
- raise StandardError, "Error: #{parsed_response["description"]}" unless parsed_response["status"] == "success"
143
+ raise StandardError, "Error: #{parsed_response["description"]}" unless parsed_response["success"] == true
143
144
 
144
145
  parsed_response["data"]
145
146
  end
@@ -165,7 +166,7 @@ module Greip
165
166
  # Validate the mode variable
166
167
  mode != "live" && mode != "test" && (raise StandardError, ErrorMessages::MODE)
167
168
 
168
- url = URI("#{BASE_URL}/Country?CountryCode=#{country_code}&params=#{params.join(",")}&lang=#{lang}&mode=#{mode}")
169
+ url = URI("#{BASE_URL}/lookup/countries/#{CGI.escape(country_code)}?params=#{params.join(",")}&lang=#{lang}&mode=#{mode}&source=Ruby-Gem")
169
170
 
170
171
  http = Net::HTTP.new(url.host, url.port)
171
172
  http.use_ssl = (url.scheme == "https")
@@ -179,7 +180,7 @@ module Greip
179
180
 
180
181
  parsed_response = JSON.parse(response.body)
181
182
 
182
- raise StandardError, "Error: #{parsed_response["description"]}" unless parsed_response["status"] == "success"
183
+ raise StandardError, "Error: #{parsed_response["description"]}" unless parsed_response["success"] == true
183
184
 
184
185
  parsed_response["data"]
185
186
  end
@@ -199,13 +200,21 @@ module Greip
199
200
  # Validate the mode variable
200
201
  mode != "live" && mode != "test" && (raise StandardError, ErrorMessages::MODE)
201
202
 
202
- url = URI("#{BASE_URL}/badWords?text=#{text}&params=#{params.join(",")}&format=JSON&lang=#{lang}&mode=#{mode}")
203
+ url = URI("#{BASE_URL}/score/text")
203
204
 
204
205
  http = Net::HTTP.new(url.host, url.port)
205
206
  http.use_ssl = (url.scheme == "https")
206
207
 
207
- request = Net::HTTP::Get.new(url)
208
+ request = Net::HTTP::Post.new(url)
209
+ request["Content-Type"] = "application/json"
208
210
  request["Authorization"] = "Bearer #{@token}"
211
+ request.body = {
212
+ text: text,
213
+ format: "JSON",
214
+ lang: lang,
215
+ mode: mode,
216
+ source: "Ruby-Gem"
217
+ }.to_json
209
218
 
210
219
  response = http.request(request)
211
220
 
@@ -213,7 +222,7 @@ module Greip
213
222
 
214
223
  parsed_response = JSON.parse(response.body)
215
224
 
216
- raise StandardError, "Error: #{parsed_response["description"]}" unless parsed_response["status"] == "success"
225
+ raise StandardError, "Error: #{parsed_response["description"]}" unless parsed_response["success"] == true
217
226
 
218
227
  parsed_response["data"]
219
228
  end
@@ -228,7 +237,7 @@ module Greip
228
237
  # Validate the mode variable
229
238
  mode != "live" && mode != "test" && (raise StandardError, ErrorMessages::MODE)
230
239
 
231
- url = URI("#{BASE_URL}/ASNLookup?asn=#{asn}&mode=#{mode}")
240
+ url = URI("#{BASE_URL}/lookup/asn/#{CGI.escape(asn)}?mode=#{mode}&source=Ruby-Gem")
232
241
 
233
242
  http = Net::HTTP.new(url.host, url.port)
234
243
  http.use_ssl = (url.scheme == "https")
@@ -242,7 +251,7 @@ module Greip
242
251
 
243
252
  parsed_response = JSON.parse(response.body)
244
253
 
245
- raise StandardError, "Error: #{parsed_response["description"]}" unless parsed_response["status"] == "success"
254
+ raise StandardError, "Error: #{parsed_response["description"]}" unless parsed_response["success"] == true
246
255
 
247
256
  parsed_response["data"]
248
257
  end
@@ -257,7 +266,7 @@ module Greip
257
266
  # Validate the mode variable
258
267
  mode != "live" && mode != "test" && (raise StandardError, ErrorMessages::MODE)
259
268
 
260
- url = URI("#{BASE_URL}/validateEmail?email=#{email}&mode=#{mode}")
269
+ url = URI("#{BASE_URL}/score/email/#{CGI.escape(email)}?mode=#{mode}&source=Ruby-Gem")
261
270
 
262
271
  http = Net::HTTP.new(url.host, url.port)
263
272
  http.use_ssl = (url.scheme == "https")
@@ -271,7 +280,7 @@ module Greip
271
280
 
272
281
  parsed_response = JSON.parse(response.body)
273
282
 
274
- raise StandardError, "Error: #{parsed_response["description"]}" unless parsed_response["status"] == "success"
283
+ raise StandardError, "Error: #{parsed_response["description"]}" unless parsed_response["success"] == true
275
284
 
276
285
  parsed_response["data"]
277
286
  end
@@ -287,7 +296,7 @@ module Greip
287
296
  # Validate the mode variable
288
297
  mode != "live" && mode != "test" && (raise StandardError, ErrorMessages::MODE)
289
298
 
290
- url = URI("#{BASE_URL}/validatePhone?phone=#{phone}&countryCode=#{country_code}&mode=#{mode}")
299
+ url = URI("#{BASE_URL}/score/phone/#{CGI.escape(phone)}?country_code=#{country_code}&mode=#{mode}&source=Ruby-Gem")
291
300
 
292
301
  http = Net::HTTP.new(url.host, url.port)
293
302
  http.use_ssl = (url.scheme == "https")
@@ -301,7 +310,7 @@ module Greip
301
310
 
302
311
  parsed_response = JSON.parse(response.body)
303
312
 
304
- raise StandardError, "Error: #{parsed_response["description"]}" unless parsed_response["status"] == "success"
313
+ raise StandardError, "Error: #{parsed_response["description"]}" unless parsed_response["success"] == true
305
314
 
306
315
  parsed_response["data"]
307
316
  end
@@ -316,7 +325,7 @@ module Greip
316
325
  # Validate the mode variable
317
326
  mode != "live" && mode != "test" && (raise StandardError, ErrorMessages::MODE)
318
327
 
319
- url = URI("#{BASE_URL}/validateIBAN?iban=#{iban}&mode=#{mode}")
328
+ url = URI("#{BASE_URL}/lookup/iban/#{CGI.escape(iban)}?mode=#{mode}&source=Ruby-Gem")
320
329
 
321
330
  http = Net::HTTP.new(url.host, url.port)
322
331
  http.use_ssl = (url.scheme == "https")
@@ -330,7 +339,7 @@ module Greip
330
339
 
331
340
  parsed_response = JSON.parse(response.body)
332
341
 
333
- raise StandardError, "Error: #{parsed_response["description"]}" unless parsed_response["status"] == "success"
342
+ raise StandardError, "Error: #{parsed_response["description"]}" unless parsed_response["success"] == true
334
343
 
335
344
  parsed_response["data"]
336
345
  end
@@ -345,7 +354,7 @@ module Greip
345
354
  # Validate the data variable
346
355
  raise StandardError, ErrorMessages::DATA unless data.is_a?(Hash) && !data.empty?
347
356
 
348
- url = URI("#{BASE_URL}/paymentFraud")
357
+ url = URI("#{BASE_URL}/score/payments")
349
358
 
350
359
  http = Net::HTTP.new(url.host, url.port)
351
360
  http.use_ssl = (url.scheme == "https")
@@ -353,14 +362,14 @@ module Greip
353
362
  request = Net::HTTP::Post.new(url)
354
363
  request["Content-Type"] = "application/json"
355
364
  request["Authorization"] = "Bearer #{@token}"
356
- request.body = data.to_json
365
+ request.body = { data: data, mode: mode, source: "Ruby-Gem" }.to_json
357
366
 
358
367
  response = http.request(request)
359
368
 
360
369
  raise StandardError, "Error: #{response.code} - #{response.message}" unless response.code == "200"
361
370
 
362
371
  parsed_response = JSON.parse(response.body)
363
- raise StandardError, "Error: #{parsed_response["description"]}" unless parsed_response["status"] == "success"
372
+ raise StandardError, "Error: #{parsed_response["description"]}" unless parsed_response["success"] == true
364
373
 
365
374
  parsed_response["data"]
366
375
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: greip
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greip Team
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-03-14 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: faraday
@@ -102,6 +101,7 @@ extensions: []
102
101
  extra_rdoc_files: []
103
102
  files:
104
103
  - ".rubocop.yml"
104
+ - CHANGELOG.md
105
105
  - CODE_OF_CONDUCT.md
106
106
  - LICENSE
107
107
  - README.md
@@ -120,7 +120,6 @@ metadata:
120
120
  homepage_uri: https://greip.io/
121
121
  source_code_uri: https://github.com/Greipio/ruby
122
122
  changelog_uri: https://changelog.greip.io/
123
- post_install_message:
124
123
  rdoc_options: []
125
124
  require_paths:
126
125
  - lib
@@ -135,8 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
134
  - !ruby/object:Gem::Version
136
135
  version: '0'
137
136
  requirements: []
138
- rubygems_version: 3.5.6
139
- signing_key:
137
+ rubygems_version: 4.0.8
140
138
  specification_version: 4
141
139
  summary: Greip services for Ruby.
142
140
  test_files: []