verifalia 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 +5 -5
- data/Gemfile +5 -5
- data/LICENSE +3 -4
- data/README.md +328 -82
- data/Rakefile +4 -0
- data/lib/verifalia/client.rb +60 -0
- data/lib/verifalia/credits/balance.rb +30 -0
- data/lib/verifalia/credits/client.rb +25 -0
- data/lib/verifalia/email_validation/client.rb +207 -0
- data/lib/verifalia/email_validation/completion_callback.rb +15 -0
- data/lib/verifalia/email_validation/entry.rb +89 -0
- data/lib/verifalia/email_validation/job.rb +75 -0
- data/lib/verifalia/email_validation/overview.rb +76 -0
- data/lib/verifalia/email_validation/progress.rb +19 -0
- data/lib/verifalia/email_validation/request.rb +19 -0
- data/lib/verifalia/email_validation/request_entry.rb +14 -0
- data/lib/verifalia/email_validation/wait_options.rb +53 -0
- data/lib/verifalia/rest/client.rb +82 -0
- data/lib/verifalia/security/certificate_authenticator.rb +21 -0
- data/lib/verifalia/security/username_password_authenticator.rb +22 -0
- data/lib/verifalia.rb +8 -23
- data/sig/completion_callback.rbs +5 -0
- data/sig/verifalia/client.rbs +11 -0
- data/sig/verifalia/credits/balance.rbs +11 -0
- data/sig/verifalia/credits/client.rbs +7 -0
- data/sig/verifalia/email_validations/client.rbs +24 -0
- data/sig/verifalia/email_validations/entry.rbs +22 -0
- data/sig/verifalia/email_validations/job.rbs +13 -0
- data/sig/verifalia/email_validations/overview.rbs +20 -0
- data/sig/verifalia/email_validations/progress.rbs +8 -0
- data/sig/verifalia/email_validations/request.rbs +13 -0
- data/sig/verifalia/email_validations/request_entry.rbs +8 -0
- data/sig/verifalia/email_validations/wait_options.rbs +20 -0
- data/sig/verifalia/rest/client.rbs +12 -0
- data/sig/verifalia/rest.rbs +6 -0
- data/sig/verifalia/security/username_password_authenticator.rbs +10 -0
- data/verifalia.gemspec +27 -18
- metadata +56 -57
- data/.gitignore +0 -24
- data/lib/rest/account_balance.rb +0 -93
- data/lib/rest/client.rb +0 -83
- data/lib/rest/email_validations.rb +0 -195
- data/lib/verifalia/util/configuration.rb +0 -7
- data/lib/verifalia/version.rb +0 -3
- data/spec/rest/account_balance_spec.rb +0 -93
- data/spec/rest/client_spec.rb +0 -105
- data/spec/rest/email_validations_spec.rb +0 -322
- data/spec/spec_helper.rb +0 -21
- data/spec/util/configuration_spec.rb +0 -15
- data/spec/verifalia_spec.rb +0 -17
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Verifalia
|
4
|
+
module Security
|
5
|
+
# Allows to authenticate to Verifalia with a username and password pair.
|
6
|
+
class UsernamePasswordAuthenticator
|
7
|
+
def initialize(username, password = nil)
|
8
|
+
if username.nil? || username.strip.length == 0
|
9
|
+
raise ArgumentError, 'username is nil or empty: please visit https://verifalia.com/client-area to set up a new user, if you don\'t have one.'
|
10
|
+
end
|
11
|
+
|
12
|
+
@username = username
|
13
|
+
@password = password || ''
|
14
|
+
end
|
15
|
+
|
16
|
+
def authenticate(connection, request)
|
17
|
+
header = Faraday::Utils.basic_header_from(@username, @password)
|
18
|
+
request.headers[Faraday::Request::Authorization::KEY] = header
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/verifalia.rb
CHANGED
@@ -1,27 +1,12 @@
|
|
1
|
-
|
2
|
-
require 'forwardable'
|
1
|
+
# frozen_string_literal: true
|
3
2
|
|
4
|
-
|
5
|
-
require 'verifalia/util/configuration'
|
3
|
+
require_relative 'verifalia/client'
|
6
4
|
|
7
|
-
|
5
|
+
require_relative 'verifalia/security/username_password_authenticator'
|
6
|
+
require_relative 'verifalia/security/certificate_authenticator'
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
def_delegators :configuration, :account_sid, :auth_token
|
8
|
+
require_relative 'verifalia/email_validation/client'
|
9
|
+
require_relative 'verifalia/credits/client'
|
13
10
|
|
14
|
-
|
15
|
-
|
16
|
-
# pass them to various initializers each time.
|
17
|
-
def self.configure(&block)
|
18
|
-
yield configuration
|
19
|
-
end
|
20
|
-
|
21
|
-
##
|
22
|
-
# Returns an existing or instantiates a new configuration object.
|
23
|
-
def self.configuration
|
24
|
-
@configuration ||= Util::Configuration.new
|
25
|
-
end
|
26
|
-
private_class_method :configuration
|
27
|
-
end
|
11
|
+
module Verifalia
|
12
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Verifalia
|
2
|
+
module Credits
|
3
|
+
class Balance
|
4
|
+
def self.from_json: (Hash[String, untyped]) -> Balance
|
5
|
+
|
6
|
+
attr_reader credit_packs: BigDecimal
|
7
|
+
attr_reader free_credits: BigDecimal | nil
|
8
|
+
attr_reader free_credits_reset_in: String | nil
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Verifalia
|
2
|
+
module EmailValidations
|
3
|
+
class Client
|
4
|
+
@rest_client: Rest::Client
|
5
|
+
|
6
|
+
def delete: (String) -> void
|
7
|
+
def export: (String, String) -> String
|
8
|
+
def get: (String, wait_options: WaitOptions) -> (Job | nil)
|
9
|
+
def submit: ((String | Array[String] | Array[RequestEntry] | Array[Hash[String, untyped]] | RequestEntry | Request),
|
10
|
+
quality: String,
|
11
|
+
priority: (Integer | nil),
|
12
|
+
deduplication: String,
|
13
|
+
name: String,
|
14
|
+
retention: String,
|
15
|
+
completion_callback: CompletionCallback | Hash[String, untyped] | nil,
|
16
|
+
wait_options: WaitOptions) -> (Job | nil)
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def build_job: -> Job
|
21
|
+
def wait_for_completion: (Job, WaitOptions) -> (Job | nil)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Verifalia
|
2
|
+
module EmailValidations
|
3
|
+
class Entry
|
4
|
+
attr_reader completed_on: DateTime
|
5
|
+
attr_reader custom: String | nil
|
6
|
+
attr_reader duplicate_of: Integer | nil
|
7
|
+
attr_reader email_address: String | nil
|
8
|
+
attr_reader email_address_domain_part: String | nil
|
9
|
+
attr_reader email_address_local_part: String | nil
|
10
|
+
attr_reader has_international_domain_name: bool | nil
|
11
|
+
attr_reader has_international_mailbox_name: bool | nil
|
12
|
+
attr_reader index: Integer
|
13
|
+
attr_reader input_data: String
|
14
|
+
attr_reader classification: String
|
15
|
+
attr_reader is_disposable_email_address: bool | nil
|
16
|
+
attr_reader is_free_email_address: bool | nil
|
17
|
+
attr_reader is_role_account: bool | nil
|
18
|
+
attr_reader status: String
|
19
|
+
attr_reader syntax_failure_index: Integer | nil
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Verifalia
|
2
|
+
module EmailValidations
|
3
|
+
class Overview
|
4
|
+
attr_reader client_ip: IPAddr
|
5
|
+
attr_reader completed_on: (DateTime | nil)
|
6
|
+
attr_reader created_on: DateTime
|
7
|
+
attr_reader deduplication: String
|
8
|
+
attr_reader id: String
|
9
|
+
attr_reader name: String
|
10
|
+
attr_reader no_of_entries: Integer
|
11
|
+
attr_reader owner: String
|
12
|
+
attr_reader priority: (Integer | nil)
|
13
|
+
attr_reader progress: (Progress | nil)
|
14
|
+
attr_reader quality: String
|
15
|
+
attr_reader retention: String
|
16
|
+
attr_reader status: String
|
17
|
+
attr_reader submitted_on: DateTime
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Verifalia
|
2
|
+
module EmailValidations
|
3
|
+
class Request
|
4
|
+
attr_accessor callback: CompletionCallback | nil
|
5
|
+
attr_accessor deduplication: String | nil
|
6
|
+
attr_accessor entries: Array[RequestEntry]
|
7
|
+
attr_accessor name: String | nil
|
8
|
+
attr_accessor priority: Integer | nil
|
9
|
+
attr_accessor quality: String | nil
|
10
|
+
attr_accessor retention: String | nil
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Verifalia
|
2
|
+
module EmailValidations
|
3
|
+
class WaitOptions
|
4
|
+
@@default: WaitOptions
|
5
|
+
@@no_wait: WaitOptions
|
6
|
+
@submission_wait_time: Integer
|
7
|
+
@poll_wait_time: Integer
|
8
|
+
|
9
|
+
def self.default: -> WaitOptions
|
10
|
+
def self.no_wait: -> WaitOptions
|
11
|
+
|
12
|
+
attr_reader poll_wait_time: Integer
|
13
|
+
attr_reader progress: (^(Overview) -> void) | nil
|
14
|
+
attr_reader submission_wait_time: Integer
|
15
|
+
|
16
|
+
def initialize: (Integer, Integer) -> WaitOptions
|
17
|
+
def wait_for_next_poll: (Job) -> void
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/verifalia.gemspec
CHANGED
@@ -1,29 +1,38 @@
|
|
1
1
|
# coding: utf-8
|
2
|
+
|
2
3
|
lib = File.expand_path('../lib', __FILE__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'verifalia/
|
5
|
+
require 'verifalia/client'
|
5
6
|
|
6
7
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
8
|
-
spec.version = Verifalia::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
11
|
-
spec.summary =
|
12
|
-
spec.description =
|
13
|
-
spec.homepage =
|
14
|
-
spec.license =
|
8
|
+
spec.name = 'verifalia'
|
9
|
+
spec.version = Verifalia::Client::VERSION
|
10
|
+
spec.authors = ['Verifalia', 'Efran Cobisi', 'Guido Tersilli', 'Rudy Chiappetta', 'Germano Mosconi']
|
11
|
+
spec.email = ['support@verifalia.com']
|
12
|
+
spec.summary = 'Verifalia - Ruby SDK and helper library'
|
13
|
+
spec.description = 'Verifalia provides a simple API for validating email addresses and checking whether they are deliverable or not. This library allows to easily integrate with Verifalia and verify email addresses in real-time.'
|
14
|
+
spec.homepage = 'https://verifalia.com/'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
spec.required_ruby_version = '>= 2.6.0'
|
17
|
+
|
18
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
19
|
+
spec.metadata['source_code_uri'] = 'https://github.com/verifalia/verifalia-ruby-sdk.git'
|
15
20
|
|
16
|
-
|
17
|
-
|
18
|
-
spec.
|
19
|
-
|
21
|
+
# Specify which files should be added to the gem when it is released.
|
22
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
|
+
spec.files = Dir.chdir(__dir__) do
|
24
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
25
|
+
(File.expand_path(f) == __FILE__) || f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor])
|
26
|
+
end
|
27
|
+
end
|
28
|
+
spec.bindir = 'exe'
|
29
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
30
|
+
spec.require_paths = ['lib']
|
20
31
|
|
21
32
|
spec.extra_rdoc_files = ['README.md']
|
22
|
-
spec.rdoc_options = ['--line-numbers', '--inline-source', '--title', '--main', 'README.md']
|
23
33
|
|
24
|
-
spec.add_dependency('
|
25
|
-
spec.add_dependency('rest-client', '>= 2.0.0')
|
34
|
+
spec.add_dependency('faraday', '~> 2.7')
|
26
35
|
|
27
|
-
spec.add_development_dependency
|
28
|
-
spec.add_development_dependency
|
36
|
+
spec.add_development_dependency 'bundler', '~> 2.4.8'
|
37
|
+
spec.add_development_dependency 'rake'
|
29
38
|
end
|
metadata
CHANGED
@@ -1,57 +1,47 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: verifalia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Verifalia
|
8
|
+
- Efran Cobisi
|
9
|
+
- Guido Tersilli
|
10
|
+
- Rudy Chiappetta
|
11
|
+
- Germano Mosconi
|
8
12
|
autorequire:
|
9
|
-
bindir:
|
13
|
+
bindir: exe
|
10
14
|
cert_chain: []
|
11
|
-
date:
|
15
|
+
date: 2023-03-12 00:00:00.000000000 Z
|
12
16
|
dependencies:
|
13
17
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
18
|
+
name: faraday
|
15
19
|
requirement: !ruby/object:Gem::Requirement
|
16
20
|
requirements:
|
17
|
-
- - "
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 2.1.2
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: 2.1.2
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rest-client
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
21
|
+
- - "~>"
|
32
22
|
- !ruby/object:Gem::Version
|
33
|
-
version: 2.
|
23
|
+
version: '2.7'
|
34
24
|
type: :runtime
|
35
25
|
prerelease: false
|
36
26
|
version_requirements: !ruby/object:Gem::Requirement
|
37
27
|
requirements:
|
38
|
-
- - "
|
28
|
+
- - "~>"
|
39
29
|
- !ruby/object:Gem::Version
|
40
|
-
version: 2.
|
30
|
+
version: '2.7'
|
41
31
|
- !ruby/object:Gem::Dependency
|
42
32
|
name: bundler
|
43
33
|
requirement: !ruby/object:Gem::Requirement
|
44
34
|
requirements:
|
45
35
|
- - "~>"
|
46
36
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
37
|
+
version: 2.4.8
|
48
38
|
type: :development
|
49
39
|
prerelease: false
|
50
40
|
version_requirements: !ruby/object:Gem::Requirement
|
51
41
|
requirements:
|
52
42
|
- - "~>"
|
53
43
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
44
|
+
version: 2.4.8
|
55
45
|
- !ruby/object:Gem::Dependency
|
56
46
|
name: rake
|
57
47
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,8 +56,9 @@ dependencies:
|
|
66
56
|
- - ">="
|
67
57
|
- !ruby/object:Gem::Version
|
68
58
|
version: '0'
|
69
|
-
description:
|
70
|
-
|
59
|
+
description: Verifalia provides a simple API for validating email addresses and checking
|
60
|
+
whether they are deliverable or not. This library allows to easily integrate with
|
61
|
+
Verifalia and verify email addresses in real-time.
|
71
62
|
email:
|
72
63
|
- support@verifalia.com
|
73
64
|
executables: []
|
@@ -75,57 +66,65 @@ extensions: []
|
|
75
66
|
extra_rdoc_files:
|
76
67
|
- README.md
|
77
68
|
files:
|
78
|
-
- ".gitignore"
|
79
69
|
- Gemfile
|
80
70
|
- LICENSE
|
81
71
|
- README.md
|
82
72
|
- Rakefile
|
83
|
-
- lib/rest/account_balance.rb
|
84
|
-
- lib/rest/client.rb
|
85
|
-
- lib/rest/email_validations.rb
|
86
73
|
- lib/verifalia.rb
|
87
|
-
- lib/verifalia/
|
88
|
-
- lib/verifalia/
|
89
|
-
-
|
90
|
-
-
|
91
|
-
-
|
92
|
-
-
|
93
|
-
-
|
94
|
-
-
|
74
|
+
- lib/verifalia/client.rb
|
75
|
+
- lib/verifalia/credits/balance.rb
|
76
|
+
- lib/verifalia/credits/client.rb
|
77
|
+
- lib/verifalia/email_validation/client.rb
|
78
|
+
- lib/verifalia/email_validation/completion_callback.rb
|
79
|
+
- lib/verifalia/email_validation/entry.rb
|
80
|
+
- lib/verifalia/email_validation/job.rb
|
81
|
+
- lib/verifalia/email_validation/overview.rb
|
82
|
+
- lib/verifalia/email_validation/progress.rb
|
83
|
+
- lib/verifalia/email_validation/request.rb
|
84
|
+
- lib/verifalia/email_validation/request_entry.rb
|
85
|
+
- lib/verifalia/email_validation/wait_options.rb
|
86
|
+
- lib/verifalia/rest/client.rb
|
87
|
+
- lib/verifalia/security/certificate_authenticator.rb
|
88
|
+
- lib/verifalia/security/username_password_authenticator.rb
|
89
|
+
- sig/completion_callback.rbs
|
90
|
+
- sig/verifalia/client.rbs
|
91
|
+
- sig/verifalia/credits/balance.rbs
|
92
|
+
- sig/verifalia/credits/client.rbs
|
93
|
+
- sig/verifalia/email_validations/client.rbs
|
94
|
+
- sig/verifalia/email_validations/entry.rbs
|
95
|
+
- sig/verifalia/email_validations/job.rbs
|
96
|
+
- sig/verifalia/email_validations/overview.rbs
|
97
|
+
- sig/verifalia/email_validations/progress.rbs
|
98
|
+
- sig/verifalia/email_validations/request.rbs
|
99
|
+
- sig/verifalia/email_validations/request_entry.rbs
|
100
|
+
- sig/verifalia/email_validations/wait_options.rbs
|
101
|
+
- sig/verifalia/rest.rbs
|
102
|
+
- sig/verifalia/rest/client.rbs
|
103
|
+
- sig/verifalia/security/username_password_authenticator.rbs
|
95
104
|
- verifalia.gemspec
|
96
|
-
homepage:
|
105
|
+
homepage: https://verifalia.com/
|
97
106
|
licenses:
|
98
107
|
- MIT
|
99
|
-
metadata:
|
108
|
+
metadata:
|
109
|
+
homepage_uri: https://verifalia.com/
|
110
|
+
source_code_uri: https://github.com/verifalia/verifalia-ruby-sdk.git
|
100
111
|
post_install_message:
|
101
|
-
rdoc_options:
|
102
|
-
- "--line-numbers"
|
103
|
-
- "--inline-source"
|
104
|
-
- "--title"
|
105
|
-
- "--main"
|
106
|
-
- README.md
|
112
|
+
rdoc_options: []
|
107
113
|
require_paths:
|
108
114
|
- lib
|
109
115
|
required_ruby_version: !ruby/object:Gem::Requirement
|
110
116
|
requirements:
|
111
117
|
- - ">="
|
112
118
|
- !ruby/object:Gem::Version
|
113
|
-
version:
|
119
|
+
version: 2.6.0
|
114
120
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
121
|
requirements:
|
116
122
|
- - ">="
|
117
123
|
- !ruby/object:Gem::Version
|
118
124
|
version: '0'
|
119
125
|
requirements: []
|
120
|
-
|
121
|
-
rubygems_version: 2.4.8
|
126
|
+
rubygems_version: 3.3.5
|
122
127
|
signing_key:
|
123
128
|
specification_version: 4
|
124
|
-
summary: Verifalia
|
125
|
-
test_files:
|
126
|
-
- spec/rest/account_balance_spec.rb
|
127
|
-
- spec/rest/client_spec.rb
|
128
|
-
- spec/rest/email_validations_spec.rb
|
129
|
-
- spec/spec_helper.rb
|
130
|
-
- spec/util/configuration_spec.rb
|
131
|
-
- spec/verifalia_spec.rb
|
129
|
+
summary: Verifalia - Ruby SDK and helper library
|
130
|
+
test_files: []
|
data/.gitignore
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
*.gem
|
2
|
-
*.rbc
|
3
|
-
.bundle
|
4
|
-
.config
|
5
|
-
.yardoc
|
6
|
-
Gemfile.lock
|
7
|
-
InstalledFiles
|
8
|
-
_yardoc
|
9
|
-
coverage
|
10
|
-
doc/
|
11
|
-
lib/bundler/man
|
12
|
-
pkg
|
13
|
-
rdoc
|
14
|
-
spec/reports
|
15
|
-
test/tmp
|
16
|
-
test/version_tmp
|
17
|
-
tmp
|
18
|
-
*.bundle
|
19
|
-
*.so
|
20
|
-
*.o
|
21
|
-
*.a
|
22
|
-
mkmf.log
|
23
|
-
.rvmrc
|
24
|
-
test.rb
|
data/lib/rest/account_balance.rb
DELETED
@@ -1,93 +0,0 @@
|
|
1
|
-
require 'rest_client'
|
2
|
-
require 'json'
|
3
|
-
module Verifalia
|
4
|
-
module REST
|
5
|
-
class AccountBalance
|
6
|
-
##
|
7
|
-
# The Verifalia::REST::AccountBalance class allow you to comminucate
|
8
|
-
# with Account balance Api. You don't need to instantiate this class, but
|
9
|
-
# use the client for autoconfiguration. # The +args+ parameter is a hash of configuration
|
10
|
-
def initialize(config, account_sid, account_token, args = {})
|
11
|
-
@resources = build_resources(config, account_sid, account_token)
|
12
|
-
end
|
13
|
-
|
14
|
-
##
|
15
|
-
# Query the Account balance
|
16
|
-
#
|
17
|
-
def balance()
|
18
|
-
begin
|
19
|
-
response = multiplex_request do |resource|
|
20
|
-
resource[@unique_id].get
|
21
|
-
end
|
22
|
-
@error = nil
|
23
|
-
JSON.parse(response)
|
24
|
-
rescue => e
|
25
|
-
compute_error(e)
|
26
|
-
false
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def error
|
31
|
-
@error
|
32
|
-
end
|
33
|
-
|
34
|
-
private
|
35
|
-
|
36
|
-
def multiplex_request
|
37
|
-
@resources.shuffle.each do |resource|
|
38
|
-
begin
|
39
|
-
response = yield(resource)
|
40
|
-
return response
|
41
|
-
rescue => e
|
42
|
-
if ((e.is_a? RestClient::Exception) && (e.http_code != 500))
|
43
|
-
raise e
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
raise RestClient::Exception.new(nil, 500)
|
48
|
-
end
|
49
|
-
|
50
|
-
def compute_error(e)
|
51
|
-
unless e.is_a? RestClient::Exception
|
52
|
-
@error = :internal_server_error
|
53
|
-
end
|
54
|
-
|
55
|
-
case e.http_code
|
56
|
-
when 400
|
57
|
-
@error = :bad_request
|
58
|
-
when 401
|
59
|
-
@error = :unauthorized
|
60
|
-
when 402
|
61
|
-
@error = :payment_required
|
62
|
-
when 403
|
63
|
-
@error = :forbidden
|
64
|
-
when 404
|
65
|
-
@error = :not_found
|
66
|
-
when 406
|
67
|
-
@error = :not_acceptable
|
68
|
-
when 410
|
69
|
-
@error = :gone
|
70
|
-
when 429
|
71
|
-
@error = :too_many_request
|
72
|
-
else
|
73
|
-
@error = :internal_server_error
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
def build_resources(config, account_sid, account_token)
|
78
|
-
opts = {
|
79
|
-
user: account_sid,
|
80
|
-
password: account_token,
|
81
|
-
headers: {
|
82
|
-
content_type: :json,
|
83
|
-
user_agent: "verifalia-rest-client/ruby/#{Verifalia::VERSION}"
|
84
|
-
}
|
85
|
-
}
|
86
|
-
config[:hosts].map do |host|
|
87
|
-
api_url = "#{host}/#{config[:api_version]}/account-balance"
|
88
|
-
RestClient::Resource.new api_url, opts
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|