cheetahmails 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +6 -0
- data/lib/cheetahmails.rb +17 -27
- metadata +1 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3ec8ac69916c77a941007e1fddc41708398bad7
|
4
|
+
data.tar.gz: 4306f5a649501c0177e142612d875c98d2b5fca8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2fff01fb3c7628e643a7b4ecb7360ce02ea1ac9f1d8c9c181732f8a29759e6a953ba7fa26e86876f577b5e536285ec78c4ce76aad5b7120ee8d943e3e611df1
|
7
|
+
data.tar.gz: 8297b710d12becd0f287a9e8b93b34213898cbf48d2d5a2fb496f9ede92b83165594582742613c5bed40b760be375b1fde7957d8f59f8cd7f882dfafb908dc0a
|
data/Gemfile
CHANGED
data/lib/cheetahmails.rb
CHANGED
@@ -63,22 +63,19 @@ module Cheetahmails
|
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
|
-
def self.find_list_member(email, prop='')
|
67
|
-
tries ||= 2
|
68
|
-
|
66
|
+
def self.find_list_member(email, prop = '', allow_retry_qty = 3)
|
69
67
|
faraday = Faraday.new(:url => @base_uri) do |faraday|
|
70
|
-
faraday.request
|
71
|
-
|
72
|
-
faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
|
68
|
+
faraday.request :url_encoded
|
69
|
+
faraday.adapter Faraday.default_adapter
|
73
70
|
end
|
74
71
|
|
75
|
-
faraday.headers["Authorization"] = "Bearer
|
72
|
+
faraday.headers["Authorization"] = "Bearer #{Cheetahmails.get_token(false)}"
|
76
73
|
faraday.headers["Content-Type"] = "application/json"
|
77
74
|
faraday.headers["Accept"] = "application/json"
|
78
75
|
|
79
76
|
params = {
|
80
77
|
"viewName" => Cheetahmails.configuration.view_name,
|
81
|
-
"prop" => prop,
|
78
|
+
"prop" => prop,
|
82
79
|
"columnName" => "email_address",
|
83
80
|
"operation" => "=",
|
84
81
|
"param" => email
|
@@ -86,25 +83,18 @@ module Cheetahmails
|
|
86
83
|
|
87
84
|
response = faraday.get '/services2/api/SearchRecords', params
|
88
85
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
rescue => error
|
102
|
-
return false
|
103
|
-
end
|
104
|
-
|
105
|
-
rescue RetryException => e
|
106
|
-
if (tries -= 1) > 0
|
107
|
-
retry
|
86
|
+
case response.status
|
87
|
+
when 200
|
88
|
+
return JSON.parse(response.body)[0]
|
89
|
+
when 404
|
90
|
+
return false
|
91
|
+
when 401
|
92
|
+
if allow_retry_qty > 0
|
93
|
+
Cheetahmails.get_token(true)
|
94
|
+
find_list_member(email, prop, allow_retry_qty - 1)
|
95
|
+
else
|
96
|
+
raise "401"
|
97
|
+
end
|
108
98
|
end
|
109
99
|
end
|
110
100
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cheetahmails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Holder
|
@@ -38,34 +38,6 @@ dependencies:
|
|
38
38
|
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 3.0.1
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rspec
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - '>='
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - '>='
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: dotenv
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - '>='
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - '>='
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
41
|
description: Some basic cheetah mail API end points implemented
|
70
42
|
email: tom@simpleweb.co.uk
|
71
43
|
executables: []
|